Merge pull request #4694 from PaulAdamDavis/navigation-ember

Navigation UI Ember Integration
This commit is contained in:
Hannah Wolfe 2015-01-13 09:31:32 +00:00
commit 53296aaf8f
8 changed files with 107 additions and 1 deletions

View File

@ -10,6 +10,9 @@ var SettingsController = Ember.Controller.extend({
showTags: Ember.computed('session.user.name', function () {
return this.get('session.user.isAuthor') ? false : true;
}),
showNavigation: Ember.computed('session.user.name', 'config.navigationUI', function () {
return this.get('session.user.isAuthor') || this.get('session.user.isEditor') || !this.get('config.navigationUI') ? false : true;
}),
showCodeInjection: Ember.computed('session.user.name', 'controllers.feature.codeInjectionUI', function () {
return this.get('session.user.isAuthor') || this.get('session.user.isEditor') || !this.get('controllers.feature.codeInjectionUI') ? false : true;
}),

View File

@ -0,0 +1,25 @@
var NavigationController = Ember.Controller.extend(Ember.Evented, {
navigationJSON: Ember.computed('model.navigation', function () {
var navJSON = JSON.parse(this.get('model.navigation') || {}),
lastNavItem = navJSON[navJSON.length - 1];
lastNavItem.last = true; // Set a 'last' property on the last nav item, only used in the template
return navJSON;
}),
actions: {
addItem: function () {
// Add a new item
},
deleteItem: function () {
// Delete navItem which should be a function param like: `deleteItem: function(navItem) {`
},
save: function () {
// Save everything
}
}
});
export default NavigationController;

View File

@ -17,7 +17,8 @@ var Setting = DS.Model.extend(NProgressSaveMixin, ValidationEngine, {
availableThemes: DS.attr(),
ghost_head: DS.attr('string'),
ghost_foot: DS.attr('string'),
labs: DS.attr('string')
labs: DS.attr('string'),
navigation: DS.attr('string')
});
export default Setting;

View File

@ -41,6 +41,7 @@ Router.map(function () {
this.route('tags');
this.route('labs');
this.route('code-injection');
this.route('navigation');
});
// Redirect debug to settings labs

View File

@ -0,0 +1,27 @@
import AuthenticatedRoute from 'ghost/routes/authenticated';
import CurrentUserSettings from 'ghost/mixins/current-user-settings';
var NavigationRoute = AuthenticatedRoute.extend(CurrentUserSettings, {
titleToken: 'Navigation',
beforeModel: function () {
if (!this.get('config.navigationUI')) {
return this.transitionTo('settings.general');
}
return this.currentUser().then(this.transitionAuthor());
},
model: function () {
return this.store.find('setting', {type: 'blog,theme'}).then(function (records) {
return records.get('firstObject');
});
},
setupController: function (controller, model) {
this._super(controller, model);
}
});
export default NavigationRoute;

View File

@ -19,6 +19,10 @@
{{gh-activating-list-item route="settings.tags" title="Tags" classNames="settings-nav-tags icon-tag"}}
{{/if}}
{{#if showNavigation}}
{{gh-activating-list-item route="settings.navigation" title="Navigation" classNames="settings-nav-navigation icon-compass"}}
{{/if}}
{{#if showCodeInjection}}
{{gh-activating-list-item route="settings.code-injection" title="Code Injection" classNames="settings-nav-code icon-code"}}
{{/if}}

View File

@ -0,0 +1,40 @@
<header class="settings-view-header">
{{#link-to "settings" class="btn btn-default btn-back"}}Back{{/link-to}}
<h2 class="page-title">Navigation</h2>
<section class="page-actions">
<button type="button" class="btn btn-blue" {{action "save"}}>Save</button>
</section>
</header>
<section class="content settings-navigation">
<form id="settings-navigation" novalidate="novalidate">
{{#each navItem in navigationJSON}}
<div class="navigation-item">
<button type="button" class="navigation-item-drag-handle icon-grab">
<span class="hidden">Reorder</span>
</button>
<div class="navigation-inputs">
<span class="navigation-item-label">
<input type="text" {{bind-attr value=navItem.label}} placeholder="Label">
</span>
<span class="navigation-item-url">
<input type="text" {{bind-attr value=navItem.url}} placeholder="http://my-ghost-blog.com/">
</span>
</div>
<span class="navigation-item-action">
{{#if navItem.last}}
<button type="button" class="add-navigation-link icon-add" {{action 'addItem'}}>
<span class="hidden">Add</span>
</button>
{{else}}
<button type="button" class="navigation-delete icon-trash" {{action 'deleteItem' navItem}}>
<span class="hidden">Delete</span>
</button>
{{/if}}
</span>
</div>
{{/each}}
</form>
</section>

View File

@ -0,0 +1,5 @@
import BaseView from 'ghost/views/settings/content-base';
var SettingsNavigationView = BaseView.extend();
export default SettingsNavigationView;