0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Merge pull request #4750 from ErisDS/labs-thing

Labs page checkboxes
This commit is contained in:
Jason Williams 2015-01-04 13:44:47 -06:00
commit 7c7dbb911c
8 changed files with 124 additions and 9 deletions

View file

@ -5,18 +5,15 @@ var SettingsController = Ember.Controller.extend({
showUsers: Ember.computed('session.user.name', function () {
return this.get('session.user.isAuthor') ? false : true;
}),
showTags: Ember.computed('session.user.name', 'config.tagsUI', function () {
return this.get('session.user.isAuthor') || !this.get('config.tagsUI') ? false : true;
showTags: Ember.computed('session.user.name', 'feature.tagsUI', function () {
return this.get('session.user.isAuthor') || !this.get('feature.tagsUI') ? false : true;
}),
showCodeInjection: Ember.computed('session.user.name', 'config.codeInjectionUI', function () {
return this.get('session.user.isAuthor') || this.get('session.user.isEditor') || !this.get('config.codeInjectionUI') ? false : true;
showCodeInjection: Ember.computed('session.user.name', 'feature.codeInjectionUI', function () {
return this.get('session.user.isAuthor') || this.get('session.user.isEditor') || !this.get('feature.codeInjectionUI') ? false : true;
}),
showLabs: Ember.computed('session.user.name', function () {
return this.get('session.user.isAuthor') || this.get('session.user.isEditor') ? false : true;
}),
showAbout: Ember.computed('session.user.name', function () {
return this.get('session.user.isAuthor') ? false : true;
})

View file

@ -1,6 +1,47 @@
var LabsController = Ember.Controller.extend(Ember.Evented, {
uploadButtonText: 'Import',
importErrors: '',
labsJSON: Ember.computed('model.labs', function () {
return JSON.parse(this.get('model.labs') || {});
}),
saveLabs: function (optionName, optionValue) {
var self = this,
labsJSON = this.get('labsJSON');
// Set new value in the JSON object
labsJSON[optionName] = optionValue;
this.set('model.labs', JSON.stringify(labsJSON));
this.get('model').save().catch(function (errors) {
self.showErrors(errors);
self.get('model').rollback();
});
},
tagsUIFlag: Ember.computed.alias('config.tagsUI'),
codeUIFlag: Ember.computed.alias('config.codeInjectionUI'),
useTagsUI: Ember.computed('tagsUI', function (key, value) {
// setter
if (arguments.length > 1) {
this.saveLabs('tagsUI', value);
}
// getter
return this.get('feature.tagsUI') || false;
}),
useCodeInjectionUI: Ember.computed('codeInjectionUI', function (key, value) {
// setter
if (arguments.length > 1) {
this.saveLabs('codeInjectionUI', value);
}
// getter
return this.get('feature.codeInjectionUI') || false;
}),
actions: {
onUpload: function (file) {

View 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;

View file

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

View file

@ -22,7 +22,7 @@ TagsRoute = AuthenticatedRoute.extend(CurrentUserSettings, PaginationRouteMixin,
titleToken: 'Tags',
beforeModel: function () {
if (!this.get('config.tagsUI')) {
if (!this.get('feature.tagsUI')) {
return this.transitionTo('settings.general');
}

View file

@ -42,4 +42,36 @@
</div>
</fieldset>
</form>
<hr>
<form>
<fieldset>
{{#unless tagsUIFlag}}
<div class="form-group for-checkbox">
<label for="labs-tagsUI">Tag Management</label>
<label class="checkbox" for="labs-tagsUI">
{{input id="labs-tagsUI" name="labs[tagsUI]" type="checkbox" checked=useTagsUI}}
<span class="input-toggle-component"></span>
<p>Enable the tag management interface</p>
</label>
<p>A settings screen which enables you to add, edit and delete tags (work in progress)</p>
</div>
{{/unless}}
{{#unless codeUIFlag}}
<div class="form-group for-checkbox">
<label for="labs-codeInjectionUI">Code Injection</label>
<label class="check box" for="labs-codeInjectionUI">
{{input id="labs-codeInjectionUI" name="labs[codeInjectionUI]" type="checkbox"
checked=useCodeInjectionUI}}
<span class="input-toggle-component"></span>
<p>Enable the code injection interface</p>
</label>
<p>A settings screen which enables you to add code into your theme (work in progress)</p>
</div>
{{/unless}}
</fieldset>
</form>
</section>

View 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;

View file

@ -67,6 +67,9 @@
},
"ghost_foot": {
"defaultValue" : ""
},
"labs": {
"defaultValue": "{}"
}
},
"theme": {