update contribute share button

This commit is contained in:
Inga Kirschnick 2022-11-21 16:35:11 +01:00
parent 0128c6310b
commit c0f6c9333c
2 changed files with 22 additions and 5 deletions

View File

@ -31,7 +31,7 @@ class SpaCyNLPPipelineModelList extends RessourceList {
<td><b><span class="title"></span> <span class="version"></span></b><br><i><span class="description"></span></i></td>
<td><a class="publisher-url"><span class="publisher"></span></a> (<span class="publishing-year"></span>)<br><a class="publishing-url"><span class="publishing-url-2"></span></a></td>
<td>
<div class="switch action-switch center-align" data-action="share-request" data-user-role=>
<div class="switch action-switch center-align" data-action="share-request">
<span class="share"></span>
<label>
<input type="checkbox" class="shared">
@ -86,8 +86,8 @@ class SpaCyNLPPipelineModelList extends RessourceList {
init(user) {
this._init(user.spacy_nlp_pipeline_models);
for (let switchElement of this.listjs.list.querySelectorAll('.shared')) {
if (user.role.name !== 'Administrator' || user.role.name !== 'Contributor') {
if (user.role.name !== ('Administrator' || 'Contributor')) {
for (let switchElement of this.listjs.list.querySelectorAll('.shared')) {
switchElement.setAttribute('disabled', '');
}
}
@ -101,7 +101,13 @@ class SpaCyNLPPipelineModelList extends RessourceList {
}
onClick(event) {
if (event.target.closest('.action-switch')) {return;}
if (event.target.closest('.action-switch')) {
let userRole = app.data.users[this.userId].role.name;
if (userRole !== ('Administrator' || 'Contributor')) {
app.flash('You need the "Contributor" or "Administrator" role to perform this action.', 'error');
}
return;
}
let actionButtonElement = event.target.closest('.action-button');
let action = actionButtonElement === null ? 'view' : actionButtonElement.dataset.action;
let spaCyNLPPipelineModelElement = event.target.closest('tr');

View File

@ -86,6 +86,11 @@ class TesseractOCRPipelineModelList extends RessourceList {
init (user) {
this._init(user.tesseract_ocr_pipeline_models);
if (user.role.name !== ('Administrator' || 'Contributor')) {
for (let switchElement of this.listjs.list.querySelectorAll('.shared')) {
switchElement.setAttribute('disabled', '');
}
}
}
_init(ressources) {
@ -96,7 +101,13 @@ class TesseractOCRPipelineModelList extends RessourceList {
}
onClick(event) {
if (event.target.closest('.action-switch')) {return;}
if (event.target.closest('.action-switch')) {
let userRole = app.data.users[this.userId].role.name;
if (userRole !== ('Administrator' || 'Contributor')) {
app.flash('You need the "Contributor" or "Administrator" role to perform this action.', 'error');
}
return;
}
let actionButtonElement = event.target.closest('.action-button');
let action = actionButtonElement === null ? 'view' : actionButtonElement.dataset.action;
let tesseractOCRPipelineModelElement = event.target.closest('tr');