mirror of
https://github.com/discourse/discourse.git
synced 2026-08-09 04:28:29 -05:00
Fix deprecations with site text, upgrade to ES6 / store
This commit is contained in:
@@ -1,20 +1,16 @@
|
||||
export default Ember.ObjectController.extend({
|
||||
saving: false,
|
||||
export default Ember.Controller.extend({
|
||||
saved: false,
|
||||
|
||||
saveDisabled: function() {
|
||||
if (this.get('saving')) { return true; }
|
||||
if ((!this.get('allow_blank')) && Ember.isEmpty(this.get('value'))) { return true; }
|
||||
if (this.get('model.isSaving')) { return true; }
|
||||
if ((!this.get('allow_blank')) && Ember.isEmpty(this.get('model.value'))) { return true; }
|
||||
return false;
|
||||
}.property('saving', 'value'),
|
||||
}.property('model.iSaving', 'model.value'),
|
||||
|
||||
actions: {
|
||||
saveChanges: function() {
|
||||
var self = this;
|
||||
self.setProperties({saving: true, saved: false});
|
||||
self.get('model').save().then(function () {
|
||||
self.setProperties({saving: false, saved: true});
|
||||
});
|
||||
saveChanges() {
|
||||
const model = this.get('model');
|
||||
model.save(model.getProperties('value')).then(() => this.set('saved', true));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
import RestModel from 'discourse/models/rest';
|
||||
export default RestModel.extend();
|
||||
@@ -0,0 +1,8 @@
|
||||
import RestModel from 'discourse/models/rest';
|
||||
|
||||
export default RestModel.extend({
|
||||
markdown: Em.computed.equal('format', 'markdown'),
|
||||
plainText: Em.computed.equal('format', 'plain'),
|
||||
html: Em.computed.equal('format', 'html'),
|
||||
css: Em.computed.equal('format', 'css'),
|
||||
});
|
||||
@@ -1,21 +0,0 @@
|
||||
Discourse.SiteText = Discourse.Model.extend({
|
||||
markdown: Em.computed.equal('format', 'markdown'),
|
||||
plainText: Em.computed.equal('format', 'plain'),
|
||||
html: Em.computed.equal('format', 'html'),
|
||||
css: Em.computed.equal('format', 'css'),
|
||||
|
||||
save: function() {
|
||||
return Discourse.ajax("/admin/customize/site_text/" + this.get('text_type'), {
|
||||
type: 'PUT',
|
||||
data: {value: this.get('value')}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Discourse.SiteText.reopenClass({
|
||||
find: function(type) {
|
||||
return Discourse.ajax("/admin/customize/site_text/" + type).then(function (data) {
|
||||
return Discourse.SiteText.create(data.site_text);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -1,11 +0,0 @@
|
||||
Discourse.SiteTextType = Discourse.Model.extend();
|
||||
|
||||
Discourse.SiteTextType.reopenClass({
|
||||
findAll: function() {
|
||||
return Discourse.ajax("/admin/customize/site_text_types").then(function(data) {
|
||||
return data.map(function(ct) {
|
||||
return Discourse.SiteTextType.create(ct);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -21,7 +21,7 @@ export default {
|
||||
this.route('show', {path: '/:site_customization_id/:section'});
|
||||
});
|
||||
|
||||
this.resource('adminSiteText', { path: '/site_text' }, function() {
|
||||
this.resource('adminSiteText', { path: '/site_texts' }, function() {
|
||||
this.route('edit', {path: '/:text_type'});
|
||||
});
|
||||
this.resource('adminUserFields', { path: '/user_fields' });
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export default Discourse.Route.extend({
|
||||
model: function(params) {
|
||||
return Discourse.SiteText.find(params.text_type);
|
||||
model(params) {
|
||||
return this.store.find('site-text', params.text_type);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export default Discourse.Route.extend({
|
||||
model: function() {
|
||||
return Discourse.SiteTextType.findAll();
|
||||
model() {
|
||||
return this.store.findAll('site-text-type');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<h3>{{model.title}}</h3>
|
||||
<p class='description'>{{model.description}}</p>
|
||||
|
||||
{{#if model.markdown}}
|
||||
{{pagedown-editor value=model.value}}
|
||||
{{/if}}
|
||||
{{#if model.plainText}}
|
||||
{{textarea value=model.value class="plain"}}
|
||||
{{/if}}
|
||||
{{#if model.html}}
|
||||
{{ace-editor content=model.value mode="html"}}
|
||||
{{/if}}
|
||||
{{#if model.css}}
|
||||
{{ace-editor content=model.value mode="css"}}
|
||||
{{/if}}
|
||||
|
||||
<div class='controls'>
|
||||
<button class='btn' {{action "saveChanges"}} disabled={{saveDisabled}}>
|
||||
{{#if model.isSaving}}
|
||||
{{i18n 'saving'}}
|
||||
{{else}}
|
||||
{{i18n 'save'}}
|
||||
{{/if}}
|
||||
</button>
|
||||
{{#if saved}}{{i18n 'saved'}}{{/if}}
|
||||
</div>
|
||||
@@ -1,26 +0,0 @@
|
||||
<h3>{{title}}</h3>
|
||||
<p class='description'>{{description}}</p>
|
||||
|
||||
{{#if markdown}}
|
||||
{{pagedown-editor value=value}}
|
||||
{{/if}}
|
||||
{{#if plainText}}
|
||||
{{textarea value=value class="plain"}}
|
||||
{{/if}}
|
||||
{{#if html}}
|
||||
{{ace-editor content=value mode="html"}}
|
||||
{{/if}}
|
||||
{{#if css}}
|
||||
{{ace-editor content=value mode="css"}}
|
||||
{{/if}}
|
||||
|
||||
<div class='controls'>
|
||||
<button class='btn' {{action "saveChanges"}} {{bind-attr disabled="saveDisabled"}}>
|
||||
{{#if saving}}
|
||||
{{i18n 'saving'}}
|
||||
{{else}}
|
||||
{{i18n 'save'}}
|
||||
{{/if}}
|
||||
</button>
|
||||
{{#if saved}}{{i18n 'saved'}}{{/if}}
|
||||
</div>
|
||||
@@ -0,0 +1,7 @@
|
||||
import RestAdapter from 'discourse/adapters/rest';
|
||||
|
||||
export default RestAdapter.extend({
|
||||
basePath() {
|
||||
return "/admin/customize/";
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,2 @@
|
||||
import CustomizationBase from 'discourse/adapters/customization-base';
|
||||
export default CustomizationBase;
|
||||
@@ -0,0 +1,2 @@
|
||||
import CustomizationBase from 'discourse/adapters/customization-base';
|
||||
export default CustomizationBase;
|
||||
@@ -1,7 +1,2 @@
|
||||
import RestAdapter from 'discourse/adapters/rest';
|
||||
|
||||
export default RestAdapter.extend({
|
||||
basePath() {
|
||||
return "/admin/customize/";
|
||||
}
|
||||
});
|
||||
import CustomizationBase from 'discourse/adapters/customization-base';
|
||||
export default CustomizationBase;
|
||||
|
||||
@@ -74,7 +74,7 @@ const ApplicationRoute = Discourse.Route.extend(OpenComposer, {
|
||||
}
|
||||
exceptionController.setProperties({ lastTransition: transition, thrown: err });
|
||||
|
||||
this.transitionTo('exception');
|
||||
this.intermediateTransitionTo('exception');
|
||||
},
|
||||
|
||||
showLogin: unlessReadOnly('handleShowLogin'),
|
||||
|
||||
Reference in New Issue
Block a user