summaryrefslogtreecommitdiffstats
path: root/test-scheduler/ui/src/components/env_component/api_param.vue
blob: 55eb913e4a5ebeb5a4d679c2a6dbe6b8b842fe8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<template>
    <div class="row">
         <div class="form-group">
            <label class="col-lg-3 control-label">Params</label>
            <div class="col-lg-2">
                <button type="button" class="btn btn-primary btn-sm" v-on:click="addNewParam()">New</button>
            </div>
         </div>
         <div class="form-group">
            <div class="col-lg-offset-2 col-lg-8">
                <div class="table-responsive">
                 <table class="table table-bordered text-center">
                    <thead>
                        <tr>
                            <th>name</th>
                            <th class="text-center">description</th>
                            <th class="text-center">operation</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr v-for="param in params">
                            <td><input type="text" class="form-control text-center" style="border: 0px" v-model="param['name']"></td>
                            <td><input type="text" class="form-control text-center" style="border: 0px" v-bind:title="param['description']" v-model="param['description']"></td>
                            <td>
                                <button type="button" class="btn btn-white" v-on:click="deleteParam(param['name'])">
                                    <i class="fa fa-trash"></i>
                                </button>
                            </td>
                        </tr>
                    </tbody>
                 </table>
                </div>
             </div>
          </div>
     </div>
</template>
<script>
export default {
    props: ["params"],
    data: function() {
        return {
            paramArr: this.params
        }
    },
    watch: {
        paramArr: function(){
            this.$emit("params", this.paramArr);
        }
    },
    methods: {
        addNewParam: function() {
            this.params.push({'name': '', 'description': ''});
        },
        deleteParam: function(paramName) {
            for(var i = 0;i < this.params.length; i++) {
                if(paramName == this.params[i]['name']) {
                    this.params.splice(i, 1);
                }
            }
        }
    }
}
</script>