Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 1 | <template> |
Yoshie Muranaka | 3111b6f | 2020-04-21 19:48:38 -0700 | [diff] [blame] | 2 | <b-container fluid="xl"> |
Derick Montague | 09e45cd | 2020-01-23 15:45:57 -0600 | [diff] [blame] | 3 | <page-title /> |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 4 | <b-row> |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 5 | <b-col xl="9" class="text-right"> |
Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 6 | <b-button variant="link" @click="initModalSettings"> |
Yoshie Muranaka | 996d2d5 | 2019-12-30 09:06:45 -0800 | [diff] [blame] | 7 | <icon-settings /> |
Yoshie Muranaka | 80735e1 | 2020-04-28 09:48:59 -0700 | [diff] [blame] | 8 | {{ $t('pageLocalUserManagement.accountPolicySettings') }} |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 9 | </b-button> |
Dixsie Wolmers | fe1e658 | 2020-07-15 11:18:12 -0500 | [diff] [blame] | 10 | <b-button |
| 11 | variant="primary" |
| 12 | data-test-id="localUserManagement-button-addUser" |
| 13 | @click="initModalUser(null)" |
| 14 | > |
Yoshie Muranaka | 996d2d5 | 2019-12-30 09:06:45 -0800 | [diff] [blame] | 15 | <icon-add /> |
Yoshie Muranaka | 80735e1 | 2020-04-28 09:48:59 -0700 | [diff] [blame] | 16 | {{ $t('pageLocalUserManagement.addUser') }} |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 17 | </b-button> |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 18 | </b-col> |
| 19 | </b-row> |
| 20 | <b-row> |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 21 | <b-col xl="9"> |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 22 | <table-toolbar |
| 23 | ref="toolbar" |
| 24 | :selected-items-count="selectedRows.length" |
| 25 | :actions="tableToolbarActions" |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame] | 26 | @clear-selected="clearSelectedRows($refs.table)" |
| 27 | @batch-action="onBatchAction" |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 28 | /> |
| 29 | <b-table |
| 30 | ref="table" |
SurenNeware | 5e25e28 | 2020-07-08 15:57:23 +0530 | [diff] [blame] | 31 | responsive="md" |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 32 | selectable |
SurenNeware | 307382e | 2020-07-27 20:45:14 +0530 | [diff] [blame] | 33 | show-empty |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 34 | no-select-on-click |
Sukanya Pandey | fde429e | 2020-09-14 20:48:39 +0530 | [diff] [blame] | 35 | hover |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 36 | :fields="fields" |
| 37 | :items="tableItems" |
SurenNeware | 307382e | 2020-07-27 20:45:14 +0530 | [diff] [blame] | 38 | :empty-text="$t('global.table.emptyMessage')" |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 39 | @row-selected="onRowSelected($event, tableItems.length)" |
| 40 | > |
| 41 | <!-- Checkbox column --> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 42 | <template #head(checkbox)> |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 43 | <b-form-checkbox |
| 44 | v-model="tableHeaderCheckboxModel" |
Dixsie Wolmers | fe1e658 | 2020-07-15 11:18:12 -0500 | [diff] [blame] | 45 | data-test-id="localUserManagement-checkbox-tableHeaderCheckbox" |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 46 | :indeterminate="tableHeaderCheckboxIndeterminate" |
| 47 | @change="onChangeHeaderCheckbox($refs.table)" |
Dixsie Wolmers | c42ad71 | 2020-11-19 17:29:24 -0600 | [diff] [blame^] | 48 | > |
| 49 | <span class="sr-only">{{ $t('global.table.selectAll') }}</span> |
| 50 | </b-form-checkbox> |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 51 | </template> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 52 | <template #cell(checkbox)="row"> |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 53 | <b-form-checkbox |
| 54 | v-model="row.rowSelected" |
Dixsie Wolmers | fe1e658 | 2020-07-15 11:18:12 -0500 | [diff] [blame] | 55 | data-test-id="localUserManagement-checkbox-toggleSelectRow" |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 56 | @change="toggleSelectRow($refs.table, row.index)" |
Dixsie Wolmers | c42ad71 | 2020-11-19 17:29:24 -0600 | [diff] [blame^] | 57 | > |
| 58 | <span class="sr-only">{{ $t('global.table.selectItem') }}</span> |
| 59 | </b-form-checkbox> |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 60 | </template> |
| 61 | |
| 62 | <!-- table actions column --> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 63 | <template #cell(actions)="{ item }"> |
Yoshie Muranaka | 0e893f0 | 2020-02-18 13:39:45 -0800 | [diff] [blame] | 64 | <table-row-action |
| 65 | v-for="(action, index) in item.actions" |
| 66 | :key="index" |
| 67 | :value="action.value" |
| 68 | :enabled="action.enabled" |
Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 69 | :title="action.title" |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame] | 70 | @click-table-action="onTableRowAction($event, item)" |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 71 | > |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 72 | <template #icon> |
Dixsie Wolmers | fe1e658 | 2020-07-15 11:18:12 -0500 | [diff] [blame] | 73 | <icon-edit |
| 74 | v-if="action.value === 'edit'" |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 75 | :data-test-id="`localUserManagement-tableRowAction-edit-${index}`" |
Dixsie Wolmers | fe1e658 | 2020-07-15 11:18:12 -0500 | [diff] [blame] | 76 | /> |
| 77 | <icon-trashcan |
| 78 | v-if="action.value === 'delete'" |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 79 | :data-test-id="`localUserManagement-tableRowAction-delete-${index}`" |
Dixsie Wolmers | fe1e658 | 2020-07-15 11:18:12 -0500 | [diff] [blame] | 80 | /> |
Yoshie Muranaka | 0e893f0 | 2020-02-18 13:39:45 -0800 | [diff] [blame] | 81 | </template> |
| 82 | </table-row-action> |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 83 | </template> |
| 84 | </b-table> |
| 85 | </b-col> |
| 86 | </b-row> |
| 87 | <b-row> |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 88 | <b-col xl="8"> |
Dixsie Wolmers | fe1e658 | 2020-07-15 11:18:12 -0500 | [diff] [blame] | 89 | <b-button |
| 90 | v-b-toggle.collapse-role-table |
| 91 | data-test-id="localUserManagement-button-viewPrivilegeRoleDescriptions" |
| 92 | variant="link" |
| 93 | class="mt-3" |
| 94 | > |
Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 95 | <icon-chevron /> |
Yoshie Muranaka | 80735e1 | 2020-04-28 09:48:59 -0700 | [diff] [blame] | 96 | {{ $t('pageLocalUserManagement.viewPrivilegeRoleDescriptions') }} |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 97 | </b-button> |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 98 | <b-collapse id="collapse-role-table" class="mt-3"> |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 99 | <table-roles /> |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 100 | </b-collapse> |
| 101 | </b-col> |
| 102 | </b-row> |
| 103 | <!-- Modals --> |
Yoshie Muranaka | 1b1c100 | 2020-02-20 10:18:36 -0800 | [diff] [blame] | 104 | <modal-settings :settings="settings" @ok="saveAccountSettings" /> |
Yoshie Muranaka | 52b0223 | 2020-02-20 08:00:45 -0800 | [diff] [blame] | 105 | <modal-user |
| 106 | :user="activeUser" |
| 107 | :password-requirements="passwordRequirements" |
| 108 | @ok="saveUser" |
Yoshie Muranaka | 791622b | 2020-04-17 13:55:16 -0700 | [diff] [blame] | 109 | @hidden="activeUser = null" |
Yoshie Muranaka | 52b0223 | 2020-02-20 08:00:45 -0800 | [diff] [blame] | 110 | /> |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 111 | </b-container> |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 112 | </template> |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 113 | |
| 114 | <script> |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 115 | import IconTrashcan from '@carbon/icons-vue/es/trash-can/20'; |
| 116 | import IconEdit from '@carbon/icons-vue/es/edit/20'; |
| 117 | import IconAdd from '@carbon/icons-vue/es/add--alt/20'; |
| 118 | import IconSettings from '@carbon/icons-vue/es/settings/20'; |
Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 119 | import IconChevron from '@carbon/icons-vue/es/chevron--up/20'; |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 120 | |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 121 | import ModalUser from './ModalUser'; |
| 122 | import ModalSettings from './ModalSettings'; |
SurenNeware | 5e25e28 | 2020-07-08 15:57:23 +0530 | [diff] [blame] | 123 | import PageTitle from '@/components/Global/PageTitle'; |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 124 | import TableRoles from './TableRoles'; |
SurenNeware | 5e25e28 | 2020-07-08 15:57:23 +0530 | [diff] [blame] | 125 | import TableToolbar from '@/components/Global/TableToolbar'; |
| 126 | import TableRowAction from '@/components/Global/TableRowAction'; |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 127 | |
SurenNeware | 5e25e28 | 2020-07-08 15:57:23 +0530 | [diff] [blame] | 128 | import BVTableSelectableMixin from '@/components/Mixins/BVTableSelectableMixin'; |
| 129 | import BVToastMixin from '@/components/Mixins/BVToastMixin'; |
Yoshie Muranaka | 346be2a | 2020-04-28 11:12:14 -0700 | [diff] [blame] | 130 | import LoadingBarMixin from '@/components/Mixins/LoadingBarMixin'; |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 131 | |
| 132 | export default { |
Derick Montague | 09e45cd | 2020-01-23 15:45:57 -0600 | [diff] [blame] | 133 | name: 'LocalUsers', |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 134 | components: { |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 135 | IconAdd, |
Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 136 | IconChevron, |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 137 | IconEdit, |
| 138 | IconSettings, |
| 139 | IconTrashcan, |
| 140 | ModalSettings, |
| 141 | ModalUser, |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 142 | PageTitle, |
Yoshie Muranaka | 8d12910 | 2019-12-19 09:51:55 -0800 | [diff] [blame] | 143 | TableRoles, |
Yoshie Muranaka | 0e893f0 | 2020-02-18 13:39:45 -0800 | [diff] [blame] | 144 | TableRowAction, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 145 | TableToolbar, |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 146 | }, |
Yoshie Muranaka | 346be2a | 2020-04-28 11:12:14 -0700 | [diff] [blame] | 147 | mixins: [BVTableSelectableMixin, BVToastMixin, LoadingBarMixin], |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 148 | beforeRouteLeave(to, from, next) { |
| 149 | this.hideLoader(); |
| 150 | next(); |
| 151 | }, |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 152 | data() { |
| 153 | return { |
| 154 | activeUser: null, |
Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 155 | fields: [ |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 156 | { |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 157 | key: 'checkbox', |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 158 | }, |
Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 159 | { |
| 160 | key: 'username', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 161 | label: this.$t('pageLocalUserManagement.table.username'), |
Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 162 | }, |
| 163 | { |
| 164 | key: 'privilege', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 165 | label: this.$t('pageLocalUserManagement.table.privilege'), |
Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 166 | }, |
| 167 | { |
| 168 | key: 'status', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 169 | label: this.$t('pageLocalUserManagement.table.status'), |
Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 170 | }, |
Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 171 | { |
| 172 | key: 'actions', |
| 173 | label: '', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 174 | tdClass: 'text-right text-nowrap', |
| 175 | }, |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 176 | ], |
| 177 | tableToolbarActions: [ |
| 178 | { |
| 179 | value: 'delete', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 180 | label: this.$t('global.action.delete'), |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 181 | }, |
| 182 | { |
| 183 | value: 'enable', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 184 | label: this.$t('global.action.enable'), |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 185 | }, |
| 186 | { |
| 187 | value: 'disable', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 188 | label: this.$t('global.action.disable'), |
| 189 | }, |
| 190 | ], |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 191 | }; |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 192 | }, |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 193 | computed: { |
| 194 | allUsers() { |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 195 | return this.$store.getters['localUsers/allUsers']; |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 196 | }, |
| 197 | tableItems() { |
| 198 | // transform user data to table data |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 199 | return this.allUsers.map((user) => { |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 200 | return { |
| 201 | username: user.UserName, |
| 202 | privilege: user.RoleId, |
| 203 | status: user.Locked |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 204 | ? 'Locked' |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 205 | : user.Enabled |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 206 | ? 'Enabled' |
| 207 | : 'Disabled', |
Yoshie Muranaka | 0e893f0 | 2020-02-18 13:39:45 -0800 | [diff] [blame] | 208 | actions: [ |
Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 209 | { |
| 210 | value: 'edit', |
| 211 | enabled: true, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 212 | title: this.$t('pageLocalUserManagement.editUser'), |
Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 213 | }, |
Yoshie Muranaka | 0e893f0 | 2020-02-18 13:39:45 -0800 | [diff] [blame] | 214 | { |
| 215 | value: 'delete', |
Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 216 | enabled: user.UserName === 'root' ? false : true, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 217 | title: this.$tc('pageLocalUserManagement.deleteUser'), |
| 218 | }, |
Yoshie Muranaka | 0e893f0 | 2020-02-18 13:39:45 -0800 | [diff] [blame] | 219 | ], |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 220 | ...user, |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 221 | }; |
| 222 | }); |
Yoshie Muranaka | 52b0223 | 2020-02-20 08:00:45 -0800 | [diff] [blame] | 223 | }, |
| 224 | settings() { |
| 225 | return this.$store.getters['localUsers/accountSettings']; |
| 226 | }, |
| 227 | passwordRequirements() { |
| 228 | return this.$store.getters['localUsers/accountPasswordRequirements']; |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 229 | }, |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 230 | }, |
Derick Montague | 09e45cd | 2020-01-23 15:45:57 -0600 | [diff] [blame] | 231 | created() { |
Yoshie Muranaka | 346be2a | 2020-04-28 11:12:14 -0700 | [diff] [blame] | 232 | this.startLoader(); |
| 233 | this.$store.dispatch('localUsers/getUsers').finally(() => this.endLoader()); |
Yoshie Muranaka | fb78d19 | 2020-03-03 11:55:52 -0800 | [diff] [blame] | 234 | this.$store.dispatch('localUsers/getAccountSettings'); |
Yoshie Muranaka | 038a9da | 2020-04-17 11:22:56 -0700 | [diff] [blame] | 235 | this.$store.dispatch('localUsers/getAccountRoles'); |
Derick Montague | 09e45cd | 2020-01-23 15:45:57 -0600 | [diff] [blame] | 236 | }, |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 237 | methods: { |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 238 | initModalUser(user) { |
| 239 | this.activeUser = user; |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 240 | this.$bvModal.show('modal-user'); |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 241 | }, |
| 242 | initModalDelete(user) { |
| 243 | this.$bvModal |
| 244 | .msgBoxConfirm( |
Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 245 | this.$t('pageLocalUserManagement.modal.deleteConfirmMessage', { |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 246 | user: user.username, |
Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 247 | }), |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 248 | { |
Yoshie Muranaka | 2932165 | 2020-05-04 10:52:36 -0700 | [diff] [blame] | 249 | title: this.$tc('pageLocalUserManagement.deleteUser'), |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 250 | okTitle: this.$tc('pageLocalUserManagement.deleteUser'), |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 251 | } |
| 252 | ) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 253 | .then((deleteConfirmed) => { |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 254 | if (deleteConfirmed) { |
| 255 | this.deleteUser(user); |
| 256 | } |
| 257 | }); |
| 258 | }, |
| 259 | initModalSettings() { |
Yoshie Muranaka | 1b1c100 | 2020-02-20 10:18:36 -0800 | [diff] [blame] | 260 | this.$bvModal.show('modal-settings'); |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 261 | }, |
Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 262 | saveUser({ isNewUser, userData }) { |
Yoshie Muranaka | 346be2a | 2020-04-28 11:12:14 -0700 | [diff] [blame] | 263 | this.startLoader(); |
Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 264 | if (isNewUser) { |
Yoshie Muranaka | 0fc91e7 | 2020-02-05 11:23:06 -0800 | [diff] [blame] | 265 | this.$store |
| 266 | .dispatch('localUsers/createUser', userData) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 267 | .then((success) => this.successToast(success)) |
Yoshie Muranaka | 346be2a | 2020-04-28 11:12:14 -0700 | [diff] [blame] | 268 | .catch(({ message }) => this.errorToast(message)) |
| 269 | .finally(() => this.endLoader()); |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 270 | } else { |
Yoshie Muranaka | 0fc91e7 | 2020-02-05 11:23:06 -0800 | [diff] [blame] | 271 | this.$store |
| 272 | .dispatch('localUsers/updateUser', userData) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 273 | .then((success) => this.successToast(success)) |
Yoshie Muranaka | 346be2a | 2020-04-28 11:12:14 -0700 | [diff] [blame] | 274 | .catch(({ message }) => this.errorToast(message)) |
| 275 | .finally(() => this.endLoader()); |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 276 | } |
| 277 | }, |
| 278 | deleteUser({ username }) { |
Yoshie Muranaka | 346be2a | 2020-04-28 11:12:14 -0700 | [diff] [blame] | 279 | this.startLoader(); |
Yoshie Muranaka | 0fc91e7 | 2020-02-05 11:23:06 -0800 | [diff] [blame] | 280 | this.$store |
| 281 | .dispatch('localUsers/deleteUser', username) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 282 | .then((success) => this.successToast(success)) |
Yoshie Muranaka | 346be2a | 2020-04-28 11:12:14 -0700 | [diff] [blame] | 283 | .catch(({ message }) => this.errorToast(message)) |
| 284 | .finally(() => this.endLoader()); |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 285 | }, |
| 286 | onBatchAction(action) { |
| 287 | switch (action) { |
| 288 | case 'delete': |
Yoshie Muranaka | 2932165 | 2020-05-04 10:52:36 -0700 | [diff] [blame] | 289 | this.$bvModal |
| 290 | .msgBoxConfirm( |
| 291 | this.$tc( |
| 292 | 'pageLocalUserManagement.modal.batchDeleteConfirmMessage', |
| 293 | this.selectedRows.length |
| 294 | ), |
| 295 | { |
| 296 | title: this.$tc( |
| 297 | 'pageLocalUserManagement.deleteUser', |
| 298 | this.selectedRows.length |
| 299 | ), |
| 300 | okTitle: this.$tc( |
| 301 | 'pageLocalUserManagement.deleteUser', |
| 302 | this.selectedRows.length |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 303 | ), |
Yoshie Muranaka | 2932165 | 2020-05-04 10:52:36 -0700 | [diff] [blame] | 304 | } |
| 305 | ) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 306 | .then((deleteConfirmed) => { |
Yoshie Muranaka | 2932165 | 2020-05-04 10:52:36 -0700 | [diff] [blame] | 307 | if (deleteConfirmed) { |
Yoshie Muranaka | 8e4b5c3 | 2020-05-27 14:10:52 -0700 | [diff] [blame] | 308 | this.startLoader(); |
Yoshie Muranaka | 2932165 | 2020-05-04 10:52:36 -0700 | [diff] [blame] | 309 | this.$store |
| 310 | .dispatch('localUsers/deleteUsers', this.selectedRows) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 311 | .then((messages) => { |
Yoshie Muranaka | 2932165 | 2020-05-04 10:52:36 -0700 | [diff] [blame] | 312 | messages.forEach(({ type, message }) => { |
| 313 | if (type === 'success') this.successToast(message); |
| 314 | if (type === 'error') this.errorToast(message); |
| 315 | }); |
| 316 | }) |
| 317 | .finally(() => this.endLoader()); |
| 318 | } |
| 319 | }); |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 320 | break; |
| 321 | case 'enable': |
Yoshie Muranaka | 8e4b5c3 | 2020-05-27 14:10:52 -0700 | [diff] [blame] | 322 | this.startLoader(); |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 323 | this.$store |
| 324 | .dispatch('localUsers/enableUsers', this.selectedRows) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 325 | .then((messages) => { |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 326 | messages.forEach(({ type, message }) => { |
| 327 | if (type === 'success') this.successToast(message); |
| 328 | if (type === 'error') this.errorToast(message); |
| 329 | }); |
Yoshie Muranaka | 346be2a | 2020-04-28 11:12:14 -0700 | [diff] [blame] | 330 | }) |
| 331 | .finally(() => this.endLoader()); |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 332 | break; |
| 333 | case 'disable': |
Yoshie Muranaka | 8e4b5c3 | 2020-05-27 14:10:52 -0700 | [diff] [blame] | 334 | this.startLoader(); |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 335 | this.$store |
| 336 | .dispatch('localUsers/disableUsers', this.selectedRows) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 337 | .then((messages) => { |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 338 | messages.forEach(({ type, message }) => { |
| 339 | if (type === 'success') this.successToast(message); |
| 340 | if (type === 'error') this.errorToast(message); |
| 341 | }); |
Yoshie Muranaka | 346be2a | 2020-04-28 11:12:14 -0700 | [diff] [blame] | 342 | }) |
| 343 | .finally(() => this.endLoader()); |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 344 | break; |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 345 | } |
Yoshie Muranaka | 0e893f0 | 2020-02-18 13:39:45 -0800 | [diff] [blame] | 346 | }, |
| 347 | onTableRowAction(action, row) { |
| 348 | switch (action) { |
| 349 | case 'edit': |
| 350 | this.initModalUser(row); |
| 351 | break; |
| 352 | case 'delete': |
| 353 | this.initModalDelete(row); |
| 354 | break; |
| 355 | default: |
| 356 | break; |
| 357 | } |
Yoshie Muranaka | 1b1c100 | 2020-02-20 10:18:36 -0800 | [diff] [blame] | 358 | }, |
| 359 | saveAccountSettings(settings) { |
Yoshie Muranaka | 346be2a | 2020-04-28 11:12:14 -0700 | [diff] [blame] | 360 | this.startLoader(); |
Yoshie Muranaka | 1b1c100 | 2020-02-20 10:18:36 -0800 | [diff] [blame] | 361 | this.$store |
| 362 | .dispatch('localUsers/saveAccountSettings', settings) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 363 | .then((message) => this.successToast(message)) |
Yoshie Muranaka | 346be2a | 2020-04-28 11:12:14 -0700 | [diff] [blame] | 364 | .catch(({ message }) => this.errorToast(message)) |
| 365 | .finally(() => this.endLoader()); |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 366 | }, |
| 367 | }, |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 368 | }; |
| 369 | </script> |
| 370 | |
| 371 | <style lang="scss" scoped> |
Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 372 | .btn.collapsed { |
| 373 | svg { |
| 374 | transform: rotate(180deg); |
| 375 | } |
| 376 | } |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 377 | </style> |