mirror of
https://github.com/fluent/fluentd-ui.git
synced 2025-08-19 13:31:03 +02:00
Handle adding/removing grep-container properly
Signed-off-by: Kenji Okimoto <okimoto@clear-code.com>
This commit is contained in:
parent
85b0ff71fc
commit
dceed5493d
@ -1,4 +1,6 @@
|
|||||||
|
/* global _ */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
import "lodash/lodash";
|
||||||
|
|
||||||
import GrepContainer from "./grep_container";
|
import GrepContainer from "./grep_container";
|
||||||
|
|
||||||
@ -10,7 +12,10 @@ $(document).ready(() => {
|
|||||||
},
|
},
|
||||||
data: function() {
|
data: function() {
|
||||||
return {
|
return {
|
||||||
index: 0
|
containers: {
|
||||||
|
and: [true],
|
||||||
|
or: [true]
|
||||||
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted: function() {
|
mounted: function() {
|
||||||
@ -19,10 +24,16 @@ $(document).ready(() => {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
addGrepContainer: function(containerType, index) {
|
addGrepContainer: function(containerType, index) {
|
||||||
this.index += 1;
|
let found = this.containers[containerType].indexOf(false);
|
||||||
|
if (found < 0) {
|
||||||
|
this.$set(this.containers[containerType], this.containers[containerType].length, true);
|
||||||
|
} else {
|
||||||
|
this.$set(this.containers[containerType], found, true);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
removeGrepContainer: function(containerType, index) {
|
removeGrepContainer: function(containerType, index) {
|
||||||
this.index -= 1;
|
this.$set(this.containers[containerType], index, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -3,21 +3,15 @@
|
|||||||
= render "shared/vue/grep_container"
|
= render "shared/vue/grep_container"
|
||||||
|
|
||||||
#filter-grep-setting
|
#filter-grep-setting
|
||||||
%grep-container{"v-bind:container-type" => '"and"',
|
%template{"v-for" => "(enabled, i) in containers.and"}
|
||||||
"v-bind:index" => "0",
|
%grep-container{"v-if" => "enabled",
|
||||||
|
"v-bind:container-type" => '"and"',
|
||||||
|
"v-bind:index" => "i",
|
||||||
"v-on:add-grep-container" => "addGrepContainer",
|
"v-on:add-grep-container" => "addGrepContainer",
|
||||||
"v-on:remove-grep-container" => "removeGrepContainer"}
|
"v-on:remove-grep-container" => "removeGrepContainer"}
|
||||||
%template{"v-for" => "n in index"}
|
%template{"v-for" => "(enabled, i) in containers.or"}
|
||||||
%grep-container{"v-bind:container-type" => '"and"',
|
%grep-container{"v-if" => "enabled",
|
||||||
"v-bind:index" => "n",
|
"v-bind:container-type" => '"or"',
|
||||||
"v-on:add-grep-container" => "addGrepContainer",
|
"v-bind:index" => "i",
|
||||||
"v-on:remove-grep-container" => "removeGrepContainer"}
|
|
||||||
%grep-container{"v-bind:container-type" => '"or"',
|
|
||||||
"v-bind:index" => "0",
|
|
||||||
"v-on:add-grep-container" => "addGrepContainer",
|
|
||||||
"v-on:remove-grep-container" => "removeGrepContainer"}
|
|
||||||
%template{"v-for" => "n in index"}
|
|
||||||
%grep-container{"v-bind:container-type" => '"or"',
|
|
||||||
"v-bind:index" => "n",
|
|
||||||
"v-on:add-grep-container" => "addGrepContainer",
|
"v-on:add-grep-container" => "addGrepContainer",
|
||||||
"v-on:remove-grep-container" => "removeGrepContainer"}
|
"v-on:remove-grep-container" => "removeGrepContainer"}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user