UI still a tad rough, but we have a first pass of secure categories

This commit is contained in:
Sam
2013-05-10 16:47:47 +10:00
parent 4030722a8f
commit 942f168ab6
16 changed files with 127 additions and 42 deletions

View File

@@ -9,7 +9,7 @@
<li>{{#linkTo 'adminSiteContents'}}{{i18n admin.site_content.title}}{{/linkTo}}</li>
{{/if}}
<li>{{#linkTo 'adminUsersList.active'}}{{i18n admin.users.title}}{{/linkTo}}</li>
<!--<li>{{#linkTo 'admin.groups'}}{{i18n admin.groups.title}}{{/linkTo}}</li>-->
<li>{{#linkTo 'admin.groups'}}{{i18n admin.groups.title}}{{/linkTo}}</li>
<li>{{#linkTo 'admin.email_logs'}}{{i18n admin.email_logs.title}}{{/linkTo}}</li>
<li>{{#linkTo 'adminFlags.active'}}{{i18n admin.flags.title}}{{/linkTo}}</li>
{{#if Discourse.currentUser.admin}}

View File

@@ -15,6 +15,9 @@ Discourse.Category = Discourse.Model.extend({
if (!this.get('color')) this.set('color', Discourse.SiteSettings.uncategorized_color);
if (!this.get('text_color')) this.set('text_color', Discourse.SiteSettings.uncategorized_text_color);
}
this.set("availableGroups", Em.A(this.get("available_groups")));
this.set("groups", Em.A(this.groups));
},
url: function() {
@@ -40,7 +43,9 @@ Discourse.Category = Discourse.Model.extend({
name: this.get('name'),
color: this.get('color'),
text_color: this.get('text_color'),
hotness: this.get('hotness')
hotness: this.get('hotness'),
secure: this.get('secure'),
group_names: this.get('groups').join(",")
},
type: this.get('id') ? 'PUT' : 'POST'
});
@@ -48,6 +53,17 @@ Discourse.Category = Discourse.Model.extend({
destroy: function(callback) {
return Discourse.ajax("/categories/" + (this.get('slug') || this.get('id')), { type: 'DELETE' });
},
addGroup: function(group){
this.get("groups").addObject(group);
this.get("availableGroups").removeObject(group);
},
removeGroup: function(group){
this.get("groups").removeObject(group);
this.get("availableGroups").addObject(group);
}
});

View File

@@ -23,10 +23,30 @@
{{/if}}
</section>
<section class='field'>
<label>{{i18n category.security}}</label>
<label>
{{view Ember.Checkbox checkedBinding="secure"}}
{{i18n category.is_secure}}
</label>
{{#if secure}}
<div>
{{i18n category.allowed_groups}}
{{#each groups}}
{{this}} <a {{action removeGroup this target="view"}}>x</a>
{{/each}}
</div>
{{view Ember.Select contentBinding="availableGroups" valueBinding="view.selectedGroup"}}
<button {{action addGroup target="view"}}>{{i18n category.add_group}}</button>
{{/if}}
</section>
<!-- Sam, disabled for now
<section class='field'>
<label>{{i18n category.hotness}}</label>
{{view Discourse.HotnessView hotnessBinding="hotness"}}
</section>
-->
{{/unless}}
<section class='field'>
@@ -58,4 +78,4 @@
</div>
</div>
{{/with}}
{{/with}}

View File

@@ -93,6 +93,16 @@ Discourse.EditCategoryView = Discourse.ModalBodyView.extend({
return false;
},
addGroup: function(){
this.get("category").addGroup(this.get("selectedGroup"));
},
removeGroup: function(group){
// OBVIOUS, Ember treats this as Ember.String, we need a real string here
group = group + "";
this.get("category").removeGroup(group);
},
saveCategory: function() {
var categoryView = this;
this.set('saving', true);