import AdmVue from '@assets/js/adm-vue';
import initVue from "@assets/js/initVue";

const vm = new AdmVue({
    components: {
      BaseCard: () => import(/* webpackChunkName: "BaseCard" */ '@elements/BaseCard/index.vue'),
      BaseTabs: () => import(/* webpackChunkName: "BaseTabs" */ '@components/BaseTabs/index.vue'),
      BaseManual: () => import(/* webpackChunkName: "BaseManual" */ "@elements/BaseManual/index.vue")
    },
    data() {
      return {
        configurations: {
          brandproducts_title: '',
          brandproducts_module: []
        },
        disableForm: false,
        loadingBtn: false,
      };
    },
    methods:{
      onAddModule(){

        const { configurations } = this;
        const brandproductsModule = configurations.brandproducts_module;

        let sortOrder = 0;
        if (brandproductsModule[brandproductsModule.length - 1]) {
          const { sort_order } = brandproductsModule[brandproductsModule.length - 1];
          sortOrder = Number(sort_order) + 1;
        }

          this.configurations.brandproducts_module.push({
            layout_id: Type_IdLayout.Tp_IdProduct,
            limit: '24',
            sort_order: sortOrder,
          });


        this.configurations = {...configurations};

      },
      onRemoveModule(moduleIndex){
        const { configurations } = this;
        const brandproductsModule = configurations.brandproducts_module;
        brandproductsModule.splice(moduleIndex, 1);
        this.configurations = {...configurations};
      }
    },

});

initVue(vm);
