Revert Function option is not working


#1

Hello. The revert option is not working as expected,

My ember Code is:

Admin.Inspector.extend()
    .named("Admin.RoleInspect.Inspector")
    .reopen({
        name: "AdminUser",
        icon: 'admin',
        logical: function () {
            return Admin.Role.detectInstance(this.get('model'));
        }.property('model'),
        titleView: Core.view.Message.extend()
            .reopen({
                tagName: 'h2',
                key: 'admin/role-inspect/details/title'
            }),
        bodyView: Admin.RoleDetailsView.extend()
            .named("Admin.RoleInspect.InspectorView")
            .reopen({
                roleModelBinding: 'inspector.model',
                readOnly: function () {
                    return !this.get('roleModel.canModify');
                }.property('roleModel.canModify'),
                hasChangesChanged: function () {
                    if (!Admin.RoleInspect.Inspector.detectInstance(this.get('inspector'))) { return; }
                    this.get('inspector').set('hasChanges', this.get('hasChanges'));
                }.on('init').observes('hasChanges'),
                roleModelCopyChanged: function () {
                    this.set('inspector.roleModelCopy', this.get('roleModelCopy'));
                }.observes('roleModelCopy')
            }),
        actionsView: Inspect.EditableModelFooter,
        save: function () {
            var model = this.get('model'),
                copy = this.get('roleModelCopy'),
                payload = [];
           var roleName = model.name;
           var roleDescription = model.description;
                       Core.services({
                type: 'put',
                json: true,
                service: 'admin/roles',
                data: {
                    name: roleName,
                    description: roleDescription
                }
            }).done(function (result) {
                Core.notify({
                    title: 'Success',
                    message: 'Role Details Updated' 
                });
                this.set('model', result);
                model.set('olddescription',roleDescription)
                console.log(model.olddescription)
                this.set('hasChanges', false);
            }.bind(this)).fail(function (xhr, status, reason) {
                reject(reason || status);
            }).always(function () {
                Admin.getController().send('publish');
            }).fail(function (xhr, status, reason) {
                Core.Error.show(reason || status);
            });
        },
        canSave: function () {
            return this.get('canModify') && this.get('hasChanges');
        }.property('canModify', 'hasChanges'),
        canRevert: function () {
            return this.get('canSave');
        }.property('canSave'),
        revert: function () {
            console.log(this.get('model'));
            var view = this.get('bodyViewInstance') || this;
            view.set('roleModelCopy', null);
            view.notifyPropertyChange('model');
        },

        tooltipBinding: 'Core.messageTable.admin/user-inspect/roles/title',
        actionsView: Ember.ContainerView.extend({
            createChildView: function (View, ext) {
                ext = ext || {};
                ext.inspector = this.get('inspector');
                return this._super(View, ext);
            },
            childViews: [

                Core.component.UiButton.extend({
                    labelBinding: 'Core.messageTable.admin/user-inspect/roles/save',
                    titleBinding: 'Core.messageTable.admin/user-inspect/roles/save',
                    click: function () {
                        this.get('inspector').save();
                        return false;
                    }
                }),

                Core.component.UiButton.extend({
                    labelBinding: 'Core.messageTable.admin/user-inspect/roles/revert',
                    titleBinding: 'Core.messageTable.admin/user-inspect/roles/revert',
                    click: function () {
                        this.get('inspector').revert();
                        return false;
                    }
                })

            ]
        }),

        canModify: function () {
            return !!this.get('model.canModify');
        }.property('model.canModify')
    });

Inspect.registerInspector(Admin.RoleInspect.Inspector);

In my ember file, the save option is working fine. But the revert option not working as expect in my side. I need to revert the saved text and misspelling text while doing this operation. I’m new to the ember. I’m using ember-1.4.0. Your help will be appreciate. Thanks in advance.


#2

@Boo if you are new to Ember is there any reason you are using ember 1.4.0? Is this a legacy app you are maintaining perhaps? The problem is that ember 1.4.0 is REALLY old, in fact the published Ember docs only go back to 1.13. It might be pretty difficult to get help on an Ember version that out of date because so much has changed since then.

EDIT: I personally started on Ember 1.11 and I’ll take another look at the above code but upon my initial glance I didn’t have any thoughts on how you might fix it. It’s pretty unfamiliar to me.