scinote-web/app/javascript/vue/shared/access_modal/modal.vue

100 lines
2.8 KiB
Vue
Raw Normal View History

2023-12-05 03:59:16 +08:00
<template>
<div ref="modal" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
2024-01-29 22:19:25 +08:00
<div class="modal-header">
<button type="button"
class="close"
data-dismiss="modal"
aria-label="Close"><i class="sn-icon sn-icon-close"></i></button>
<h4 class="modal-title truncate !block">
{{ i18n.t(`access_permissions.${params.object.type}.modals.edit_modal.title`, {
resource_name: params.object.name
}) }}
</h4>
</div>
<div class="modal-body">
<AssignFlyout
v-if="params.object.urls.new_access"
:params="params"
:visible="visible"
:default_role="default_role"
:reloadUsers="reloadUnAssignedUsers"
@modified="modified = true; reloadUsers = true"
@assigningNewUsers="(v) => { assigningNewUsers = v }"
@usersReloaded="reloadUnAssignedUsers = false"
@changeVisibility="changeVisibility"
/>
<h5 class="py-2.5">
{{ i18n.t('access_permissions.partials.new_assignments_form.people_with_access') }}
</h5>
<editView
:class="{'opacity-50 pointer-events-none': assigningNewUsers}"
:params="params"
:visible="visible"
:default_role="default_role"
:reloadUsers="reloadUsers"
@modified="modified = true; reloadUnAssignedUsers = true"
@usersReloaded="reloadUsers = false"
@changeVisibility="changeVisibility"
/>
</div>
2023-12-05 03:59:16 +08:00
</div>
</div>
</div>
</template>
<script>
2023-12-11 22:41:03 +08:00
import SelectDropdown from '../select_dropdown.vue';
import modalMixin from '../modal_mixin';
2023-12-05 03:59:16 +08:00
import editView from './edit.vue';
2024-01-29 22:19:25 +08:00
import AssignFlyout from './assign_flyout.vue';
2023-12-05 03:59:16 +08:00
export default {
2024-01-29 22:19:25 +08:00
emits: ['modified', 'usersReloaded', 'changeVisibility'],
2023-12-11 22:41:03 +08:00
name: 'AccessModal',
2023-12-05 03:59:16 +08:00
props: {
params: {
type: Object,
2024-01-29 22:19:25 +08:00
required: true
}
2023-12-05 03:59:16 +08:00
},
2023-12-11 22:41:03 +08:00
mixins: [modalMixin],
2023-12-05 03:59:16 +08:00
components: {
SelectDropdown,
editView,
2024-01-29 22:19:25 +08:00
AssignFlyout
2023-12-05 03:59:16 +08:00
},
data() {
return {
mode: 'editView',
modified: false,
visible: false,
default_role: null,
2024-01-29 22:19:25 +08:00
reloadUsers: false,
assigningNewUsers: false,
reloadUnAssignedUsers: false
2023-12-05 03:59:16 +08:00
};
},
mounted() {
this.visible = !this.params.object.hidden;
this.default_role = this.params.object.default_public_user_role_id;
},
beforeUnmount() {
if (this.modified) {
this.$emit('refresh');
}
},
methods: {
changeMode(mode) {
this.mode = mode;
},
changeVisibility(status, role) {
this.visible = status;
this.default_role = role;
2024-01-29 22:19:25 +08:00
}
}
2023-12-11 22:41:03 +08:00
};
2023-12-05 03:59:16 +08:00
</script>