From 625204c8bd2b48037cdbefce3d957c3cbbce778a Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 17 Jul 2013 14:54:21 +1000 Subject: [PATCH] work in progress category UI refactor hack from earlier --- .../javascripts/admin/models/site_content_type.js | 6 ++---- .../admin/routes/admin_site_content_edit_route.js | 11 +++-------- .../controllers/edit_category_controller.js | 12 ++++++++---- .../templates/modal/edit_category.js.handlebars | 1 + config/locales/client.en.yml | 7 ++++--- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/app/assets/javascripts/admin/models/site_content_type.js b/app/assets/javascripts/admin/models/site_content_type.js index b8cc03b0762..6e1d0a5fff2 100644 --- a/app/assets/javascripts/admin/models/site_content_type.js +++ b/app/assets/javascripts/admin/models/site_content_type.js @@ -10,14 +10,12 @@ Discourse.SiteContentType = Discourse.Model.extend({}); Discourse.SiteContentType.reopenClass({ findAll: function() { - var promise = new Em.Deferred(); - Discourse.ajax("/admin/site_content_types").then(function(data) { + return Discourse.ajax("/admin/site_content_types").then(function(data) { var contentTypes = Em.A(); data.forEach(function (ct) { contentTypes.pushObject(Discourse.SiteContentType.create(ct)); }); - promise.resolve(contentTypes); + return contentTypes; }); - return promise; } }); diff --git a/app/assets/javascripts/admin/routes/admin_site_content_edit_route.js b/app/assets/javascripts/admin/routes/admin_site_content_edit_route.js index 5ada1036e66..90465427d76 100644 --- a/app/assets/javascripts/admin/routes/admin_site_content_edit_route.js +++ b/app/assets/javascripts/admin/routes/admin_site_content_edit_route.js @@ -14,7 +14,6 @@ Discourse.AdminSiteContentEditRoute = Discourse.Route.extend({ model: function(params) { var list = this.controllerFor('adminSiteContents').get('model'); - var model; // ember routing is fun ... this is what happens // @@ -28,14 +27,10 @@ Discourse.AdminSiteContentEditRoute = Discourse.Route.extend({ // we could avoid this hack if Ember just compared .serialize(model) with .serialize(context) // // alternatively we could use some sort of identity map + // + // see also: https://github.com/emberjs/ember.js/issues/3005 - list.forEach(function(orig){ - if(orig.get("content_type") === params.content_type){ - model = orig; - } - }); - - return model; + return list.findProperty("content_type", params.content_type); }, renderTemplate: function() { diff --git a/app/assets/javascripts/discourse/controllers/edit_category_controller.js b/app/assets/javascripts/discourse/controllers/edit_category_controller.js index 5786c0cbedf..4c5d7080e4d 100644 --- a/app/assets/javascripts/discourse/controllers/edit_category_controller.js +++ b/app/assets/javascripts/discourse/controllers/edit_category_controller.js @@ -22,10 +22,14 @@ Discourse.EditCategoryController = Discourse.ObjectController.extend(Discourse.M }.observes('description'), title: function() { - if (this.get('id')) return I18n.t("category.edit_long"); - if (this.get('isUncategorized')) return I18n.t("category.edit_uncategorized"); - return I18n.t("category.create"); - }.property('id'), + if (this.get('id')) { + return I18n.t("category.edit_long") + ": " + this.get('model.name'); + } + if (this.get('isUncategorized')){ + return I18n.t("category.edit_uncategorized"); + } + return I18n.t("category.create") + " : " + this.get('model.name'); + }.property('id', 'model.name'), titleChanged: function() { this.set('controllers.modal.title', this.get('title')); diff --git a/app/assets/javascripts/discourse/templates/modal/edit_category.js.handlebars b/app/assets/javascripts/discourse/templates/modal/edit_category.js.handlebars index 6a73794be57..b9b5e972025 100644 --- a/app/assets/javascripts/discourse/templates/modal/edit_category.js.handlebars +++ b/app/assets/javascripts/discourse/templates/modal/edit_category.js.handlebars @@ -64,6 +64,7 @@ {{#each permissions}}
  • {{group_name}} + {{{i18n "category.can"}}} {{permission.description}}
  • diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index e2f45a6480c..1d5a9735fd8 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -876,6 +876,7 @@ en: other: "Are you sure you want to delete all those posts?" category: + can: 'can… ' none: '(no category)' edit: 'edit' edit_long: "Edit Category" @@ -998,9 +999,9 @@ en: browser_update: 'Unfortunately, your browser is too old to work on this Discourse forum. Please upgrade your browser.' permission_types: - full: "Create Topics, Create Posts and Read" - create_post: "Create Posts and Read" - readonly: "Read Only" + full: "CREATE / REPLY / SEE" + create_post: "REPLY / SEE" + readonly: "SEE" # This section is exported to the javascript for i18n in the admin section admin_js: