# weforms/1.6.1/assets/components/form-notification/index.js

weForms – Easy Drag &amp; Drop Contact Form Builder For WordPress, version 1.6.1. 88 lines.

- Page: https://pluginprobe.com/plugins/weforms/1.6.1/code/assets/components/form-notification/index.js
- Raw: https://pluginprobe.com/plugins/weforms/1.6.1/raw/assets/components/form-notification/index.js
- Modified: 2020-11-11T12:52:22+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/weforms/1.6.1/code/assets/components/form-notification/index.js#L10-L20`.

```javascript
Vue.component('wpuf-cf-form-notification', {
    template: '#tmpl-wpuf-form-notification',
    mixins: [weForms.mixins.Loading],
    data: function() {
        return {
            editing: false,
            editingIndex: 0,
        };
    },

    computed: {
        is_pro: function() {
            return 'true' === weForms.is_pro;
        },
        has_sms: function() {
            return 'true' === weForms.has_sms;
        },
        pro_link: function() {
            return wpuf_form_builder.pro_link;
        },
        notifications: function() {
            return this.$store.state.notifications;
        },

        hasNotifications: function() {
            return Object.keys( this.$store.state.notifications ).length;
        }
    },

    methods: {
        addNew: function() {
            this.$store.commit('addNotification', wpuf_form_builder.defaultNotification);
        },

        editItem: function(index) {
            this.editing = true;
            this.editingIndex = index;
        },

        editDone: function() {
            this.editing = false;

            this.$store.commit('updateNotification', {
                index: this.editingIndex,
                value: this.notifications[this.editingIndex]
            });

            jQuery('.advanced-field-wrap').slideUp('fast');
        },

        deleteItem: function(index) {
            if ( confirm( 'Are you sure' ) ) {
                this.editing = false;
                this.$store.commit( 'deleteNotification', index);
                this.$emit('deleteNotification', index);
            }
        },

        toggelNotification: function(index) {
            this.$store.commit('updateNotificationProperty', {
                index: index,
                property: 'active',
                value: !this.notifications[index].active
            });
        },

        duplicate: function(index) {
            this.$store.commit('cloneNotification', index);
        },

        toggleAdvanced: function() {
            jQuery('.advanced-field-wrap').slideToggle('fast');
        },

        insertValue: function(type, field, property) {
            var notification = this.notifications[this.editingIndex],
                value = ( field !== undefined ) ? '{' + type + ':' + field + '}' : '{' + type + '}';

            notification[property] = notification[property] + value;
        },

        insertValueEditor: function(type, field, property) {
            var value = ( field !== undefined ) ? '{' + type + ':' + field + '}' : '{' + type + '}';
            this.$emit('insertValueEditor', value);
        },
    }
});

```
