mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
fix links to site contents, fix it so the site contents page is refreshable
This commit is contained in:
parent
d1dbcf52fc
commit
63cbe8dd17
4 changed files with 35 additions and 7 deletions
|
@ -10,12 +10,14 @@ Discourse.SiteContentType = Discourse.Model.extend({});
|
||||||
|
|
||||||
Discourse.SiteContentType.reopenClass({
|
Discourse.SiteContentType.reopenClass({
|
||||||
findAll: function() {
|
findAll: function() {
|
||||||
var contentTypes = Em.A();
|
promise = new Em.Deferred();
|
||||||
Discourse.ajax("/admin/site_content_types").then(function(data) {
|
Discourse.ajax("/admin/site_content_types").then(function(data) {
|
||||||
|
var contentTypes = Em.A();
|
||||||
data.forEach(function (ct) {
|
data.forEach(function (ct) {
|
||||||
contentTypes.pushObject(Discourse.SiteContentType.create(ct));
|
contentTypes.pushObject(Discourse.SiteContentType.create(ct));
|
||||||
});
|
});
|
||||||
|
promise.resolve(contentTypes);
|
||||||
});
|
});
|
||||||
return contentTypes;
|
return promise;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,7 +13,29 @@ Discourse.AdminSiteContentEditRoute = Discourse.Route.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
model: function(params) {
|
model: function(params) {
|
||||||
return {content_type: params.content_type};
|
var list = this.controllerFor('adminSiteContents').get('model');
|
||||||
|
var model;
|
||||||
|
|
||||||
|
// ember routing is fun ... this is what happens
|
||||||
|
//
|
||||||
|
// linkTo creates an Ember.LinkView , it marks an <a> with the class "active"
|
||||||
|
// if the "context" of this dynamic route is equal to the model in the linkTo
|
||||||
|
// the route "context" is set here, so we want to make sure we have the exact
|
||||||
|
// same object, from Ember we have:
|
||||||
|
//
|
||||||
|
// if (handlerInfo.context !== object) { return false; }
|
||||||
|
//
|
||||||
|
// we could avoid this hack if Ember just compared .serialize(model) with .serialize(context)
|
||||||
|
//
|
||||||
|
// alternatively we could use some sort of identity map
|
||||||
|
|
||||||
|
list.forEach(function(orig){
|
||||||
|
if(orig.get("content_type") === params.content_type){
|
||||||
|
model = orig;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return model;
|
||||||
},
|
},
|
||||||
|
|
||||||
renderTemplate: function() {
|
renderTemplate: function() {
|
||||||
|
@ -26,6 +48,7 @@ Discourse.AdminSiteContentEditRoute = Discourse.Route.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
setupController: function(controller, model) {
|
setupController: function(controller, model) {
|
||||||
|
|
||||||
controller.set('loaded', false);
|
controller.set('loaded', false);
|
||||||
controller.setProperties({
|
controller.setProperties({
|
||||||
model: model,
|
model: model,
|
||||||
|
@ -33,7 +56,7 @@ Discourse.AdminSiteContentEditRoute = Discourse.Route.extend({
|
||||||
saved: false
|
saved: false
|
||||||
});
|
});
|
||||||
|
|
||||||
Discourse.SiteContent.find(Em.get(model, 'content_type')).then(function (sc) {
|
Discourse.SiteContent.find(model.get('content_type')).then(function (sc) {
|
||||||
controller.set('content', sc);
|
controller.set('content', sc);
|
||||||
controller.set('loaded', true);
|
controller.set('loaded', true);
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,9 +13,12 @@ Discourse.AdminSiteContentsRoute = Discourse.Route.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
renderTemplate: function(controller, model) {
|
renderTemplate: function(controller, model) {
|
||||||
controller.set('model', model);
|
|
||||||
this.render('admin/templates/site_contents', {into: 'admin/templates/admin'});
|
this.render('admin/templates/site_contents', {into: 'admin/templates/admin'});
|
||||||
this.render('admin/templates/site_contents_empty', {into: 'admin/templates/site_contents'});
|
this.render('admin/templates/site_contents_empty', {into: 'admin/templates/site_contents'});
|
||||||
|
},
|
||||||
|
|
||||||
|
setupController: function(controller, model) {
|
||||||
|
controller.set('model', model);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<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 content}}
|
{{#each type in model}}
|
||||||
<li>
|
<li>
|
||||||
{{#linkTo 'adminSiteContentEdit' type}}{{type.title}}{{/linkTo}}
|
{{#linkTo 'adminSiteContentEdit' type}}{{type.title}}{{/linkTo}}
|
||||||
</li>
|
</li>
|
||||||
|
@ -13,4 +13,4 @@
|
||||||
<div class='content-editor'>
|
<div class='content-editor'>
|
||||||
{{outlet}}
|
{{outlet}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue