blob: 43f3a404b3ca5a4a8b2c19f9db89c6ec2ec387d0 [file] [log] [blame]
Derick Montaguea2988f42020-01-17 13:46:30 -06001<template>
Yoshie Muranaka3111b6f2020-04-21 19:48:38 -07002 <b-container fluid="xl">
Derick Montague09e45cd2020-01-23 15:45:57 -06003 <page-title />
Yoshie Muranaka35080ac2020-01-17 15:38:57 -06004 <b-row>
Yoshie Muranaka74f86872020-02-10 12:28:37 -08005 <b-col xl="9" class="text-right">
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -08006 <b-button variant="link" @click="initModalSettings">
Yoshie Muranaka996d2d52019-12-30 09:06:45 -08007 <icon-settings />
Sandeepa Singhb4406162021-07-26 15:05:39 +05308 {{ $t('pageUserManagement.accountPolicySettings') }}
Yoshie Muranaka463a5702019-12-04 09:09:36 -08009 </b-button>
Dixsie Wolmersfe1e6582020-07-15 11:18:12 -050010 <b-button
11 variant="primary"
Sandeepa Singhb4406162021-07-26 15:05:39 +053012 data-test-id="userManagement-button-addUser"
Dixsie Wolmersfe1e6582020-07-15 11:18:12 -050013 @click="initModalUser(null)"
14 >
Yoshie Muranaka996d2d52019-12-30 09:06:45 -080015 <icon-add />
Sandeepa Singhb4406162021-07-26 15:05:39 +053016 {{ $t('pageUserManagement.addUser') }}
Yoshie Muranaka463a5702019-12-04 09:09:36 -080017 </b-button>
Yoshie Muranaka35080ac2020-01-17 15:38:57 -060018 </b-col>
19 </b-row>
20 <b-row>
Yoshie Muranaka74f86872020-02-10 12:28:37 -080021 <b-col xl="9">
Yoshie Muranaka183c2752020-02-12 11:30:49 -080022 <table-toolbar
23 ref="toolbar"
24 :selected-items-count="selectedRows.length"
25 :actions="tableToolbarActions"
Sukanya Pandeyedb8a772020-10-29 11:33:42 +053026 @clear-selected="clearSelectedRows($refs.table)"
27 @batch-action="onBatchAction"
Yoshie Muranaka183c2752020-02-12 11:30:49 -080028 />
29 <b-table
30 ref="table"
SurenNeware5e25e282020-07-08 15:57:23 +053031 responsive="md"
Yoshie Muranaka183c2752020-02-12 11:30:49 -080032 selectable
SurenNeware307382e2020-07-27 20:45:14 +053033 show-empty
Yoshie Muranaka183c2752020-02-12 11:30:49 -080034 no-select-on-click
Sukanya Pandeyfde429e2020-09-14 20:48:39 +053035 hover
Kenneth Fullbright41057852021-12-27 16:19:37 -060036 :busy="isBusy"
Yoshie Muranaka183c2752020-02-12 11:30:49 -080037 :fields="fields"
38 :items="tableItems"
SurenNeware307382e2020-07-27 20:45:14 +053039 :empty-text="$t('global.table.emptyMessage')"
Yoshie Muranaka183c2752020-02-12 11:30:49 -080040 @row-selected="onRowSelected($event, tableItems.length)"
41 >
42 <!-- Checkbox column -->
Derick Montague602e98a2020-10-21 16:20:00 -050043 <template #head(checkbox)>
Yoshie Muranaka183c2752020-02-12 11:30:49 -080044 <b-form-checkbox
45 v-model="tableHeaderCheckboxModel"
Sandeepa Singhb4406162021-07-26 15:05:39 +053046 data-test-id="userManagement-checkbox-tableHeaderCheckbox"
Yoshie Muranaka183c2752020-02-12 11:30:49 -080047 :indeterminate="tableHeaderCheckboxIndeterminate"
48 @change="onChangeHeaderCheckbox($refs.table)"
Dixsie Wolmersc42ad712020-11-19 17:29:24 -060049 >
50 <span class="sr-only">{{ $t('global.table.selectAll') }}</span>
51 </b-form-checkbox>
Yoshie Muranaka183c2752020-02-12 11:30:49 -080052 </template>
Derick Montague602e98a2020-10-21 16:20:00 -050053 <template #cell(checkbox)="row">
Yoshie Muranaka183c2752020-02-12 11:30:49 -080054 <b-form-checkbox
55 v-model="row.rowSelected"
Sandeepa Singhb4406162021-07-26 15:05:39 +053056 data-test-id="userManagement-checkbox-toggleSelectRow"
Yoshie Muranaka183c2752020-02-12 11:30:49 -080057 @change="toggleSelectRow($refs.table, row.index)"
Dixsie Wolmersc42ad712020-11-19 17:29:24 -060058 >
59 <span class="sr-only">{{ $t('global.table.selectItem') }}</span>
60 </b-form-checkbox>
Yoshie Muranaka183c2752020-02-12 11:30:49 -080061 </template>
62
63 <!-- table actions column -->
Derick Montague602e98a2020-10-21 16:20:00 -050064 <template #cell(actions)="{ item }">
Yoshie Muranaka0e893f02020-02-18 13:39:45 -080065 <table-row-action
66 v-for="(action, index) in item.actions"
67 :key="index"
68 :value="action.value"
69 :enabled="action.enabled"
Yoshie Muranakaeaa04802020-02-28 13:21:27 -080070 :title="action.title"
Sukanya Pandeyedb8a772020-10-29 11:33:42 +053071 @click-table-action="onTableRowAction($event, item)"
Yoshie Muranaka35080ac2020-01-17 15:38:57 -060072 >
Derick Montague602e98a2020-10-21 16:20:00 -050073 <template #icon>
Dixsie Wolmersfe1e6582020-07-15 11:18:12 -050074 <icon-edit
75 v-if="action.value === 'edit'"
Sandeepa Singhb4406162021-07-26 15:05:39 +053076 :data-test-id="`userManagement-tableRowAction-edit-${index}`"
Dixsie Wolmersfe1e6582020-07-15 11:18:12 -050077 />
78 <icon-trashcan
79 v-if="action.value === 'delete'"
Sandeepa Singhb4406162021-07-26 15:05:39 +053080 :data-test-id="`userManagement-tableRowAction-delete-${index}`"
Dixsie Wolmersfe1e6582020-07-15 11:18:12 -050081 />
Yoshie Muranaka0e893f02020-02-18 13:39:45 -080082 </template>
83 </table-row-action>
Yoshie Muranaka35080ac2020-01-17 15:38:57 -060084 </template>
85 </b-table>
86 </b-col>
87 </b-row>
88 <b-row>
Yoshie Muranaka74f86872020-02-10 12:28:37 -080089 <b-col xl="8">
Dixsie Wolmersfe1e6582020-07-15 11:18:12 -050090 <b-button
91 v-b-toggle.collapse-role-table
Sandeepa Singhb4406162021-07-26 15:05:39 +053092 data-test-id="userManagement-button-viewPrivilegeRoleDescriptions"
Dixsie Wolmersfe1e6582020-07-15 11:18:12 -050093 variant="link"
94 class="mt-3"
95 >
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -080096 <icon-chevron />
Sandeepa Singhb4406162021-07-26 15:05:39 +053097 {{ $t('pageUserManagement.viewPrivilegeRoleDescriptions') }}
Yoshie Muranaka463a5702019-12-04 09:09:36 -080098 </b-button>
Yoshie Muranaka35080ac2020-01-17 15:38:57 -060099 <b-collapse id="collapse-role-table" class="mt-3">
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800100 <table-roles />
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600101 </b-collapse>
102 </b-col>
103 </b-row>
104 <!-- Modals -->
kirankumarb076ad19aa2023-03-21 19:19:02 +0530105 <modal-settings :settings="setting" @ok="saveAccountSettings" />
Yoshie Muranaka52b02232020-02-20 08:00:45 -0800106 <modal-user
107 :user="activeUser"
108 :password-requirements="passwordRequirements"
109 @ok="saveUser"
Yoshie Muranaka791622b2020-04-17 13:55:16 -0700110 @hidden="activeUser = null"
Yoshie Muranaka52b02232020-02-20 08:00:45 -0800111 />
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600112 </b-container>
Derick Montaguea2988f42020-01-17 13:46:30 -0600113</template>
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600114
115<script>
Derick Montaguee2fd1562019-12-20 13:26:53 -0600116import IconTrashcan from '@carbon/icons-vue/es/trash-can/20';
117import IconEdit from '@carbon/icons-vue/es/edit/20';
118import IconAdd from '@carbon/icons-vue/es/add--alt/20';
119import IconSettings from '@carbon/icons-vue/es/settings/20';
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800120import IconChevron from '@carbon/icons-vue/es/chevron--up/20';
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800121
Derick Montaguee2fd1562019-12-20 13:26:53 -0600122import ModalUser from './ModalUser';
123import ModalSettings from './ModalSettings';
SurenNeware5e25e282020-07-08 15:57:23 +0530124import PageTitle from '@/components/Global/PageTitle';
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800125import TableRoles from './TableRoles';
SurenNeware5e25e282020-07-08 15:57:23 +0530126import TableToolbar from '@/components/Global/TableToolbar';
127import TableRowAction from '@/components/Global/TableRowAction';
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800128
SurenNewareba91c492020-10-27 14:18:54 +0530129import BVTableSelectableMixin, {
130 selectedRows,
131 tableHeaderCheckboxModel,
132 tableHeaderCheckboxIndeterminate,
133} from '@/components/Mixins/BVTableSelectableMixin';
SurenNeware5e25e282020-07-08 15:57:23 +0530134import BVToastMixin from '@/components/Mixins/BVToastMixin';
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700135import LoadingBarMixin from '@/components/Mixins/LoadingBarMixin';
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600136
137export default {
Sandeepa Singhb4406162021-07-26 15:05:39 +0530138 name: 'UserManagement',
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600139 components: {
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800140 IconAdd,
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800141 IconChevron,
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800142 IconEdit,
143 IconSettings,
144 IconTrashcan,
145 ModalSettings,
146 ModalUser,
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800147 PageTitle,
Yoshie Muranaka8d129102019-12-19 09:51:55 -0800148 TableRoles,
Yoshie Muranaka0e893f02020-02-18 13:39:45 -0800149 TableRowAction,
Derick Montague602e98a2020-10-21 16:20:00 -0500150 TableToolbar,
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800151 },
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700152 mixins: [BVTableSelectableMixin, BVToastMixin, LoadingBarMixin],
Derick Montague602e98a2020-10-21 16:20:00 -0500153 beforeRouteLeave(to, from, next) {
154 this.hideLoader();
155 next();
156 },
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800157 data() {
158 return {
Kenneth Fullbright41057852021-12-27 16:19:37 -0600159 isBusy: true,
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800160 activeUser: null,
kirankumarb076ad19aa2023-03-21 19:19:02 +0530161 setting: {},
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800162 fields: [
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800163 {
Derick Montague602e98a2020-10-21 16:20:00 -0500164 key: 'checkbox',
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800165 },
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800166 {
167 key: 'username',
Sandeepa Singhb4406162021-07-26 15:05:39 +0530168 label: this.$t('pageUserManagement.table.username'),
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800169 },
170 {
171 key: 'privilege',
Sandeepa Singhb4406162021-07-26 15:05:39 +0530172 label: this.$t('pageUserManagement.table.privilege'),
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800173 },
174 {
175 key: 'status',
Sandeepa Singhb4406162021-07-26 15:05:39 +0530176 label: this.$t('pageUserManagement.table.status'),
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800177 },
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800178 {
179 key: 'actions',
180 label: '',
Derick Montague602e98a2020-10-21 16:20:00 -0500181 tdClass: 'text-right text-nowrap',
182 },
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800183 ],
184 tableToolbarActions: [
185 {
186 value: 'delete',
Derick Montague602e98a2020-10-21 16:20:00 -0500187 label: this.$t('global.action.delete'),
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800188 },
189 {
190 value: 'enable',
Derick Montague602e98a2020-10-21 16:20:00 -0500191 label: this.$t('global.action.enable'),
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800192 },
193 {
194 value: 'disable',
Derick Montague602e98a2020-10-21 16:20:00 -0500195 label: this.$t('global.action.disable'),
196 },
197 ],
SurenNewareba91c492020-10-27 14:18:54 +0530198 selectedRows: selectedRows,
199 tableHeaderCheckboxModel: tableHeaderCheckboxModel,
200 tableHeaderCheckboxIndeterminate: tableHeaderCheckboxIndeterminate,
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800201 };
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600202 },
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600203 computed: {
204 allUsers() {
Sandeepa Singhb4406162021-07-26 15:05:39 +0530205 return this.$store.getters['userManagement/allUsers'];
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600206 },
207 tableItems() {
208 // transform user data to table data
Derick Montague602e98a2020-10-21 16:20:00 -0500209 return this.allUsers.map((user) => {
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600210 return {
211 username: user.UserName,
212 privilege: user.RoleId,
213 status: user.Locked
Derick Montaguee2fd1562019-12-20 13:26:53 -0600214 ? 'Locked'
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600215 : user.Enabled
Ed Tanous81323992024-02-27 11:26:24 -0800216 ? 'Enabled'
217 : 'Disabled',
Yoshie Muranaka0e893f02020-02-18 13:39:45 -0800218 actions: [
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800219 {
220 value: 'edit',
Sivaprabu Ganesan28974472023-01-05 18:52:51 +0530221 enabled: this.editEnable(user),
Sandeepa Singhb4406162021-07-26 15:05:39 +0530222 title: this.$t('pageUserManagement.editUser'),
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800223 },
Yoshie Muranaka0e893f02020-02-18 13:39:45 -0800224 {
225 value: 'delete',
Sivaprabu Ganesan28974472023-01-05 18:52:51 +0530226 enabled:
227 user.UserName === this.$store.getters['global/username']
228 ? false
229 : true && user.UserName === 'root'
Ed Tanous81323992024-02-27 11:26:24 -0800230 ? false
231 : true,
Sandeepa Singhb4406162021-07-26 15:05:39 +0530232 title: this.$tc('pageUserManagement.deleteUser'),
Derick Montague602e98a2020-10-21 16:20:00 -0500233 },
Yoshie Muranaka0e893f02020-02-18 13:39:45 -0800234 ],
Derick Montague602e98a2020-10-21 16:20:00 -0500235 ...user,
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600236 };
237 });
Yoshie Muranaka52b02232020-02-20 08:00:45 -0800238 },
239 settings() {
Sandeepa Singhb4406162021-07-26 15:05:39 +0530240 return this.$store.getters['userManagement/accountSettings'];
Yoshie Muranaka52b02232020-02-20 08:00:45 -0800241 },
242 passwordRequirements() {
Sandeepa Singhb4406162021-07-26 15:05:39 +0530243 return this.$store.getters['userManagement/accountPasswordRequirements'];
Derick Montague602e98a2020-10-21 16:20:00 -0500244 },
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600245 },
Derick Montague09e45cd2020-01-23 15:45:57 -0600246 created() {
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700247 this.startLoader();
Kenneth Fullbright41057852021-12-27 16:19:37 -0600248 this.$store.dispatch('userManagement/getUsers').finally(() => {
249 this.endLoader();
250 this.isBusy = false;
251 });
Sandeepa Singhb4406162021-07-26 15:05:39 +0530252 this.$store.dispatch('userManagement/getAccountSettings');
253 this.$store.dispatch('userManagement/getAccountRoles');
Derick Montague09e45cd2020-01-23 15:45:57 -0600254 },
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600255 methods: {
Sivaprabu Ganesan28974472023-01-05 18:52:51 +0530256 editEnable(user) {
257 if ('root' === this.$store.getters['global/username']) {
258 return true;
259 } else {
260 return user.UserName === 'root' ? false : true;
261 }
262 },
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800263 initModalUser(user) {
264 this.activeUser = user;
Derick Montaguee2fd1562019-12-20 13:26:53 -0600265 this.$bvModal.show('modal-user');
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800266 },
267 initModalDelete(user) {
268 this.$bvModal
269 .msgBoxConfirm(
Sandeepa Singhb4406162021-07-26 15:05:39 +0530270 this.$t('pageUserManagement.modal.deleteConfirmMessage', {
Derick Montague602e98a2020-10-21 16:20:00 -0500271 user: user.username,
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800272 }),
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800273 {
Sandeepa Singhb4406162021-07-26 15:05:39 +0530274 title: this.$tc('pageUserManagement.deleteUser'),
275 okTitle: this.$tc('pageUserManagement.deleteUser'),
Sukanya Pandey38357132020-12-22 13:40:59 +0530276 cancelTitle: this.$t('global.action.cancel'),
Paul Fertserd1ef18e2024-04-06 08:04:14 +0000277 autoFocusButton: 'ok',
Ed Tanous81323992024-02-27 11:26:24 -0800278 },
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800279 )
Derick Montague602e98a2020-10-21 16:20:00 -0500280 .then((deleteConfirmed) => {
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800281 if (deleteConfirmed) {
282 this.deleteUser(user);
283 }
284 });
285 },
286 initModalSettings() {
kirankumarb076ad19aa2023-03-21 19:19:02 +0530287 this.setting = this.settings;
Yoshie Muranaka1b1c1002020-02-20 10:18:36 -0800288 this.$bvModal.show('modal-settings');
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800289 },
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800290 saveUser({ isNewUser, userData }) {
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700291 this.startLoader();
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800292 if (isNewUser) {
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -0800293 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530294 .dispatch('userManagement/createUser', userData)
Derick Montague602e98a2020-10-21 16:20:00 -0500295 .then((success) => this.successToast(success))
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700296 .catch(({ message }) => this.errorToast(message))
297 .finally(() => this.endLoader());
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800298 } else {
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -0800299 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530300 .dispatch('userManagement/updateUser', userData)
Derick Montague602e98a2020-10-21 16:20:00 -0500301 .then((success) => this.successToast(success))
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700302 .catch(({ message }) => this.errorToast(message))
303 .finally(() => this.endLoader());
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800304 }
305 },
306 deleteUser({ username }) {
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700307 this.startLoader();
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -0800308 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530309 .dispatch('userManagement/deleteUser', username)
Derick Montague602e98a2020-10-21 16:20:00 -0500310 .then((success) => this.successToast(success))
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700311 .catch(({ message }) => this.errorToast(message))
312 .finally(() => this.endLoader());
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800313 },
314 onBatchAction(action) {
315 switch (action) {
316 case 'delete':
Yoshie Muranaka29321652020-05-04 10:52:36 -0700317 this.$bvModal
318 .msgBoxConfirm(
319 this.$tc(
Sandeepa Singhb4406162021-07-26 15:05:39 +0530320 'pageUserManagement.modal.batchDeleteConfirmMessage',
Ed Tanous81323992024-02-27 11:26:24 -0800321 this.selectedRows.length,
Yoshie Muranaka29321652020-05-04 10:52:36 -0700322 ),
323 {
324 title: this.$tc(
Sandeepa Singhb4406162021-07-26 15:05:39 +0530325 'pageUserManagement.deleteUser',
Ed Tanous81323992024-02-27 11:26:24 -0800326 this.selectedRows.length,
Yoshie Muranaka29321652020-05-04 10:52:36 -0700327 ),
328 okTitle: this.$tc(
Sandeepa Singhb4406162021-07-26 15:05:39 +0530329 'pageUserManagement.deleteUser',
Ed Tanous81323992024-02-27 11:26:24 -0800330 this.selectedRows.length,
Derick Montague602e98a2020-10-21 16:20:00 -0500331 ),
Sukanya Pandey38357132020-12-22 13:40:59 +0530332 cancelTitle: this.$t('global.action.cancel'),
Paul Fertserd1ef18e2024-04-06 08:04:14 +0000333 autoFocusButton: 'ok',
Ed Tanous81323992024-02-27 11:26:24 -0800334 },
Yoshie Muranaka29321652020-05-04 10:52:36 -0700335 )
Derick Montague602e98a2020-10-21 16:20:00 -0500336 .then((deleteConfirmed) => {
Yoshie Muranaka29321652020-05-04 10:52:36 -0700337 if (deleteConfirmed) {
Yoshie Muranaka8e4b5c32020-05-27 14:10:52 -0700338 this.startLoader();
Yoshie Muranaka29321652020-05-04 10:52:36 -0700339 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530340 .dispatch('userManagement/deleteUsers', this.selectedRows)
Derick Montague602e98a2020-10-21 16:20:00 -0500341 .then((messages) => {
Yoshie Muranaka29321652020-05-04 10:52:36 -0700342 messages.forEach(({ type, message }) => {
343 if (type === 'success') this.successToast(message);
344 if (type === 'error') this.errorToast(message);
345 });
346 })
347 .finally(() => this.endLoader());
348 }
349 });
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800350 break;
351 case 'enable':
Yoshie Muranaka8e4b5c32020-05-27 14:10:52 -0700352 this.startLoader();
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800353 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530354 .dispatch('userManagement/enableUsers', this.selectedRows)
Derick Montague602e98a2020-10-21 16:20:00 -0500355 .then((messages) => {
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800356 messages.forEach(({ type, message }) => {
357 if (type === 'success') this.successToast(message);
358 if (type === 'error') this.errorToast(message);
359 });
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700360 })
361 .finally(() => this.endLoader());
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800362 break;
363 case 'disable':
Farah Rasheedb2acbca2024-07-08 10:05:37 -0500364 this.$bvModal
365 .msgBoxConfirm(
366 this.$tc(
367 'pageUserManagement.modal.batchDisableConfirmMessage',
368 this.selectedRows.length,
369 ),
370 {
371 title: this.$tc(
372 'pageUserManagement.disableUser',
373 this.selectedRows.length,
374 ),
375 okTitle: this.$tc(
376 'pageUserManagement.disableUser',
377 this.selectedRows.length,
378 ),
379 cancelTitle: this.$t('global.action.cancel'),
380 autoFocusButton: 'ok',
381 },
382 )
383 .then((disableConfirmed) => {
384 if (disableConfirmed) {
385 this.startLoader();
386 this.$store
387 .dispatch('userManagement/disableUsers', this.selectedRows)
388 .then((messages) => {
389 messages.forEach(({ type, message }) => {
390 if (type === 'success') this.successToast(message);
391 if (type === 'error') this.errorToast(message);
392 });
393 })
394 .finally(() => this.endLoader());
395 }
396 });
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800397 break;
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800398 }
Yoshie Muranaka0e893f02020-02-18 13:39:45 -0800399 },
400 onTableRowAction(action, row) {
401 switch (action) {
402 case 'edit':
403 this.initModalUser(row);
404 break;
405 case 'delete':
406 this.initModalDelete(row);
407 break;
408 default:
409 break;
410 }
Yoshie Muranaka1b1c1002020-02-20 10:18:36 -0800411 },
412 saveAccountSettings(settings) {
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700413 this.startLoader();
Yoshie Muranaka1b1c1002020-02-20 10:18:36 -0800414 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530415 .dispatch('userManagement/saveAccountSettings', settings)
Derick Montague602e98a2020-10-21 16:20:00 -0500416 .then((message) => this.successToast(message))
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700417 .catch(({ message }) => this.errorToast(message))
418 .finally(() => this.endLoader());
Derick Montague602e98a2020-10-21 16:20:00 -0500419 },
420 },
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600421};
422</script>
423
424<style lang="scss" scoped>
Ed Tanous7d6b44c2024-03-23 14:56:34 -0700425@import '@/assets/styles/bmc/helpers/_index.scss';
426@import '@/assets/styles/bootstrap/_helpers.scss';
427
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800428.btn.collapsed {
429 svg {
430 transform: rotate(180deg);
431 }
432}
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600433</style>