mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Transfer Ownership
closes #3364 (special thanks to @jaswilli) closes #3087 - added modal - added controller
This commit is contained in:
parent
3fa2981c0e
commit
c43d860a3f
9 changed files with 56 additions and 19 deletions
45
core/client/controllers/modals/transfer-owner.js
Normal file
45
core/client/controllers/modals/transfer-owner.js
Normal 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;
|
|
@ -22,6 +22,7 @@ var popoverInitializer = {
|
||||||
application.inject('component:gh-popover', 'popover', 'popover:service');
|
application.inject('component:gh-popover', 'popover', 'popover:service');
|
||||||
application.inject('component:gh-popover-button', '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.delete-post', 'popover', 'popover:service');
|
||||||
|
application.inject('controller:modals.transfer-owner', 'popover', 'popover:service');
|
||||||
application.inject('route:application', 'popover', 'popover:service');
|
application.inject('route:application', 'popover', 'popover:service');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,10 +18,7 @@ var Post = DS.Model.extend(NProgressSaveMixin, ValidationEngine, {
|
||||||
meta_title: DS.attr('string'),
|
meta_title: DS.attr('string'),
|
||||||
meta_description: DS.attr('string'),
|
meta_description: DS.attr('string'),
|
||||||
author: DS.belongsTo('user', { async: true }),
|
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_at: DS.attr('moment-date'),
|
||||||
updated_by: DS.belongsTo('user', { async: true }),
|
|
||||||
published_at: DS.attr('moment-date'),
|
published_at: DS.attr('moment-date'),
|
||||||
published_by: DS.belongsTo('user', { async: true }),
|
published_by: DS.belongsTo('user', { async: true }),
|
||||||
tags: DS.hasMany('tag', { embedded: 'always' }),
|
tags: DS.hasMany('tag', { embedded: 'always' }),
|
||||||
|
|
|
@ -2,11 +2,6 @@ var Role = DS.Model.extend({
|
||||||
uuid: DS.attr('string'),
|
uuid: DS.attr('string'),
|
||||||
name: DS.attr('string'),
|
name: DS.attr('string'),
|
||||||
description: 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 () {
|
lowerCaseName: Ember.computed('name', function () {
|
||||||
return this.get('name').toLocaleLowerCase();
|
return this.get('name').toLocaleLowerCase();
|
||||||
})
|
})
|
||||||
|
|
|
@ -6,10 +6,6 @@ var Tag = DS.Model.extend({
|
||||||
parent_id: DS.attr('number'),
|
parent_id: DS.attr('number'),
|
||||||
meta_title: DS.attr('string'),
|
meta_title: DS.attr('string'),
|
||||||
meta_description: 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;
|
export default Tag;
|
|
@ -20,9 +20,6 @@ var User = DS.Model.extend(NProgressSaveMixin, ValidationEngine, {
|
||||||
meta_description: DS.attr('string'),
|
meta_description: DS.attr('string'),
|
||||||
last_login: DS.attr('moment-date'),
|
last_login: DS.attr('moment-date'),
|
||||||
created_at: 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' }),
|
roles: DS.hasMany('role', { embedded: 'always' }),
|
||||||
|
|
||||||
|
|
||||||
|
|
6
core/client/templates/modals/transfer-owner.hbs
Normal file
6
core/client/templates/modals/transfer-owner.hbs
Normal 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}}
|
|
@ -10,13 +10,13 @@
|
||||||
|
|
||||||
<section class="page-actions">
|
<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>
|
<i class="icon-settings"></i>
|
||||||
<span class="hidden">User Settings</span>
|
<span class="hidden">User Settings</span>
|
||||||
{{/gh-popover-button}}
|
{{/gh-popover-button}}
|
||||||
{{#gh-popover name="user-actions-menu" classNames="user-actions-menu menu-drop-right"}}
|
{{#gh-popover name="user-actions-menu" classNames="user-actions-menu menu-drop-right"}}
|
||||||
{{render "user-actions-menu" model}}
|
{{render "user-actions-menu" model}}
|
||||||
{{/gh-popover}} --}}
|
{{/gh-popover}}
|
||||||
|
|
||||||
<button class="button-save" {{action "save"}}>Save</button>
|
<button class="button-save" {{action "save"}}>Save</button>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
<a href="#">Make Owner</a>
|
<a href="javascript:void(0);" {{action "openModal" "transfer-owner" this}}>Make Owner</a>
|
||||||
<a href="#" class="delete">Delete User</a>
|
<a href="javascript:void(0);" class="delete">Delete User</a>
|
Loading…
Add table
Reference in a new issue