Sha256: 1fd2c5fe72dfc349073984142ef7967802355eaa965446995a37bb99026624a8

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

/* 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 };

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fluentd-ui-1.1.0 app/javascript/packs/grep_container.js