Skip to content

Commit 73b4560

Browse files
Merge pull request #3997 from Tahi-project/bugs/APERTA-12445-fix-participant-perms
APERTA-12445 first card
2 parents d25fef9 + 371bc41 commit 73b4560

File tree

7 files changed

+171
-136
lines changed

7 files changed

+171
-136
lines changed

app/controllers/card_permissions_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class CardPermissionsController < ApplicationController
33
before_action :authenticate_user!
44
respond_to :json
55

6-
CARD_ACTIONS = ['view', 'edit', 'view_discussion_footer', 'edit_discussion_footer', 'be_assigned', 'assign_others'].freeze
6+
CARD_ACTIONS = %w[view edit view_discussion_footer edit_discussion_footer be_assigned assign_others view_participants manage_participant].freeze
77

88
def create
99
card = Card.find(safe_params[:filter_by_card_id])

client/app/pods/admin-card-permission/service.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ export default Ember.Service.extend({
1515
* @return {Ember.Array.<CardPermission>} All permissions that were modified
1616
*/
1717

18-
editPermissions: ['edit', 'edit_discussion_footer', 'assign_others', 'be_assigned'],
18+
editPermissions: ['edit', 'edit_discussion_footer', 'assign_others', 'be_assigned', 'manage_participant'],
1919

2020
correspondingActions: {
2121
'edit': ['view'],
2222
'be_assigned': ['view', 'edit'],
2323
'assign_others': ['view', 'edit'],
24-
'edit_discussion_footer': ['view_discussion_footer']
24+
'edit_discussion_footer': ['view_discussion_footer'],
25+
'manage_participant': ['view_participants']
2526
},
2627

2728
addRoleToPermissionSensible(role, filterByCardId, permissionAction) {

client/app/pods/components/card-editor/permissions/role/component.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,15 @@ export default Ember.Component.extend({
1818
edit_discussion_footerAllowed: permissionExists('card', 'role', 'edit_discussion_footer'),
1919
be_assignedAllowed: permissionExists('card', 'role', 'be_assigned'),
2020
assign_othersAllowed: permissionExists('card', 'role', 'assign_others'),
21-
22-
togglePermission(permissionAction) {
23-
if (this.get(`${permissionAction}Allowed`)) {
24-
this.get('turnOffPermission')(this.get('role'), this.get('card'), permissionAction);
25-
} else {
26-
this.get('turnOnPermission')(this.get('role'), this.get('card'), permissionAction);
27-
}
28-
},
29-
21+
view_participantsAllowed: permissionExists('card', 'role', 'view_participants'),
22+
manage_participantAllowed: permissionExists('card', 'role', 'manage_participant'),
3023
actions: {
31-
toggleViewPermission() { this.togglePermission('view'); },
32-
toggleEditPermission() { this.togglePermission('edit'); },
33-
toggleViewDiscussionFooterPermission() { this.togglePermission('view_discussion_footer'); },
34-
toggleEditDiscussionFooterPermission() { this.togglePermission('edit_discussion_footer'); },
35-
toggleBeAssignedPermission() { this.togglePermission('be_assigned'); },
36-
toggleAssignOthersAllowed() { this.togglePermission('assign_others'); }
24+
togglePermission(permissionAction) {
25+
if (this.get(`${permissionAction}Allowed`)) {
26+
this.get('turnOffPermission')(this.get('role'), this.get('card'), permissionAction);
27+
} else {
28+
this.get('turnOnPermission')(this.get('role'), this.get('card'), permissionAction);
29+
}
30+
}
3731
}
3832
});

client/app/pods/components/card-editor/permissions/role/template.hbs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,49 @@
66
name=(concat role.name "-view")
77
checked=(readonly viewAllowed)
88
disabled=(readonly editAllowed)
9-
action=(action "toggleViewPermission")}}
9+
action=(action "togglePermission" "view")}}
1010
</td>
1111
<td class="centered">
1212
{{check-box
1313
name=(concat role.name "-edit")
1414
checked=(readonly editAllowed)
15-
action=(action "toggleEditPermission")}}
15+
action=(action "togglePermission" "edit")}}
1616
</td>
1717
<td class="centered">
1818
{{check-box
1919
name=(concat role.name "-discussion-view")
2020
checked=(readonly view_discussion_footerAllowed)
2121
disabled=(readonly edit_discussion_footerAllowed)
22-
action=(action "toggleViewDiscussionFooterPermission")}}
22+
action=(action "togglePermission" "view_discussion_footer")}}
2323
</td>
2424
<td class="centered">
2525
{{check-box
2626
name=(concat role.name "-discussion-edit")
2727
checked=(readonly edit_discussion_footerAllowed)
28-
action=(action "toggleEditDiscussionFooterPermission")}}
28+
action=(action "togglePermission" "edit_discussion_footer")}}
2929
</td>
3030
<td class="centered">
3131
{{check-box
3232
name=(concat role.name "-be_assigned")
3333
checked=(readonly be_assignedAllowed)
34-
action=(action "toggleBeAssignedPermission")}}
34+
action=(action "togglePermission" "be_assigned")}}
3535
</td>
3636
<td class="centered">
3737
{{check-box
3838
name=(concat role.name "-assign_others")
3939
checked=(readonly assign_othersAllowed)
40-
action=(action "toggleAssignOthersAllowed")}}
41-
</td>
40+
action=(action "togglePermission" "assign_others")}}
41+
</td>
42+
<td class="centered">
43+
{{check-box
44+
name=(concat role.name "-view_participants")
45+
checked=(readonly view_participantsAllowed)
46+
disabled=(readonly manage_participantAllowed)
47+
action=(action "togglePermission" "view_participants")}}
48+
</td>
49+
<td class="centered">
50+
{{check-box
51+
name=(concat role.name "-manage_participant")
52+
checked=(readonly manage_participantAllowed)
53+
action=(action "togglePermission" "manage_participant")}}
54+
</td>

client/app/pods/components/card-editor/permissions/template.hbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
<th class="permission centered">WRITE<br>Can comment in discussions</th>
99
<th class="permission centered">WRITE<br>Can be assigned </th>
1010
<th class="permission centered">WRITE<br>Can assign others</th>
11+
<th class="permission centered">READ<br>Can view card discussion participants</th>
12+
<th class="permission centered">WRITE<br>Can manage card discussion participants </th>
1113
</tr>
1214
</thead>
1315
<tbody>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { moduleForComponent, test } from 'ember-qunit';
2+
import sinon from 'sinon';
3+
import * as AdminCardPermission from 'tahi/lib/admin-card-permission';
4+
import hbs from 'htmlbars-inline-precompile';
5+
import Ember from 'ember';
6+
7+
moduleForComponent('card-editor/permissions/role', 'Integration | Component | card editor | permissions | role', {
8+
integration: true
9+
});
10+
11+
test('it renders participant checkboxes', function(assert) {
12+
sinon.stub(AdminCardPermission, 'permissionExists');
13+
const card = Ember.Object.create({ id: 1 });
14+
const role = Ember.Object.create({name: 'Foo'});
15+
this.setProperties({card: card, role: role, noop: sinon.stub()});
16+
17+
this.render(hbs `{{card-editor/permissions/role
18+
role=role
19+
card=card
20+
turnOnPermission=noop
21+
turnOffPermission=noop}}`);
22+
23+
assert.elementFound('input[name=Foo-manage_participant]');
24+
assert.elementFound('input[name=Foo-view_participants]');
25+
});

0 commit comments

Comments
 (0)