-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ref #4248 - Added tags settings menu - Added basic new, edit, delete, and save actions - Show actionable edit buttons dynamically based on tag state - Infinite scroll - Closing the tag settings menu rollbacks your changes - Removed not-yet-implementable code
- Loading branch information
Showing
9 changed files
with
123 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import PaginationMixin from 'ghost/mixins/pagination-controller'; | ||
|
||
var TagsController = Ember.ArrayController.extend(PaginationMixin, { | ||
tags: Ember.computed.alias('model'), | ||
activeTag: null, | ||
init: function (options) { | ||
options = options || {}; | ||
options.modelType = 'tag'; | ||
this._super(options); | ||
}, | ||
actions: { | ||
// Clear any unsaved changes until autosave is implemented | ||
closeTagEditor: function () { | ||
this.get('activeTag').rollback(); | ||
this.send('closeSettingsMenu'); | ||
}, | ||
newTag: function () { | ||
this.set('activeTag', this.store.createRecord('tag')); | ||
this.send('openSettingsMenu'); | ||
}, | ||
editTag: function (tag) { | ||
this.set('activeTag', tag); | ||
this.send('openSettingsMenu'); | ||
}, | ||
deleteTag: function (tag) { | ||
var name = tag.get('name'), | ||
self = this; | ||
|
||
this.send('closeSettingsMenu'); | ||
|
||
tag.destroyRecord().then(function () { | ||
self.notifications.showSuccess('Deleted ' + name); | ||
}).catch(function (error) { | ||
self.notifications.showAPIError(error); | ||
}); | ||
}, | ||
saveTag: function (tag) { | ||
var name = tag.get('name'), | ||
self = this; | ||
|
||
tag.save().then(function () { | ||
self.notifications.showSuccess('Saved ' + name); | ||
}).catch(function (error) { | ||
self.notifications.showAPIError(error); | ||
}); | ||
} | ||
} | ||
}); | ||
|
||
export default TagsController; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<div class="content-cover" {{action "closeTagEditor"}}></div> | ||
<div class="settings-menu-container"> | ||
<div class="settings-menu settings-menu-pane settings-menu-pane-in"> | ||
<div class="settings-menu-header"> | ||
<h4>Tag Settings</h4> | ||
<button class="close icon-x settings-menu-header-action" {{action "closeTagEditor"}}> | ||
<span class="hidden">Close</span> | ||
</button> | ||
</div> | ||
<div class="settings-menu-content"> | ||
<form> | ||
<div class="form-group"> | ||
<label>Tag Name</label> | ||
{{input type="text" value=activeTag.name}} | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label>Slug</label>{{!--@TODO show full url preview, not just slug--}} | ||
{{input type="text" value=activeTag.slug}} | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label>Description</label> | ||
{{textarea value=activeTag.description}} | ||
</div> | ||
|
||
{{#unless activeTag.isNew}} | ||
<button class="btn btn-red icon-trash" {{action "deleteTag" activeTag}}>Delete Tag</button> | ||
{{/unless}} | ||
<button class="btn btn-green tag-save-button" {{action "saveTag" activeTag}}>{{view.saveText}}</button> | ||
</form> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import BaseView from 'ghost/views/settings/content-base'; | ||
import PaginationScrollMixin from 'ghost/mixins/pagination-view-infinite-scroll'; | ||
|
||
var SettingsTagsView = BaseView.extend(); | ||
var SettingsTagsView = BaseView.extend(PaginationScrollMixin); | ||
|
||
export default SettingsTagsView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var TagsSettingsMenuView = Ember.View.extend({ | ||
saveText: Ember.computed('controller.model.isNew', function () { | ||
return this.get('controller.model.isNew') ? | ||
'Add Tag' : | ||
'Save Tag'; | ||
}) | ||
}); | ||
|
||
export default TagsSettingsMenuView; |