blob: b17be86eebf11ef43f1281e0c59e2745e42d4a28 [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 -->
Yoshie Muranaka1b1c1002020-02-20 10:18:36 -0800105 <modal-settings :settings="settings" @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,
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800161 fields: [
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800162 {
Derick Montague602e98a2020-10-21 16:20:00 -0500163 key: 'checkbox',
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800164 },
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800165 {
166 key: 'username',
Sandeepa Singhb4406162021-07-26 15:05:39 +0530167 label: this.$t('pageUserManagement.table.username'),
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800168 },
169 {
170 key: 'privilege',
Sandeepa Singhb4406162021-07-26 15:05:39 +0530171 label: this.$t('pageUserManagement.table.privilege'),
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800172 },
173 {
174 key: 'status',
Sandeepa Singhb4406162021-07-26 15:05:39 +0530175 label: this.$t('pageUserManagement.table.status'),
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800176 },
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800177 {
178 key: 'actions',
179 label: '',
Derick Montague602e98a2020-10-21 16:20:00 -0500180 tdClass: 'text-right text-nowrap',
181 },
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800182 ],
183 tableToolbarActions: [
184 {
185 value: 'delete',
Derick Montague602e98a2020-10-21 16:20:00 -0500186 label: this.$t('global.action.delete'),
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800187 },
188 {
189 value: 'enable',
Derick Montague602e98a2020-10-21 16:20:00 -0500190 label: this.$t('global.action.enable'),
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800191 },
192 {
193 value: 'disable',
Derick Montague602e98a2020-10-21 16:20:00 -0500194 label: this.$t('global.action.disable'),
195 },
196 ],
SurenNewareba91c492020-10-27 14:18:54 +0530197 selectedRows: selectedRows,
198 tableHeaderCheckboxModel: tableHeaderCheckboxModel,
199 tableHeaderCheckboxIndeterminate: tableHeaderCheckboxIndeterminate,
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800200 };
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600201 },
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600202 computed: {
203 allUsers() {
Sandeepa Singhb4406162021-07-26 15:05:39 +0530204 return this.$store.getters['userManagement/allUsers'];
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600205 },
206 tableItems() {
207 // transform user data to table data
Derick Montague602e98a2020-10-21 16:20:00 -0500208 return this.allUsers.map((user) => {
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600209 return {
210 username: user.UserName,
211 privilege: user.RoleId,
212 status: user.Locked
Derick Montaguee2fd1562019-12-20 13:26:53 -0600213 ? 'Locked'
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600214 : user.Enabled
Derick Montaguee2fd1562019-12-20 13:26:53 -0600215 ? 'Enabled'
216 : 'Disabled',
Yoshie Muranaka0e893f02020-02-18 13:39:45 -0800217 actions: [
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800218 {
219 value: 'edit',
Sivaprabu Ganesan28974472023-01-05 18:52:51 +0530220 enabled: this.editEnable(user),
Sandeepa Singhb4406162021-07-26 15:05:39 +0530221 title: this.$t('pageUserManagement.editUser'),
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800222 },
Yoshie Muranaka0e893f02020-02-18 13:39:45 -0800223 {
224 value: 'delete',
Sivaprabu Ganesan28974472023-01-05 18:52:51 +0530225 enabled:
226 user.UserName === this.$store.getters['global/username']
227 ? false
228 : true && user.UserName === 'root'
229 ? false
230 : true,
Sandeepa Singhb4406162021-07-26 15:05:39 +0530231 title: this.$tc('pageUserManagement.deleteUser'),
Derick Montague602e98a2020-10-21 16:20:00 -0500232 },
Yoshie Muranaka0e893f02020-02-18 13:39:45 -0800233 ],
Derick Montague602e98a2020-10-21 16:20:00 -0500234 ...user,
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600235 };
236 });
Yoshie Muranaka52b02232020-02-20 08:00:45 -0800237 },
238 settings() {
Sandeepa Singhb4406162021-07-26 15:05:39 +0530239 return this.$store.getters['userManagement/accountSettings'];
Yoshie Muranaka52b02232020-02-20 08:00:45 -0800240 },
241 passwordRequirements() {
Sandeepa Singhb4406162021-07-26 15:05:39 +0530242 return this.$store.getters['userManagement/accountPasswordRequirements'];
Derick Montague602e98a2020-10-21 16:20:00 -0500243 },
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600244 },
Derick Montague09e45cd2020-01-23 15:45:57 -0600245 created() {
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700246 this.startLoader();
Kenneth Fullbright41057852021-12-27 16:19:37 -0600247 this.$store.dispatch('userManagement/getUsers').finally(() => {
248 this.endLoader();
249 this.isBusy = false;
250 });
Sandeepa Singhb4406162021-07-26 15:05:39 +0530251 this.$store.dispatch('userManagement/getAccountSettings');
252 this.$store.dispatch('userManagement/getAccountRoles');
Derick Montague09e45cd2020-01-23 15:45:57 -0600253 },
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600254 methods: {
Sivaprabu Ganesan28974472023-01-05 18:52:51 +0530255 editEnable(user) {
256 if ('root' === this.$store.getters['global/username']) {
257 return true;
258 } else {
259 return user.UserName === 'root' ? false : true;
260 }
261 },
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800262 initModalUser(user) {
263 this.activeUser = user;
Derick Montaguee2fd1562019-12-20 13:26:53 -0600264 this.$bvModal.show('modal-user');
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800265 },
266 initModalDelete(user) {
267 this.$bvModal
268 .msgBoxConfirm(
Sandeepa Singhb4406162021-07-26 15:05:39 +0530269 this.$t('pageUserManagement.modal.deleteConfirmMessage', {
Derick Montague602e98a2020-10-21 16:20:00 -0500270 user: user.username,
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800271 }),
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800272 {
Sandeepa Singhb4406162021-07-26 15:05:39 +0530273 title: this.$tc('pageUserManagement.deleteUser'),
274 okTitle: this.$tc('pageUserManagement.deleteUser'),
Sukanya Pandey38357132020-12-22 13:40:59 +0530275 cancelTitle: this.$t('global.action.cancel'),
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800276 }
277 )
Derick Montague602e98a2020-10-21 16:20:00 -0500278 .then((deleteConfirmed) => {
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800279 if (deleteConfirmed) {
280 this.deleteUser(user);
281 }
282 });
283 },
284 initModalSettings() {
Yoshie Muranaka1b1c1002020-02-20 10:18:36 -0800285 this.$bvModal.show('modal-settings');
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800286 },
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800287 saveUser({ isNewUser, userData }) {
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700288 this.startLoader();
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800289 if (isNewUser) {
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -0800290 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530291 .dispatch('userManagement/createUser', userData)
Derick Montague602e98a2020-10-21 16:20:00 -0500292 .then((success) => this.successToast(success))
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700293 .catch(({ message }) => this.errorToast(message))
294 .finally(() => this.endLoader());
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800295 } else {
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -0800296 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530297 .dispatch('userManagement/updateUser', userData)
Derick Montague602e98a2020-10-21 16:20:00 -0500298 .then((success) => this.successToast(success))
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700299 .catch(({ message }) => this.errorToast(message))
300 .finally(() => this.endLoader());
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800301 }
302 },
303 deleteUser({ username }) {
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700304 this.startLoader();
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -0800305 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530306 .dispatch('userManagement/deleteUser', username)
Derick Montague602e98a2020-10-21 16:20:00 -0500307 .then((success) => this.successToast(success))
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700308 .catch(({ message }) => this.errorToast(message))
309 .finally(() => this.endLoader());
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800310 },
311 onBatchAction(action) {
312 switch (action) {
313 case 'delete':
Yoshie Muranaka29321652020-05-04 10:52:36 -0700314 this.$bvModal
315 .msgBoxConfirm(
316 this.$tc(
Sandeepa Singhb4406162021-07-26 15:05:39 +0530317 'pageUserManagement.modal.batchDeleteConfirmMessage',
Yoshie Muranaka29321652020-05-04 10:52:36 -0700318 this.selectedRows.length
319 ),
320 {
321 title: this.$tc(
Sandeepa Singhb4406162021-07-26 15:05:39 +0530322 'pageUserManagement.deleteUser',
Yoshie Muranaka29321652020-05-04 10:52:36 -0700323 this.selectedRows.length
324 ),
325 okTitle: this.$tc(
Sandeepa Singhb4406162021-07-26 15:05:39 +0530326 'pageUserManagement.deleteUser',
Yoshie Muranaka29321652020-05-04 10:52:36 -0700327 this.selectedRows.length
Derick Montague602e98a2020-10-21 16:20:00 -0500328 ),
Sukanya Pandey38357132020-12-22 13:40:59 +0530329 cancelTitle: this.$t('global.action.cancel'),
Yoshie Muranaka29321652020-05-04 10:52:36 -0700330 }
331 )
Derick Montague602e98a2020-10-21 16:20:00 -0500332 .then((deleteConfirmed) => {
Yoshie Muranaka29321652020-05-04 10:52:36 -0700333 if (deleteConfirmed) {
Yoshie Muranaka8e4b5c32020-05-27 14:10:52 -0700334 this.startLoader();
Yoshie Muranaka29321652020-05-04 10:52:36 -0700335 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530336 .dispatch('userManagement/deleteUsers', this.selectedRows)
Derick Montague602e98a2020-10-21 16:20:00 -0500337 .then((messages) => {
Yoshie Muranaka29321652020-05-04 10:52:36 -0700338 messages.forEach(({ type, message }) => {
339 if (type === 'success') this.successToast(message);
340 if (type === 'error') this.errorToast(message);
341 });
342 })
343 .finally(() => this.endLoader());
344 }
345 });
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800346 break;
347 case 'enable':
Yoshie Muranaka8e4b5c32020-05-27 14:10:52 -0700348 this.startLoader();
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800349 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530350 .dispatch('userManagement/enableUsers', this.selectedRows)
Derick Montague602e98a2020-10-21 16:20:00 -0500351 .then((messages) => {
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800352 messages.forEach(({ type, message }) => {
353 if (type === 'success') this.successToast(message);
354 if (type === 'error') this.errorToast(message);
355 });
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700356 })
357 .finally(() => this.endLoader());
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800358 break;
359 case 'disable':
Yoshie Muranaka8e4b5c32020-05-27 14:10:52 -0700360 this.startLoader();
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800361 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530362 .dispatch('userManagement/disableUsers', this.selectedRows)
Derick Montague602e98a2020-10-21 16:20:00 -0500363 .then((messages) => {
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800364 messages.forEach(({ type, message }) => {
365 if (type === 'success') this.successToast(message);
366 if (type === 'error') this.errorToast(message);
367 });
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700368 })
369 .finally(() => this.endLoader());
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800370 break;
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800371 }
Yoshie Muranaka0e893f02020-02-18 13:39:45 -0800372 },
373 onTableRowAction(action, row) {
374 switch (action) {
375 case 'edit':
376 this.initModalUser(row);
377 break;
378 case 'delete':
379 this.initModalDelete(row);
380 break;
381 default:
382 break;
383 }
Yoshie Muranaka1b1c1002020-02-20 10:18:36 -0800384 },
385 saveAccountSettings(settings) {
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700386 this.startLoader();
Yoshie Muranaka1b1c1002020-02-20 10:18:36 -0800387 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530388 .dispatch('userManagement/saveAccountSettings', settings)
Derick Montague602e98a2020-10-21 16:20:00 -0500389 .then((message) => this.successToast(message))
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700390 .catch(({ message }) => this.errorToast(message))
391 .finally(() => this.endLoader());
Derick Montague602e98a2020-10-21 16:20:00 -0500392 },
393 },
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600394};
395</script>
396
397<style lang="scss" scoped>
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800398.btn.collapsed {
399 svg {
400 transform: rotate(180deg);
401 }
402}
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600403</style>