@fishawack/lab-velocity 2.0.0-beta.2 → 2.0.0-beta.21
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 +439 -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} +5 -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 +9 -7
- 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} +19 -17
- package/_Build/vue/{modules/AuthModule/components/VTableSorter.vue → components/layout/TableSorter.vue} +35 -25
- 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 +21 -89
- package/_Build/vue/modules/AuthModule/js/store.js +15 -6
- package/_Build/vue/modules/AuthModule/{adminRoutes/PCompanies/Children/partials → routes/PCompanies}/form.vue +32 -17
- package/_Build/vue/modules/AuthModule/routes/PCompanies/resource.js +168 -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 +202 -0
- package/_Build/vue/modules/AuthModule/routes/account-exists.vue +3 -3
- 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 +6 -6
- package/_Build/vue/modules/AuthModule/routes/expired-verification.vue +11 -10
- package/_Build/vue/modules/AuthModule/routes/force-reset.vue +24 -28
- package/_Build/vue/modules/AuthModule/routes/forgot.vue +6 -6
- package/_Build/vue/modules/AuthModule/routes/login.vue +9 -13
- package/_Build/vue/modules/AuthModule/routes/logincallback.vue +2 -4
- package/_Build/vue/modules/AuthModule/routes/loginsso.vue +9 -11
- 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 +10 -9
- package/_Build/vue/modules/AuthModule/routes/success-reset.vue +3 -3
- package/_Build/vue/modules/AuthModule/routes/success-verify.vue +2 -4
- package/_Build/vue/modules/AuthModule/routes/verify.vue +13 -16
- package/_Build/vue/modules/resource/Children/create.vue +76 -0
- package/_Build/vue/modules/resource/Children/edit.vue +110 -0
- package/_Build/vue/modules/resource/Children/index.vue +47 -0
- package/_Build/vue/modules/resource/Children/partials/form.vue +57 -0
- package/_Build/vue/modules/resource/Children/show.vue +97 -0
- package/_Build/vue/modules/resource/index.js +280 -0
- package/_Build/vue/modules/resource/parent.vue +41 -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 +7 -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,110 @@
|
|
|
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
|
+
:model="model"
|
|
22
|
+
/>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script>
|
|
29
|
+
import Form from "form-backend-validation";
|
|
30
|
+
|
|
31
|
+
export default {
|
|
32
|
+
components: {
|
|
33
|
+
VBreadcrumbs: require("../../../components/layout/Breadcrumbs.vue")
|
|
34
|
+
.default,
|
|
35
|
+
XForm: require("./partials/form.vue").default,
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
props: {
|
|
39
|
+
breadcrumbs: {
|
|
40
|
+
type: Array,
|
|
41
|
+
required: true,
|
|
42
|
+
},
|
|
43
|
+
resource: {
|
|
44
|
+
type: Object,
|
|
45
|
+
required: true,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
data() {
|
|
50
|
+
return {
|
|
51
|
+
form: null,
|
|
52
|
+
model: null,
|
|
53
|
+
addBreadcrumbs: [...this.$props.breadcrumbs],
|
|
54
|
+
method: "patch",
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
beforeMount() {
|
|
59
|
+
this.form = new Form(this.resource.form.fields(this), {
|
|
60
|
+
resetOnSuccess: false,
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
async mounted() {
|
|
65
|
+
window.axios
|
|
66
|
+
.get(
|
|
67
|
+
`${this.resource.api}/${this.$route.params.id}?${this.resource.defaults}`,
|
|
68
|
+
)
|
|
69
|
+
.then((res) => {
|
|
70
|
+
this.model = res.data.data;
|
|
71
|
+
|
|
72
|
+
// Set initial form data
|
|
73
|
+
Object.entries(this.resource.form.fields(this)).forEach(
|
|
74
|
+
([key, value]) => {
|
|
75
|
+
this.form[key] = value;
|
|
76
|
+
},
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
this.addBreadcrumbs.push({
|
|
80
|
+
href: {
|
|
81
|
+
name: `${this.resource.slug}.show`,
|
|
82
|
+
param: this.model.id,
|
|
83
|
+
},
|
|
84
|
+
text: this.model.name,
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
methods: {
|
|
90
|
+
async submit() {
|
|
91
|
+
if (this.resource.form.submit) {
|
|
92
|
+
await this.resource.form.submit(this);
|
|
93
|
+
} else {
|
|
94
|
+
try {
|
|
95
|
+
let res = await this.form.patch(
|
|
96
|
+
`${this.resource.api}/${this.model.id}`,
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
this.$router.replace({
|
|
100
|
+
name: `${this.resource.slug}.show`,
|
|
101
|
+
params: { id: res.data.id },
|
|
102
|
+
});
|
|
103
|
+
} catch (e) {
|
|
104
|
+
console.log(e);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
</script>
|
|
@@ -0,0 +1,47 @@
|
|
|
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="(render, index) in resource.index.actions"
|
|
13
|
+
:key="index"
|
|
14
|
+
>
|
|
15
|
+
<component :is="render(this)" />
|
|
16
|
+
</template>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<template
|
|
20
|
+
v-for="(render, index) in resource.index.layout"
|
|
21
|
+
:key="index"
|
|
22
|
+
>
|
|
23
|
+
<component :is="render(this)" />
|
|
24
|
+
</template>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<script>
|
|
30
|
+
export default {
|
|
31
|
+
components: {
|
|
32
|
+
VBreadcrumbs: require("../../../components/layout/Breadcrumbs.vue")
|
|
33
|
+
.default,
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
props: {
|
|
37
|
+
breadcrumbs: {
|
|
38
|
+
type: Array,
|
|
39
|
+
required: true,
|
|
40
|
+
},
|
|
41
|
+
resource: {
|
|
42
|
+
type: Object,
|
|
43
|
+
required: true,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
</script>
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
model: {
|
|
52
|
+
type: Object,
|
|
53
|
+
default: null,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
</script>
|
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
<template v-if="model">
|
|
11
|
+
<div class="bg-0 p-3 box-shadow-1 border-r-4 mb-6">
|
|
12
|
+
<VelPageHeader
|
|
13
|
+
:icon="resource.icon"
|
|
14
|
+
:title="`${model.name} ${model.last_name ?? ''}`"
|
|
15
|
+
>
|
|
16
|
+
<template
|
|
17
|
+
v-for="(render, index) in resource.show.actions"
|
|
18
|
+
:key="index"
|
|
19
|
+
>
|
|
20
|
+
<component :is="render(this)" />
|
|
21
|
+
</template>
|
|
22
|
+
</VelPageHeader>
|
|
23
|
+
|
|
24
|
+
<hr class="my-3 hr-muted" />
|
|
25
|
+
|
|
26
|
+
<template
|
|
27
|
+
v-for="(render, index) in resource.show.layout"
|
|
28
|
+
:key="index"
|
|
29
|
+
>
|
|
30
|
+
<component :is="render(this)" />
|
|
31
|
+
|
|
32
|
+
<hr
|
|
33
|
+
v-if="index < resource.show.layout.length - 1"
|
|
34
|
+
class="my-3 hr-muted"
|
|
35
|
+
/>
|
|
36
|
+
</template>
|
|
37
|
+
</div>
|
|
38
|
+
</template>
|
|
39
|
+
|
|
40
|
+
<div v-else class="absolute transform-center text-center">
|
|
41
|
+
<VelSpinner />
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
</template>
|
|
46
|
+
|
|
47
|
+
<script>
|
|
48
|
+
import axios from "axios";
|
|
49
|
+
import VelSpinner from "../../../components/form/Spinner.vue";
|
|
50
|
+
import VelButton from "../../../components/basic/Button.vue";
|
|
51
|
+
|
|
52
|
+
export default {
|
|
53
|
+
components: {
|
|
54
|
+
VBreadcrumbs: require("../../../components/layout/Breadcrumbs.vue")
|
|
55
|
+
.default,
|
|
56
|
+
VelPageHeader: require("../../../components/layout/PageHeader.vue")
|
|
57
|
+
.default,
|
|
58
|
+
VelSpinner,
|
|
59
|
+
VelButton,
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
props: {
|
|
63
|
+
breadcrumbs: {
|
|
64
|
+
type: Array,
|
|
65
|
+
required: true,
|
|
66
|
+
},
|
|
67
|
+
resource: {
|
|
68
|
+
type: Object,
|
|
69
|
+
required: true,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
data() {
|
|
74
|
+
return {
|
|
75
|
+
model: null,
|
|
76
|
+
addBreadcrumbs: [...this.$props.breadcrumbs],
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
mounted() {
|
|
81
|
+
axios
|
|
82
|
+
.get(
|
|
83
|
+
`${this.resource.api}/${this.$route.params.id}?${this.resource.defaults}`,
|
|
84
|
+
)
|
|
85
|
+
.then((res) => {
|
|
86
|
+
this.model = res.data.data;
|
|
87
|
+
this.addBreadcrumbs.push({
|
|
88
|
+
href: {
|
|
89
|
+
name: `${this.resource.slug}.show`,
|
|
90
|
+
param: this.model.id,
|
|
91
|
+
},
|
|
92
|
+
text: this.model.name,
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
</script>
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { merge, kebabCase } from "lodash";
|
|
4
|
+
import axios from "axios";
|
|
5
|
+
import { h, resolveComponent } from "vue";
|
|
6
|
+
|
|
7
|
+
import VTableSorter from "../../components/layout/TableSorter.vue";
|
|
8
|
+
import { ElDescriptions, ElDescriptionsItem, ElPopconfirm } from "element-plus";
|
|
9
|
+
import VelButton from "../../components/basic/Button.vue";
|
|
10
|
+
|
|
11
|
+
export const defaultResource = meta();
|
|
12
|
+
|
|
13
|
+
export function meta(name = "default", properties = {}) {
|
|
14
|
+
const singular = properties.singular || name.slice(0, -1);
|
|
15
|
+
|
|
16
|
+
return merge(
|
|
17
|
+
{
|
|
18
|
+
name,
|
|
19
|
+
title: properties.title || name[0].toUpperCase() + name.slice(1),
|
|
20
|
+
singular,
|
|
21
|
+
label: singular,
|
|
22
|
+
multiLabel: name,
|
|
23
|
+
slug: properties?.slug || kebabCase(name),
|
|
24
|
+
api: `/api/${properties?.slug || kebabCase(name)}`,
|
|
25
|
+
permissions: {
|
|
26
|
+
create: () => true,
|
|
27
|
+
edit: () => true,
|
|
28
|
+
delete: () => false,
|
|
29
|
+
},
|
|
30
|
+
searchable: {
|
|
31
|
+
value: "name",
|
|
32
|
+
label: `Search ${name}`,
|
|
33
|
+
},
|
|
34
|
+
form: {
|
|
35
|
+
component: null,
|
|
36
|
+
fields: () => ({}),
|
|
37
|
+
structure: [],
|
|
38
|
+
},
|
|
39
|
+
table: {
|
|
40
|
+
structure: [
|
|
41
|
+
{
|
|
42
|
+
key: "id",
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
description: {
|
|
47
|
+
structure: [
|
|
48
|
+
{
|
|
49
|
+
key: "id",
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
index: {
|
|
54
|
+
actions: [],
|
|
55
|
+
layout: [
|
|
56
|
+
(props) => {
|
|
57
|
+
const { resource } = props;
|
|
58
|
+
|
|
59
|
+
return h(VTableSorter, {
|
|
60
|
+
key: "PIndex",
|
|
61
|
+
"json-data": {
|
|
62
|
+
...resource,
|
|
63
|
+
tableStructure: resource.table.structure,
|
|
64
|
+
},
|
|
65
|
+
defaults: resource.defaults,
|
|
66
|
+
"fixed-height": false,
|
|
67
|
+
"display-edit-action":
|
|
68
|
+
resource.permissions.create(props),
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
show: {
|
|
74
|
+
actions: [
|
|
75
|
+
(props) => {
|
|
76
|
+
const { resource, model, $router } = props;
|
|
77
|
+
|
|
78
|
+
if (resource.permissions.edit(props)) {
|
|
79
|
+
return h(
|
|
80
|
+
VelButton,
|
|
81
|
+
{
|
|
82
|
+
tag: "a",
|
|
83
|
+
type: "primary",
|
|
84
|
+
onClick: () => {
|
|
85
|
+
$router.push({
|
|
86
|
+
name: `${resource.slug}.edit`,
|
|
87
|
+
params: { id: model.id },
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
() => [
|
|
92
|
+
h(resolveComponent("GIcon"), {
|
|
93
|
+
class: "fill-0 mr-0.5 icon--0.5",
|
|
94
|
+
name: "icon-edit",
|
|
95
|
+
embed: true,
|
|
96
|
+
artboard: true,
|
|
97
|
+
}),
|
|
98
|
+
`Edit ${resource.singular}`,
|
|
99
|
+
],
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
(props) => {
|
|
104
|
+
const { resource, model, $router } = props;
|
|
105
|
+
|
|
106
|
+
if (resource.permissions.delete(props)) {
|
|
107
|
+
return h(
|
|
108
|
+
ElPopconfirm,
|
|
109
|
+
{
|
|
110
|
+
title: `Are you sure you want to delete this ${resource.singular}?`,
|
|
111
|
+
confirmButtonText: "Delete",
|
|
112
|
+
cancelButtonText: "Cancel",
|
|
113
|
+
confirmButtonType: "danger",
|
|
114
|
+
onConfirm: async () => {
|
|
115
|
+
await axios.delete(
|
|
116
|
+
`${resource.api}/${model.id}`,
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
$router.push({
|
|
120
|
+
name: `${resource.slug}.index`,
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
reference: () =>
|
|
126
|
+
h(
|
|
127
|
+
VelButton,
|
|
128
|
+
{
|
|
129
|
+
tag: "a",
|
|
130
|
+
type: "danger",
|
|
131
|
+
},
|
|
132
|
+
() => [
|
|
133
|
+
h(resolveComponent("GIcon"), {
|
|
134
|
+
class: "fill-0 mr-0.5 icon--0.5",
|
|
135
|
+
name: "icon-trash",
|
|
136
|
+
embed: true,
|
|
137
|
+
artboard: true,
|
|
138
|
+
}),
|
|
139
|
+
`Delete ${resource.singular}`,
|
|
140
|
+
],
|
|
141
|
+
),
|
|
142
|
+
},
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
layout: [
|
|
148
|
+
(props) => {
|
|
149
|
+
const { resource, model } = props;
|
|
150
|
+
|
|
151
|
+
return h(
|
|
152
|
+
ElDescriptions,
|
|
153
|
+
{
|
|
154
|
+
border: true,
|
|
155
|
+
column: 1,
|
|
156
|
+
},
|
|
157
|
+
() =>
|
|
158
|
+
resource.description.structure.map(
|
|
159
|
+
(item, index) =>
|
|
160
|
+
h(
|
|
161
|
+
ElDescriptionsItem,
|
|
162
|
+
{
|
|
163
|
+
key: index,
|
|
164
|
+
labelWidth: "20%",
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
label: () =>
|
|
168
|
+
item.label ||
|
|
169
|
+
item.key[0].toUpperCase() +
|
|
170
|
+
item.key.slice(1),
|
|
171
|
+
default: () =>
|
|
172
|
+
item.render
|
|
173
|
+
? h(item.render(props))
|
|
174
|
+
: model?.[item.key] ||
|
|
175
|
+
"",
|
|
176
|
+
},
|
|
177
|
+
),
|
|
178
|
+
),
|
|
179
|
+
);
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
},
|
|
183
|
+
defaults: "",
|
|
184
|
+
icon: `icon-${singular}`,
|
|
185
|
+
},
|
|
186
|
+
properties,
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export function columns(columns = []) {
|
|
191
|
+
return {
|
|
192
|
+
table: {
|
|
193
|
+
structure: columns
|
|
194
|
+
.filter((column) => !column.filter?.table)
|
|
195
|
+
.map((column) => ({
|
|
196
|
+
...column,
|
|
197
|
+
render: column.render?.read || column.render?.table,
|
|
198
|
+
})),
|
|
199
|
+
},
|
|
200
|
+
description: {
|
|
201
|
+
structure: columns
|
|
202
|
+
.filter((column) => !column.filter?.description)
|
|
203
|
+
.map((column) => ({
|
|
204
|
+
...column,
|
|
205
|
+
render: column.render?.read || column.render?.description,
|
|
206
|
+
})),
|
|
207
|
+
},
|
|
208
|
+
form: {
|
|
209
|
+
fields: (props) =>
|
|
210
|
+
columns
|
|
211
|
+
.filter((column) => !column.filter?.form)
|
|
212
|
+
.reduce((fields, column) => {
|
|
213
|
+
fields[column.key] = column.initial
|
|
214
|
+
? column.initial(props)
|
|
215
|
+
: (props.model?.[column.key] ?? null);
|
|
216
|
+
return fields;
|
|
217
|
+
}, {}),
|
|
218
|
+
structure: columns
|
|
219
|
+
.filter((column) => !column.filter?.form)
|
|
220
|
+
.map((column) => ({
|
|
221
|
+
...column,
|
|
222
|
+
render: column.render?.write || column.render?.form,
|
|
223
|
+
})),
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// Export resource
|
|
229
|
+
export function routes(node, name, properties = {}) {
|
|
230
|
+
const resource = meta(name, properties);
|
|
231
|
+
|
|
232
|
+
return [
|
|
233
|
+
{
|
|
234
|
+
path: `/${resource.slug}`,
|
|
235
|
+
component: node ? "" : require("../resource/parent.vue").default,
|
|
236
|
+
name,
|
|
237
|
+
meta: {
|
|
238
|
+
resource,
|
|
239
|
+
title: resource.title,
|
|
240
|
+
icon: resource.icon,
|
|
241
|
+
},
|
|
242
|
+
children: [
|
|
243
|
+
{
|
|
244
|
+
path: "",
|
|
245
|
+
component: node
|
|
246
|
+
? ""
|
|
247
|
+
: require("../resource/Children/index.vue").default,
|
|
248
|
+
name: `${resource.slug}.index`,
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
path: "create",
|
|
252
|
+
component: node
|
|
253
|
+
? ""
|
|
254
|
+
: require("../resource/Children/create.vue").default,
|
|
255
|
+
name: `${resource.slug}.create`,
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
path: ":id",
|
|
259
|
+
component: node
|
|
260
|
+
? ""
|
|
261
|
+
: require("../resource/Children/show.vue").default,
|
|
262
|
+
name: `${resource.slug}.show`,
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
path: ":id/edit",
|
|
266
|
+
component: node
|
|
267
|
+
? ""
|
|
268
|
+
: require("../resource/Children/edit.vue").default,
|
|
269
|
+
name: `${resource.slug}.edit`,
|
|
270
|
+
},
|
|
271
|
+
],
|
|
272
|
+
},
|
|
273
|
+
];
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export default {
|
|
277
|
+
routes,
|
|
278
|
+
meta,
|
|
279
|
+
columns,
|
|
280
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<PageTitle :title="resource.title" />
|
|
3
|
+
|
|
4
|
+
<router-view
|
|
5
|
+
:key="$route.path"
|
|
6
|
+
:breadcrumbs="breadcrumbs"
|
|
7
|
+
:resource="resource"
|
|
8
|
+
/>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script>
|
|
12
|
+
import PageTitle from "../../components/layout/pageTitle.vue";
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
components: {
|
|
16
|
+
PageTitle,
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
computed: {
|
|
20
|
+
resource() {
|
|
21
|
+
return this.$route.meta.resource;
|
|
22
|
+
},
|
|
23
|
+
breadcrumbs() {
|
|
24
|
+
return [
|
|
25
|
+
{
|
|
26
|
+
href: {
|
|
27
|
+
name: "index",
|
|
28
|
+
},
|
|
29
|
+
text: "Home",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
href: {
|
|
33
|
+
name: `${this.resource.slug}.index`,
|
|
34
|
+
},
|
|
35
|
+
text: this.resource.title,
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
</script>
|
package/_base.scss
CHANGED
package/_defaults.scss
CHANGED
|
@@ -5,16 +5,5 @@
|
|
|
5
5
|
$colors: variables.dynamic("color", module-variables("variables"));
|
|
6
6
|
|
|
7
7
|
// Override lab-ui defaults here, e.g $button: $color6;
|
|
8
|
-
$
|
|
9
|
-
|
|
10
|
-
margin-left: 0;
|
|
11
|
-
padding: 0px 5 * $spacing;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
body {
|
|
15
|
-
font-family: $primaryFont, sans-serif;
|
|
16
|
-
font-size: get-ratio(16px);
|
|
17
|
-
line-height: 1.5;
|
|
18
|
-
color: $color1;
|
|
19
|
-
background-color: $color3;
|
|
20
|
-
}
|
|
8
|
+
$fontColor: $color1;
|
|
9
|
+
$fontFamily: $primaryFont, sans-serif;
|
package/_variables.scss
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
@import "@fishawack/lab-ui/_variables.scss";
|
|
2
|
-
// Set global variables here, e.g $color6: red;
|
|
3
|
-
@import "./modules/AuthVariables";
|
|
4
2
|
|
|
3
|
+
// Set global variables here, e.g $color6: red;
|
|
5
4
|
$primaryFont: "Inter";
|
|
6
5
|
$primaryFontThin: "Inter-Thin";
|
|
7
6
|
$primaryFontExtraLight: "Inter-ExtraLight";
|
|
@@ -10,11 +9,10 @@ $primaryFontRegular: "Inter-Regular";
|
|
|
10
9
|
$primaryFontMedium: "Inter-Medium";
|
|
11
10
|
$primaryFontSemiBold: "Inter-SemiBold";
|
|
12
11
|
$primaryFontBold: "Inter-Bold";
|
|
13
|
-
|
|
14
12
|
$secondaryFont: "NotoSerif";
|
|
15
13
|
$secondaryFontMedium: "NotoSerif-Medium";
|
|
16
|
-
// Colors
|
|
17
14
|
|
|
15
|
+
// Colors
|
|
18
16
|
$color1: #2d2d2d;
|
|
19
17
|
$color2: #333333;
|
|
20
18
|
$color3: #f7f7f7;
|
|
@@ -29,3 +27,10 @@ $color11: #8c8c8c; //Used
|
|
|
29
27
|
$color12: #5c5c5c;
|
|
30
28
|
$color13: #3c976e;
|
|
31
29
|
$colorAlert: #d53a3a;
|
|
30
|
+
|
|
31
|
+
// Spacing
|
|
32
|
+
$spacing: 8px;
|
|
33
|
+
|
|
34
|
+
// Auth
|
|
35
|
+
$am-spacing: 8px;
|
|
36
|
+
$am-highlight: #3c976e;
|