@fishawack/lab-velocity 2.0.0-beta.11 → 2.0.0-beta.13
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 +148 -6
- 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} +2 -2
- package/_Build/vue/{modules/AuthModule/components → components/layout}/FormRole.vue +7 -7
- package/_Build/vue/components/layout/Layout.vue +74 -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} +6 -15
- package/_Build/vue/{modules/AuthModule/components/VTableSorter.vue → components/layout/TableSorter.vue} +15 -17
- 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/router.js +21 -89
- package/_Build/vue/modules/AuthModule/js/store.js +13 -4
- package/_Build/vue/modules/AuthModule/{adminRoutes/PCompanies/Children/partials → routes/PCompanies}/form.vue +15 -8
- package/_Build/vue/modules/AuthModule/routes/PCompanies/resource.js +180 -0
- package/_Build/vue/modules/AuthModule/{adminRoutes/PUsers/Children/partials → routes/PUsers}/form.vue +15 -8
- package/_Build/vue/modules/AuthModule/routes/PUsers/resource.js +214 -0
- package/_Build/vue/modules/AuthModule/routes/change-password.vue +9 -8
- package/_Build/vue/modules/AuthModule/routes/container.vue +2 -11
- package/_Build/vue/modules/AuthModule/routes/force-reset.vue +9 -8
- package/_Build/vue/modules/AuthModule/routes/register.vue +9 -8
- package/_Build/vue/modules/AuthModule/routes/reset.vue +9 -8
- package/_Build/vue/modules/resource/Children/create.vue +76 -0
- package/_Build/vue/modules/resource/Children/edit.vue +109 -0
- package/_Build/vue/modules/resource/Children/index.vue +51 -0
- package/_Build/vue/modules/resource/Children/partials/form.vue +53 -0
- package/_Build/vue/modules/resource/Children/show.vue +145 -0
- package/_Build/vue/modules/resource/index.js +112 -0
- package/_Build/vue/modules/resource/parent.vue +41 -0
- package/components/_descriptions.scss +2 -0
- package/components/_footer.scss +1 -0
- package/components/_header.scss +3 -27
- package/components/_layout.scss +56 -0
- package/components/_sidebar.scss +12 -27
- package/index.js +7 -1
- package/package.json +3 -2
- package/_Build/vue/components/layout/sideBar.vue +0 -25
- package/_Build/vue/modules/AuthModule/adminRoutes/PCompanies/Children/Upload/upload.vue +0 -259
- 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 -267
- package/_Build/vue/modules/AuthModule/adminRoutes/PCompanies/parent.vue +0 -36
- package/_Build/vue/modules/AuthModule/adminRoutes/PUsers/Children/create.vue +0 -113
- package/_Build/vue/modules/AuthModule/adminRoutes/PUsers/Children/edit.vue +0 -101
- package/_Build/vue/modules/AuthModule/adminRoutes/PUsers/Children/index.vue +0 -112
- package/_Build/vue/modules/AuthModule/adminRoutes/PUsers/Children/show.vue +0 -123
- 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,214 @@
|
|
|
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 VelTableSorter from "../../../../components/layout/TableSorter.vue";
|
|
5
|
+
import VelRoleLegend from "../../../../components/layout/RoleLegend.vue";
|
|
6
|
+
import component from "./form.vue";
|
|
7
|
+
|
|
8
|
+
import { ElMessageBox } from "element-plus";
|
|
9
|
+
import { ElNotification } from "element-plus";
|
|
10
|
+
import { h, resolveComponent } from "vue";
|
|
11
|
+
|
|
12
|
+
function generatePassword(
|
|
13
|
+
length = 20,
|
|
14
|
+
characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~!@-#$",
|
|
15
|
+
) {
|
|
16
|
+
return (
|
|
17
|
+
Array.from(crypto.getRandomValues(new Uint32Array(length)))
|
|
18
|
+
.map((x) => characters[x % characters.length])
|
|
19
|
+
.join("") + Math.floor(Math.random() * 10)
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default [
|
|
24
|
+
"users",
|
|
25
|
+
{
|
|
26
|
+
defaults: "include=company",
|
|
27
|
+
searchable: {
|
|
28
|
+
value: "email",
|
|
29
|
+
},
|
|
30
|
+
form: {
|
|
31
|
+
async submit({ model, form, $router, $store, method }) {
|
|
32
|
+
try {
|
|
33
|
+
if (method === "post") {
|
|
34
|
+
if (form.set_password) {
|
|
35
|
+
const password = generatePassword();
|
|
36
|
+
form.password = password;
|
|
37
|
+
form.password_confirmation = password;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let res = await form.post(`/api/users`);
|
|
41
|
+
|
|
42
|
+
if (form.set_password && !form.notify_user) {
|
|
43
|
+
ElMessageBox.alert(
|
|
44
|
+
`<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>`,
|
|
45
|
+
"User Created",
|
|
46
|
+
{
|
|
47
|
+
confirmButtonText: "Ok",
|
|
48
|
+
dangerouslyUseHTMLString: true,
|
|
49
|
+
},
|
|
50
|
+
)
|
|
51
|
+
.then(() => {
|
|
52
|
+
$router.replace({
|
|
53
|
+
name: "users.show",
|
|
54
|
+
params: { id: res.data.id },
|
|
55
|
+
});
|
|
56
|
+
})
|
|
57
|
+
.catch(() => {});
|
|
58
|
+
} else {
|
|
59
|
+
ElNotification({
|
|
60
|
+
title: "Success",
|
|
61
|
+
message:
|
|
62
|
+
"User created a notified of their new account",
|
|
63
|
+
type: "success",
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
$router.replace({
|
|
67
|
+
name: "users.show",
|
|
68
|
+
params: { id: res.data.id },
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
let res = await form.patch(`/api/users/${model.id}`);
|
|
73
|
+
|
|
74
|
+
// if changing ourselves, re-fetch user data
|
|
75
|
+
if (res.data.id === $store.state.auth.user.id) {
|
|
76
|
+
await $store.dispatch("getUser");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
$router.replace({
|
|
80
|
+
name: "users.show",
|
|
81
|
+
params: { id: res.data.id },
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
} catch (e) {
|
|
85
|
+
console.log(e);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
component,
|
|
89
|
+
fields: ({ model, method }) => ({
|
|
90
|
+
...{
|
|
91
|
+
name: model?.name ?? null,
|
|
92
|
+
email: model?.email ?? null,
|
|
93
|
+
roles: model?.overrides_roles_and_permissions
|
|
94
|
+
? model?.roles.map((val) => {
|
|
95
|
+
return val.id;
|
|
96
|
+
})
|
|
97
|
+
: [],
|
|
98
|
+
company_id: model?.company_id ?? null,
|
|
99
|
+
},
|
|
100
|
+
...(method === "post"
|
|
101
|
+
? {
|
|
102
|
+
notify_user: true,
|
|
103
|
+
force_password_change: true,
|
|
104
|
+
set_password: true,
|
|
105
|
+
password: null,
|
|
106
|
+
password_confirmation: null,
|
|
107
|
+
}
|
|
108
|
+
: {}),
|
|
109
|
+
}),
|
|
110
|
+
},
|
|
111
|
+
table: {
|
|
112
|
+
structure: [
|
|
113
|
+
{
|
|
114
|
+
label: "Name",
|
|
115
|
+
key: "name",
|
|
116
|
+
sortable: true,
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
label: "Email",
|
|
120
|
+
key: "email",
|
|
121
|
+
sortable: true,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
label: "Company",
|
|
125
|
+
sortable: true,
|
|
126
|
+
render: (model) =>
|
|
127
|
+
h(resolveComponent("router-link"), {
|
|
128
|
+
class: "underline",
|
|
129
|
+
to: {
|
|
130
|
+
name: "companies.show",
|
|
131
|
+
params: { id: model.company_id },
|
|
132
|
+
},
|
|
133
|
+
text: model.company.name,
|
|
134
|
+
}),
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
label: "Role",
|
|
138
|
+
render: (row) =>
|
|
139
|
+
h(
|
|
140
|
+
!row.overrides_roles_and_permissions ||
|
|
141
|
+
row.roles.length === 1
|
|
142
|
+
? Chip
|
|
143
|
+
: Chips,
|
|
144
|
+
!row.overrides_roles_and_permissions
|
|
145
|
+
? {
|
|
146
|
+
name: "inherited",
|
|
147
|
+
label: "Inherited",
|
|
148
|
+
}
|
|
149
|
+
: row.roles.length === 1
|
|
150
|
+
? {
|
|
151
|
+
name: row.roles[0].name,
|
|
152
|
+
label: row.roles[0].label,
|
|
153
|
+
}
|
|
154
|
+
: { array: row.roles },
|
|
155
|
+
),
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
},
|
|
159
|
+
index: {
|
|
160
|
+
structure: [
|
|
161
|
+
{
|
|
162
|
+
render: ({ resource, $store }) =>
|
|
163
|
+
h(VelTableSorter, {
|
|
164
|
+
key: "PIndex",
|
|
165
|
+
"json-data": {
|
|
166
|
+
...resource,
|
|
167
|
+
tableStructure: resource.table.structure,
|
|
168
|
+
},
|
|
169
|
+
defaults: resource.defaults,
|
|
170
|
+
"fixed-height": false,
|
|
171
|
+
"display-edit-action":
|
|
172
|
+
$store.getters.can("write users"),
|
|
173
|
+
}),
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
render: () =>
|
|
177
|
+
h(VelRoleLegend, {
|
|
178
|
+
class: "mt-5",
|
|
179
|
+
}),
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
},
|
|
183
|
+
show: {
|
|
184
|
+
structure: [
|
|
185
|
+
[
|
|
186
|
+
{
|
|
187
|
+
label: "Email",
|
|
188
|
+
key: "email",
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
label: "Company",
|
|
192
|
+
render: ({ model }) =>
|
|
193
|
+
h(resolveComponent("router-link"), {
|
|
194
|
+
class: "underline",
|
|
195
|
+
to: {
|
|
196
|
+
name: "companies.show",
|
|
197
|
+
params: { id: model.company_id },
|
|
198
|
+
},
|
|
199
|
+
text: model.company.name,
|
|
200
|
+
}),
|
|
201
|
+
},
|
|
202
|
+
],
|
|
203
|
+
{
|
|
204
|
+
render: ({ model }) =>
|
|
205
|
+
h(VelFormRole, {
|
|
206
|
+
overrides: model.overrides_roles_and_permissions,
|
|
207
|
+
form: { roles: model.roles.map((d) => d.id) },
|
|
208
|
+
readonly: true,
|
|
209
|
+
}),
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
];
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
:password="true"
|
|
37
37
|
/>
|
|
38
38
|
|
|
39
|
-
<
|
|
39
|
+
<VelPasswordValidation
|
|
40
40
|
:password="form.password"
|
|
41
41
|
@passwordValid="updatePasswordValidity"
|
|
42
42
|
/>
|
|
@@ -83,6 +83,14 @@
|
|
|
83
83
|
import Form from "form-backend-validation";
|
|
84
84
|
|
|
85
85
|
export default {
|
|
86
|
+
components: {
|
|
87
|
+
VelPasswordValidation:
|
|
88
|
+
require("../../../components/layout/PasswordValidation.vue")
|
|
89
|
+
.default,
|
|
90
|
+
elInput: require("../../../components/form/basic.vue").default,
|
|
91
|
+
elButton: require("../../../components/basic/Button.vue").default,
|
|
92
|
+
},
|
|
93
|
+
|
|
86
94
|
data() {
|
|
87
95
|
return {
|
|
88
96
|
form: new Form(
|
|
@@ -152,12 +160,5 @@ export default {
|
|
|
152
160
|
title: "Reset Password",
|
|
153
161
|
};
|
|
154
162
|
},
|
|
155
|
-
|
|
156
|
-
components: {
|
|
157
|
-
VPasswordValidation: require("./../components/VPasswordValidation.vue")
|
|
158
|
-
.default,
|
|
159
|
-
elInput: require("../../../components/form/basic.vue").default,
|
|
160
|
-
elButton: require("../../../components/basic/Button.vue").default,
|
|
161
|
-
},
|
|
162
163
|
};
|
|
163
164
|
</script>
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<router-link to="/" class="logo" aria-label="Go to home page">
|
|
6
6
|
<GSvg
|
|
7
7
|
class="AuthModule__logo"
|
|
8
|
-
:name="
|
|
8
|
+
:name="$store.state.auth.logo"
|
|
9
9
|
embed
|
|
10
10
|
asis
|
|
11
11
|
role="presentation"
|
|
@@ -21,14 +21,5 @@
|
|
|
21
21
|
</template>
|
|
22
22
|
|
|
23
23
|
<script>
|
|
24
|
-
export default {
|
|
25
|
-
mounted() {},
|
|
26
|
-
data() {
|
|
27
|
-
return {
|
|
28
|
-
logoName: process.env.HYDRATE_LOGO,
|
|
29
|
-
};
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
components: {},
|
|
33
|
-
};
|
|
24
|
+
export default {};
|
|
34
25
|
</script>
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
required
|
|
34
34
|
/>
|
|
35
35
|
|
|
36
|
-
<
|
|
36
|
+
<VelPasswordValidation
|
|
37
37
|
:password="form.password"
|
|
38
38
|
@passwordValid="updatePasswordValidity"
|
|
39
39
|
/>
|
|
@@ -71,6 +71,14 @@
|
|
|
71
71
|
import Form from "form-backend-validation";
|
|
72
72
|
|
|
73
73
|
export default {
|
|
74
|
+
components: {
|
|
75
|
+
VelPasswordValidation:
|
|
76
|
+
require("../../../components/layout/PasswordValidation.vue")
|
|
77
|
+
.default,
|
|
78
|
+
elInput: require("../../../components/form/basic.vue").default,
|
|
79
|
+
elButton: require("../../../components/basic/Button.vue").default,
|
|
80
|
+
},
|
|
81
|
+
|
|
74
82
|
data() {
|
|
75
83
|
return {
|
|
76
84
|
form: new Form(
|
|
@@ -136,12 +144,5 @@ export default {
|
|
|
136
144
|
title: "Reset Password",
|
|
137
145
|
};
|
|
138
146
|
},
|
|
139
|
-
|
|
140
|
-
components: {
|
|
141
|
-
VPasswordValidation: require("./../components/VPasswordValidation.vue")
|
|
142
|
-
.default,
|
|
143
|
-
elInput: require("../../../components/form/basic.vue").default,
|
|
144
|
-
elButton: require("../../../components/basic/Button.vue").default,
|
|
145
|
-
},
|
|
146
147
|
};
|
|
147
148
|
</script>
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
:error="form.errors"
|
|
43
43
|
/>
|
|
44
44
|
|
|
45
|
-
<
|
|
45
|
+
<VelPasswordValidation
|
|
46
46
|
:password="form.password"
|
|
47
47
|
@passwordValid="updatePasswordValidity"
|
|
48
48
|
/>
|
|
@@ -86,6 +86,14 @@ import Form from "form-backend-validation";
|
|
|
86
86
|
import { ElNotification } from "element-plus";
|
|
87
87
|
|
|
88
88
|
export default {
|
|
89
|
+
components: {
|
|
90
|
+
VelPasswordValidation:
|
|
91
|
+
require("../../../components/layout/PasswordValidation.vue")
|
|
92
|
+
.default,
|
|
93
|
+
elInput: require("../../../components/form/basic.vue").default,
|
|
94
|
+
elButton: require("../../../components/basic/Button.vue").default,
|
|
95
|
+
},
|
|
96
|
+
|
|
89
97
|
data() {
|
|
90
98
|
return {
|
|
91
99
|
form: new Form(
|
|
@@ -160,12 +168,5 @@ export default {
|
|
|
160
168
|
this.isPasswordValid = isValid;
|
|
161
169
|
},
|
|
162
170
|
},
|
|
163
|
-
|
|
164
|
-
components: {
|
|
165
|
-
VPasswordValidation: require("./../components/VPasswordValidation.vue")
|
|
166
|
-
.default,
|
|
167
|
-
elInput: require("../../../components/form/basic.vue").default,
|
|
168
|
-
elButton: require("../../../components/basic/Button.vue").default,
|
|
169
|
-
},
|
|
170
171
|
};
|
|
171
172
|
</script>
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
required
|
|
24
24
|
/>
|
|
25
25
|
|
|
26
|
-
<
|
|
26
|
+
<VelPasswordValidation
|
|
27
27
|
:password="form.password"
|
|
28
28
|
@passwordValid="updatePasswordValidity"
|
|
29
29
|
/>
|
|
@@ -68,6 +68,14 @@
|
|
|
68
68
|
import Form from "form-backend-validation";
|
|
69
69
|
|
|
70
70
|
export default {
|
|
71
|
+
components: {
|
|
72
|
+
VelPasswordValidation:
|
|
73
|
+
require("../../../components/layout/PasswordValidation.vue")
|
|
74
|
+
.default,
|
|
75
|
+
elInput: require("../../../components/form/basic.vue").default,
|
|
76
|
+
elButton: require("../../../components/basic/Button.vue").default,
|
|
77
|
+
},
|
|
78
|
+
|
|
71
79
|
data() {
|
|
72
80
|
return {
|
|
73
81
|
form: new Form(
|
|
@@ -122,12 +130,5 @@ export default {
|
|
|
122
130
|
title: "Reset Password",
|
|
123
131
|
};
|
|
124
132
|
},
|
|
125
|
-
|
|
126
|
-
components: {
|
|
127
|
-
VPasswordValidation: require("./../components/VPasswordValidation.vue")
|
|
128
|
-
.default,
|
|
129
|
-
elInput: require("../../../components/form/basic.vue").default,
|
|
130
|
-
elButton: require("../../../components/basic/Button.vue").default,
|
|
131
|
-
},
|
|
132
133
|
};
|
|
133
134
|
</script>
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<VBreadcrumbs :items="breadcrumbs" class="mb-8" container-classes="m-0" />
|
|
3
|
+
|
|
4
|
+
<div class="container px-6 tablet:px-4 mobile:px-2 mb-8 ml-0 mr-0">
|
|
5
|
+
<div class="grid__1/1">
|
|
6
|
+
<div class="grid__1/1 mb-4">
|
|
7
|
+
<h2 class="h1">Create {{ resource.singular }}</h2>
|
|
8
|
+
</div>
|
|
9
|
+
<div class="mt grid__1/2">
|
|
10
|
+
<component
|
|
11
|
+
:is="resource.form.component ?? 'XForm'"
|
|
12
|
+
ref="form"
|
|
13
|
+
:form="form"
|
|
14
|
+
:submit="submit"
|
|
15
|
+
:method="method"
|
|
16
|
+
:resource="resource"
|
|
17
|
+
/>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<script>
|
|
24
|
+
import Form from "form-backend-validation";
|
|
25
|
+
|
|
26
|
+
export default {
|
|
27
|
+
components: {
|
|
28
|
+
VBreadcrumbs: require("../../../components/layout/Breadcrumbs.vue")
|
|
29
|
+
.default,
|
|
30
|
+
XForm: require("./partials/form.vue").default,
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
props: {
|
|
34
|
+
breadcrumbs: {
|
|
35
|
+
type: Array,
|
|
36
|
+
required: true,
|
|
37
|
+
},
|
|
38
|
+
resource: {
|
|
39
|
+
type: Object,
|
|
40
|
+
required: true,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
data() {
|
|
45
|
+
return {
|
|
46
|
+
form: null,
|
|
47
|
+
method: "post",
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
beforeMount() {
|
|
52
|
+
this.form = new Form(this.resource.form.fields(this), {
|
|
53
|
+
resetOnSuccess: false,
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
methods: {
|
|
58
|
+
async submit() {
|
|
59
|
+
if (this.resource.form.submit) {
|
|
60
|
+
await this.resource.form.submit(this);
|
|
61
|
+
} else {
|
|
62
|
+
try {
|
|
63
|
+
let res = await this.form.post(`${this.resource.api}`);
|
|
64
|
+
|
|
65
|
+
this.$router.replace({
|
|
66
|
+
name: `${this.resource.name}.show`,
|
|
67
|
+
params: { id: res.data.id },
|
|
68
|
+
});
|
|
69
|
+
} catch (e) {
|
|
70
|
+
console.log(e);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
</script>
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<VBreadcrumbs
|
|
3
|
+
:items="addBreadcrumbs"
|
|
4
|
+
class="mb-8"
|
|
5
|
+
container-classes="m-0"
|
|
6
|
+
/>
|
|
7
|
+
|
|
8
|
+
<div class="container px-6 tablet:px-4 mobile:px-2 mb-8 ml-0 mr-0">
|
|
9
|
+
<div class="grid__1/1">
|
|
10
|
+
<div class="grid__1/1 mb-4">
|
|
11
|
+
<h2 class="h1">Edit {{ resource.singular }}</h2>
|
|
12
|
+
</div>
|
|
13
|
+
<div class="grid__1/2">
|
|
14
|
+
<component
|
|
15
|
+
:is="resource.form.component ?? 'XForm'"
|
|
16
|
+
ref="form"
|
|
17
|
+
:form="form"
|
|
18
|
+
:submit="submit"
|
|
19
|
+
:method="method"
|
|
20
|
+
:resource="resource"
|
|
21
|
+
/>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<script>
|
|
28
|
+
import Form from "form-backend-validation";
|
|
29
|
+
|
|
30
|
+
export default {
|
|
31
|
+
components: {
|
|
32
|
+
VBreadcrumbs: require("../../../components/layout/Breadcrumbs.vue")
|
|
33
|
+
.default,
|
|
34
|
+
XForm: require("./partials/form.vue").default,
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
props: {
|
|
38
|
+
breadcrumbs: {
|
|
39
|
+
type: Array,
|
|
40
|
+
required: true,
|
|
41
|
+
},
|
|
42
|
+
resource: {
|
|
43
|
+
type: Object,
|
|
44
|
+
required: true,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
data() {
|
|
49
|
+
return {
|
|
50
|
+
form: null,
|
|
51
|
+
model: null,
|
|
52
|
+
addBreadcrumbs: [...this.$props.breadcrumbs],
|
|
53
|
+
method: "patch",
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
beforeMount() {
|
|
58
|
+
this.form = new Form(this.resource.form.fields(this), {
|
|
59
|
+
resetOnSuccess: false,
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
async mounted() {
|
|
64
|
+
window.axios
|
|
65
|
+
.get(
|
|
66
|
+
`${this.resource.api}/${this.$route.params.id}?${this.resource.defaults}`,
|
|
67
|
+
)
|
|
68
|
+
.then((res) => {
|
|
69
|
+
this.model = res.data.data;
|
|
70
|
+
|
|
71
|
+
// Set initial form data
|
|
72
|
+
Object.entries(this.resource.form.fields(this)).forEach(
|
|
73
|
+
([key, value]) => {
|
|
74
|
+
this.form[key] = value;
|
|
75
|
+
},
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
this.addBreadcrumbs.push({
|
|
79
|
+
href: {
|
|
80
|
+
name: `${this.resource.name}.show`,
|
|
81
|
+
param: this.model.id,
|
|
82
|
+
},
|
|
83
|
+
text: this.model.name,
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
methods: {
|
|
89
|
+
async submit() {
|
|
90
|
+
if (this.resource.form.submit) {
|
|
91
|
+
await this.resource.form.submit(this);
|
|
92
|
+
} else {
|
|
93
|
+
try {
|
|
94
|
+
let res = await this.form.patch(
|
|
95
|
+
`${this.resource.api}/${this.model.id}`,
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
this.$router.replace({
|
|
99
|
+
name: `${this.resource.name}.show`,
|
|
100
|
+
params: { id: res.data.id },
|
|
101
|
+
});
|
|
102
|
+
} catch (e) {
|
|
103
|
+
console.log(e);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
</script>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<VBreadcrumbs :items="breadcrumbs" />
|
|
3
|
+
|
|
4
|
+
<div class="container px-6 tablet:px-4 mobile:px-2 mb-8 ml-0 mr-0">
|
|
5
|
+
<div class="grid__1/1">
|
|
6
|
+
<h2 class="h1 pb-4">
|
|
7
|
+
{{ breadcrumbs[breadcrumbs.length - 1].text }}
|
|
8
|
+
</h2>
|
|
9
|
+
|
|
10
|
+
<div class="flex gap items-center justify-end">
|
|
11
|
+
<template
|
|
12
|
+
v-for="(row, index) in resource.index.actions"
|
|
13
|
+
:key="index"
|
|
14
|
+
>
|
|
15
|
+
<template v-if="row.render">
|
|
16
|
+
<component :is="row.render(this)" />
|
|
17
|
+
</template>
|
|
18
|
+
</template>
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<template
|
|
22
|
+
v-for="(row, index) in resource.index.structure"
|
|
23
|
+
:key="index"
|
|
24
|
+
>
|
|
25
|
+
<template v-if="row.render">
|
|
26
|
+
<component :is="row.render(this)" />
|
|
27
|
+
</template>
|
|
28
|
+
</template>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<script>
|
|
34
|
+
export default {
|
|
35
|
+
components: {
|
|
36
|
+
VBreadcrumbs: require("../../../components/layout/Breadcrumbs.vue")
|
|
37
|
+
.default,
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
props: {
|
|
41
|
+
breadcrumbs: {
|
|
42
|
+
type: Array,
|
|
43
|
+
required: true,
|
|
44
|
+
},
|
|
45
|
+
resource: {
|
|
46
|
+
type: Object,
|
|
47
|
+
required: true,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
</script>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<!-- eslint-disable vue/no-mutating-props -->
|
|
2
|
+
<template>
|
|
3
|
+
<form @submit.prevent="submit">
|
|
4
|
+
<template v-for="(item, index) in resource.form.structure" :key="index">
|
|
5
|
+
<component
|
|
6
|
+
:is="item.render ? item.render(this) : 'VelBasic'"
|
|
7
|
+
v-model="form[item.key]"
|
|
8
|
+
:type="item.type || 'text'"
|
|
9
|
+
:error="form.errors"
|
|
10
|
+
:name="item.key"
|
|
11
|
+
:placeholder="
|
|
12
|
+
item.placeholder ||
|
|
13
|
+
item.key[0].toUpperCase() + item.key.slice(1)
|
|
14
|
+
"
|
|
15
|
+
:label="
|
|
16
|
+
item.label || item.key[0].toUpperCase() + item.key.slice(1)
|
|
17
|
+
"
|
|
18
|
+
v-bind="item"
|
|
19
|
+
/>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<VelFormFooter :loading="form.processing" />
|
|
23
|
+
</form>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script>
|
|
27
|
+
export default {
|
|
28
|
+
components: {
|
|
29
|
+
VelFormFooter: require("../../../../components/layout/FormFooter.vue")
|
|
30
|
+
.default,
|
|
31
|
+
VelBasic: require("../../../../components/form/basic.vue").default,
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
props: {
|
|
35
|
+
form: {
|
|
36
|
+
required: true,
|
|
37
|
+
type: Object,
|
|
38
|
+
},
|
|
39
|
+
submit: {
|
|
40
|
+
required: true,
|
|
41
|
+
type: Function,
|
|
42
|
+
},
|
|
43
|
+
method: {
|
|
44
|
+
type: String,
|
|
45
|
+
default: "post",
|
|
46
|
+
},
|
|
47
|
+
resource: {
|
|
48
|
+
required: true,
|
|
49
|
+
type: Object,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
</script>
|