@fishawack/lab-velocity 2.0.0-beta.3 → 2.0.0-beta.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +441 -37
- package/_Build/vue/components/basic/Button.vue +1 -1
- package/_Build/vue/components/form/Select.vue +2 -2
- package/_Build/vue/components/form/Spinner.vue +5 -0
- package/_Build/vue/components/layout/Alert.vue +5 -5
- package/_Build/vue/{modules/AuthModule/components/VBreadcrumbs.vue → components/layout/Breadcrumbs.vue} +4 -4
- package/_Build/vue/{modules/AuthModule/components → components/layout}/Chips.vue +2 -2
- package/_Build/vue/components/layout/Footer.vue +11 -10
- package/_Build/vue/{modules/AuthModule/components/VFormFooter.vue → components/layout/FormFooter.vue} +13 -7
- package/_Build/vue/{modules/AuthModule/components → components/layout}/FormRole.vue +10 -8
- package/_Build/vue/components/layout/Layout.vue +76 -0
- package/_Build/vue/components/layout/Navigation.vue +77 -0
- package/_Build/vue/{modules/AuthModule/components/VPageHeader.vue → components/layout/PageHeader.vue} +7 -2
- package/_Build/vue/components/layout/SideBar.vue +26 -0
- package/_Build/vue/{modules/AuthModule/components/VTable.vue → components/layout/Table.vue} +32 -16
- package/_Build/vue/{modules/AuthModule/components/VTableSorter.vue → components/layout/TableSorter.vue} +68 -43
- package/_Build/vue/components/layout/pageTitle.vue +1 -1
- package/_Build/vue/components/navigation/MenuItem.vue +7 -2
- package/_Build/vue/components/navigation/MenuItemGroup.vue +7 -2
- package/_Build/vue/modules/AuthModule/js/axios.js +19 -0
- package/_Build/vue/modules/AuthModule/js/router.js +28 -88
- package/_Build/vue/modules/AuthModule/js/store.js +15 -6
- package/_Build/vue/modules/AuthModule/{adminRoutes/PCompanies/Children/partials → routes/PCompanies}/form.vue +50 -18
- package/_Build/vue/modules/AuthModule/routes/PCompanies/resource.js +259 -0
- package/_Build/vue/modules/AuthModule/routes/PTeams/resource.js +308 -0
- package/_Build/vue/modules/AuthModule/{adminRoutes/PUsers/Children/partials → routes/PUsers}/form.vue +30 -18
- package/_Build/vue/modules/AuthModule/routes/PUsers/resource.js +215 -0
- package/_Build/vue/modules/AuthModule/routes/account-exists.vue +2 -2
- package/_Build/vue/modules/AuthModule/routes/change-password.vue +23 -24
- package/_Build/vue/modules/AuthModule/routes/container.vue +2 -11
- package/_Build/vue/modules/AuthModule/routes/expired-reset.vue +4 -4
- package/_Build/vue/modules/AuthModule/routes/expired-verification.vue +9 -8
- package/_Build/vue/modules/AuthModule/routes/force-reset.vue +24 -28
- package/_Build/vue/modules/AuthModule/routes/forgot.vue +4 -4
- package/_Build/vue/modules/AuthModule/routes/login.vue +7 -11
- package/_Build/vue/modules/AuthModule/routes/logincallback.vue +2 -4
- package/_Build/vue/modules/AuthModule/routes/loginsso.vue +7 -9
- package/_Build/vue/modules/AuthModule/routes/logout.vue +1 -3
- package/_Build/vue/modules/AuthModule/routes/logoutheadless.vue +1 -3
- package/_Build/vue/modules/AuthModule/routes/register.vue +19 -21
- package/_Build/vue/modules/AuthModule/routes/reset.vue +14 -13
- package/_Build/vue/modules/AuthModule/routes/success-forgot.vue +8 -7
- package/_Build/vue/modules/AuthModule/routes/success-reset.vue +2 -2
- package/_Build/vue/modules/AuthModule/routes/success-verify.vue +1 -3
- package/_Build/vue/modules/AuthModule/routes/verify.vue +11 -14
- package/_Build/vue/modules/resource/Children/create.vue +70 -0
- package/_Build/vue/modules/resource/Children/edit.vue +92 -0
- package/_Build/vue/modules/resource/Children/index.vue +42 -0
- package/_Build/vue/modules/resource/Children/partials/form.vue +57 -0
- package/_Build/vue/modules/resource/Children/show.vue +133 -0
- package/_Build/vue/modules/resource/index.js +486 -0
- package/_Build/vue/modules/resource/parent.vue +63 -0
- package/_base.scss +0 -1
- package/_defaults.scss +2 -13
- package/_variables.scss +9 -4
- package/components/_alert.scss +5 -0
- package/components/_auth.scss +163 -0
- package/components/_basic.scss +55 -0
- package/components/_breadcrumbs.scss +39 -0
- package/components/_button.scss +304 -0
- package/components/_cascader.scss +12 -0
- package/components/_checkbox.scss +41 -0
- package/components/_chip.scss +24 -0
- package/components/_collapse.scss +24 -0
- package/components/_datepicker.scss +52 -0
- package/components/_descriptions.scss +2 -0
- package/components/_footer.scss +47 -0
- package/components/_form.scss +24 -0
- package/components/_header.scss +30 -0
- package/components/_icon.scss +25 -0
- package/components/_inputNumber.scss +22 -0
- package/components/_layout.scss +56 -0
- package/components/_link.scss +44 -0
- package/components/_loader.scss +43 -0
- package/components/_menu.scss +112 -0
- package/components/_modal.scss +24 -0
- package/components/_pageTitle.scss +8 -0
- package/components/_permissionLegend.scss +18 -0
- package/components/_select.scss +29 -0
- package/components/_sidebar.scss +41 -0
- package/components/_switch.scss +14 -0
- package/components/_table.scss +20 -0
- package/components/_tooltip.scss +4 -0
- package/components/_typography.scss +162 -0
- package/components/_upload.scss +15 -0
- package/components/_wysiwyg.scss +7 -0
- package/components/_wysiwyg2.scss +142 -0
- package/index.js +9 -1
- package/package.json +4 -2
- package/vendor.scss +0 -1
- package/_Build/vue/components/layout/sideBar.vue +0 -25
- package/_Build/vue/modules/AuthModule/adminRoutes/PCompanies/Children/Upload/upload.vue +0 -251
- package/_Build/vue/modules/AuthModule/adminRoutes/PCompanies/Children/create.vue +0 -62
- package/_Build/vue/modules/AuthModule/adminRoutes/PCompanies/Children/edit.vue +0 -98
- package/_Build/vue/modules/AuthModule/adminRoutes/PCompanies/Children/index.vue +0 -90
- package/_Build/vue/modules/AuthModule/adminRoutes/PCompanies/Children/show.vue +0 -262
- package/_Build/vue/modules/AuthModule/adminRoutes/PCompanies/parent.vue +0 -36
- package/_Build/vue/modules/AuthModule/adminRoutes/PUsers/Children/create.vue +0 -112
- package/_Build/vue/modules/AuthModule/adminRoutes/PUsers/Children/edit.vue +0 -103
- package/_Build/vue/modules/AuthModule/adminRoutes/PUsers/Children/index.vue +0 -112
- package/_Build/vue/modules/AuthModule/adminRoutes/PUsers/Children/show.vue +0 -120
- package/_Build/vue/modules/AuthModule/adminRoutes/PUsers/parent.vue +0 -36
- /package/_Build/vue/{modules/AuthModule/components → components/layout}/AuthModal.vue +0 -0
- /package/_Build/vue/{modules/AuthModule/components → components/layout}/Chip.vue +0 -0
- /package/_Build/vue/{modules/AuthModule/components/VPasswordValidation.vue → components/layout/PasswordValidation.vue} +0 -0
- /package/_Build/vue/{modules/AuthModule/components/VRoleLegend.vue → components/layout/RoleLegend.vue} +0 -0
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import { merge } from "lodash";
|
|
2
|
+
import { h, resolveComponent } from "vue";
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
import { throttle } from "lodash";
|
|
5
|
+
|
|
6
|
+
import { columns } from "../../../resource/index.js";
|
|
7
|
+
import userResource from "../PUsers/resource.js";
|
|
8
|
+
import { defaultResource, meta } from "../../../resource/index.js";
|
|
9
|
+
|
|
10
|
+
import VelFormRole from "../../../../components/layout/FormRole.vue";
|
|
11
|
+
import Chip from "../../../../components/layout/Chip.vue";
|
|
12
|
+
import Chips from "../../../../components/layout/Chips.vue";
|
|
13
|
+
import VelRoleLegend from "../../../../components/layout/RoleLegend.vue";
|
|
14
|
+
|
|
15
|
+
import VelTableSorter from "../../../../components/layout/TableSorter.vue";
|
|
16
|
+
import VelButton from "../../../../components/basic/Button.vue";
|
|
17
|
+
import VelCheckbox from "../../../../components/form/Checkbox.vue";
|
|
18
|
+
|
|
19
|
+
export default [
|
|
20
|
+
"teams",
|
|
21
|
+
{
|
|
22
|
+
icon: `icon-account-circle`,
|
|
23
|
+
api: {
|
|
24
|
+
params: {
|
|
25
|
+
index: ({ $route }) => ({
|
|
26
|
+
include: "company",
|
|
27
|
+
"filter[company_id]": $route.params.companiesId,
|
|
28
|
+
}),
|
|
29
|
+
show: () => ({
|
|
30
|
+
include: "company",
|
|
31
|
+
}),
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
permissions: {
|
|
35
|
+
create: ({ $store }) => $store.getters.can("write teams"),
|
|
36
|
+
edit: ({ $store }) => $store.getters.can("write teams"),
|
|
37
|
+
delete: ({ $store }) => $store.getters.can("delete teams"),
|
|
38
|
+
},
|
|
39
|
+
...merge(
|
|
40
|
+
columns([
|
|
41
|
+
{
|
|
42
|
+
key: "name",
|
|
43
|
+
sortable: true,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
key: "description",
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
key: "company_id",
|
|
50
|
+
label: "Company",
|
|
51
|
+
class: "hidden",
|
|
52
|
+
render: {
|
|
53
|
+
read: ({ model }) => h("span", model.company.name),
|
|
54
|
+
},
|
|
55
|
+
initial: ({ $route, model }) =>
|
|
56
|
+
model?.company_id || $route.params.companiesId || null,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
key: "roles",
|
|
60
|
+
initial: ({ model }) =>
|
|
61
|
+
model?.roles.map((val) => val.id) || [],
|
|
62
|
+
render: {
|
|
63
|
+
read: ({ model }) =>
|
|
64
|
+
h(
|
|
65
|
+
!model.overrides_roles_and_permissions ||
|
|
66
|
+
model.roles.length === 1
|
|
67
|
+
? Chip
|
|
68
|
+
: Chips,
|
|
69
|
+
!model.overrides_roles_and_permissions
|
|
70
|
+
? {
|
|
71
|
+
name: "inherited",
|
|
72
|
+
label: "Inherited",
|
|
73
|
+
}
|
|
74
|
+
: model.roles.length === 1
|
|
75
|
+
? {
|
|
76
|
+
name: model.roles[0].name,
|
|
77
|
+
label: model.roles[0].label,
|
|
78
|
+
}
|
|
79
|
+
: { array: model.roles },
|
|
80
|
+
),
|
|
81
|
+
write: ({ model, form }) =>
|
|
82
|
+
h(VelFormRole, {
|
|
83
|
+
overrides:
|
|
84
|
+
model?.overrides_roles_and_permissions,
|
|
85
|
+
form,
|
|
86
|
+
}),
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
]),
|
|
90
|
+
{
|
|
91
|
+
index: {
|
|
92
|
+
layout: [
|
|
93
|
+
...defaultResource.index.layout,
|
|
94
|
+
() =>
|
|
95
|
+
h(VelRoleLegend, {
|
|
96
|
+
class: "mt-5",
|
|
97
|
+
}),
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
show: {
|
|
101
|
+
layout: [
|
|
102
|
+
...defaultResource.show.layout,
|
|
103
|
+
({ model }) => ({
|
|
104
|
+
label: "Access control",
|
|
105
|
+
component: h(VelFormRole, {
|
|
106
|
+
overrides:
|
|
107
|
+
model.overrides_roles_and_permissions,
|
|
108
|
+
form: { roles: model.roles.map((d) => d.id) },
|
|
109
|
+
readonly: true,
|
|
110
|
+
}),
|
|
111
|
+
}),
|
|
112
|
+
(props) => {
|
|
113
|
+
const { model, $store, $router, $route, ...rest } =
|
|
114
|
+
props;
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
label: "Members",
|
|
118
|
+
component: h({
|
|
119
|
+
data: () => ({
|
|
120
|
+
scoped: true,
|
|
121
|
+
}),
|
|
122
|
+
mounted() {
|
|
123
|
+
this.emitter.on("reload-teams", () => {
|
|
124
|
+
this.reload();
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
beforeUnmount() {
|
|
128
|
+
this.emitter.off("reload-teams");
|
|
129
|
+
},
|
|
130
|
+
methods: {
|
|
131
|
+
reload: throttle(function () {
|
|
132
|
+
this.$refs.members.reload();
|
|
133
|
+
this.$refs.users.reload();
|
|
134
|
+
}, 1000),
|
|
135
|
+
},
|
|
136
|
+
render() {
|
|
137
|
+
return h("div", [
|
|
138
|
+
h("h3", "Members"),
|
|
139
|
+
(() => {
|
|
140
|
+
const resource = meta(
|
|
141
|
+
...userResource,
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
resource.api.params.index = ({
|
|
145
|
+
$route,
|
|
146
|
+
}) => ({
|
|
147
|
+
include: "company",
|
|
148
|
+
"filter[teams.id]":
|
|
149
|
+
$route.params.teamsId,
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
resource.table.actions = [
|
|
153
|
+
({ model }) =>
|
|
154
|
+
h({
|
|
155
|
+
data: () => ({
|
|
156
|
+
loading: false,
|
|
157
|
+
}),
|
|
158
|
+
render() {
|
|
159
|
+
return h(
|
|
160
|
+
VelButton,
|
|
161
|
+
{
|
|
162
|
+
tag: "a",
|
|
163
|
+
size: "small",
|
|
164
|
+
type: "warning",
|
|
165
|
+
loading:
|
|
166
|
+
this
|
|
167
|
+
.loading,
|
|
168
|
+
onClick:
|
|
169
|
+
async () => {
|
|
170
|
+
this.loading = true;
|
|
171
|
+
|
|
172
|
+
await axios.delete(
|
|
173
|
+
`api/teams/${$route.params.teamsId}/users/${model.id}`,
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
this.emitter.emit(
|
|
177
|
+
"reload-teams",
|
|
178
|
+
);
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
"Remove",
|
|
182
|
+
);
|
|
183
|
+
},
|
|
184
|
+
}),
|
|
185
|
+
];
|
|
186
|
+
|
|
187
|
+
const props = {
|
|
188
|
+
model,
|
|
189
|
+
$store,
|
|
190
|
+
$router,
|
|
191
|
+
$route,
|
|
192
|
+
...rest,
|
|
193
|
+
resource,
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
return h(
|
|
197
|
+
VelTableSorter,
|
|
198
|
+
merge(
|
|
199
|
+
resource.index.structure(
|
|
200
|
+
props,
|
|
201
|
+
),
|
|
202
|
+
{
|
|
203
|
+
ref: "members",
|
|
204
|
+
},
|
|
205
|
+
),
|
|
206
|
+
);
|
|
207
|
+
})(),
|
|
208
|
+
h("h3", "Users"),
|
|
209
|
+
h(VelCheckbox, {
|
|
210
|
+
label: "Only show users from this company",
|
|
211
|
+
class: "mt-2",
|
|
212
|
+
modelValue: this.scoped,
|
|
213
|
+
"onUpdate:modelValue": (
|
|
214
|
+
value,
|
|
215
|
+
) => {
|
|
216
|
+
this.scoped = value;
|
|
217
|
+
this.$nextTick(() => {
|
|
218
|
+
this.$refs.users.reload();
|
|
219
|
+
});
|
|
220
|
+
},
|
|
221
|
+
}),
|
|
222
|
+
(() => {
|
|
223
|
+
const resource = meta(
|
|
224
|
+
...userResource,
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
resource.api.params.index = ({
|
|
228
|
+
$route,
|
|
229
|
+
}) => ({
|
|
230
|
+
include: "company",
|
|
231
|
+
"filter[company_id]": this
|
|
232
|
+
.scoped
|
|
233
|
+
? $route.params
|
|
234
|
+
.companiesId
|
|
235
|
+
: null,
|
|
236
|
+
"filter[teams.id]": `!${$route.params.teamsId}`,
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
resource.table.actions = [
|
|
240
|
+
({ model }) =>
|
|
241
|
+
h({
|
|
242
|
+
data: () => ({
|
|
243
|
+
loading: false,
|
|
244
|
+
}),
|
|
245
|
+
render() {
|
|
246
|
+
return h(
|
|
247
|
+
VelButton,
|
|
248
|
+
{
|
|
249
|
+
tag: "a",
|
|
250
|
+
size: "small",
|
|
251
|
+
type: "primary",
|
|
252
|
+
loading:
|
|
253
|
+
this
|
|
254
|
+
.loading,
|
|
255
|
+
onClick:
|
|
256
|
+
async () => {
|
|
257
|
+
this.loading = true;
|
|
258
|
+
|
|
259
|
+
await axios.post(
|
|
260
|
+
`api/teams/${$route.params.teamsId}/users`,
|
|
261
|
+
{
|
|
262
|
+
id: model.id,
|
|
263
|
+
},
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
this.emitter.emit(
|
|
267
|
+
"reload-teams",
|
|
268
|
+
);
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
"Add",
|
|
272
|
+
);
|
|
273
|
+
},
|
|
274
|
+
}),
|
|
275
|
+
];
|
|
276
|
+
|
|
277
|
+
const props = {
|
|
278
|
+
model,
|
|
279
|
+
$store,
|
|
280
|
+
$router,
|
|
281
|
+
$route,
|
|
282
|
+
...rest,
|
|
283
|
+
resource,
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
return h(
|
|
287
|
+
VelTableSorter,
|
|
288
|
+
merge(
|
|
289
|
+
resource.index.structure(
|
|
290
|
+
props,
|
|
291
|
+
),
|
|
292
|
+
{
|
|
293
|
+
ref: "users",
|
|
294
|
+
},
|
|
295
|
+
),
|
|
296
|
+
);
|
|
297
|
+
})(),
|
|
298
|
+
]);
|
|
299
|
+
},
|
|
300
|
+
}),
|
|
301
|
+
};
|
|
302
|
+
},
|
|
303
|
+
],
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
|
+
),
|
|
307
|
+
},
|
|
308
|
+
];
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<template>
|
|
3
3
|
<form class="" @submit.prevent="submit">
|
|
4
4
|
<template v-if="method !== 'patch'">
|
|
5
|
-
<
|
|
5
|
+
<VelBasic
|
|
6
6
|
v-model="form.name"
|
|
7
7
|
name="name"
|
|
8
8
|
:error="form.errors"
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
label="Name"
|
|
12
12
|
/>
|
|
13
13
|
|
|
14
|
-
<
|
|
14
|
+
<VelBasic
|
|
15
15
|
v-model="form.email"
|
|
16
16
|
placeholder="Email"
|
|
17
17
|
label="Email"
|
|
@@ -24,26 +24,26 @@
|
|
|
24
24
|
|
|
25
25
|
<hr class="my-3 hr-muted" />
|
|
26
26
|
|
|
27
|
-
<
|
|
27
|
+
<VelCheckbox
|
|
28
28
|
v-model="form.notify_user"
|
|
29
29
|
name="notify_user"
|
|
30
30
|
:error="form.errors"
|
|
31
31
|
label="Send email to notify user of account and password"
|
|
32
32
|
/>
|
|
33
|
-
<
|
|
33
|
+
<VelCheckbox
|
|
34
34
|
v-model="form.force_password_change"
|
|
35
35
|
name="force_password_change"
|
|
36
36
|
:error="form.errors"
|
|
37
37
|
label="Force password change on first login"
|
|
38
38
|
/>
|
|
39
|
-
<
|
|
39
|
+
<VelCheckbox
|
|
40
40
|
v-model="form.set_password"
|
|
41
41
|
name="set_password"
|
|
42
42
|
:error="form.errors"
|
|
43
43
|
label="Auto generate password"
|
|
44
44
|
/>
|
|
45
45
|
<template v-if="!form.set_password">
|
|
46
|
-
<
|
|
46
|
+
<VelBasic
|
|
47
47
|
v-model="form.password"
|
|
48
48
|
name="password"
|
|
49
49
|
:error="form.errors"
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
placeholder="Password"
|
|
52
52
|
label="Password"
|
|
53
53
|
/>
|
|
54
|
-
<
|
|
54
|
+
<VelBasic
|
|
55
55
|
v-model="form.password_confirmation"
|
|
56
56
|
name="password_confirmation"
|
|
57
57
|
:error="form.errors"
|
|
@@ -66,22 +66,26 @@
|
|
|
66
66
|
|
|
67
67
|
<template v-if="$store.getters.can('edit roles')">
|
|
68
68
|
<template v-if="enableRoles">
|
|
69
|
-
<
|
|
70
|
-
type="secondary"
|
|
69
|
+
<VelButton
|
|
71
70
|
@click="
|
|
72
71
|
form.roles = [];
|
|
73
72
|
enableRoles = false;
|
|
74
73
|
"
|
|
75
74
|
>
|
|
76
75
|
Reset roles
|
|
77
|
-
</
|
|
78
|
-
<
|
|
76
|
+
</VelButton>
|
|
77
|
+
<VelFormRole :form="form" />
|
|
79
78
|
</template>
|
|
80
79
|
<template v-else>
|
|
81
|
-
<
|
|
82
|
-
<GIcon
|
|
80
|
+
<VelButton @click="enableRoles = true">
|
|
81
|
+
<GIcon
|
|
82
|
+
name="icon-plus"
|
|
83
|
+
embed
|
|
84
|
+
asis
|
|
85
|
+
class="fill-0 icon--0.5 mr"
|
|
86
|
+
/>
|
|
83
87
|
Override roles
|
|
84
|
-
</
|
|
88
|
+
</VelButton>
|
|
85
89
|
<p class="mt-2">
|
|
86
90
|
Roles will be inherited from the company level.
|
|
87
91
|
</p>
|
|
@@ -89,18 +93,26 @@
|
|
|
89
93
|
<hr class="my-5 hr-muted" />
|
|
90
94
|
</template>
|
|
91
95
|
|
|
92
|
-
<
|
|
96
|
+
<VelFormFooter :loading="form.processing" />
|
|
93
97
|
</form>
|
|
94
98
|
</template>
|
|
95
99
|
|
|
96
100
|
<script>
|
|
97
101
|
import axios from "axios";
|
|
98
102
|
import { debounce } from "lodash";
|
|
103
|
+
import VelButton from "../../../../components/basic/Button.vue";
|
|
104
|
+
import VelCheckbox from "../../../../components/form/Checkbox.vue";
|
|
105
|
+
import VelBasic from "../../../../components/form/basic.vue";
|
|
106
|
+
import VelFormRole from "../../../../components/layout/FormRole.vue";
|
|
107
|
+
import VelFormFooter from "../../../../components/layout/FormFooter.vue";
|
|
99
108
|
|
|
100
109
|
export default {
|
|
101
110
|
components: {
|
|
102
|
-
|
|
103
|
-
|
|
111
|
+
VelFormFooter,
|
|
112
|
+
VelFormRole,
|
|
113
|
+
VelCheckbox,
|
|
114
|
+
VelButton,
|
|
115
|
+
VelBasic,
|
|
104
116
|
},
|
|
105
117
|
props: {
|
|
106
118
|
form: {
|
|
@@ -112,8 +124,8 @@ export default {
|
|
|
112
124
|
type: Function,
|
|
113
125
|
},
|
|
114
126
|
method: {
|
|
115
|
-
required: true,
|
|
116
127
|
type: String,
|
|
128
|
+
default: "post",
|
|
117
129
|
},
|
|
118
130
|
},
|
|
119
131
|
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import VelFormRole from "../../../../components/layout/FormRole.vue";
|
|
2
|
+
import Chip from "../../../../components/layout/Chip.vue";
|
|
3
|
+
import Chips from "../../../../components/layout/Chips.vue";
|
|
4
|
+
import VelRoleLegend from "../../../../components/layout/RoleLegend.vue";
|
|
5
|
+
import component from "./form.vue";
|
|
6
|
+
import companyResource from "../PCompanies/resource.js";
|
|
7
|
+
import { defaultResource, meta } from "../../../resource/index.js";
|
|
8
|
+
|
|
9
|
+
import { ElMessageBox } from "element-plus";
|
|
10
|
+
import { ElNotification } from "element-plus";
|
|
11
|
+
import { h, resolveComponent } from "vue";
|
|
12
|
+
|
|
13
|
+
function generatePassword(
|
|
14
|
+
length = 20,
|
|
15
|
+
characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~!@-#$",
|
|
16
|
+
) {
|
|
17
|
+
return (
|
|
18
|
+
Array.from(crypto.getRandomValues(new Uint32Array(length)))
|
|
19
|
+
.map((x) => characters[x % characters.length])
|
|
20
|
+
.join("") + Math.floor(Math.random() * 10)
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default [
|
|
25
|
+
"users",
|
|
26
|
+
{
|
|
27
|
+
api: {
|
|
28
|
+
params: {
|
|
29
|
+
index: () => ({ include: "company" }),
|
|
30
|
+
show: () => ({ include: "company" }),
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
searchable: {
|
|
34
|
+
value: "email",
|
|
35
|
+
},
|
|
36
|
+
permissions: {
|
|
37
|
+
create: ({ $store }) => $store.getters.can("write users"),
|
|
38
|
+
edit: ({ $store }) => $store.getters.can("write users"),
|
|
39
|
+
delete: ({ $store }) => $store.getters.can("delete companies"),
|
|
40
|
+
},
|
|
41
|
+
form: {
|
|
42
|
+
async submit({ model, form, $router, $store, method, resource }) {
|
|
43
|
+
try {
|
|
44
|
+
if (method === "post") {
|
|
45
|
+
if (form.set_password) {
|
|
46
|
+
const password = generatePassword();
|
|
47
|
+
form.password = password;
|
|
48
|
+
form.password_confirmation = password;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
let res = await form.post(`/api/users`);
|
|
52
|
+
|
|
53
|
+
if (form.set_password && !form.notify_user) {
|
|
54
|
+
ElMessageBox.alert(
|
|
55
|
+
`<p>The password below will not be shown again. Ensure you've taken a copy if you plan to send manually. <br><br><strong>Email</strong>: ${form.email}<br> <strong>Password</strong>: ${form.password}</p>`,
|
|
56
|
+
"User Created",
|
|
57
|
+
{
|
|
58
|
+
confirmButtonText: "Ok",
|
|
59
|
+
dangerouslyUseHTMLString: true,
|
|
60
|
+
},
|
|
61
|
+
)
|
|
62
|
+
.then(() => {
|
|
63
|
+
$router.replace({
|
|
64
|
+
name: "users.show",
|
|
65
|
+
params: { [resource.id]: res.data.id },
|
|
66
|
+
});
|
|
67
|
+
})
|
|
68
|
+
.catch(() => {});
|
|
69
|
+
} else {
|
|
70
|
+
ElNotification({
|
|
71
|
+
title: "Success",
|
|
72
|
+
message:
|
|
73
|
+
"User created a notified of their new account",
|
|
74
|
+
type: "success",
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
$router.replace({
|
|
78
|
+
name: "users.show",
|
|
79
|
+
params: { [resource.id]: res.data.id },
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
let res = await form.patch(`/api/users/${model.id}`);
|
|
84
|
+
|
|
85
|
+
// if changing ourselves, re-fetch user data
|
|
86
|
+
if (res.data.id === $store.state.auth.user.id) {
|
|
87
|
+
await $store.dispatch("getUser");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
$router.replace({
|
|
91
|
+
name: "users.show",
|
|
92
|
+
params: { [resource.id]: res.data.id },
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
} catch (e) {
|
|
96
|
+
console.log(e);
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
component,
|
|
100
|
+
fields: ({ model, method }) => ({
|
|
101
|
+
...{
|
|
102
|
+
name: model?.name ?? null,
|
|
103
|
+
email: model?.email ?? null,
|
|
104
|
+
roles: model?.overrides_roles_and_permissions
|
|
105
|
+
? model?.roles.map((val) => {
|
|
106
|
+
return val.id;
|
|
107
|
+
})
|
|
108
|
+
: [],
|
|
109
|
+
company_id: model?.company_id ?? null,
|
|
110
|
+
},
|
|
111
|
+
...(method === "post"
|
|
112
|
+
? {
|
|
113
|
+
notify_user: true,
|
|
114
|
+
force_password_change: true,
|
|
115
|
+
set_password: true,
|
|
116
|
+
password: null,
|
|
117
|
+
password_confirmation: null,
|
|
118
|
+
}
|
|
119
|
+
: {}),
|
|
120
|
+
}),
|
|
121
|
+
},
|
|
122
|
+
table: {
|
|
123
|
+
structure: [
|
|
124
|
+
{
|
|
125
|
+
key: "name",
|
|
126
|
+
sortable: true,
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
key: "email",
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
key: "company",
|
|
133
|
+
sortable: true,
|
|
134
|
+
render: ({ model }) =>
|
|
135
|
+
h(resolveComponent("router-link"), {
|
|
136
|
+
class: "underline",
|
|
137
|
+
to: {
|
|
138
|
+
name: "companies.show",
|
|
139
|
+
params: {
|
|
140
|
+
[meta(...companyResource).id]:
|
|
141
|
+
model.company_id,
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
text: model.company?.name,
|
|
145
|
+
}),
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
key: "role",
|
|
149
|
+
render: ({ model }) =>
|
|
150
|
+
h(
|
|
151
|
+
!model.overrides_roles_and_permissions ||
|
|
152
|
+
model.roles.length === 1
|
|
153
|
+
? Chip
|
|
154
|
+
: Chips,
|
|
155
|
+
!model.overrides_roles_and_permissions
|
|
156
|
+
? {
|
|
157
|
+
name: "inherited",
|
|
158
|
+
label: "Inherited",
|
|
159
|
+
}
|
|
160
|
+
: model.roles.length === 1
|
|
161
|
+
? {
|
|
162
|
+
name: model.roles[0].name,
|
|
163
|
+
label: model.roles[0].label,
|
|
164
|
+
}
|
|
165
|
+
: { array: model.roles },
|
|
166
|
+
),
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
description: {
|
|
171
|
+
structure: [
|
|
172
|
+
{
|
|
173
|
+
key: "email",
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
key: "company",
|
|
177
|
+
render: ({ model }) =>
|
|
178
|
+
h(resolveComponent("router-link"), {
|
|
179
|
+
class: "underline",
|
|
180
|
+
to: {
|
|
181
|
+
name: "companies.show",
|
|
182
|
+
params: {
|
|
183
|
+
[meta(...companyResource).id]:
|
|
184
|
+
model.company_id,
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
text: model.company.name,
|
|
188
|
+
}),
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
},
|
|
192
|
+
index: {
|
|
193
|
+
layout: [
|
|
194
|
+
...defaultResource.index.layout,
|
|
195
|
+
() =>
|
|
196
|
+
h(VelRoleLegend, {
|
|
197
|
+
class: "mt-5",
|
|
198
|
+
}),
|
|
199
|
+
],
|
|
200
|
+
},
|
|
201
|
+
show: {
|
|
202
|
+
layout: [
|
|
203
|
+
...defaultResource.show.layout,
|
|
204
|
+
({ model }) => ({
|
|
205
|
+
label: "Access control",
|
|
206
|
+
component: h(VelFormRole, {
|
|
207
|
+
overrides: model.overrides_roles_and_permissions,
|
|
208
|
+
form: { roles: model.roles.map((d) => d.id) },
|
|
209
|
+
readonly: true,
|
|
210
|
+
}),
|
|
211
|
+
}),
|
|
212
|
+
],
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
];
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
<section id="resetPasswordForm">
|
|
4
4
|
<h1 class="h2">Account already exists</h1>
|
|
5
5
|
|
|
6
|
-
<p class="mt
|
|
6
|
+
<p class="mt mb-0 color-21">
|
|
7
7
|
<strong class="">Company: {{ $route.query.company }}</strong>
|
|
8
8
|
</p>
|
|
9
|
-
<p class="
|
|
9
|
+
<p class="mt-0.5">Your company already has an active account.</p>
|
|
10
10
|
|
|
11
11
|
<elButton
|
|
12
12
|
tag="router-link"
|