blob: e9b1fdaaf966512e46b944b862df330371a6c1b7 [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'),
Ed Tanous81323992024-02-27 11:26:24 -0800277 },
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800278 )
Derick Montague602e98a2020-10-21 16:20:00 -0500279 .then((deleteConfirmed) => {
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800280 if (deleteConfirmed) {
281 this.deleteUser(user);
282 }
283 });
284 },
285 initModalSettings() {
kirankumarb076ad19aa2023-03-21 19:19:02 +0530286 this.setting = this.settings;
Yoshie Muranaka1b1c1002020-02-20 10:18:36 -0800287 this.$bvModal.show('modal-settings');
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800288 },
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800289 saveUser({ isNewUser, userData }) {
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700290 this.startLoader();
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800291 if (isNewUser) {
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -0800292 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530293 .dispatch('userManagement/createUser', userData)
Derick Montague602e98a2020-10-21 16:20:00 -0500294 .then((success) => this.successToast(success))
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700295 .catch(({ message }) => this.errorToast(message))
296 .finally(() => this.endLoader());
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800297 } else {
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -0800298 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530299 .dispatch('userManagement/updateUser', userData)
Derick Montague602e98a2020-10-21 16:20:00 -0500300 .then((success) => this.successToast(success))
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700301 .catch(({ message }) => this.errorToast(message))
302 .finally(() => this.endLoader());
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800303 }
304 },
305 deleteUser({ username }) {
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700306 this.startLoader();
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -0800307 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530308 .dispatch('userManagement/deleteUser', username)
Derick Montague602e98a2020-10-21 16:20:00 -0500309 .then((success) => this.successToast(success))
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700310 .catch(({ message }) => this.errorToast(message))
311 .finally(() => this.endLoader());
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800312 },
313 onBatchAction(action) {
314 switch (action) {
315 case 'delete':
Yoshie Muranaka29321652020-05-04 10:52:36 -0700316 this.$bvModal
317 .msgBoxConfirm(
318 this.$tc(
Sandeepa Singhb4406162021-07-26 15:05:39 +0530319 'pageUserManagement.modal.batchDeleteConfirmMessage',
Ed Tanous81323992024-02-27 11:26:24 -0800320 this.selectedRows.length,
Yoshie Muranaka29321652020-05-04 10:52:36 -0700321 ),
322 {
323 title: this.$tc(
Sandeepa Singhb4406162021-07-26 15:05:39 +0530324 'pageUserManagement.deleteUser',
Ed Tanous81323992024-02-27 11:26:24 -0800325 this.selectedRows.length,
Yoshie Muranaka29321652020-05-04 10:52:36 -0700326 ),
327 okTitle: this.$tc(
Sandeepa Singhb4406162021-07-26 15:05:39 +0530328 'pageUserManagement.deleteUser',
Ed Tanous81323992024-02-27 11:26:24 -0800329 this.selectedRows.length,
Derick Montague602e98a2020-10-21 16:20:00 -0500330 ),
Sukanya Pandey38357132020-12-22 13:40:59 +0530331 cancelTitle: this.$t('global.action.cancel'),
Ed Tanous81323992024-02-27 11:26:24 -0800332 },
Yoshie Muranaka29321652020-05-04 10:52:36 -0700333 )
Derick Montague602e98a2020-10-21 16:20:00 -0500334 .then((deleteConfirmed) => {
Yoshie Muranaka29321652020-05-04 10:52:36 -0700335 if (deleteConfirmed) {
Yoshie Muranaka8e4b5c32020-05-27 14:10:52 -0700336 this.startLoader();
Yoshie Muranaka29321652020-05-04 10:52:36 -0700337 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530338 .dispatch('userManagement/deleteUsers', this.selectedRows)
Derick Montague602e98a2020-10-21 16:20:00 -0500339 .then((messages) => {
Yoshie Muranaka29321652020-05-04 10:52:36 -0700340 messages.forEach(({ type, message }) => {
341 if (type === 'success') this.successToast(message);
342 if (type === 'error') this.errorToast(message);
343 });
344 })
345 .finally(() => this.endLoader());
346 }
347 });
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800348 break;
349 case 'enable':
Yoshie Muranaka8e4b5c32020-05-27 14:10:52 -0700350 this.startLoader();
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800351 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530352 .dispatch('userManagement/enableUsers', this.selectedRows)
Derick Montague602e98a2020-10-21 16:20:00 -0500353 .then((messages) => {
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800354 messages.forEach(({ type, message }) => {
355 if (type === 'success') this.successToast(message);
356 if (type === 'error') this.errorToast(message);
357 });
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700358 })
359 .finally(() => this.endLoader());
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800360 break;
361 case 'disable':
Yoshie Muranaka8e4b5c32020-05-27 14:10:52 -0700362 this.startLoader();
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800363 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530364 .dispatch('userManagement/disableUsers', this.selectedRows)
Derick Montague602e98a2020-10-21 16:20:00 -0500365 .then((messages) => {
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800366 messages.forEach(({ type, message }) => {
367 if (type === 'success') this.successToast(message);
368 if (type === 'error') this.errorToast(message);
369 });
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700370 })
371 .finally(() => this.endLoader());
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800372 break;
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800373 }
Yoshie Muranaka0e893f02020-02-18 13:39:45 -0800374 },
375 onTableRowAction(action, row) {
376 switch (action) {
377 case 'edit':
378 this.initModalUser(row);
379 break;
380 case 'delete':
381 this.initModalDelete(row);
382 break;
383 default:
384 break;
385 }
Yoshie Muranaka1b1c1002020-02-20 10:18:36 -0800386 },
387 saveAccountSettings(settings) {
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700388 this.startLoader();
Yoshie Muranaka1b1c1002020-02-20 10:18:36 -0800389 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530390 .dispatch('userManagement/saveAccountSettings', settings)
Derick Montague602e98a2020-10-21 16:20:00 -0500391 .then((message) => this.successToast(message))
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700392 .catch(({ message }) => this.errorToast(message))
393 .finally(() => this.endLoader());
Derick Montague602e98a2020-10-21 16:20:00 -0500394 },
395 },
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600396};
397</script>
398
399<style lang="scss" scoped>
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800400.btn.collapsed {
401 svg {
402 transform: rotate(180deg);
403 }
404}
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600405</style>