0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

add "delete post" button to the PSM (#649)

closes https://github.com/TryGhost/Ghost/issues/8332

- moves `toggleDeletePostModal` action from the `edit` controller to the `editor-base-controller` mixin
- adds delete button to the bottom of the PSM unless it's a new post
- adds `deletePost` attribute to `gh-post-settings-menu` to allow a delete post action to be passed in
This commit is contained in:
Kevin Ansfield 2017-04-19 10:46:42 +01:00 committed by Katharina Irrgang
parent aaed8d9cf4
commit 14e26f79ac
5 changed files with 21 additions and 11 deletions

View file

@ -388,6 +388,12 @@ export default Component.extend(SettingsMenuMixin, {
if (tag.get('isNew')) { if (tag.get('isNew')) {
tag.destroyRecord(); tag.destroyRecord();
} }
},
deletePost() {
if (this.get('deletePost')) {
this.get('deletePost')();
}
} }
} }
}); });

View file

@ -1,12 +1,4 @@
import Controller from 'ember-controller'; import Controller from 'ember-controller';
import EditorControllerMixin from 'ghost-admin/mixins/editor-base-controller'; import EditorControllerMixin from 'ghost-admin/mixins/editor-base-controller';
export default Controller.extend(EditorControllerMixin, { export default Controller.extend(EditorControllerMixin);
showDeletePostModal: false,
actions: {
toggleDeletePostModal() {
this.toggleProperty('showDeletePostModal');
}
}
});

View file

@ -35,6 +35,7 @@ export default Mixin.create({
showLeaveEditorModal: false, showLeaveEditorModal: false,
showReAuthenticateModal: false, showReAuthenticateModal: false,
showDeletePostModal: false,
application: injectController(), application: injectController(),
notifications: injectService(), notifications: injectService(),
@ -539,8 +540,8 @@ export default Mixin.create({
}, },
updateTitle() { updateTitle() {
let currentTitle = this.model.get('title'); let currentTitle = this.get('model.title');
let newTitle = this.model.get('titleScratch').trim(); let newTitle = this.get('model.titleScratch').trim();
if (currentTitle === newTitle) { if (currentTitle === newTitle) {
return; return;
@ -557,6 +558,12 @@ export default Mixin.create({
} }
}, },
toggleDeletePostModal() {
if (!this.get('model.isNew')) {
this.toggleProperty('showDeletePostModal');
}
},
toggleReAuthenticateModal() { toggleReAuthenticateModal() {
this.toggleProperty('showReAuthenticateModal'); this.toggleProperty('showReAuthenticateModal');
}, },

View file

@ -113,6 +113,10 @@
</label> </label>
</div> </div>
{{#unless model.isNew}}
<button type="button" class="gh-btn gh-btn-link gh-btn-sm gh-btn-icon tag-delete-button" {{action "deletePost"}}><span>{{inline-svg "trash"}} Delete Post</span></button>
{{/unless}}
</form> </form>
</div>{{! .settings-menu-content }} </div>{{! .settings-menu-content }}
</div>{{! .post-settings-menu }} </div>{{! .post-settings-menu }}

View file

@ -82,5 +82,6 @@
showSettingsMenu=application.showSettingsMenu showSettingsMenu=application.showSettingsMenu
closeNavMenu=(action "closeNavMenu") closeNavMenu=(action "closeNavMenu")
closeMenus=(action "closeMenus") closeMenus=(action "closeMenus")
deletePost=(action "toggleDeletePostModal")
}} }}
{{/liquid-wormhole}} {{/liquid-wormhole}}