mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Move "Content" under "customize" in admin.
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
import DiscourseController from 'discourse/controllers/controller';
|
export default Ember.ObjectController.extend({
|
||||||
|
saving: false,
|
||||||
export default DiscourseController.extend({
|
saved: false,
|
||||||
|
|
||||||
saveDisabled: function() {
|
saveDisabled: function() {
|
||||||
if (this.get('saving')) { return true; }
|
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;
|
return false;
|
||||||
}.property('saving', 'content.content'),
|
}.property('saving', 'content.content'),
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ export default DiscourseController.extend({
|
|||||||
saveChanges: function() {
|
saveChanges: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
self.setProperties({saving: true, saved: false});
|
self.setProperties({saving: true, saved: false});
|
||||||
self.get('content').save().then(function () {
|
self.get('model').save().then(function () {
|
||||||
self.setProperties({saving: false, saved: true});
|
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({
|
Discourse.SiteContent = Discourse.Model.extend({
|
||||||
|
|
||||||
markdown: Em.computed.equal('format', 'markdown'),
|
markdown: Em.computed.equal('format', 'markdown'),
|
||||||
@@ -13,14 +5,8 @@ Discourse.SiteContent = Discourse.Model.extend({
|
|||||||
html: Em.computed.equal('format', 'html'),
|
html: Em.computed.equal('format', 'html'),
|
||||||
css: Em.computed.equal('format', 'css'),
|
css: Em.computed.equal('format', 'css'),
|
||||||
|
|
||||||
/**
|
|
||||||
Save the content
|
|
||||||
|
|
||||||
@method save
|
|
||||||
@return {jqXHR} a jQuery Promise object
|
|
||||||
**/
|
|
||||||
save: function() {
|
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',
|
type: 'PUT',
|
||||||
data: {content: this.get('content')}
|
data: {content: this.get('content')}
|
||||||
});
|
});
|
||||||
@@ -31,7 +17,7 @@ Discourse.SiteContent = Discourse.Model.extend({
|
|||||||
Discourse.SiteContent.reopenClass({
|
Discourse.SiteContent.reopenClass({
|
||||||
|
|
||||||
find: function(type) {
|
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);
|
return Discourse.SiteContent.create(data.site_content);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,11 @@
|
|||||||
/**
|
Discourse.SiteContentType = Discourse.Model.extend();
|
||||||
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.reopenClass({
|
Discourse.SiteContentType.reopenClass({
|
||||||
findAll: function() {
|
findAll: function() {
|
||||||
return Discourse.ajax("/admin/site_content_types").then(function(data) {
|
return Discourse.ajax("/admin/customize/site_content_types").then(function(data) {
|
||||||
var contentTypes = Em.A();
|
return data.map(function(ct) {
|
||||||
data.forEach(function (ct) {
|
return Discourse.SiteContentType.create(ct);
|
||||||
contentTypes.pushObject(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() {
|
Discourse.Route.buildRoutes(function() {
|
||||||
this.resource('admin', function() {
|
this.resource('admin', function() {
|
||||||
this.route('dashboard', { path: '/' });
|
this.route('dashboard', { path: '/' });
|
||||||
@@ -11,10 +5,6 @@ Discourse.Route.buildRoutes(function() {
|
|||||||
this.resource('adminSiteSettingsCategory', { path: 'category/:category_id'} );
|
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.resource('adminEmail', { path: '/email'}, function() {
|
||||||
this.route('all');
|
this.route('all');
|
||||||
this.route('sent');
|
this.route('sent');
|
||||||
@@ -25,6 +15,9 @@ Discourse.Route.buildRoutes(function() {
|
|||||||
this.resource('adminCustomize', { path: '/customize' } ,function() {
|
this.resource('adminCustomize', { path: '/customize' } ,function() {
|
||||||
this.route('colors');
|
this.route('colors');
|
||||||
this.route('css_html');
|
this.route('css_html');
|
||||||
|
this.resource('adminSiteContents', { path: '/site_contents' }, function() {
|
||||||
|
this.route('edit', {path: '/:content_type'});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
this.route('api');
|
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>
|
<li>{{#link-to 'admin.dashboard'}}{{i18n admin.dashboard.title}}{{/link-to}}</li>
|
||||||
{{#if currentUser.admin}}
|
{{#if currentUser.admin}}
|
||||||
<li>{{#link-to 'adminSiteSettings'}}{{i18n admin.site_settings.title}}{{/link-to}}</li>
|
<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}}
|
{{/if}}
|
||||||
<li>{{#link-to 'adminUsersList'}}{{i18n admin.users.title}}{{/link-to}}</li>
|
<li>{{#link-to 'adminUsersList'}}{{i18n admin.users.title}}{{/link-to}}</li>
|
||||||
{{#if showBadges}}
|
{{#if showBadges}}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
<ul class="nav nav-pills">
|
<ul class="nav nav-pills">
|
||||||
<li>{{#link-to 'adminCustomize.colors'}}{{i18n admin.customize.colors.title}}{{/link-to}}</li>
|
<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 '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>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<div class='content-list span6'>
|
<div class='content-list span6'>
|
||||||
<h3>{{i18n admin.site_content.edit}}</h3>
|
<h3>{{i18n admin.site_content.edit}}</h3>
|
||||||
<ul>
|
<ul>
|
||||||
{{#each type in model}}
|
{{#each model}}
|
||||||
<li>
|
<li>
|
||||||
{{#link-to 'adminSiteContentEdit' type}}{{type.title}}{{/link-to}}
|
{{#link-to 'adminSiteContents.edit' content_type}}{{title}}{{/link-to}}
|
||||||
</li>
|
</li>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
<h3>{{model.title}}</h3>
|
<h3>{{title}}</h3>
|
||||||
<p class='description'>{{model.description}}</p>
|
<p class='description'>{{description}}</p>
|
||||||
|
|
||||||
{{#if model.markdown}}
|
{{#if markdown}}
|
||||||
{{pagedown-editor value=model.content}}
|
{{pagedown-editor value=model.content}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if model.plainText}}
|
{{#if plainText}}
|
||||||
{{textarea value=model.content class="plain"}}
|
{{textarea value=model.content class="plain"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if model.html}}
|
{{#if html}}
|
||||||
{{aceEditor content=model.content mode="html"}}
|
{{aceEditor content=model.content mode="html"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if model.css}}
|
{{#if css}}
|
||||||
{{aceEditor content=model.content mode="css"}}
|
{{aceEditor content=model.content mode="css"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<div class='controls'>
|
<div class='controls'>
|
||||||
<button class='btn' {{action saveChanges}} {{bind-attr disabled="saveDisabled"}}>
|
<button class='btn' {{action "saveChanges"}} {{bind-attr disabled="saveDisabled"}}>
|
||||||
{{#if saving}}
|
{{#if saving}}
|
||||||
{{i18n saving}}
|
{{i18n saving}}
|
||||||
{{else}}
|
{{else}}
|
||||||
@@ -109,8 +109,11 @@ Discourse::Application.routes.draw do
|
|||||||
post "flags/disagree/:id" => "flags#disagree"
|
post "flags/disagree/:id" => "flags#disagree"
|
||||||
post "flags/defer/:id" => "flags#defer"
|
post "flags/defer/:id" => "flags#defer"
|
||||||
resources :site_customizations, constraints: AdminConstraint.new
|
resources :site_customizations, constraints: AdminConstraint.new
|
||||||
resources :site_contents, constraints: AdminConstraint.new
|
scope "/customize" do
|
||||||
resources :site_content_types, constraints: AdminConstraint.new
|
resources :site_contents, constraints: AdminConstraint.new
|
||||||
|
resources :site_content_types, constraints: AdminConstraint.new
|
||||||
|
end
|
||||||
|
|
||||||
resources :color_schemes, constraints: AdminConstraint.new
|
resources :color_schemes, constraints: AdminConstraint.new
|
||||||
|
|
||||||
get "version_check" => "versions#show"
|
get "version_check" => "versions#show"
|
||||||
|
|||||||
Reference in New Issue
Block a user