mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-10 05:46:47 +08:00
Add preselected role for new protocol template [SCI-10326]
This commit is contained in:
parent
65c1e549f2
commit
b497c7e9a7
4 changed files with 48 additions and 8 deletions
|
@ -29,12 +29,12 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-6" :class="{'hidden': !visible}">
|
<div class="mt-6" :class="{'hidden': !visible}">
|
||||||
<label class="sci-label">{{ i18n.t("user_assignment.select_default_user_role") }}</label>
|
<label class="sci-label">{{ i18n.t("user_assignment.select_default_user_role") }}</label>
|
||||||
<SelectDropdown :optionsUrl="userRolesUrl" :value="defaultRole" @change="changeRole" />
|
<SelectDropdown :options="userRoles" :value="defaultRole" @change="changeRole" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{ i18n.t('general.cancel') }}</button>
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{ i18n.t('general.cancel') }}</button>
|
||||||
<button class="btn btn-primary" type="submit">
|
<button class="btn btn-primary" type="submit" :disabled="visible && !defaultRole">
|
||||||
{{ i18n.t('projects.index.modal_edit_project.submit') }}
|
{{ i18n.t('projects.index.modal_edit_project.submit') }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -60,12 +60,25 @@ export default {
|
||||||
components: {
|
components: {
|
||||||
SelectDropdown,
|
SelectDropdown,
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
visible(newValue) {
|
||||||
|
if (newValue) {
|
||||||
|
[this.defaultRole] = this.userRoles.find((role) => role[1] === 'Viewer');
|
||||||
|
} else {
|
||||||
|
this.defaultRole = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.fetchUserRoles();
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
name: this.project.name,
|
name: this.project.name,
|
||||||
visible: !this.project.hidden,
|
visible: !this.project.hidden,
|
||||||
defaultRole: this.project.default_public_user_role_id,
|
defaultRole: this.project.default_public_user_role_id,
|
||||||
error: null,
|
error: null,
|
||||||
|
userRoles: []
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -86,6 +99,14 @@ export default {
|
||||||
changeRole(role) {
|
changeRole(role) {
|
||||||
this.defaultRole = role;
|
this.defaultRole = role;
|
||||||
},
|
},
|
||||||
|
fetchUserRoles() {
|
||||||
|
if (this.userRolesUrl) {
|
||||||
|
axios.get(this.userRolesUrl)
|
||||||
|
.then((response) => {
|
||||||
|
this.userRoles = response.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{ i18n.t('general.cancel') }}</button>
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{ i18n.t('general.cancel') }}</button>
|
||||||
<button class="btn btn-primary" type="submit" :disabled="visible && !defaultRole">
|
<button class="btn btn-primary" type="submit" :disabled="disableSubmit || (visible && !defaultRole)">
|
||||||
{{ i18n.t('projects.index.modal_new_project.create') }}
|
{{ i18n.t('projects.index.modal_new_project.create') }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -30,12 +30,12 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-6" :class="{'hidden': !visible}">
|
<div class="mt-6" :class="{'hidden': !visible}">
|
||||||
<label class="sci-label">{{ i18n.t("protocols.new_protocol_modal.role_label") }}</label>
|
<label class="sci-label">{{ i18n.t("protocols.new_protocol_modal.role_label") }}</label>
|
||||||
<SelectDropdown :optionsUrl="userRolesUrl" :value="defaultRole" @change="changeRole" />
|
<SelectDropdown :options="userRoles" :value="defaultRole" @change="changeRole" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{ i18n.t('general.cancel') }}</button>
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{ i18n.t('general.cancel') }}</button>
|
||||||
<button class="btn btn-primary" type="submit">
|
<button class="btn btn-primary" type="submit" :disabled="visible && !defaultRole">
|
||||||
{{ i18n.t('protocols.new_protocol_modal.create_new') }}
|
{{ i18n.t('protocols.new_protocol_modal.create_new') }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -61,11 +61,24 @@ export default {
|
||||||
components: {
|
components: {
|
||||||
SelectDropdown
|
SelectDropdown
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
visible(newValue) {
|
||||||
|
if (newValue) {
|
||||||
|
[this.defaultRole] = this.userRoles.find((role) => role[1] === 'Viewer');
|
||||||
|
} else {
|
||||||
|
this.defaultRole = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.fetchUserRoles();
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
name: '',
|
name: '',
|
||||||
visible: false,
|
visible: false,
|
||||||
defaultRole: null,
|
defaultRole: null,
|
||||||
|
userRoles: [],
|
||||||
error: null
|
error: null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -86,6 +99,14 @@ export default {
|
||||||
},
|
},
|
||||||
changeRole(role) {
|
changeRole(role) {
|
||||||
this.defaultRole = role;
|
this.defaultRole = role;
|
||||||
|
},
|
||||||
|
fetchUserRoles() {
|
||||||
|
if (this.userRolesUrl) {
|
||||||
|
axios.get(this.userRolesUrl)
|
||||||
|
.then((response) => {
|
||||||
|
this.userRoles = response.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -64,8 +64,6 @@ module Lists
|
||||||
count: object.comments.count,
|
count: object.comments.count,
|
||||||
count_unseen: count_unseen_comments(object, @user)
|
count_unseen: count_unseen_comments(object, @user)
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -98,7 +96,7 @@ module Lists
|
||||||
|
|
||||||
def permissions
|
def permissions
|
||||||
{
|
{
|
||||||
create_comments: comment_addable?(object)
|
create_comments: can_create_project_comments?(object)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue