appReductionCart = new Vue({
    el: '#lc-reduction-cart-edit',
    delimiters: ['${', '}'],
    mixins: [mixinReduction],
    data() {
        return Object.assign(
            {
                reductionCombinable:true,
                reductionUncombinableTypes:[],
                reductionUncombinables:[],
                reductionPointSalesActive: false,
                reductionPointSales: [],
                reductionDeliveryZonesActive:false,
                reductionDeliveryZones:[],
                reductionDeliverySlotsActive:false,
                reductionDeliverySlots:[],
                reductionAppliedTo: null,
                currentSection: 'info',
                sectionsArray: [
                    {
                        name: 'info',
                        nameDisplay: 'Info'
                    },
                    {
                        name: 'conditions',
                        nameDisplay: 'Conditions '
                    },
                    {
                        name: 'actions',
                        nameDisplay: 'Actions'
                    }
                ]
            }, window.reductionCartValues);
    },
    mounted: function () {
        log(window.reductionCartValues );
        this.isMounted = true;
    },
    methods: {
        changeSection: function (section) {
            this.currentSection = section.name;
        },
        updateCodes:function (e) {

            if( window.reductionCartCodesUsed.indexOf($(e.target).val().toUpperCase())!=-1){
                e.target.setCustomValidity("Invalid field.");
            }else{
                e.target.setCustomValidity("");
            }
        }
    },
    watch: {
        reductionDeliveryZonesActive:function(){
            this.emptySelect2('reductionDeliveryZones');
        },
        reductionDeliveryZones:function(){
            this.filterOn(this.reductionDeliveryZones, 'reductionDeliverySlots', 'delivery-zone', 'array');
        },
        reductionDeliverySlotsActive:function(){
            this.emptySelect2('reductionDeliverySlots');
        },
        reductionPointSalesActive:function(){
            this.emptySelect2('reductionPointSales');
        },
        reductionUncombinableTypes: function () {
            this.filterOn(this.reductionUncombinableTypes, 'reductionUncombinables', 'type', 'string', true);
        }
    }
});
