mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
Move "Content" under "customize" in admin.
This commit is contained in:
parent
f7e9bfb199
commit
fc32a0920d
13 changed files with 45 additions and 129 deletions
|
@ -1,10 +1,10 @@
|
|||
import DiscourseController from 'discourse/controllers/controller';
|
||||
|
||||
export default DiscourseController.extend({
|
||||
export default Ember.ObjectController.extend({
|
||||
saving: false,
|
||||
saved: false,
|
||||
|
||||
saveDisabled: function() {
|
||||
if (this.get('saving')) { return true; }
|
||||
if ((!this.get('content.allow_blank')) && this.blank('content.content')) { return true; }
|
||||
if ((!this.get('content.allow_blank')) && Ember.empty(this.get('content.content'))) { return true; }
|
||||
return false;
|
||||
}.property('saving', 'content.content'),
|
||||
|
||||
|
@ -12,7 +12,7 @@ export default DiscourseController.extend({
|
|||
saveChanges: function() {
|
||||
var self = this;
|
||||
self.setProperties({saving: true, saved: false});
|
||||
self.get('content').save().then(function () {
|
||||
self.get('model').save().then(function () {
|
||||
self.setProperties({saving: false, saved: true});
|
||||
});
|
||||
}
|
|
@ -1,11 +1,3 @@
|
|||
/**
|
||||
Our data model for interacting with custom site content
|
||||
|
||||
@class SiteContent
|
||||
@extends Discourse.Model
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.SiteContent = Discourse.Model.extend({
|
||||
|
||||
markdown: Em.computed.equal('format', 'markdown'),
|
||||
|
@ -13,14 +5,8 @@ Discourse.SiteContent = Discourse.Model.extend({
|
|||
html: Em.computed.equal('format', 'html'),
|
||||
css: Em.computed.equal('format', 'css'),
|
||||
|
||||
/**
|
||||
Save the content
|
||||
|
||||
@method save
|
||||
@return {jqXHR} a jQuery Promise object
|
||||
**/
|
||||
save: function() {
|
||||
return Discourse.ajax("/admin/site_contents/" + this.get('content_type'), {
|
||||
return Discourse.ajax("/admin/customize/site_contents/" + this.get('content_type'), {
|
||||
type: 'PUT',
|
||||
data: {content: this.get('content')}
|
||||
});
|
||||
|
@ -31,7 +17,7 @@ Discourse.SiteContent = Discourse.Model.extend({
|
|||
Discourse.SiteContent.reopenClass({
|
||||
|
||||
find: function(type) {
|
||||
return Discourse.ajax("/admin/site_contents/" + type).then(function (data) {
|
||||
return Discourse.ajax("/admin/customize/site_contents/" + type).then(function (data) {
|
||||
return Discourse.SiteContent.create(data.site_content);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,21 +1,11 @@
|
|||
/**
|
||||
Our data model that represents types of editing site content
|
||||
|
||||
@class SiteContentType
|
||||
@extends Discourse.Model
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.SiteContentType = Discourse.Model.extend({});
|
||||
Discourse.SiteContentType = Discourse.Model.extend();
|
||||
|
||||
Discourse.SiteContentType.reopenClass({
|
||||
findAll: function() {
|
||||
return Discourse.ajax("/admin/site_content_types").then(function(data) {
|
||||
var contentTypes = Em.A();
|
||||
data.forEach(function (ct) {
|
||||
contentTypes.pushObject(Discourse.SiteContentType.create(ct));
|
||||
return Discourse.ajax("/admin/customize/site_content_types").then(function(data) {
|
||||
return data.map(function(ct) {
|
||||
return Discourse.SiteContentType.create(ct);
|
||||
});
|
||||
return contentTypes;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
export default Ember.Route.extend({
|
||||
|
||||
serialize: function(model) {
|
||||
return {content_type: model.get('content_type')};
|
||||
},
|
||||
|
||||
model: function(params) {
|
||||
return Discourse.SiteContent.find(params.content_type);
|
||||
}
|
||||
|
||||
});
|
|
@ -0,0 +1,5 @@
|
|||
export default Ember.Route.extend({
|
||||
model: function() {
|
||||
return Discourse.SiteContentType.findAll();
|
||||
}
|
||||
});
|
|
@ -1,9 +1,3 @@
|
|||
/**
|
||||
Builds the routes for the admin section
|
||||
|
||||
@method buildRoutes
|
||||
@for Discourse.AdminRoute
|
||||
**/
|
||||
Discourse.Route.buildRoutes(function() {
|
||||
this.resource('admin', function() {
|
||||
this.route('dashboard', { path: '/' });
|
||||
|
@ -11,10 +5,6 @@ Discourse.Route.buildRoutes(function() {
|
|||
this.resource('adminSiteSettingsCategory', { path: 'category/:category_id'} );
|
||||
});
|
||||
|
||||
this.resource('adminSiteContents', { path: '/site_contents' }, function() {
|
||||
this.resource('adminSiteContentEdit', {path: '/:content_type'});
|
||||
});
|
||||
|
||||
this.resource('adminEmail', { path: '/email'}, function() {
|
||||
this.route('all');
|
||||
this.route('sent');
|
||||
|
@ -25,6 +15,9 @@ Discourse.Route.buildRoutes(function() {
|
|||
this.resource('adminCustomize', { path: '/customize' } ,function() {
|
||||
this.route('colors');
|
||||
this.route('css_html');
|
||||
this.resource('adminSiteContents', { path: '/site_contents' }, function() {
|
||||
this.route('edit', {path: '/:content_type'});
|
||||
});
|
||||
});
|
||||
this.route('api');
|
||||
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
/**
|
||||
Allows users to customize site content
|
||||
|
||||
@class AdminSiteContentEditRoute
|
||||
@extends Discourse.Route
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.AdminSiteContentEditRoute = Discourse.Route.extend({
|
||||
|
||||
serialize: function(model) {
|
||||
return {content_type: model.get('content_type')};
|
||||
},
|
||||
|
||||
model: function(params) {
|
||||
var list = Discourse.SiteContentType.findAll();
|
||||
|
||||
return list.then(function(items) {
|
||||
return items.findProperty("content_type", params.content_type);
|
||||
});
|
||||
},
|
||||
|
||||
renderTemplate: function() {
|
||||
this.render('admin/templates/site_content_edit', {into: 'admin/templates/site_contents'});
|
||||
},
|
||||
|
||||
deactivate: function() {
|
||||
this._super();
|
||||
this.render('admin/templates/site_contents_empty', {into: 'admin/templates/site_contents'});
|
||||
},
|
||||
|
||||
setupController: function(controller, model) {
|
||||
|
||||
controller.set('loaded', false);
|
||||
controller.setProperties({
|
||||
model: model,
|
||||
saving: false,
|
||||
saved: false
|
||||
});
|
||||
|
||||
Discourse.SiteContent.find(model.get('content_type')).then(function (sc) {
|
||||
controller.set('content', sc);
|
||||
controller.set('loaded', true);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
});
|
|
@ -1,24 +0,0 @@
|
|||
/**
|
||||
Allows users to customize site content
|
||||
|
||||
@class AdminSiteContentsRoute
|
||||
@extends Discourse.Route
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.AdminSiteContentsRoute = Discourse.Route.extend({
|
||||
|
||||
model: function() {
|
||||
return Discourse.SiteContentType.findAll();
|
||||
},
|
||||
|
||||
renderTemplate: function() {
|
||||
this.render('admin/templates/site_contents', {into: 'admin/templates/admin'});
|
||||
this.render('admin/templates/site_contents_empty', {into: 'admin/templates/site_contents'});
|
||||
},
|
||||
|
||||
setupController: function(controller, model) {
|
||||
controller.set('model', model);
|
||||
}
|
||||
});
|
||||
|
|
@ -7,7 +7,6 @@
|
|||
<li>{{#link-to 'admin.dashboard'}}{{i18n admin.dashboard.title}}{{/link-to}}</li>
|
||||
{{#if currentUser.admin}}
|
||||
<li>{{#link-to 'adminSiteSettings'}}{{i18n admin.site_settings.title}}{{/link-to}}</li>
|
||||
<li>{{#link-to 'adminSiteContents'}}{{i18n admin.site_content.title}}{{/link-to}}</li>
|
||||
{{/if}}
|
||||
<li>{{#link-to 'adminUsersList'}}{{i18n admin.users.title}}{{/link-to}}</li>
|
||||
{{#if showBadges}}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<ul class="nav nav-pills">
|
||||
<li>{{#link-to 'adminCustomize.colors'}}{{i18n admin.customize.colors.title}}{{/link-to}}</li>
|
||||
<li>{{#link-to 'adminCustomize.css_html'}}{{i18n admin.customize.css_html.title}}{{/link-to}}</li>
|
||||
<li>{{#link-to 'adminSiteContents'}}{{i18n admin.site_content.title}}{{/link-to}}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
<div class='content-list span6'>
|
||||
<h3>{{i18n admin.site_content.edit}}</h3>
|
||||
<ul>
|
||||
{{#each type in model}}
|
||||
{{#each model}}
|
||||
<li>
|
||||
{{#link-to 'adminSiteContentEdit' type}}{{type.title}}{{/link-to}}
|
||||
{{#link-to 'adminSiteContents.edit' content_type}}{{title}}{{/link-to}}
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
<h3>{{model.title}}</h3>
|
||||
<p class='description'>{{model.description}}</p>
|
||||
<h3>{{title}}</h3>
|
||||
<p class='description'>{{description}}</p>
|
||||
|
||||
{{#if model.markdown}}
|
||||
{{#if markdown}}
|
||||
{{pagedown-editor value=model.content}}
|
||||
{{/if}}
|
||||
{{#if model.plainText}}
|
||||
{{#if plainText}}
|
||||
{{textarea value=model.content class="plain"}}
|
||||
{{/if}}
|
||||
{{#if model.html}}
|
||||
{{#if html}}
|
||||
{{aceEditor content=model.content mode="html"}}
|
||||
{{/if}}
|
||||
{{#if model.css}}
|
||||
{{#if css}}
|
||||
{{aceEditor content=model.content mode="css"}}
|
||||
{{/if}}
|
||||
|
||||
<div class='controls'>
|
||||
<button class='btn' {{action saveChanges}} {{bind-attr disabled="saveDisabled"}}>
|
||||
<button class='btn' {{action "saveChanges"}} {{bind-attr disabled="saveDisabled"}}>
|
||||
{{#if saving}}
|
||||
{{i18n saving}}
|
||||
{{else}}
|
|
@ -109,8 +109,11 @@ Discourse::Application.routes.draw do
|
|||
post "flags/disagree/:id" => "flags#disagree"
|
||||
post "flags/defer/:id" => "flags#defer"
|
||||
resources :site_customizations, constraints: AdminConstraint.new
|
||||
resources :site_contents, constraints: AdminConstraint.new
|
||||
resources :site_content_types, constraints: AdminConstraint.new
|
||||
scope "/customize" do
|
||||
resources :site_contents, constraints: AdminConstraint.new
|
||||
resources :site_content_types, constraints: AdminConstraint.new
|
||||
end
|
||||
|
||||
resources :color_schemes, constraints: AdminConstraint.new
|
||||
|
||||
get "version_check" => "versions#show"
|
||||
|
|
Loading…
Reference in a new issue