Merge pull request #3362 from sebgie/issue#3087-2

Transfer Ownership
This commit is contained in:
Hannah Wolfe 2014-07-24 12:19:08 +01:00
commit 96a61025ec
9 changed files with 56 additions and 19 deletions

View File

@ -0,0 +1,45 @@
var TransferOwnerController = Ember.Controller.extend({
actions: {
confirmAccept: function () {
var user = this.get('model'),
self = this;
// Get owner role
this.store.find('role').then(function (result) {
return result.findBy('name', 'Owner');
}).then(function (ownerRole) {
// remove roles and assign owner role
user.get('roles').clear();
user.get('roles').pushObject(ownerRole);
return user.save({ format: false });
}).then(function (model) {
self.notifications.closePassive();
self.notifications.showSuccess('Settings successfully saved.');
return model;
}).catch(function (errors) {
self.notifications.closePassive();
self.notifications.showErrors(errors);
}).finally(function () {
self.get('popover').closePopovers();
});
},
confirmReject: function () {
return false;
}
},
confirm: {
accept: {
text: 'YEP - I\'M SURE',
buttonClass: 'button-delete'
},
reject: {
text: 'CANCEL',
buttonClass: 'button'
}
}
});
export default TransferOwnerController;

View File

@ -22,6 +22,7 @@ var popoverInitializer = {
application.inject('component:gh-popover', 'popover', 'popover:service');
application.inject('component:gh-popover-button', 'popover', 'popover:service');
application.inject('controller:modals.delete-post', 'popover', 'popover:service');
application.inject('controller:modals.transfer-owner', 'popover', 'popover:service');
application.inject('route:application', 'popover', 'popover:service');
}
};

View File

@ -18,10 +18,7 @@ var Post = DS.Model.extend(NProgressSaveMixin, ValidationEngine, {
meta_title: DS.attr('string'),
meta_description: DS.attr('string'),
author: DS.belongsTo('user', { async: true }),
created_at: DS.attr('moment-date'),
created_by: DS.belongsTo('user', { async: true }),
updated_at: DS.attr('moment-date'),
updated_by: DS.belongsTo('user', { async: true }),
published_at: DS.attr('moment-date'),
published_by: DS.belongsTo('user', { async: true }),
tags: DS.hasMany('tag', { embedded: 'always' }),

View File

@ -2,11 +2,6 @@ var Role = DS.Model.extend({
uuid: DS.attr('string'),
name: DS.attr('string'),
description: DS.attr('string'),
created_at: DS.attr('moment-date'),
created_by: DS.belongsTo('user', { async: true }),
updated_at: DS.attr('moment-date'),
updated_by: DS.belongsTo('user', { async: true }),
lowerCaseName: Ember.computed('name', function () {
return this.get('name').toLocaleLowerCase();
})

View File

@ -6,10 +6,6 @@ var Tag = DS.Model.extend({
parent_id: DS.attr('number'),
meta_title: DS.attr('string'),
meta_description: DS.attr('string'),
created_at: DS.attr('moment-date'),
created_by: DS.belongsTo('user', {async: true}),
updated_at: DS.attr('moment-date'),
updated_by: DS.belongsTo('user', {async: true})
});
export default Tag;

View File

@ -20,9 +20,6 @@ var User = DS.Model.extend(NProgressSaveMixin, ValidationEngine, {
meta_description: DS.attr('string'),
last_login: DS.attr('moment-date'),
created_at: DS.attr('moment-date'),
created_by: DS.belongsTo('user', { async: true }),
updated_at: DS.attr('moment-date'),
updated_by: DS.belongsTo('user', { async: true }),
roles: DS.hasMany('role', { embedded: 'always' }),

View File

@ -0,0 +1,6 @@
{{#gh-modal-dialog action="closeModal" showClose=true type="action" style="wide,centered" animation="fade"
title="Transfer Ownership" confirm=confirm}}
<p>Are you sure you want to transfer the ownership of this blog? You will not be able to undo this action.</p>
{{/gh-modal-dialog}}

View File

@ -10,13 +10,13 @@
<section class="page-actions">
{{!-- {{#gh-popover-button popoverName="user-actions-menu" tagName="a" classNames="button only-has-icon user-actions-cog" title="User Actions"}}
{{#gh-popover-button popoverName="user-actions-menu" tagName="a" classNames="button only-has-icon user-actions-cog" title="User Actions"}}
<i class="icon-settings"></i>
<span class="hidden">User Settings</span>
{{/gh-popover-button}}
{{#gh-popover name="user-actions-menu" classNames="user-actions-menu menu-drop-right"}}
{{render "user-actions-menu" model}}
{{/gh-popover}} --}}
{{/gh-popover}}
<button class="button-save" {{action "save"}}>Save</button>
</section>

View File

@ -1,2 +1,2 @@
<a href="#">Make Owner</a>
<a href="#" class="delete">Delete User</a>
<a href="javascript:void(0);" {{action "openModal" "transfer-owner" this}}>Make Owner</a>
<a href="javascript:void(0);" class="delete">Delete User</a>