fluentd-ui/app/javascript/packs/components/grep_container.js
Kenji Okimoto c8f37e96b5
Move components under components directory
Signed-off-by: Kenji Okimoto <okimoto@clear-code.com>
2018-11-05 13:11:19 +09:00

54 lines
1.3 KiB
JavaScript

/* global _ */
"use strict";
import "lodash/lodash";
import GrepPattern from "./grep_pattern";
const GrepContainer = {
template: "#vue-grep-container",
components: {
"grep-pattern": GrepPattern
},
props: [
"containerType", // and/or
"index",
],
data: function() {
return {
grepType: "regexp",
patterns: [true],
};
},
filters: {
humanize: function(value) {
return _.capitalize(value.replace(/_/g, " "));
}
},
methods: {
add: function(event) {
this.$emit("add-grep-container", this.containerType, this.index);
},
remove: function(event) {
this.$emit("remove-grep-container", this.containerType, this.index);
},
addGrepPattern: function(grepType, index) {
const found = this.patterns.indexOf(false);
if (found < 0) {
this.$set(this.patterns, this.patterns.length, true);
} else {
this.$set(this.patterns, found, true);
}
},
removeGrepPattern: function(grepType, index) {
console.log(index);
console.log(this.patterns);
this.$set(this.patterns, index, false);
console.log(this.patterns);
},
inputName: function(index) {
return `setting[${this.containerType}[${this.index}]][grep_type]`;
}
}
};
export { GrepContainer as default };