'use strict';

/**
 * Switch view extension
 *
 * @author    Aman Srivastava <aman.srivastava462@webkul.com>
 * @copyright 2019 Webkul Soft. Pvt. Ltd. (http://www.webkul.com)
 */
define([
    'pim/job/common/edit/field/switch',
    'pim/template/export/common/edit/field/switch',
    'pim/common/property',
], function (
    BaseField,
    fieldTemplate,
    propertyAccessor,
) {
    return BaseField.extend({
        fieldTemplate: _.template(fieldTemplate),  
        /**
         * Update the model after dom update
         */
        updateState: function () {
            var data = propertyAccessor.updateProperty(this.getFormData(), this.getFieldCode(), this.getFieldValue());

            var properties = ['configuration.files_single_asset','configuration.dir_asset_check','configuration.only_asset_check'];

            $.each(properties,function(index,value){
                if(value !== this.getFieldCode()) {
                    data = propertyAccessor.updateProperty(data, value, false);
                }  
            }.bind(this))

            this.setData(data);

            this.parent.render()
        }
    });
});
