* DEV: Provide radix 10 argument to parseInt * DEV: Provide radix 16 argument to parseInt * DEV: Remove unnecessary parseInt calls * Fix year formatting parseInt was used here to convert decimals to ints
62 lines
1.5 KiB
JavaScript
62 lines
1.5 KiB
JavaScript
import { buildCategoryPanel } from "discourse/components/edit-category-panel";
|
|
import PermissionType from "discourse/models/permission-type";
|
|
import { on } from "discourse-common/utils/decorators";
|
|
|
|
export default buildCategoryPanel("security", {
|
|
editingPermissions: false,
|
|
selectedGroup: null,
|
|
selectedPermission: null,
|
|
showPendingGroupChangesAlert: false,
|
|
interactedWithDropdowns: false,
|
|
|
|
@on("init")
|
|
_registerValidator() {
|
|
this.registerValidator(() => {
|
|
if (
|
|
!this.showPendingGroupChangesAlert &&
|
|
this.interactedWithDropdowns &&
|
|
this.activeTab
|
|
) {
|
|
this.set("showPendingGroupChangesAlert", true);
|
|
return true;
|
|
}
|
|
});
|
|
},
|
|
|
|
actions: {
|
|
onDropdownChange() {
|
|
this.set("interactedWithDropdowns", true);
|
|
},
|
|
|
|
editPermissions() {
|
|
if (!this.get("category.is_special")) {
|
|
this.set("editingPermissions", true);
|
|
}
|
|
},
|
|
|
|
addPermission(group, id) {
|
|
if (!this.get("category.is_special")) {
|
|
this.category.addPermission({
|
|
group_name: group + "",
|
|
permission: PermissionType.create({ id: parseInt(id, 10) })
|
|
});
|
|
}
|
|
|
|
this.set(
|
|
"selectedGroup",
|
|
this.get("category.availableGroups.firstObject")
|
|
);
|
|
this.setProperties({
|
|
showPendingGroupChangesAlert: false,
|
|
interactedWithDropdowns: false
|
|
});
|
|
},
|
|
|
|
removePermission(permission) {
|
|
if (!this.get("category.is_special")) {
|
|
this.category.removePermission(permission);
|
|
}
|
|
}
|
|
}
|
|
});
|