-
-
-
+
+
-
-
-
- View
-
-
+
-
-
-
- Contribute
-
-
-
-
-
-
- Administrate
-
-
+
+
+
+
+
+ Viewer
+ Contributor
+ Administrator
+
+
delete
@@ -66,10 +60,10 @@ class CorpusFollowerList extends ResourceList {
return [
{data: ['id']},
{data: ['follower-id']},
- {name: 'avatar', attr: 'src'},
- 'username',
- 'about-me',
- 'full-name'
+ {name: 'follower-avatar', attr: 'src'},
+ 'follower-username',
+ 'follower-about-me',
+ 'follower-full-name'
];
}
@@ -90,7 +84,7 @@ class CorpusFollowerList extends ResourceList {
Username
User details
- Permissions
+ Role
@@ -104,13 +98,11 @@ class CorpusFollowerList extends ResourceList {
return {
'id': corpusFollowerAssociation.id,
'follower-id': corpusFollowerAssociation.follower.id,
- 'avatar': corpusFollowerAssociation.follower.avatar ? `/users/${corpusFollowerAssociation.follower.id}/avatar` : '/static/images/user_avatar.png',
- 'username': corpusFollowerAssociation.follower.username,
- 'full-name': corpusFollowerAssociation.follower.full_name ? corpusFollowerAssociation.follower.full_name : '',
- 'about-me': corpusFollowerAssociation.follower.about_me ? corpusFollowerAssociation.follower.about_me : '',
- 'permission-can-VIEW': corpusFollowerAssociation.permissions.includes('VIEW'),
- 'permission-can-CONTRIBUTE': corpusFollowerAssociation.permissions.includes('CONTRIBUTE'),
- 'permission-can-ADMINISTRATE': corpusFollowerAssociation.permissions.includes('ADMINISTRATE')
+ 'follower-avatar': corpusFollowerAssociation.follower.avatar ? `/users/${corpusFollowerAssociation.follower.id}/avatar` : '/static/images/user_avatar.png',
+ 'follower-username': corpusFollowerAssociation.follower.username,
+ 'follower-full-name': corpusFollowerAssociation.follower.full_name ? corpusFollowerAssociation.follower.full_name : '',
+ 'follower-about-me': corpusFollowerAssociation.follower.about_me ? corpusFollowerAssociation.follower.about_me : '',
+ 'role-name': corpusFollowerAssociation.role.name
};
}
@@ -119,7 +111,7 @@ class CorpusFollowerList extends ResourceList {
}
onChange(event) {
- if (event.target.tagName !== 'INPUT') {return;}
+ console.log(event.target.tagName);
let listItemElement = event.target.closest('.list-item[data-id]');
if (listItemElement === null) {return;}
let itemId = listItemElement.dataset.id;
@@ -127,16 +119,10 @@ class CorpusFollowerList extends ResourceList {
if (listActionElement === null) {return;}
let listAction = listActionElement.dataset.listAction;
switch (listAction) {
- case 'toggle-permission': {
+ case 'update-role': {
let followerId = listItemElement.dataset.followerId;
- let permission = listActionElement.dataset.permission;
- if (event.target.checked) {
- Utils.addCorpusFollowerPermissionRequest(this.corpusId, followerId, permission)
- .catch((error) => {event.target.checked = !event.target.checked;});
- } else {
- Utils.removeCorpusFollowerPermissionRequest(this.corpusId, followerId, permission)
- .catch((error) => {event.target.checked = !event.target.checked;});
- }
+ let roleName = event.target.value;
+ Utils.updateCorpusFollowerRole(this.corpusId, followerId, roleName);
break;
}
default: {
@@ -188,11 +174,11 @@ class CorpusFollowerList extends ResourceList {
break;
}
case 'replace': {
- // let re = new RegExp(`^/users/${this.userId}/corpora/${this.corpusId}/corpus_follower_associations/([A-Za-z0-9]*)/(service|status|description|title)$`);
- // if (re.test(operation.path)) {
- // let [match, jobId, valueName] = operation.path.match(re);
- // this.replace(jobId, valueName, operation.value);
- // }
+ let re = new RegExp(`^/users/${this.userId}/corpora/${this.corpusId}/corpus_follower_associations/([A-Za-z0-9]*)/role$`);
+ if (re.test(operation.path)) {
+ let [match, jobId, valueName] = operation.path.match(re);
+ this.replace(jobId, valueName, operation.value);
+ }
break;
}
default: {
diff --git a/app/templates/_sidenav.html.j2 b/app/templates/_sidenav.html.j2
index 676b7069..7fa34623 100644
--- a/app/templates/_sidenav.html.j2
+++ b/app/templates/_sidenav.html.j2
@@ -36,13 +36,13 @@