Skip to content

Commit f634e00

Browse files
authored
support setting moderator organizations for a user (#605)
1 parent 82f865b commit f634e00

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

client/scripts/controllers/UserController.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
const angular = require('angular')
66
const forms = require('../configs/forms')
77

8-
require('../app').controller('UserController', /* @ngInject */function ($scope, $state, $stateParams, $q, $timeout, $translate, api, ngToast, user, User, Raven) {
8+
require('../app').controller('UserController', /* @ngInject */function ($scope, $state, $stateParams, $q, $timeout, $translate, api, ngToast, user, User, Raven, Organization) {
99
const controller = this
1010

1111
const id = $stateParams.id || $stateParams.fromId
@@ -14,6 +14,7 @@ require('../app').controller('UserController', /* @ngInject */function ($scope,
1414
controller.data.id = id
1515

1616
controller.moderatorForms = []
17+
controller.moderatorOrganizations = []
1718
controller.privacyChoices = [
1819
{ id: 'public', label: 'PRIVACY_PUBLIC' },
1920
{ id: 'private', label: 'PRIVACY_PRIVATE' }
@@ -28,6 +29,15 @@ require('../app').controller('UserController', /* @ngInject */function ($scope,
2829
controller.roleChoices.push({ id: 'admin', label: 'admin' })
2930
}
3031

32+
Organization.query({ limit: -1 }).$promise.then(function (organizations) {
33+
controller.moderatorOrganizations = organizations.map(function (org) {
34+
return {
35+
id: org.slug,
36+
label: org.toString()
37+
}
38+
})
39+
})
40+
3141
angular.forEach(forms, function (formDef) {
3242
controller.moderatorForms.push({ id: formDef.serverModel, label: formDef.label })
3343
})

client/views/users/detail.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ <h3 translate>USER_DETAIL_RIGHTS</h3>
116116
choices="user.moderatorForms"
117117
label="{{::'USER_DETAIL_FORMS' | translate}}"
118118
model="user.data.forms"></field>
119+
120+
<field ng-if="::$user.isAdmin()" name="moderatorOrganizations" type="checkbox-group"
121+
disabled="user.data.role !== 'moderator'"
122+
choices="user.moderatorOrganizations"
123+
label="{{::'USER_DETAIL_MODERATOR_ORGANIZATIONS' | translate}}"
124+
model="user.data.moderatorOrganizations"></field>
119125
</div>
120126

121127
<div ng-if="::$user.getIdentity().id === user.data.id">

i18n/bg.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1377,5 +1377,6 @@
13771377
"ETRS89_TASK_START_TIME": "Начален час на ETRS89 задача",
13781378
"BG_ATLAS_2008_GRID_SIZE": "Размер на BG Атлас 2008 мрежа (в km)",
13791379
"BG_ATLAS_2008_START_TIMESTAMP": "Начален времеви печат за BG Атлас 2008",
1380-
"EBP_API_BASE_URL": "EBP API базов URL"
1380+
"EBP_API_BASE_URL": "EBP API базов URL",
1381+
"USER_DETAIL_MODERATOR_ORGANIZATIONS": "Организации за модериране"
13811382
}

i18n/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1384,5 +1384,6 @@
13841384
"AUTO_TRANSLATE_MAX_RECORDS": "AutoTranslate max records",
13851385
"TASKS_MAX_RECORDS": "Tasks max records",
13861386
"ETRS89_TASK_MAX_RECORDS": "ETRS89 task max records",
1387-
"ETRS89_TASK_START_TIME": "ETRS89 task start time"
1387+
"ETRS89_TASK_START_TIME": "ETRS89 task start time",
1388+
"USER_DETAIL_MODERATOR_ORGANIZATIONS": "Moderator organizations"
13881389
}

0 commit comments

Comments
 (0)