this.$entityChoice.on('change', function(e, extraArgs) {
                _.extend(e, extraArgs);

                var data = self.load() || [];
                var requiresConfirm = _.some(data, function(value) {
                    return !_.isEmpty(value);
                });

                var ok = _.partial(_.bind(self._onEntityChangeConfirm, self), e, _.pick(e, 'val', 'removed'));

                var cancel = function() {
                    var oldVal = (e.removed && e.removed.id) || null;
                    self.$entityChoice.val(oldVal).change();
                };

                if (requiresConfirm) {
                    confirm.on('ok', ok);
                    confirm.on('cancel', cancel);
                    confirm.once('hidden', function() {
                        confirm.off('ok');
                        confirm.off('cancel');
                    });
                    confirm.open();
                } else {
                    ok();
                }
            });
Exemplo n.º 2
0
    function processFormTypeChange() {
        if (blockNextRequest) {
            blockNextRequest = false;
            return;
        }
        var currentFormType = $formTypeField.val();

        if (!isFormStateChanged($cssField.val(), $successMessageField.val())) {
            requestDefaultFormTypeData(currentFormType);

            return;
        }

        var confirm = new DeleteConfirmation({
            title: __('embedded_form.confirm_box.title'),
            okText: __('embedded_form.confirm_box.ok_text'),
            content: __('embedded_form.confirm_box.content')
        });
        confirm.on('ok', function() {
            requestDefaultFormTypeData(currentFormType);
        });
        confirm.on('cancel', function() {
            blockNextRequest = true;
            $formTypeField.val(rememberedFormType).trigger('change');
        });
        confirm.open();
    }
Exemplo n.º 3
0
 _confirmRemoveAttachment: function() {
     var confirm = new DeleteConfirmation({
         content: this._getMessage('deleteConfirmation')
     });
     confirm.on('ok', _.bind(this._removeAttachment, this));
     confirm.open();
 },
Exemplo n.º 4
0
 _removeHandler: function(model, message) {
     var confirm = new DeleteConfirmation({
         content: message
     });
     confirm.on('ok', function() {
         model.destroy();
     });
     confirm.open();
 },
Exemplo n.º 5
0
 _deleteItem: function (model) {
     var confirm = new DeleteConfirmation({
         content: this._getMessage('deleteConfirmation')
     });
     confirm.on('ok', _.bind(function () {
         this._onItemDelete(model);
     }, this));
     confirm.open();
 },
Exemplo n.º 6
0
 function deleteHandler(collection, model, data) {
     var confirm = new DeleteConfirmation({
         content: data.message
     });
     confirm.on('ok', function () {
         collection.remove(model);
     });
     confirm.open();
 }
        handleDeleteConfirmation: function() {
            var _self = this;
            var message = __('By disabling the Channel Pricing, all data from Channel Pricing will be lost upon saving. Are you sure?');
            var confirm = new DeleteConfirmation({
                content: message,
                okText: __('Yes, I\'m sure')
            });

            confirm.open();

            confirm.on('cancel', function() {
                _self.$sourceElement.addClass('pricing-enabled');
                _self.$checkBoxElement.prop('checked',true);
            });

            confirm.on('ok', function() {
                _self.clearItems();
            });
        },
        triggerRemove: function(e) {
            e.preventDefault();

            var confirm = new Confirmation({
                content: __('Are you sure you want to delete this field?')
            });
            confirm.on('ok', _.bind(function() {
                this.trigger('removeFormOption', this.options.data);
            }, this));
            confirm.open();
        },
Exemplo n.º 9
0
        onRemoveWidget: function(cid) {
            var widget = this.getWidgets().get(cid);
            if (!widget) {
                return;
            }

            var modal = new DeleteConfirmation({
                content: __('oro.sidebar.widget.remove.confirm.message')
            });

            modal.on('ok', function() {
                widget.destroy();
                modal.off();
            });

            modal.on('cancel', function() {
                modal.off();
            });

            modal.open();
        },
Exemplo n.º 10
0
        onRemoveWidget: function (cid) {
            var widget = this.getWidgets().get(cid);
            if (!widget) {
                return;
            }

            var modal = new DeleteConfirmation({
                content: __('The widget will be removed')
            });

            modal.on('ok', function () {
                widget.destroy();
                modal.off();
            });

            modal.on('cancel', function () {
                modal.off();
            });

            modal.open();
        },
Exemplo n.º 11
0
    function onClick(reloadRequired, e) {
        e.preventDefault();

        var confirm = new DeleteConfirmation({
            title:   __(options.title),
            okText:  __(options.okText),
            content: __(options.content)
        });

        var url = $(e.target).data('url');

        confirm.on('ok', $.proxy(run, null, url, reloadRequired));
        confirm.open();
    }
Exemplo n.º 12
0
        removeModel: function (e) {
            e.stopPropagation();

            var model   = this.model;
            var confirm = new DeleteConfirmation({
                content: __('oro.comment.deleteConfirmation')
            });

            confirm.on('ok', _.bind(function () {
                model.destroy();
            }, this));

            confirm.open();
        },
Exemplo n.º 13
0
        initEntityFieldsLoader: function() {
            var confirm = new Confirmation({
                title: __('Change Entity Confirmation'),
                okText: __('Yes'),
                content: __('oro.workflow.change_entity_confirmation')
            });
            confirm.on('ok', _.bind(function() {
                this.model.set('entity', this.$entitySelectEl.val());
            }, this));
            confirm.on('cancel', _.bind(function() {
                this.$entitySelectEl.inputWidget('val', this.model.get('entity'));
            }, this));

            this.$entitySelectEl.fieldsLoader({
                router: 'oro_api_workflow_entity_get',
                routingParams: {},
                confirm: confirm,
                requireConfirm: _.bind(function() {
                    return this.model.get('steps').length > 1 &&
                        (this.model.get('transitions').length +
                            this.model.get('transition_definitions').length +
                            this.model.get('attributes').length) > 0;
                }, this)
            });

            this.$entitySelectEl.on('change', _.bind(function() {
                if (!this.model.get('entity')) {
                    this.model.set('entity', this.$entitySelectEl.val());
                }
            }, this));

            this.$entitySelectEl.on('fieldsloadercomplete', _.bind(function(e) {
                this.initEntityFieldsData($(e.target).data('fields'));
            }, this));

            this._preloadEntityFieldsData();
        },
Exemplo n.º 14
0
        onCommentRemove: function(model) {
            if (!model.get('removable')) {
                return;
            }

            var confirm = new DeleteConfirmation({
                content: __('oro.comment.deleteConfirmation')
            });

            confirm.on('ok', _.bind(function() {
                model.destroy();
            }, this));

            confirm.open();
        },
Exemplo n.º 15
0
        onDelete: function(e) {
            var id = this._getCurrentView().value;
            var model = this.viewsCollection.get(id);

            var confirm = new DeleteConfirmation({
                content: __('Are you sure you want to delete this item?')
            });
            confirm.on('ok', _.bind(function() {
                model.destroy({wait: true});
                model.once('sync', function() {
                    this._showFlashMessage('success', __('oro.datagrid.gridView.deleted'));
                    mediator.trigger('datagrid:' + this.gridName + ':views:remove', model);
                }, this);
            }, this));

            confirm.open();
        },
Exemplo n.º 16
0
        onEntityChange: function(e) {
            var view = this.view;
            var $el = $(e.currentTarget);
            var entityName = $el.val();
            var entityLabel = $el.find(':selected').data('label');

            if (!this.view.isEmpty()) {
                var confirm = new DeleteConfirmation({
                    title: __('Change Entity Confirmation'),
                    okText: __('Yes'),
                    content: __('oro.email.emailtemplate.change_entity_confirmation')
                });

                confirm.on('ok', function() {
                    view.clear();
                });

                confirm.open();
            }

            this.model.setEntity(entityName, entityLabel);
        },
Exemplo n.º 17
0
        initColumn: function() {
            var self = this;
            var options = this.options.column;
            var metadata = this.options.metadata;
            var $table = $(options.itemContainer);
            var $editor = $(options.form);

            if (_.isEmpty($table) || _.isEmpty($editor)) {
                // there's no columns
                return;
            }

            // setup FieldChoice of Items Manager Editor
            var fieldChoiceOptions = _.extend({}, this.options.columnFieldChoiceOptions, {select2: {}});
            var $fieldChoice = $editor.find('[data-purpose=column-selector]');
            $fieldChoice.fieldChoice(fieldChoiceOptions);
            this.on('fieldsLoaded', function(entity, data) {
                $fieldChoice.fieldChoice('updateData', entity, data);
            });

            // prepare collection for Items Manager
            var collection = new BaseCollection(this.load('columns'), {model: ColumnModel});
            this.listenTo(collection, 'add remove sort change', function() {
                this.save(collection.toJSON(), 'columns');
            });

            // setup confirmation dialog for delete item
            var confirm = new DeleteConfirmation({content: ''});
            confirm.on('ok', function() {
                collection.remove(this.model);
            });
            confirm.on('hidden', function() {
                delete this.model;
            });

            // setup Items Manager's editor
            $editor.find('[data-purpose=function-selector]').functionChoice({
                converters: metadata.converters,
                aggregates: metadata.aggregates
            });
            $editor.itemsManagerEditor($.extend(options.editor, {
                collection: collection,
                setter: function($el, name, value) {
                    if (name === 'func') {
                        value = value.name;
                    }
                    return value;
                },
                getter: function($el, name, value) {
                    if (name === 'func') {
                        value = value && {
                            name: value,
                            group_type: $el.find(':selected').data('group_type'),
                            group_name: $el.find(':selected').data('group_name')
                        };
                    }
                    return value;
                }
            }));

            var sortingLabels = {};
            $editor.find('select[name*=sorting]').find('option:not([value=""])').each(function() {
                sortingLabels[this.value] = $(this).text();
            });

            this.on('find-unsaved-components', function(unsavedComponents) {
                if ($editor.itemsManagerEditor('hasChanges')) {
                    unsavedComponents.push(__('oro.segment.report_column_editor'));
                }
            });

            this.on('before-submit', function() {
                $editor.itemsManagerEditor('reset');
            });

            var template = _.template(this.options.columnFieldChoiceOptions.select2.formatSelectionTemplate);
            $table.itemsManagerTable({
                collection: collection,
                itemTemplate: $(options.itemTemplate).html(),
                itemRender: function(tmpl, data) {
                    var item;
                    var itemFunc;
                    var func = data.func;

                    data.name = self.formatChoice(data.name, template);
                    if (func && func.name) {
                        item = metadata[func.group_type][func.group_name];
                        if (item) {
                            itemFunc = _.findWhere(item.functions, {name: func.name});
                            if (itemFunc) {
                                data.func = itemFunc.label;
                            }
                        }
                    } else {
                        data.func = '';
                    }
                    if (data.sorting && sortingLabels[data.sorting]) {
                        data.sorting = sortingLabels[data.sorting];
                    }

                    return tmpl(data);
                },
                deleteHandler: function(model, data) {
                    confirm.setContent(data.message);
                    confirm.model = model;
                    confirm.open();
                }
            });

            this.on('resetData', function(data) {
                data.columns = [];
                $table.itemsManagerTable('reset');
                $editor.itemsManagerEditor('reset');
            });

            this.once('dispose:before', function() {
                confirm.dispose();
                collection.dispose();
                $editor.itemsManagerEditor('destroy');
                $table.itemsManagerTable('destroy');
            }, this);
        },
Exemplo n.º 18
0
        initGrouping: function() {
            var self = this;
            var options = this.options.grouping;
            var $table = $(options.itemContainer);
            var $editor = $(options.form);

            if (_.isEmpty($table) || _.isEmpty($editor)) {
                // there's no grouping
                return;
            }

            // setup FieldChoice of Items Manager Editor
            var fieldChoiceOptions = _.extend({}, this.options.fieldChoiceOptions,
                this.options.metadata.grouping, {select2: {}});
            var $fieldChoice = $editor.find('[data-purpose=column-selector]');
            $fieldChoice.fieldChoice(fieldChoiceOptions);
            this.on('fieldsLoaded', function(entity, data) {
                $fieldChoice.fieldChoice('updateData', entity, data);
            });

            // prepare collection for Items Manager
            var collection = new BaseCollection(this.load('grouping_columns'), {model: GroupingModel});
            this.listenTo(collection, 'add remove sort change', function() {
                this.save(collection.toJSON(), 'grouping_columns');
            });

            // setup confirmation dialog for delete item
            var confirm = new DeleteConfirmation({content: ''});
            confirm.on('ok', function() {
                collection.remove(this.model);
            });
            confirm.on('hidden', function() {
                delete this.model;
            });

            // setup Items Manager's editor
            $editor.itemsManagerEditor($.extend(options.editor, {
                collection: collection
            }));

            this.on('find-unsaved-components', function(unsavedComponents) {
                if ($editor.itemsManagerEditor('hasChanges')) {
                    unsavedComponents.push(__('oro.segment.grouping_editor'));
                }
            });

            this.on('before-submit', function() {
                $editor.itemsManagerEditor('reset');
            });

            // setup Items Manager's table
            var template = _.template(this.options.fieldChoiceOptions.select2.formatSelectionTemplate);
            $table.itemsManagerTable({
                collection: collection,
                itemTemplate: $(options.itemTemplate).html(),
                itemRender: function(tmpl, data) {
                    data.name = self.formatChoice(data.name, template);
                    return tmpl(data);
                },
                deleteHandler: function(model, data) {
                    confirm.setContent(data.message);
                    confirm.model = model;
                    confirm.open();
                }
            });

            this.on('resetData', function(data) {
                data.grouping_columns = [];
                $table.itemsManagerTable('reset');
                $editor.itemsManagerEditor('reset');
            });

            this.once('dispose:before', function() {
                confirm.dispose();
                collection.dispose();
                $editor.itemsManagerEditor('destroy');
                $table.itemsManagerTable('destroy');
            }, this);
        },
Exemplo n.º 19
0
        initGrouping: function() {
            var self = this;
            var options = this.options.grouping;
            var $table = $(options.itemContainer);
            var $editor = $(options.form);

            if (_.isEmpty($table) || _.isEmpty($editor)) {
                // there's no grouping
                return;
            }

            // setup FieldChoice of Items Manager Editor
            var fieldChoiceOptions = _.extend({}, this.options.fieldChoiceOptions,
                this.options.metadata.grouping, {select2: {}});
            var $fieldChoice = $editor.find('[data-purpose=column-selector]');
            $fieldChoice.fieldChoice(fieldChoiceOptions);
            this.on('fieldsLoaded', function(entity, data) {
                $fieldChoice.fieldChoice('updateData', entity, data);
            });

            // prepare collection for Items Manager
            var collection = new FieldsCollection(this.load('grouping_columns'), {
                model: GroupingModel,
                entityFieldsUtil: this.entityFieldsUtil
            });
            this.listenTo(collection, 'add remove sort change', function() {
                this.save(collection.toJSON(), 'grouping_columns');
            });

            // setup confirmation dialog for delete item
            var confirm = new DeleteConfirmation({content: ''});
            confirm.on('ok', function() {
                collection.remove(this.model);
            });
            confirm.on('hidden', function() {
                delete this.model;
            });

            // setup Items Manager's editor
            $editor.itemsManagerEditor($.extend(options.editor, {
                collection: collection
            }));

            this.on('validate-data', function(issues) {
                if ($editor.itemsManagerEditor('hasChanges')) {
                    issues.push({
                        component: __('oro.segment.grouping_editor'),
                        type: SegmentComponent.UNSAVED_CHANGES_ISSUE
                    });
                }
                if (!collection.isValid()) {
                    issues.push({
                        component: __('oro.segment.grouping_editor'),
                        type: SegmentComponent.INVALID_DATA_ISSUE
                    });
                }
            });

            this.on('before-submit', function() {
                collection.removeInvalidModels();
                $editor.itemsManagerEditor('reset');
            });

            // setup Items Manager's table
            var template = _.template(this.options.fieldChoiceOptions.select2.formatSelectionTemplate);
            $table.itemsManagerTable({
                collection: collection,
                itemTemplate: $(options.itemTemplate).html(),
                itemRender: function(tmpl, data) {
                    try {
                        data.name = self.formatChoice(data.name, template);
                    } catch (e) {
                        data.name = __('oro.querydesigner.field_not_found');
                        data.deleted = true;
                    }
                    return tmpl(data);
                },
                deleteHandler: function(model, data) {
                    confirm.setContent(data.message);
                    confirm.model = model;
                    confirm.open();
                }
            });

            this.on('resetData', function(data) {
                data.grouping_columns = [];
                $table.itemsManagerTable('reset');
                $editor.itemsManagerEditor('reset');
            });

            this.once('dispose:before', function() {
                confirm.dispose();
                collection.dispose();
                $editor.itemsManagerEditor('destroy');
                $table.itemsManagerTable('destroy');
            }, this);
        },