mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-25 01:03:18 +08:00
Merge pull request #7169 from wandji20/wb-SCI-10326
Set predefined viewer role when creating new project [SCI-10326]
This commit is contained in:
commit
ff0ef34633
3 changed files with 72 additions and 9 deletions
|
@ -29,12 +29,12 @@
|
|||
</div>
|
||||
<div class="mt-6" :class="{'hidden': !visible}">
|
||||
<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 class="modal-footer">
|
||||
<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') }}
|
||||
</button>
|
||||
</div>
|
||||
|
@ -60,12 +60,25 @@ export default {
|
|||
components: {
|
||||
SelectDropdown,
|
||||
},
|
||||
watch: {
|
||||
visible(newValue) {
|
||||
if (newValue) {
|
||||
[this.defaultRole] = this.userRoles.find((role) => role[1] === 'Viewer');
|
||||
} else {
|
||||
this.defaultRole = null;
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.fetchUserRoles();
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
name: this.project.name,
|
||||
visible: !this.project.hidden,
|
||||
defaultRole: this.project.default_public_user_role_id,
|
||||
error: null,
|
||||
userRoles: []
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
|
@ -86,6 +99,14 @@ export default {
|
|||
changeRole(role) {
|
||||
this.defaultRole = role;
|
||||
},
|
||||
fetchUserRoles() {
|
||||
if (this.userRolesUrl) {
|
||||
axios.get(this.userRolesUrl)
|
||||
.then((response) => {
|
||||
this.userRoles = response.data.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -31,12 +31,12 @@
|
|||
</div>
|
||||
<div class="mt-6" :class="{'hidden': !visible}">
|
||||
<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 class="modal-footer">
|
||||
<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="disableSubmit || (visible && !defaultRole)">
|
||||
{{ i18n.t('projects.index.modal_new_project.create') }}
|
||||
</button>
|
||||
</div>
|
||||
|
@ -63,19 +63,32 @@ export default {
|
|||
components: {
|
||||
SelectDropdown,
|
||||
},
|
||||
watch: {
|
||||
visible(newValue) {
|
||||
if (newValue) {
|
||||
[this.defaultRole] = this.userRoles.find((role) => role[1] === 'Viewer');
|
||||
} else {
|
||||
this.defaultRole = null;
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.fetchUserRoles();
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
name: '',
|
||||
visible: false,
|
||||
defaultRole: null,
|
||||
error: null,
|
||||
disableSubmit: false
|
||||
disableSubmit: false,
|
||||
userRoles: []
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
submit() {
|
||||
async submit() {
|
||||
this.disableSubmit = true;
|
||||
axios.post(this.createUrl, {
|
||||
await axios.post(this.createUrl, {
|
||||
project: {
|
||||
name: this.name,
|
||||
visibility: (this.visible ? 'visible' : 'hidden'),
|
||||
|
@ -93,6 +106,14 @@ export default {
|
|||
changeRole(role) {
|
||||
this.defaultRole = role;
|
||||
},
|
||||
fetchUserRoles() {
|
||||
if (this.userRolesUrl) {
|
||||
axios.get(this.userRolesUrl)
|
||||
.then((response) => {
|
||||
this.userRoles = response.data.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -30,12 +30,12 @@
|
|||
</div>
|
||||
<div class="mt-6" :class="{'hidden': !visible}">
|
||||
<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 class="modal-footer">
|
||||
<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') }}
|
||||
</button>
|
||||
</div>
|
||||
|
@ -61,11 +61,24 @@ export default {
|
|||
components: {
|
||||
SelectDropdown
|
||||
},
|
||||
watch: {
|
||||
visible(newValue) {
|
||||
if (newValue) {
|
||||
[this.defaultRole] = this.userRoles.find((role) => role[1] === 'Viewer');
|
||||
} else {
|
||||
this.defaultRole = null;
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.fetchUserRoles();
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
name: '',
|
||||
visible: false,
|
||||
defaultRole: null,
|
||||
userRoles: [],
|
||||
error: null
|
||||
};
|
||||
},
|
||||
|
@ -86,6 +99,14 @@ export default {
|
|||
},
|
||||
changeRole(role) {
|
||||
this.defaultRole = role;
|
||||
},
|
||||
fetchUserRoles() {
|
||||
if (this.userRolesUrl) {
|
||||
axios.get(this.userRolesUrl)
|
||||
.then((response) => {
|
||||
this.userRoles = response.data.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue