NAME="$1"

MAYUS="$1"
MINUS=`echo "$1" | tr '[:upper:]' '[:lower:]'`
AMAYUS=`echo "$1" | sed -r 's/([A-Z])/_\L\1/g' | sed 's/^_//' | tr '[:lower:]' '[:upper:]'`
URL=`echo "$1" | sed -r 's/([A-Z])/-\L\1/g' | sed 's/^-//'`
MINUS=`echo "$1" | sed -r 's/([A-Z])/_\L\1/g' | sed 's/^_//'`
CAMELCASE=`echo "$1" | sed 's/./\L&/'`

# MAYUS=($MAYUS)

if [ -e "src/views/$MAYUS\s.vue" ]
then
    echo "This component already exists in this project or the name is the same"
else

# crear archivo .vue de la nueva vista
echo "<template lang=\"pug\">
  .crud(v-shortcuts=\"[{ shortcut: [ 'c', ], callback: add"$MAYUS", push: true, focus: true },{ shortcut: [ 'e', ], callback: editShortcut, push: true, focus: true },{ shortcut: [ 'f', ], callback: setFocusSearch, push: true, focus: true },]\")
    modal-import(model=\""$MINUS"\" :title=\"\$t('front.import_modal', {model: \$t('strings."$MINUS"')})\")
    modal-"$URL"s(:newRecord='newRecord', :is-add='isModalAdd')
    .container-fluid
      vm-row.heading(vm-w=\"12\")
        vm-col(vm-type=\"flex\" vm-align=\"center\" vm-lg=6 vm-sm=6)
          div
            h2 \{{ \$t('strings."$MINUS"s') }}:
            span \{{ \$t('strings.description', {attribute: \$t('strings."$MINUS"s')}) }}
          div(style=\"display:none;\")
            vm-button(type=\"default\" icon=\"list\")
            vm-button(type=\"default\" icon=\"grid\" color=\"rgba(var(--gray),1)\")
        vm-col(vm-type=\"flex\" vm-align=\"center\" vm-justify=\"flex-end\" vm-lg=6 vm-sm=6)
          div
            vm-button(icon=\"plus\" @click=\"add"$MAYUS"\") \{{ \$t('strings.add') }}
            vm-tooltip(:text=\"\$t('strings.options')\" delay=\".5s\")
              vm-dropdown(vm-custom-content vm-trigger-click vm-trigger-outside-click)
                vm-button(type=\"border\" icon=\"more-horizotnal\" color=\"#afbbc6\")

                vm-dropdown-menu
                  vm-dropdown-item.d-flex.justify-content-between(@click=\"printReport\")
                    vm-icon(icon=\"printer-outline\")
                    slot &nbsp;\{{ \$t('strings.print') }}
                  vm-dropdown-item.d-flex.justify-content-between(@click=\"delete"$MAYUS"sConfirm\" :disabled=\"!enabledDelete\")
                    vm-icon(icon=\"trash-2-outline\")
                    slot &nbsp;\{{ \$t('strings.delete') }}
                  vm-dropdown-item.d-flex.justify-content-between(@click=\"setModalImportVisible(true)\")
                    vm-icon(icon=\"upload-outline\")
                    slot &nbsp;\{{ \$t('strings.import') }}
                  //- More options
                      Agrega mas acciones para colecciones de datos
      vm-row(vm-w=\"12\")
        vm-col.card(vm-sm=12)
          vm-table(multiple v-model=\"selected\"  max-height=\"350px\" :data=\""$CAMELCASE"s\")
            template(slot=\"header\")
              .d-flex.justify-content-between
                vm-input(ref=\"search\" icon=\"search\" size=\"small\" :placeholder=\"searchPlaceholder\" v-model=\"filters.where.param\" @keyup.enter=\"applyFilter(filters)\"  width=\"300px\")
                div
                  vm-order-by(:sort-by-text=\"\$t('strings.order_by')\" placeholder=\"Ninguno\" :data=\"columnsOrderBy\" v-model=\"filters.orderBy\" @change=\"applyFilter(filters)\" size=\"small\" width=\"200px\" :serializer=\"item => \$t('"$CAMELCASE"s.'+ item)\")
                  vm-tooltip(:text=\"\$t('strings.filters')\" delay=\".5s\")
                    vm-dropdown(ref='dropdown' vm-custom-content vm-trigger-click vm-trigger-outside-click)
                      vm-button(type=\"default\" icon=\"funnel-outline\" size=\"small\")

                      vm-dropdown-menu(class=\"filters\")
                        .heading.d-flex.justify-content-between
                          h4 \{{ \$t('strings.filters') }}
                          vm-button(type=\"flat\" size=\"small\" @click=\"clearFilter\") \{{ \$t('strings.clear') }}
                        //- Add filters
                            Agrega los filtros que prefieras por ejemplo:
                            vm-select.filter(:placeholder=\"\$t('strings.multiple')\" multiple autocomplete label=\"Status\" v-model=\"filters.whereIn.status\")
                              vm-select-item(:key=\"index\" :value=\"item.value\" :text=\"item.text\" v-for=\"(item,index) in status\")
                            vm-select.filter(url=\"customers\" columns=\"tradename,etc\" :placeholder=\"\$t('strings.multiple')\" multiple autocomplete :label=\"\$t('sales.customer_id')\" v-model=\"filters.whereIn.customer_id\" @input-change=\"autoCompleteFunc\")
                              vm-select-item(:key=\"index\" :value=\"item.id\" :text=\"item.tradename\" v-for=\"(item,index) in "$CAMELCASE"sCatalog.customers\")
                            vm-date-picker.filter(type=\"daterange\" :label=\"\$t('"$MINUS"s.created_at')\" :placeholder=\"\$t('strings.select_date')\" @on-change=\"handleChange\" :value=\"filters.betweenDates.created_at\")

                            NOTA: (agregar clase .filter)
                        .filter.d-flex
                          vm-button(@click=\"applyFilter(filters)\") \{{ \$t('strings.apply') }}
                  vm-tooltip(:text=\"\$t('strings.display_list')\" delay=\".5s\")
                    vm-button(type=\"default\" size=\"small\" icon=\"list\")
                  vm-tooltip(:text=\"\$t('strings.display_grid')\" delay=\".5s\")
                    vm-button(type=\"default\" size=\"small\" icon=\"grid\" color=\"rgba(var(--gray),1)\")
            template(slot=\"thead\")
              vm-th(:key=\"index\" v-if=\"column !== 'id'\" v-for=\"(column, index) in columns\") \{{ \$t('"$MINUS"s.' + column) }}
            template(slot-scope=\"{data}\")
              vm-tr(:data=\"tr\" :key=\"indextr\" v-for=\"(tr, indextr) in data\")
                vm-td(:data=\"data[indextr][column]\" :key=\"index\" v-if=\"column !== 'id'\" v-for=\"(column, index) in columns\")
                  slot(v-if=\"column == 'total' || column == 'unit_price'\")  \{{data[indextr][column] | currency }}
                  slot(v-if=\"column != 'status' && column != 'total' && column != 'unit_price'\") \{{data[indextr][column] | truncate }}
                  vm-status-indicator(v-if=\"column == 'status'\" :pulse=\"data[indextr]['status'] !== 'Activo'\" :color=\"colorStatus(data[indextr]['status'])\") \{{data[indextr]['status']}}
                vm-td
                vm-dropdown(vm-custom-content vm-trigger-click vm-trigger-outside-click)
                  vm-button(type=\"flat\" icon=\"more-horizotnal\" color=\"#afbbc6\")

                  vm-dropdown-menu
                    vm-dropdown-item.d-flex.justify-content-between(@click=\"edit"$MAYUS"(data[indextr], tr)\")
                      vm-icon(icon=\"edit-2-outline\")
                      slot &nbsp;\{{ \$t('strings.edit') }}
                    vm-dropdown-item.d-flex.justify-content-between(@click=\"delete"$MAYUS"Confirm(data[indextr])\")
                      vm-icon(icon=\"trash-2-outline\")
                      slot &nbsp;\{{ \$t('strings.delete') }}
                    vm-dropdown-item.d-flex.justify-content-between(v-if=\"data[indextr]['status'] == '1'\" @click=\"setAction"$MAYUS"(data[indextr], 'invoiced')\")
                      vm-icon(icon=\"checkmark-circle-outline\")
                      slot &nbsp;\{{ \$t('strings.action_invoiced') }}
                    vm-dropdown-item.d-flex.justify-content-between(v-if=\"data[indextr]['status'] == '3'\" @click=\"edit"$MAYUS"(data[indextr])\")
                      vm-icon(icon=\"eye-outline\")
                      slot &nbsp;\{{ \$t('strings.view') }}
                    //- More actions
          vm-pagination(:total=\"pagination.totalPages\" v-model=\"currentPage\" goto)
          transition(name=\"enter\")
            .total-records(v-if=\"total>0\") Total: \{{ total | currency }}
</template>

<script>
import Modal"$MAYUS"s from '@/components/modals/Modal"$MAYUS"s.vue'
import ModalImport from '@/components/modals/ModalImport.vue'
import parseDeleteMany from '@/utils/parseDeleteMany'
import parseVuexObject from '@/utils/parseVuexObject'
import { createNamespacedHelpers } from 'vuex'
const { mapGetters, mapActions } = createNamespacedHelpers('"$MAYUS"s')

export default {
  name: '"$MAYUS"s',
  components: {
    Modal"$MAYUS"s,
    ModalImport
  },
  data: () => ({
    currentPage: 1,
    isModalAdd: true,
    newRecord: {},
    selected: [],
    columns: [
      // Agrega las columnas a mostrar
    ],
    columnsOrderBy: [
      // Nota solo si las columnas son atributos
    ],
    status: [
      // Agregar los estatus si maneja
      // {
      //   text: 'Pagado',
      //   value: 2,
      //   color: 'warning'
      // }
    ],
    filters: {
      // Nota: Estos campos se parsearan en el v-model de los filtros. Ver linea 60
      where: {
        // Agregar las columnas que se filtraran en el buscador
        //name_last_name: [
        //  'name',
        //  'last_name'
        //],
        //user: {
        //  email: ''
        //},
        param: ''
      },
      whereIn: {
        // Agrega las columnas que se filtraran con mas de una opcion ejemplo: status: []
      },
      whereBetween: {
        // Agrega las columnas que se filtraran entre paramentros ejemplo: priece: []
      },
      betweenDates: {
        // Agrega las columnas que se filtraran entre fechas: created_at: []
      },
      orderBy: ''
    },
    filtersClear: {}
  }),
  async created () {
    this.filtersClear = parseVuexObject(this.filters)
    await this.get"$MAYUS"s(1)
    await this.load"$MAYUS"sCatalog()
  },
  methods: {
    ...mapActions([
      'delete"$MAYUS"',
      'delete"$MAYUS"s',
      'load"$MAYUS"s',
      'loadCatalog',
      'load"$MAYUS"sCatalog',
      'action"$MAYUS"',
      'setModalImportVisible',
      'setModalVisible',
      'printReport',
      'applyFilter',
      'clearFilter'
    ]),
    colorStatus (code) {
      return this.status.find(e => e.value === parseInt(code))['color']
    },
    setFocusSearch () {
      this.\$refs.search.\$refs.vminput.focus()
    },
    editShortcut () {
      if (this.selected.length === 0 || this.selected.length > 1) return
      const idx = this."$CAMELCASE"s.findIndex(u => u.id === this.selected[0].id)
      this.edit"$MAYUS"(this.selected[0], idx)
    },
    add"$MAYUS" () {
      this.isModalAdd = true
      this.setModalVisible(true)
      this.newRecord = {}
    },
    edit"$MAYUS" ("$CAMELCASE", index) {
      this.isModalAdd = false
      this.setModalVisible(true)
      this.newRecord = { ..."$CAMELCASE" }
    },
    async delete"$MAYUS"Confirm ("$CAMELCASE") {
      let t = this
      this.auxDelete"$MAYUS" = () => {
        t.delete"$MAYUS"("$CAMELCASE").then(() => { t.selected = [] })
      }
      this.\$vm.dialog({
        color: 'danger',
        title: this.\$t('front.delete_modal'),
        text: this.\$t('front.delete_confirmation', { model: this.\$t('strings."$MINUS"'), attribute: this.\$t("$CAMELCASE"./*columna*/) }),
        accept: this.auxDelete"$MAYUS"
      })
    },
    async delete"$MAYUS"sConfirm () {
      let t = this
      let "$CAMELCASE"sMany = parseDeleteMany(this.selected, /*'columna'*/)
      this.auxDelete"$MAYUS" = () => {
        t.delete"$MAYUS"s("$CAMELCASE"sMany).then(() => { t.selected = [] })
      }
      this.\$vm.dialog({
        color: 'danger',
        title: this.\$t('front.delete_modal'),
        text: this.\$t('front.delete_confirmation', { model: this.\$t('strings."$MINUS"'), attribute: "$CAMELCASE"sMany.values }),
        accept: this.auxDelete"$MAYUS"
      })
    },
    async setAction"$MAYUS" (record, action) {
      record.id && this.action"$MAYUS"({ id: record.id, action })
    },
    async get"$MAYUS"s (page) {
      let t = this
      this.load"$MAYUS"s({ page }).then(data => t.getProps(t.\$route.params.id))
    },
    getProps (index) {
      let "$CAMELCASE" = this."$CAMELCASE"s.filter("$CAMELCASE" => "$CAMELCASE".id === parseInt(index))[0]
      "$CAMELCASE" && this.edit"$MAYUS"("$CAMELCASE", index)
    },
    autoCompleteFunc (value, url) {
      this.loadCatalog({ filter: value, url: url })
    },
    newObjectFuncModal (value) {
      //
    },
    newObjectFuncView (value) {
      //
    },
    handleChange (date) {
      // this.filters.betweenDates.created_at = date
    },
    hiddeDrop () {
      let [dropdownMenu] = this.\$refs.dropdown.\$children.filter((item) => {
        return item.hasOwnProperty('dropdownVisible')
      })
      dropdownMenu.dropdownVisible = false
    }
  },
  computed: {
    ...mapGetters([
      '"$CAMELCASE"s',
      'pagination',
      'filterParams'
    ]),
    searchPlaceholder () {
      let t = this
      let concatColumns = Object.keys(this.filters.where).reduce((str, column, index) => {
        if (column !== 'param' && index < Object.keys(t.filters.where).length - 2) return (index > 0) ? \`\${str}, $\{t.\$t('"$CAMELCASE"s.' + column)}\` : \`\${str} \${t.\$t('"$CAMELCASE"s.' + column)}\`
        return str
      }, '')
      return this.\$t('strings.search', { attribute: this.\$t('strings."$CAMELCASE"'), columns: concatColumns, column: this.\$t('"$CAMELCASE"s.' + Object.keys(this.filters.where)[Object.keys(t.filters.where).length - 2]) })
    },
    enabledDelete () {
      return this.selected.length > 0
    },
    total () {
      return this.selected.reduce((prev, cur) => prev + parseFloat(cur.total), 0).toFixed(2)
    }
  },
  watch: {
    currentPage (currentPage) {
      this.get"$MAYUS"s(currentPage)
    },
    filterParams (filter) {
      this.hiddeDrop()
      filter.length === 0 && (this.filters = parseVuexObject(this.filtersClear))
      this.selected = []
      this.currentPage = 1
      this.get"$MAYUS"s(this.currentPage)
    }
  }
}
</script>

<style lang=\"scss\">
.filters {
  .filter {
    padding: 5px 10px;
    width: 250px;
  }
}
.con-vm-tooltip {
  display: inline-block;
  float: left;
  position: relative;
}
.vm-table--header {
  padding: 10px;
  span:nth-child(1)  {
    width: 100%;
  }
  .input-select-con{
    span {
      width: auto !important;
    }
  }
  .justify-content-between {
    div:last-child {
      .vm-button {
        margin: 0 3px;
      }
      .vm-con-dropdown {
        float: left;
      }
      .con-select {
        display: inline-block;
        input {
          height: 32px;
        }
      }
    }
  }
}
</style>" > src/views/$MAYUS\s.vue

# crear archivo .vue del nuevo modal
echo "<template lang=\"pug\">
  vm-prompt(@vm-cancel=\"close\" @vm-accept=\"saveRecord\" @vm-close=\"close\" @vm-action=\"delete"$MAYUS"Confirm(newRecord)\" :vm-action=\"true\" :vm-action-text=\"\$t('strings.delete')\" :vm-accept-text=\"\$t('strings.accept')\" :vm-cancel-text=\"\$t('strings.cancel')\" :vm-buttons-hidden=\"true\" :vm-is-valid=\"!\$v.newRecord.\$invalid\" :vm-active=\"isModalVisible\" :vm-title='getTitle')
    vm-row(vm-align=\"center\" vm-type=\"flex\" vm-justify=\"space-between\" vm-w=\"12\" v-shortcuts=\"[{ shortcut: [ 'enter', ], callback: saveRecord, push: true, focus: true, disabled: \$v.newRecord.\$invalid },]\")
      vm-col(vm-justify=\"center\", vm-align=\"center\", vm-w=12)
        b-form-group
          vm-input(:placeholder='\$t(\""$MINUS"s.contact_placeholder\")' :danger=\"!\$v.newRecord.contact.minLength\" :danger-text=\"'Name must have at least 4 ' + \$v.newRecord.contact.\$params.minLength + ' letters.'\" v-model=\"newRecord.contact\" :label='\$t(\""$MINUS"s.contact\")')
</template>

<script>
import { required, minLength, email } from 'vuelidate/lib/validators' // Ver documentacion
import { createNamespacedHelpers } from 'vuex'
const { mapGetters, mapActions } = createNamespacedHelpers('"$MAYUS"s')

export default {
  name: 'Modal"$MAYUS"s',
  props: {
    newRecord: {
      type: Object
    },
    isAdd: {
      default: true,
      type: Boolean
    }
  },
  validations: {
    newRecord: {
      // contact: {
      //   required,
      //   minLength: minLength(5)
      // },
      // email: {
      //   required,
      //   email
      // }
    }
  },
  computed: {
    ...mapGetters([
      'isModalVisible',
      '"$CAMELCASE"sCatalog'
    ]),
    getTitle () {
      return this.isAdd ? this.\$t('"$MINUS"s.add') : this.\$t('"$MINUS"s.edit')
    }
  },
  methods: {
    ...mapActions([
      'add"$MAYUS"',
      'edit"$MAYUS"',
      'delete"$MAYUS"',
      'setModalVisible',
      'loadCatalog'
    ]),
    saveRecord () {
      this.isAdd ? this.add"$MAYUS"(this.newRecord) : this.edit"$MAYUS"(this.newRecord)
    },
    async delete"$MAYUS"Confirm ("$CAMELCASE") {
      let t = this
      this.auxDelete"$MAYUS" = () => {
        t.delete"$MAYUS"("$CAMELCASE")
      }
      this.\$vm.dialog({
        color: 'danger',
        title: this.\$t('front.delete_modal'),
        text: this.\$t('front.delete_confirmation', { attribute: this.\$t("$MINUS"./*columna*/) }),
        accept: this.auxDelete"$MAYUS"
      })
    },
    autoCompleteFunc (value, url) {
      this.loadCatalog({ filter: value, url: url })
    },
    close () {
      this.setModalVisible(false)
    }
  }
}
</script>" > src/components/modals/Modal$MAYUS\s.vue

# agregar ruta

ROUTE="{\n      path: '\/"$URL"s\',\n      name: \'"$CAMELCASE"s\',\n      component: () => import(\/\* webpackChunkName:  \""$CAMELCASE"\"  \*\/ \'\@\/views\/$MAYUS\s.vue\'),\n      meta: {\n        title: Vue.i18n.translate(\'strings."$MINUS"s\', null),\n        auth: true\n      },\n      children: \[{\n        path: \':id\',\n        name: \'"$CAMELCASE"Detail\',\n        component: () => import(\/\* webpackChunkName:  \""$CAMELCASE"\"  \*\/ \'\@\/views\/$MAYUS\s.vue\')\n      }\]\n    },\n    \/\/ New Route"

sed -e "s/\/\/ New Route/$ROUTE/" src/router/index.js > script_tmp
mv script_tmp src/router/index.js

# agregar vuex module

echo "import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'
import app from '../../main' // import the instance
import checkResponse from '@/utils/checkResponse'
import parserFilters from '@/utils/parserFilters'
import parserSlug from '@/utils/parserSlug'

Vue.use(Vuex)

const state = {
  "$CAMELCASE"s: [],
  pagination: {
    currentPage: 1,
    perPage: 5,
    total"$MAYUS"s: 0,
    totalPages: 0
  },
  "$CAMELCASE"sCatalog: {},
  filterParams: '',
  isModalVisible: false
}

const mutations = {
  SET_"$AMAYUS"S (state, payload) {
    state."$CAMELCASE"s = payload.data

    state.pagination = {
      currentPage: payload.current_page,
      perPage: payload.per_page,
      total"$MAYUS"s: payload.total,
      totalPages: payload.last_page
    }
  },
  ADD_"$AMAYUS" (state, payload) {
    state."$CAMELCASE"s.unshift(payload)
  },
  UPDATE_"$AMAYUS" (state, payload) {
    const idx = state."$CAMELCASE"s.findIndex(u => u.id === payload.id)

    if (idx >= 0) {
      Vue.set(state."$CAMELCASE"s, idx, payload)
    }
  },
  DELETE_"$AMAYUS" (state, payload) {
    const idx = state."$CAMELCASE"s.findIndex(u => u.id === payload.id)

    if (idx >= 0) {
      Vue.delete(state."$CAMELCASE"s, idx)
    }
  },
  DELETE_"$AMAYUS"S (state, payload) {
    for (let id of payload.ids) {
      const idx = state."$CAMELCASE"s.findIndex(u => u.id === id)

      if (idx >= 0) {
        Vue.delete(state."$CAMELCASE"s, idx)
      }
    }
  },
  SET_MODAL_VISIBLE (state, payload) {
    state.isModalVisible = payload
  },
  SET_FILTER_PARAMS (state, payload) {
    state.filterParams = payload
  },
  SET_CATALOG (state, { object, payload }) {
    state."$CAMELCASE"sCatalog[object] = payload.data
  },
  SET_"$AMAYUS"S_CATALOG (state, payload) {
    state."$CAMELCASE"sCatalog = { ...state."$CAMELCASE"sCatalog, ...payload }
  }
}

const actions = {
  async load"$MAYUS"s ({ commit }, payload) {
    app.\$Progress.start()
    try {
      const response = await axios.get(\`"$URL"s?page=\${payload.page}\${state.filterParams}\`)
      const checkErrors = checkResponse(response)

      if (checkErrors) {
        app.\$Progress.fail()
        commit('SET_ALERT_MESSAGE', { color: 'danger', title: 'errors.connection_error', text: checkErrors.message }, { root: true })
      } else {
        commit('SET_"$AMAYUS"S', response.data)
      }
    } catch (e) {
      app.\$Progress.fail()
      commit('SET_ALERT_MESSAGE', { color: 'danger', title: 'errors.connection_error', text: 'errors.generic_error' }, { root: true })
    } finally {
      app.\$Progress.finish()
    }
  },
  async add"$MAYUS" ({ commit }, payload) {
    const "$CAMELCASE" = {
      // columnas
      // sku: payload.sku,
    }

    app.\$Progress.start()

    try {
      const response = await axios.post('"$URL"s', "$CAMELCASE")
      const checkErrors = checkResponse(response)

      if (checkErrors) {
        app.\$Progress.fail()
        commit('SET_ALERT_MESSAGE', { color: 'danger', title: 'errors.connection_error', text: checkErrors.message }, { root: true })
      } else {
        commit('ADD_"$AMAYUS"', response.data)
        commit('SET_MODAL_VISIBLE', false)
        commit('SET_ACCEPT_ALERT', { color: 'success', title: 'strings."$MINUS"s', text: 'front.added_successfully', icon: 'checkmark-circle-outline' }, { root: true })
      }
    } catch (e) {
      app.\$Progress.fail()
      commit('SET_ALERT_MESSAGE', { color: 'danger', title: 'errors.connection_error', text: 'errors.generic_error' }, { root: true })
    } finally {
      app.\$Progress.finish()
    }
  },
  async edit"$MAYUS" ({ commit }, payload) {
    const "$CAMELCASE" = {
      // columnas
    }

    app.\$Progress.start()

    try {
      const response = await axios.put(\`"$URL"s/\${payload.id}\`, "$CAMELCASE")
      const checkErrors = checkResponse(response)

      if (checkErrors) {
        app.\$Progress.fail()
        commit('SET_ALERT_MESSAGE', { color: 'danger', title: 'errors.connection_error', text: checkErrors.message }, { root: true })
      } else {
        commit('UPDATE_"$AMAYUS"', response.data)
        commit('SET_MODAL_VISIBLE', false)
        commit('SET_ACCEPT_ALERT', { color: 'success', title: 'strings."$MINUS"s', text: 'front.updated_successfully', icon: 'checkmark-circle-outline' }, { root: true })
      }
    } catch (e) {
      app.\$Progress.fail()
      commit('SET_ALERT_MESSAGE', { color: 'danger', title: 'errors.connection_error', text: 'errors.generic_error' }, { root: true })
    } finally {
      app.\$Progress.finish()
    }
  },
  async delete"$MAYUS" ({ commit }, payload) {
    app.\$Progress.start()
    try {
      const response = await axios.delete(\`"$URL"s/\${payload.id}\`)
      const checkErrors = checkResponse(response)

      if (checkErrors) {
        app.\$Progress.fail()
        commit('SET_ALERT_MESSAGE', { color: 'danger', title: 'errors.connection_error', text: checkErrors.message }, { root: true })
      } else {
        commit('DELETE_"$AMAYUS"', payload)
        commit('SET_MODAL_VISIBLE', false)
        commit('SET_ACCEPT_ALERT', { color: 'success', title: 'strings."$MINUS"s', text: 'front.deleted_successfully', icon: 'checkmark-circle-outline' }, { root: true })
      }
    } catch (e) {
      app.\$Progress.fail()
      commit('SET_ALERT_MESSAGE', { color: 'danger', title: 'errors.connection_error', text: 'errors.generic_error' }, { root: true })
    } finally {
      app.\$Progress.finish()
    }
  },
  async delete"$MAYUS"s ({ commit }, payload) {
    app.\$Progress.start()
    try {
      const response = await axios.delete(\`"$URL"s/delete\`, { params: { ids: payload.ids } })
      const checkErrors = checkResponse(response)

      if (checkErrors) {
        app.\$Progress.fail()
        commit('SET_ALERT_MESSAGE', { color: 'danger', title: 'errors.connection_error', text: checkErrors.message }, { root: true })
      } else {
        commit('DELETE_"$AMAYUS"S', payload)
        commit('SET_ACCEPT_ALERT', { color: 'success', title: 'strings."$MINUS"s', text: 'front.deleted_successfully', icon: 'checkmark-circle-outline' }, { root: true })
      }
    } catch (e) {
      app.\$Progress.fail()
      commit('SET_ALERT_MESSAGE', { color: 'danger', title: 'errors.connection_error', text: 'errors.generic_error' }, { root: true })
    } finally {
      app.\$Progress.finish()
    }
  },
  async action"$MAYUS" ({ commit }, payload) {
    app.\$Progress.start()
    try {
      const response = await axios.put(\`"$URL"s/\${payload.id}/\${payload.action}\`)
      const checkErrors = checkResponse(response)

      if (checkErrors) {
        app.\$Progress.fail()
        commit('SET_ALERT_MESSAGE', { color: 'danger', title: 'errors.connection_error', text: checkErrors.message }, { root: true })
      } else {
        commit('UPDATE_"$AMAYUS"', response.data)
        commit('SET_ACCEPT_ALERT', { color: 'success', title: 'strings."$MINUS"s', text: \`"$MINUS"s.\${payload.action}\`, icon: 'checkmark-circle-outline' }, { root: true })
      }
    } catch (e) {
      app.\$Progress.fail()
      commit('SET_ALERT_MESSAGE', { color: 'danger', title: 'errors.connection_error', text: 'errors.generic_error' }, { root: true })
    } finally {
      app.\$Progress.finish()
    }
  },
  printReport ({ commit }, payload) {
    app.\$Progress.start()
    try {
      window.open(axios.defaults.baseURL + '/"$URL"s/export?' + state.filterParams)
    } catch (e) {
      app.\$Progress.fail()
      commit('SET_ALERT_MESSAGE', { color: 'danger', title: 'errors.connection_error', text: 'errors.generic_error' }, { root: true })
    } finally {
      app.\$Progress.finish()
    }
  },
  applyFilter ({ commit }, payload) {
    const filter = parserFilters(payload)
    commit('SET_FILTER_PARAMS', filter)
  },
  clearFilter ({ commit }, payload) {
    const filter = ''
    commit('SET_FILTER_PARAMS', filter)
  },
  async loadCatalog ({ commit }, payload) {
    let url = parserSlug(payload.url)
    app.\$Progress.start()
    try {
      const response = await axios.get(\`\${url}\${payload.filter}\`)
      const checkErrors = checkResponse(response)

      if (checkErrors) {
        app.\$Progress.fail()
        commit('SET_ALERT_MESSAGE', { color: 'danger', title: 'errors.connection_error', text: checkErrors.message }, { root: true })
      } else {
        commit('SET_CATALOG', { object: payload.url, payload: response.data })
      }
    } catch (e) {
      app.\$Progress.fail()
      commit('SET_ALERT_MESSAGE', { color: 'danger', title: 'errors.connection_error', text: 'errors.generic_error' }, { root: true })
    } finally {
      app.\$Progress.finish()
    }
  },
  async load"$MAYUS"sCatalog ({ commit }, payload) {
    app.\$Progress.start()
    try {
      const response = await axios.get(\`"$URL"s/catalog\`)
      const checkErrors = checkResponse(response)

      if (checkErrors) {
        app.\$Progress.fail()
        commit('SET_ALERT_MESSAGE', { color: 'danger', title: 'strings."$MINUS"s', text: checkErrors.message }, { root: true })
      } else {
        commit('SET_"$AMAYUS"S_CATALOG', response.data)
      }
    } catch (e) {
      app.\$Progress.fail()
      commit('SET_ALERT_MESSAGE', { color: 'danger', title: 'errors.connection_error', text: 'errors.generic_error' }, { root: true })
    } finally {
      app.\$Progress.finish()
    }
  },
  setModalVisible ({ commit }, payload) {
    commit('SET_MODAL_VISIBLE', payload)
  },
  setModalImportVisible ({ commit }, payload) {
    commit('SET_MODAL_IMPORT_VISIBLE', payload, { root: true })
  }
}

const getters = {
  "$CAMELCASE"s: state => state."$CAMELCASE"s,
  "$CAMELCASE"sCatalog: state => state."$CAMELCASE"sCatalog,
  pagination: state => state.pagination,
  isModalVisible: state => state.isModalVisible,
  filterParams: state => state.filterParams
}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters
}" > src/store/modules/$MAYUS\s.js


# agregar tests

echo "import Vue from 'vue'
import { mount } from '@vue/test-utils'
import faker from 'faker'

import configStore from '../mocks/config-store'
import storeMock from '../mocks/store-mock'

import "$MAYUS"s from '@/views/"$MAYUS"s.vue'

const mock"$MAYUS"s = []

for (let i = 0; i < 10; i++) {
  mock"$MAYUS"s.push({
    id: faker.random.number(),
    // campos
  });
}

Vue.prototype.\$auth = {
  check: jest.fn(),
  ready: jest.fn(),
  user: jest.fn(() => ({
    name,
  }))
}

jest.doMock('axios', () => {
  return {
    get: jest.fn(() => Promise.resolve({
      status: 200,
      data: {
        data: mock"$MAYUS"s,
      },
    })),
  };
});

storeMock.state = {
  user: {
    name: faker.name.findName(),
    view_permissions: 'Admin',
  }
}

storeMock.modules."$MAYUS"s.actions = {
  delete"$MAYUS": jest.fn(),
  delete"$MAYUS"s: jest.fn(),
  load"$MAYUS"s: jest.fn(),
  loadCatalog: jest.fn(),
  load"$MAYUS"sCatalog: jest.fn(),
  action"$MAYUS": jest.fn(),
  setModalVisible: jest.fn(),
  setModalImportVisible: jest.fn(),
  printReport: jest.fn(),
  applyFilter: jest.fn(),
  clearFilter: jest.fn()
}

storeMock.modules."$MAYUS"s.state."$CAMELCASE"s = mock"$MAYUS"s;

describe('"$MAYUS"s.vue', () => {

  const store = configStore(Vue, storeMock)
  beforeEach(() => {
    jest.resetModules()
    jest.clearAllMocks()
  })

  it('should render correct contents', (done) => {
    const wrapper = mount("$MAYUS"s, {
      store,
      mocks: {
        \$route: {
          params: { id: '' }
        }
      }
    })

    setTimeout(() => {
      expect(wrapper.findAll('.tr-table')).toHaveLength(mock"$MAYUS"s.length)
      expect(wrapper.findAll('.vm-table--td span').at(0).text()).toEqual(mock"$MAYUS"s[0].contact); //campo

      done()
    }, 1500)
  })

})" > tests/unit/views/$MINUS\s.spec.js

UNIT=""$MAYUS"s: {\n      namespaced: true,\n      state: {\n        "$CAMELCASE"s: {},\n        pagination: {\n           currentPage: 1,\n         perPage: 5,\n         total"$MAYUS"s: 10,\n         totalPages: 1,\n        },\n        "$CAMELCASE"sCatalog: {},\n        filterParams: \'\',\n        isModalVisible: false\n      },\n      getters: {\n        "$CAMELCASE"s: state => state."$CAMELCASE"s,\n        "$CAMELCASE"sCatalog: state => state."$CAMELCASE"sCatalog,\n        pagination: state => state.pagination,\n        isModalVisible: state => state.isModalVisible,\n        filterParams: state => state.filterParams\n      }\n    },\n    \/\/ New Module"

sed -e "s/\/\/ New Module/$UNIT/" tests/unit/mocks/store-mock.js > script_tmp
mv script_tmp tests/unit/mocks/store-mock.js


E2E="\'"$MAYUS"s\': browser => {\n\t\t\browser\n\r\t\t\t .useXpath()\n\r\t\t\t .click(\"\/\/a[normalize-space()=\'"$MAYUS"s\']\")\n\r\t\t\t\ .useCss()\n\r\t\t\t .pause(5000)\n\r\t\t\t .assert.elementPresent(\'.crud\')\n\t\t\t.assert.containsText(\'.heading h2\', \'"$MAYUS"s:\')\n    },\n  \/\/ New Test"

sed -e "s/\/\/ New Test/$E2E/" tests/e2e/specs/test.js > script_tmp
mv script_tmp tests/e2e/specs/test.js

echo 'finish successfully'
fi
