'use strict';
/**
 * Password view extension
 *
 * @author    Aman Srivastava <aman.srivastava462@webkul.com>
 * @copyright 2019 Webkul Soft. Pvt. Ltd. (https://webkul.com)
 */

define(
    [
        'pim/job/common/edit/field/text',
        'webkuldam/template/job/field/custom-text',
        'pim/common/property',
    ],
    function (
        parentField,
        template,
        propertyAccessor,
    ) {
        return parentField.extend({
            fieldTemplate: _.template(template),
            events: {
                'change input': 'updateState',
                'keyup .damTextArea': 'updateTextArea'
            },

            /**
             * Get the field dom value
             *
             * @return {string}
             */
            getTextFieldValue: function () {
                return this.$('.damTextArea').val();
            },

            /**
             * Update the model after dom update
             */
            updateTextArea: function () {
                var data = propertyAccessor.updateProperty(this.getFormData(), this.getFieldCode(), this.getTextFieldValue());

                this.setData(data);
            }
        });
    }
);
