mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
parent
ed6e7f16dd
commit
37b994e036
6 changed files with 69 additions and 26 deletions
|
@ -5,18 +5,15 @@ var SettingsController = Ember.Controller.extend({
|
||||||
showUsers: Ember.computed('session.user.name', function () {
|
showUsers: Ember.computed('session.user.name', function () {
|
||||||
return this.get('session.user.isAuthor') ? false : true;
|
return this.get('session.user.isAuthor') ? false : true;
|
||||||
}),
|
}),
|
||||||
showTags: Ember.computed('session.user.name', 'config.tagsUI', function () {
|
showTags: Ember.computed('session.user.name', 'feature.tagsUI', function () {
|
||||||
return this.get('session.user.isAuthor') || !this.get('config.tagsUI') ? false : true;
|
return this.get('session.user.isAuthor') || !this.get('feature.tagsUI') ? false : true;
|
||||||
}),
|
}),
|
||||||
|
showCodeInjection: Ember.computed('session.user.name', 'feature.codeInjectionUI', function () {
|
||||||
showCodeInjection: Ember.computed('session.user.name', 'config.codeInjectionUI', function () {
|
return this.get('session.user.isAuthor') || this.get('session.user.isEditor') || !this.get('feature.codeInjectionUI') ? false : true;
|
||||||
return this.get('session.user.isAuthor') || this.get('session.user.isEditor') || !this.get('config.codeInjectionUI') ? false : true;
|
|
||||||
}),
|
}),
|
||||||
|
|
||||||
showLabs: Ember.computed('session.user.name', function () {
|
showLabs: Ember.computed('session.user.name', function () {
|
||||||
return this.get('session.user.isAuthor') || this.get('session.user.isEditor') ? false : true;
|
return this.get('session.user.isAuthor') || this.get('session.user.isEditor') ? false : true;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
showAbout: Ember.computed('session.user.name', function () {
|
showAbout: Ember.computed('session.user.name', function () {
|
||||||
return this.get('session.user.isAuthor') ? false : true;
|
return this.get('session.user.isAuthor') ? false : true;
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,15 +1,18 @@
|
||||||
var LabsController = Ember.ObjectController.extend(Ember.Evented, {
|
var LabsController = Ember.Controller.extend(Ember.Evented, {
|
||||||
uploadButtonText: 'Import',
|
uploadButtonText: 'Import',
|
||||||
importErrors: '',
|
importErrors: '',
|
||||||
|
labsJSON: Ember.computed('model.labs', function () {
|
||||||
|
return JSON.parse(this.get('model.labs') || {});
|
||||||
|
}),
|
||||||
|
|
||||||
saveLabs: function (optionName, optionValue) {
|
saveLabs: function (optionName, optionValue) {
|
||||||
var labsConfig = this.get('labs'),
|
var self = this,
|
||||||
labsJSON = (this.get('labs')) ? JSON.parse(labsConfig) : {};
|
labsJSON = this.get('labsJSON');
|
||||||
|
|
||||||
// Set new value in the JSON object
|
// Set new value in the JSON object
|
||||||
labsJSON[optionName] = optionValue;
|
labsJSON[optionName] = optionValue;
|
||||||
|
|
||||||
this.set('labs', JSON.stringify(labsJSON));
|
this.set('model.labs', JSON.stringify(labsJSON));
|
||||||
|
|
||||||
this.get('model').save().catch(function (errors) {
|
this.get('model').save().catch(function (errors) {
|
||||||
self.showErrors(errors);
|
self.showErrors(errors);
|
||||||
|
@ -17,6 +20,9 @@ var LabsController = Ember.ObjectController.extend(Ember.Evented, {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
tagsUIFlag: Ember.computed.alias('config.tagsUI'),
|
||||||
|
codeUIFlag: Ember.computed.alias('config.codeInjectionUI'),
|
||||||
|
|
||||||
useTagsUI: Ember.computed('tagsUI', function (key, value) {
|
useTagsUI: Ember.computed('tagsUI', function (key, value) {
|
||||||
// setter
|
// setter
|
||||||
if (arguments.length > 1) {
|
if (arguments.length > 1) {
|
||||||
|
@ -24,10 +30,7 @@ var LabsController = Ember.ObjectController.extend(Ember.Evented, {
|
||||||
}
|
}
|
||||||
|
|
||||||
// getter
|
// getter
|
||||||
var labsConfig = (this.get('labs')) ? JSON.parse(this.get('labs')) : false;
|
return this.get('feature.tagsUI') || false;
|
||||||
|
|
||||||
|
|
||||||
return (labsConfig.tagsUI) ? labsConfig.tagsUI : false;
|
|
||||||
}),
|
}),
|
||||||
|
|
||||||
useCodeInjectionUI: Ember.computed('codeInjectionUI', function (key, value) {
|
useCodeInjectionUI: Ember.computed('codeInjectionUI', function (key, value) {
|
||||||
|
@ -37,10 +40,7 @@ var LabsController = Ember.ObjectController.extend(Ember.Evented, {
|
||||||
}
|
}
|
||||||
|
|
||||||
// getter
|
// getter
|
||||||
var labsConfig = (this.get('labs')) ? JSON.parse(this.get('labs')) : false;
|
return this.get('feature.codeInjectionUI') || false;
|
||||||
|
|
||||||
|
|
||||||
return (labsConfig.codeInjectionUI) ? labsConfig.codeInjectionUI : false;
|
|
||||||
}),
|
}),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
|
17
ghost/admin/initializers/feature.js
Normal file
17
ghost/admin/initializers/feature.js
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import Feature from 'ghost/utils/feature';
|
||||||
|
|
||||||
|
var injectFeatureInitializer = {
|
||||||
|
name: 'injectFeature',
|
||||||
|
after: ['config', 'store'],
|
||||||
|
|
||||||
|
initialize: function (container, application) {
|
||||||
|
application.register('feature:main', Feature);
|
||||||
|
application.inject('feature:main', 'store', 'store:main');
|
||||||
|
application.inject('feature:main', 'config', 'ghost:config');
|
||||||
|
|
||||||
|
application.inject('controller', 'feature', 'feature:main');
|
||||||
|
application.inject('route', 'feature', 'feature:main');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default injectFeatureInitializer;
|
|
@ -13,7 +13,7 @@ var TagsRoute = AuthenticatedRoute.extend(CurrentUserSettings, PaginationRouteMi
|
||||||
titleToken: 'Tags',
|
titleToken: 'Tags',
|
||||||
|
|
||||||
beforeModel: function () {
|
beforeModel: function () {
|
||||||
if (!this.get('config.tagsUI')) {
|
if (!this.get('feature.tagsUI')) {
|
||||||
return this.transitionTo('settings.general');
|
return this.transitionTo('settings.general');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,25 +49,30 @@
|
||||||
|
|
||||||
<form>
|
<form>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
{{#unless tagsUIFlag}}
|
||||||
<div class="form-group for-checkbox">
|
<div class="form-group for-checkbox">
|
||||||
<label for="labs-tagsUI">Tag Management</label>
|
<label for="labs-tagsUI">Tag Management</label>
|
||||||
<label class="checkbox" for="labs-tagsUI">
|
<label class="checkbox" for="labs-tagsUI">
|
||||||
{{input id="labs-tagsUI" name="labs[tagsUI]" type="checkbox" checked=useTagsUI}}
|
{{input id="labs-tagsUI" name="labs[tagsUI]" type="checkbox" checked=useTagsUI}}
|
||||||
<span class="input-toggle-component"></span>
|
<span class="input-toggle-component"></span>
|
||||||
<p>Enable the tag management interface (work in progress)</p>
|
<p>Enable the tag management interface</p>
|
||||||
<p>A settings screen which enables you to add, edit and delete tags</p>
|
|
||||||
</label>
|
</label>
|
||||||
|
<p>A settings screen which enables you to add, edit and delete tags (work in progress)</p>
|
||||||
</div>
|
</div>
|
||||||
|
{{/unless}}
|
||||||
|
|
||||||
|
{{#unless codeUIFlag}}
|
||||||
<div class="form-group for-checkbox">
|
<div class="form-group for-checkbox">
|
||||||
<label for="labs-codeInjectionUI">Code Injection</label>
|
<label for="labs-codeInjectionUI">Code Injection</label>
|
||||||
<label class="checkbox" for="labs-codeInjectionUI">
|
<label class="check box" for="labs-codeInjectionUI">
|
||||||
{{input id="labs-codeInjectionUI" name="labs[codeInjectionUI]" type="checkbox" checked=useCodeInjectionUI}}
|
{{input id="labs-codeInjectionUI" name="labs[codeInjectionUI]" type="checkbox"
|
||||||
|
checked=useCodeInjectionUI}}
|
||||||
<span class="input-toggle-component"></span>
|
<span class="input-toggle-component"></span>
|
||||||
<p>Enable the code injection interface (work in progress)</p>
|
<p>Enable the code injection interface</p>
|
||||||
<p>A settings screen which enables you to add code into your theme</p>
|
|
||||||
</label>
|
</label>
|
||||||
|
<p>A settings screen which enables you to add code into your theme (work in progress)</p>
|
||||||
</div>
|
</div>
|
||||||
|
{{/unless}}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
24
ghost/admin/utils/feature.js
Normal file
24
ghost/admin/utils/feature.js
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
var Feature;
|
||||||
|
|
||||||
|
Feature = Ember.Object.extend({
|
||||||
|
init: function () {
|
||||||
|
var self = this;
|
||||||
|
this.store.find('setting').then(function (settings) {
|
||||||
|
self.set('setting', settings.get('firstObject'));
|
||||||
|
});
|
||||||
|
},
|
||||||
|
labs: Ember.computed('setting', 'setting.labs', function () {
|
||||||
|
if (this.setting) {
|
||||||
|
return JSON.parse(this.get('setting.labs') || {});
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}),
|
||||||
|
tagsUI: Ember.computed('config.tagsUI', 'labs.tagsUI', function () {
|
||||||
|
return this.config.tagsUI || this.get('labs.tagsUI');
|
||||||
|
}),
|
||||||
|
codeInjectionUI: Ember.computed('config.codeInjectionUI', 'labs.codeInjectionUI', function () {
|
||||||
|
return this.config.codeInjectionUI || this.get('labs.codeInjectionUI');
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
export default Feature;
|
Loading…
Add table
Reference in a new issue