Fix deprecations in admin groups interface
This commit is contained in:
parent
a8d20c623f
commit
0442457e7b
|
@ -0,0 +1,9 @@
|
||||||
|
export default Ember.Component.extend({
|
||||||
|
classNames: ["item"],
|
||||||
|
|
||||||
|
actions: {
|
||||||
|
remove() {
|
||||||
|
this.sendAction('removeAction', this.get('member'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
|
@ -6,14 +6,14 @@ export default Em.ObjectController.extend({
|
||||||
disableSave: false,
|
disableSave: false,
|
||||||
|
|
||||||
currentPage: function() {
|
currentPage: function() {
|
||||||
if (this.get("user_count") === 0) { return 0; }
|
if (this.get("model.user_count") === 0) { return 0; }
|
||||||
return Math.floor(this.get("offset") / this.get("limit")) + 1;
|
return Math.floor(this.get("model.offset") / this.get("model.limit")) + 1;
|
||||||
}.property("limit", "offset", "user_count"),
|
}.property("model.limit", "model.offset", "model.user_count"),
|
||||||
|
|
||||||
totalPages: function() {
|
totalPages: function() {
|
||||||
if (this.get("user_count") === 0) { return 0; }
|
if (this.get("model.user_count") === 0) { return 0; }
|
||||||
return Math.floor(this.get("user_count") / this.get("limit")) + 1;
|
return Math.floor(this.get("model.user_count") / this.get("model.limit")) + 1;
|
||||||
}.property("limit", "user_count"),
|
}.property("model.limit", "model.user_count"),
|
||||||
|
|
||||||
showingFirst: Em.computed.lte("currentPage", 1),
|
showingFirst: Em.computed.lte("currentPage", 1),
|
||||||
showingLast: propertyEqual("currentPage", "totalPages"),
|
showingLast: propertyEqual("currentPage", "totalPages"),
|
||||||
|
@ -32,7 +32,7 @@ export default Em.ObjectController.extend({
|
||||||
if (this.get("showingLast")) { return; }
|
if (this.get("showingLast")) { return; }
|
||||||
|
|
||||||
const group = this.get("model"),
|
const group = this.get("model"),
|
||||||
offset = Math.min(group.get("offset") + group.get("limit"), group.get("user_count"));
|
offset = Math.min(group.get("offset") + group.get("model.limit"), group.get("user_count"));
|
||||||
|
|
||||||
group.set("offset", offset);
|
group.set("offset", offset);
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ export default Em.ObjectController.extend({
|
||||||
if (this.get("showingFirst")) { return; }
|
if (this.get("showingFirst")) { return; }
|
||||||
|
|
||||||
const group = this.get("model"),
|
const group = this.get("model"),
|
||||||
offset = Math.max(group.get("offset") - group.get("limit"), 0);
|
offset = Math.max(group.get("offset") - group.get("model.limit"), 0);
|
||||||
|
|
||||||
group.set("offset", offset);
|
group.set("offset", offset);
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ export default Em.ObjectController.extend({
|
||||||
|
|
||||||
removeMember(member) {
|
removeMember(member) {
|
||||||
const self = this,
|
const self = this,
|
||||||
message = I18n.t("admin.groups.delete_member_confirm", { username: member.get("username"), group: this.get("name") });
|
message = I18n.t("admin.groups.delete_member_confirm", { username: member.get("username"), group: this.get("model.name") });
|
||||||
return bootbox.confirm(message, I18n.t("no_value"), I18n.t("yes_value"), function(confirm) {
|
return bootbox.confirm(message, I18n.t("no_value"), I18n.t("yes_value"), function(confirm) {
|
||||||
if (confirm) {
|
if (confirm) {
|
||||||
self.get("model").removeMember(member);
|
self.get("model").removeMember(member);
|
||||||
|
@ -61,10 +61,9 @@ export default Em.ObjectController.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
addMembers() {
|
addMembers() {
|
||||||
if (Em.isEmpty(this.get("usernames"))) { return; }
|
if (Em.isEmpty(this.get("model.usernames"))) { return; }
|
||||||
this.get("model").addMembers(this.get("usernames"));
|
this.get("model").addMembers(this.get("model.usernames")).catch(popupAjaxError);
|
||||||
// clear the user selector
|
this.set("model.usernames", null);
|
||||||
this.set("usernames", null);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
save() {
|
save() {
|
||||||
|
|
|
@ -11,9 +11,7 @@ export default Discourse.Route.extend({
|
||||||
|
|
||||||
setupController: function(controller, model) {
|
setupController: function(controller, model) {
|
||||||
controller.set("model", model);
|
controller.set("model", model);
|
||||||
// clear the user selector
|
controller.set("model.usernames", null);
|
||||||
controller.set("usernames", null);
|
|
||||||
// load the members of the group
|
|
||||||
model.findMembers();
|
model.findMembers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
<a href={{member.adminPath}}>{{avatar member imageSize="small"}}</a> {{member.username}} {{#unless automatic}}<a class='remove' {{action "remove"}}>{{fa-icon "times"}}</a>{{/unless}}
|
|
@ -1,31 +1,33 @@
|
||||||
<form class="form-horizontal">
|
<form class="form-horizontal">
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
{{#if automatic}}
|
{{#if model.automatic}}
|
||||||
<h3>{{name}}</h3>
|
<h3>{{model.name}}</h3>
|
||||||
{{else}}
|
{{else}}
|
||||||
<label for="name">{{i18n 'admin.groups.name'}}</label>
|
<label for="name">{{i18n 'admin.groups.name'}}</label>
|
||||||
{{text-field name="name" value=name placeholderKey="admin.groups.name_placeholder"}}
|
{{text-field name="name" value=model.name placeholderKey="admin.groups.name_placeholder"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{#if id}}
|
{{#if model.id}}
|
||||||
<div>
|
<div>
|
||||||
<label>{{i18n 'admin.groups.group_members'}} ({{user_count}})</label>
|
<label>{{i18n 'admin.groups.group_members'}} ({{model.user_count}})</label>
|
||||||
<div>
|
<div>
|
||||||
<a {{bind-attr class=":previous showingFirst:disabled"}} {{action "previous"}}>{{fa-icon "fast-backward"}}</a>
|
<a {{bind-attr class=":previous showingFirst:disabled"}} {{action "previous"}}>{{fa-icon "fast-backward"}}</a>
|
||||||
{{currentPage}}/{{totalPages}}
|
{{currentPage}}/{{totalPages}}
|
||||||
<a {{bind-attr class=":next showingLast:disabled"}} {{action "next"}}>{{fa-icon "fast-forward"}}</a>
|
<a {{bind-attr class=":next showingLast:disabled"}} {{action "next"}}>{{fa-icon "fast-forward"}}</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="ac-wrap clearfix">
|
<div class="ac-wrap clearfix">
|
||||||
{{each member in members itemView="group-member"}}
|
{{#each model.members as |member|}}
|
||||||
|
{{group-member member=member automatic=model.automatic removeAction="removeMember"}}
|
||||||
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{#unless automatic}}
|
{{#unless model.automatic}}
|
||||||
<div>
|
<div>
|
||||||
<label for="user-selector">{{i18n 'admin.groups.add_members'}}</label>
|
<label for="user-selector">{{i18n 'admin.groups.add_members'}}</label>
|
||||||
{{user-selector usernames=usernames placeholderKey="admin.groups.selector_placeholder" id="user-selector"}}
|
{{user-selector usernames=model.usernames placeholderKey="admin.groups.selector_placeholder" id="user-selector"}}
|
||||||
<button {{action "addMembers"}} class='btn add'>{{fa-icon "plus"}} {{i18n 'admin.groups.add'}}</button>
|
<button {{action "addMembers"}} class='btn add'>{{fa-icon "plus"}} {{i18n 'admin.groups.add'}}</button>
|
||||||
</div>
|
</div>
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
|
@ -33,15 +35,15 @@
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label>
|
<label>
|
||||||
{{input type="checkbox" checked=visible}}
|
{{input type="checkbox" checked=model.visible}}
|
||||||
{{i18n 'groups.visible'}}
|
{{i18n 'groups.visible'}}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{#unless automatic}}
|
{{#unless model.automatic}}
|
||||||
<div>
|
<div>
|
||||||
<label for="primary_group">
|
<label for="primary_group">
|
||||||
{{input type="checkbox" checked=primary_group}}
|
{{input type="checkbox" checked=model.primary_group}}
|
||||||
{{i18n 'admin.groups.primary_group'}}
|
{{i18n 'admin.groups.primary_group'}}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
@ -49,15 +51,15 @@
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label for="alias">{{i18n 'groups.alias_levels.title'}}</label>
|
<label for="alias">{{i18n 'groups.alias_levels.title'}}</label>
|
||||||
{{combo-box name="alias" valueAttribute="value" value=alias_level content=aliasLevelOptions}}
|
{{combo-box name="alias" valueAttribute="value" value=model.alias_level content=aliasLevelOptions}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{#unless automatic}}
|
{{#unless model.automatic}}
|
||||||
<div>
|
<div>
|
||||||
<label for="automatic_membership">{{i18n 'admin.groups.automatic_membership_email_domains'}}</label>
|
<label for="automatic_membership">{{i18n 'admin.groups.automatic_membership_email_domains'}}</label>
|
||||||
{{list-setting name="automatic_membership" settingValue=emailDomains}}
|
{{list-setting name="automatic_membership" settingValue=model.emailDomains}}
|
||||||
<label>
|
<label>
|
||||||
{{input type="checkbox" checked=automatic_membership_retroactive}}
|
{{input type="checkbox" checked=model.automatic_membership_retroactive}}
|
||||||
{{i18n 'admin.groups.automatic_membership_retroactive'}}
|
{{i18n 'admin.groups.automatic_membership_retroactive'}}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
@ -66,13 +68,13 @@
|
||||||
<label for="title">
|
<label for="title">
|
||||||
{{i18n 'admin.groups.default_title'}}
|
{{i18n 'admin.groups.default_title'}}
|
||||||
</label>
|
</label>
|
||||||
{{input value=title}}
|
{{input value=model.title}}
|
||||||
</div>
|
</div>
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
|
|
||||||
<div class='buttons'>
|
<div class='buttons'>
|
||||||
<button {{action "save"}} {{bind-attr disabled="disableSave"}} class='btn btn-primary'>{{i18n 'admin.customize.save'}}</button>
|
<button {{action "save"}} {{bind-attr disabled="disableSave"}} class='btn btn-primary'>{{i18n 'admin.customize.save'}}</button>
|
||||||
{{#unless automatic}}
|
{{#unless model.automatic}}
|
||||||
<button {{action "destroy"}} class='btn btn-danger'>{{fa-icon "trash-o"}}{{i18n 'admin.customize.delete'}}</button>
|
<button {{action "destroy"}} class='btn btn-danger'>{{fa-icon "trash-o"}}{{i18n 'admin.customize.delete'}}</button>
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
<a href='{{unbound member.adminPath}}'>{{avatar member imageSize="small"}}</a> {{member.username}} {{#unless automatic}}<a class='remove' {{action "removeMember" member}}>{{fa-icon "times"}}</a>{{/unless}}
|
|
|
@ -1,4 +0,0 @@
|
||||||
export default Discourse.View.extend({
|
|
||||||
classNames: ["item"],
|
|
||||||
templateName: "admin/templates/group_member"
|
|
||||||
});
|
|
|
@ -50,14 +50,7 @@ const Group = Discourse.Model.extend({
|
||||||
type: "PUT",
|
type: "PUT",
|
||||||
data: { usernames: usernames }
|
data: { usernames: usernames }
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
// reload member list
|
|
||||||
self.findMembers();
|
self.findMembers();
|
||||||
}).catch(function(error) {
|
|
||||||
if (error && error.responseText) {
|
|
||||||
bootbox.alert($.parseJSON(error.responseText).errors[0]);
|
|
||||||
} else {
|
|
||||||
bootbox.alert(I18n.t('generic_error'));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue