@fishawack/lab-velocity 2.0.0-beta.5 → 2.0.0-beta.51
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 +467 -36
- package/_Build/js/libs/build-id.js +14 -0
- package/_Build/js/libs/filters.js +36 -0
- package/_Build/js/libs/globals.js +7 -0
- package/_Build/js/libs/router.js +22 -0
- package/_Build/js/libs/routes.js +29 -0
- package/_Build/js/libs/store.js +21 -0
- package/_Build/js/libs/utility.js +161 -0
- package/_Build/vue/components/basic/Button.vue +1 -1
- package/_Build/vue/components/form/Avatar.vue +90 -0
- package/_Build/vue/components/form/Checkbox.vue +10 -0
- package/_Build/vue/components/form/InputNumber.vue +1 -1
- package/_Build/vue/components/form/Select.vue +223 -33
- package/_Build/vue/components/form/Spinner.vue +5 -0
- package/_Build/vue/components/layout/Alert.vue +5 -5
- package/_Build/vue/components/layout/Audit.vue +143 -0
- 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 +94 -0
- package/_Build/vue/components/layout/Navigation.vue +77 -0
- package/_Build/vue/{modules/AuthModule/components/VPageHeader.vue → components/layout/PageHeader.vue} +14 -8
- package/_Build/vue/components/layout/SideBar.vue +26 -0
- package/_Build/vue/{modules/AuthModule/components/VTable.vue → components/layout/Table.vue} +37 -16
- package/_Build/vue/{modules/AuthModule/components/VTableSorter.vue → components/layout/TableSorter.vue} +108 -52
- package/_Build/vue/components/layout/TokenDisplay.vue +52 -0
- 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 +21 -1
- package/_Build/vue/modules/AuthModule/js/clear-cookies.js +33 -0
- package/_Build/vue/modules/AuthModule/js/guest-request.js +32 -0
- package/_Build/vue/modules/AuthModule/js/impersonation-banner.js +102 -0
- package/_Build/vue/modules/AuthModule/js/router.js +91 -114
- package/_Build/vue/modules/AuthModule/js/store.js +23 -6
- package/_Build/vue/modules/AuthModule/routes/PCompanies/columns.js +268 -0
- package/_Build/vue/modules/AuthModule/routes/PCompanies/resource.js +213 -0
- package/_Build/vue/modules/AuthModule/routes/PIntegrations/columns.js +58 -0
- package/_Build/vue/modules/AuthModule/routes/PIntegrations/resource.js +79 -0
- package/_Build/vue/modules/AuthModule/routes/PTeams/columns.js +78 -0
- package/_Build/vue/modules/AuthModule/routes/PTeams/resource.js +251 -0
- package/_Build/vue/modules/AuthModule/routes/PUsers/SetPasswordAction.vue +51 -0
- package/_Build/vue/modules/AuthModule/routes/PUsers/SetPasswordDialog.vue +138 -0
- package/_Build/vue/modules/AuthModule/routes/PUsers/columns.js +349 -0
- package/_Build/vue/modules/AuthModule/routes/PUsers/resource.js +239 -0
- package/_Build/vue/modules/AuthModule/routes/account-exists.vue +2 -2
- package/_Build/vue/modules/AuthModule/routes/change-password.vue +28 -32
- 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 +10 -9
- package/_Build/vue/modules/AuthModule/routes/force-reset.vue +44 -58
- package/_Build/vue/modules/AuthModule/routes/forgot.vue +10 -5
- package/_Build/vue/modules/AuthModule/routes/login.vue +12 -19
- package/_Build/vue/modules/AuthModule/routes/logincallback.vue +1 -3
- package/_Build/vue/modules/AuthModule/routes/loginsso.vue +14 -10
- package/_Build/vue/modules/AuthModule/routes/logout.vue +14 -5
- package/_Build/vue/modules/AuthModule/routes/logoutheadless.vue +5 -3
- package/_Build/vue/modules/AuthModule/routes/register.vue +24 -28
- package/_Build/vue/modules/AuthModule/routes/reset.vue +20 -14
- package/_Build/vue/modules/AuthModule/routes/success-forgot.vue +14 -8
- 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 +81 -0
- package/_Build/vue/modules/resource/Children/edit.vue +106 -0
- package/_Build/vue/modules/resource/Children/index.vue +42 -0
- package/_Build/vue/modules/resource/Children/partials/form.vue +111 -0
- package/_Build/vue/modules/resource/Children/show.vue +166 -0
- package/_Build/vue/modules/resource/index.js +561 -0
- package/_Build/vue/modules/resource/parent.vue +63 -0
- package/_Build/vue/modules/resource/trashable.js +104 -0
- package/_base.scss +0 -1
- package/_defaults.scss +2 -13
- package/_variables.scss +9 -4
- package/{modules/_AuthModule.scss → components/_auth.scss} +19 -68
- package/components/_datepicker.scss +1 -0
- package/components/_descriptions.scss +2 -0
- package/components/_footer.scss +1 -0
- package/components/_form.scss +18 -0
- package/components/_header.scss +3 -27
- package/components/_layout.scss +56 -0
- package/components/_menu.scss +0 -5
- package/components/_sidebar.scss +12 -27
- package/components/_table.scss +3 -0
- package/components/_token-display.scss +41 -0
- package/general.scss +1 -0
- package/index.js +31 -1
- package/package.json +6 -4
- 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/partials/form.vue +0 -173
- 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/partials/form.vue +0 -169
- package/_Build/vue/modules/AuthModule/adminRoutes/PUsers/Children/show.vue +0 -120
- package/_Build/vue/modules/AuthModule/adminRoutes/PUsers/parent.vue +0 -36
- package/components/_input.scss +0 -0
- package/modules/_AuthVariables.scss +0 -7
- /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
- /package/{modules → components}/_modal.scss +0 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { merge } from "lodash";
|
|
2
|
+
import { h, resolveComponent } from "vue";
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
import { ElNotification } from "element-plus";
|
|
5
|
+
|
|
6
|
+
import { columns, defaultResource, meta } from "../../../resource/index.js";
|
|
7
|
+
import companiesColumns from "./columns.js";
|
|
8
|
+
|
|
9
|
+
import VelFormRole from "../../../../components/layout/FormRole.vue";
|
|
10
|
+
import VelButton from "../../../../components/basic/Button.vue";
|
|
11
|
+
import VelTableSorter from "../../../../components/layout/TableSorter.vue";
|
|
12
|
+
import VelRoleLegend from "../../../../components/layout/RoleLegend.vue";
|
|
13
|
+
|
|
14
|
+
import userResource from "../PUsers/resource.js";
|
|
15
|
+
import teamResource from "../PTeams/resource.js";
|
|
16
|
+
|
|
17
|
+
export default [
|
|
18
|
+
"companies",
|
|
19
|
+
{
|
|
20
|
+
api: {
|
|
21
|
+
params: {
|
|
22
|
+
index: () => ({}),
|
|
23
|
+
show: () => ({
|
|
24
|
+
include: "primary_contact",
|
|
25
|
+
}),
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
permissions: {
|
|
29
|
+
create: ({ $store }) => $store.getters.can("write companies"),
|
|
30
|
+
edit: ({ $store }) => $store.getters.can("write companies"),
|
|
31
|
+
delete: ({ $store }) => $store.getters.can("delete companies"),
|
|
32
|
+
},
|
|
33
|
+
singular: "company",
|
|
34
|
+
icon: "icon-cases",
|
|
35
|
+
auditable: true,
|
|
36
|
+
trashable: true,
|
|
37
|
+
...merge(columns(companiesColumns), {
|
|
38
|
+
index: {
|
|
39
|
+
layout: [
|
|
40
|
+
...defaultResource.index.layout,
|
|
41
|
+
() =>
|
|
42
|
+
h(VelRoleLegend, {
|
|
43
|
+
class: "mt-5",
|
|
44
|
+
}),
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
show: {
|
|
48
|
+
actions: [
|
|
49
|
+
({ model }) =>
|
|
50
|
+
model.primary_contact &&
|
|
51
|
+
h(
|
|
52
|
+
VelButton,
|
|
53
|
+
{
|
|
54
|
+
type: "primary",
|
|
55
|
+
async onClick() {
|
|
56
|
+
try {
|
|
57
|
+
const res = await axios.post(
|
|
58
|
+
`/api/companies/${model.id}/welcome`,
|
|
59
|
+
);
|
|
60
|
+
ElNotification({
|
|
61
|
+
title: "Success",
|
|
62
|
+
message: res.data.message,
|
|
63
|
+
type: "success",
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
model.primary_contact_contacted = true;
|
|
67
|
+
} catch (e) {
|
|
68
|
+
ElNotification({
|
|
69
|
+
title: "Warning",
|
|
70
|
+
message:
|
|
71
|
+
e.response?.data?.message ||
|
|
72
|
+
e.message,
|
|
73
|
+
type: "warning",
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
"Send welcome email",
|
|
79
|
+
),
|
|
80
|
+
...defaultResource.show.actions,
|
|
81
|
+
],
|
|
82
|
+
tabs: [
|
|
83
|
+
...defaultResource.show.tabs,
|
|
84
|
+
({ model }) => ({
|
|
85
|
+
label: "Access control",
|
|
86
|
+
component: h(VelFormRole, {
|
|
87
|
+
overrides: model.overrides_roles_and_permissions,
|
|
88
|
+
form: { roles: model.roles.map((d) => d.id) },
|
|
89
|
+
readonly: true,
|
|
90
|
+
}),
|
|
91
|
+
}),
|
|
92
|
+
({ model, $store, $router, $route, ...rest }) => {
|
|
93
|
+
const resource = meta(...teamResource);
|
|
94
|
+
|
|
95
|
+
const props = {
|
|
96
|
+
model,
|
|
97
|
+
$store,
|
|
98
|
+
$router,
|
|
99
|
+
$route,
|
|
100
|
+
...rest,
|
|
101
|
+
resource,
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
label: "Teams",
|
|
106
|
+
component: h("div", [
|
|
107
|
+
h(
|
|
108
|
+
"div",
|
|
109
|
+
{ class: "flex justify-end items-end" },
|
|
110
|
+
[
|
|
111
|
+
resource.permissions.create(props) &&
|
|
112
|
+
h(
|
|
113
|
+
VelButton,
|
|
114
|
+
{
|
|
115
|
+
tag: "a",
|
|
116
|
+
type: "primary",
|
|
117
|
+
size: "large",
|
|
118
|
+
onClick: () => {
|
|
119
|
+
$router.push({
|
|
120
|
+
name: `companies.${resource.routeName}.create`,
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
() => [
|
|
125
|
+
h(
|
|
126
|
+
resolveComponent(
|
|
127
|
+
"GIcon",
|
|
128
|
+
),
|
|
129
|
+
{
|
|
130
|
+
class: "fill-0 mr-0.5 icon--0.5",
|
|
131
|
+
name: "icon-plus",
|
|
132
|
+
embed: true,
|
|
133
|
+
artboard: true,
|
|
134
|
+
},
|
|
135
|
+
),
|
|
136
|
+
`Create ${resource.singular}`,
|
|
137
|
+
],
|
|
138
|
+
),
|
|
139
|
+
],
|
|
140
|
+
),
|
|
141
|
+
h(
|
|
142
|
+
VelTableSorter,
|
|
143
|
+
resource.index.structure(props),
|
|
144
|
+
),
|
|
145
|
+
]),
|
|
146
|
+
};
|
|
147
|
+
},
|
|
148
|
+
({ model, $store, $router, $route, ...rest }) => {
|
|
149
|
+
const resource = meta(...userResource);
|
|
150
|
+
|
|
151
|
+
resource.api.params.index = ({ $route }) => ({
|
|
152
|
+
include: "company",
|
|
153
|
+
"filter[company_id]": $route.params.companiesId,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
const props = {
|
|
157
|
+
model,
|
|
158
|
+
$store,
|
|
159
|
+
$router,
|
|
160
|
+
$route,
|
|
161
|
+
...rest,
|
|
162
|
+
resource,
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
return {
|
|
166
|
+
label: "Users",
|
|
167
|
+
component: h("div", [
|
|
168
|
+
h(
|
|
169
|
+
"div",
|
|
170
|
+
{ class: "flex justify-end items-end" },
|
|
171
|
+
[
|
|
172
|
+
resource.permissions.create(props) &&
|
|
173
|
+
h(
|
|
174
|
+
VelButton,
|
|
175
|
+
{
|
|
176
|
+
tag: "a",
|
|
177
|
+
type: "primary",
|
|
178
|
+
size: "large",
|
|
179
|
+
onClick: () => {
|
|
180
|
+
$router.push({
|
|
181
|
+
name: `${resource.slug}.create`,
|
|
182
|
+
});
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
() => [
|
|
186
|
+
h(
|
|
187
|
+
resolveComponent(
|
|
188
|
+
"GIcon",
|
|
189
|
+
),
|
|
190
|
+
{
|
|
191
|
+
class: "fill-0 mr-0.5 icon--0.5",
|
|
192
|
+
name: "icon-plus",
|
|
193
|
+
embed: true,
|
|
194
|
+
artboard: true,
|
|
195
|
+
},
|
|
196
|
+
),
|
|
197
|
+
`Create ${resource.singular}`,
|
|
198
|
+
],
|
|
199
|
+
),
|
|
200
|
+
],
|
|
201
|
+
),
|
|
202
|
+
h(
|
|
203
|
+
VelTableSorter,
|
|
204
|
+
resource.index.structure(props),
|
|
205
|
+
),
|
|
206
|
+
]),
|
|
207
|
+
};
|
|
208
|
+
},
|
|
209
|
+
],
|
|
210
|
+
},
|
|
211
|
+
}),
|
|
212
|
+
},
|
|
213
|
+
];
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { h } from "vue";
|
|
2
|
+
|
|
3
|
+
import VelSelect from "../../../../components/form/Select.vue";
|
|
4
|
+
|
|
5
|
+
export default [
|
|
6
|
+
{
|
|
7
|
+
key: "name",
|
|
8
|
+
sortable: true,
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
key: "scopes",
|
|
12
|
+
endpoint: "api/scopes",
|
|
13
|
+
labelKey: "description",
|
|
14
|
+
filterable: true,
|
|
15
|
+
clearable: true,
|
|
16
|
+
multiple: true,
|
|
17
|
+
initial: (props) =>
|
|
18
|
+
props.model?.client?.scopes?.map((id) => ({
|
|
19
|
+
id,
|
|
20
|
+
description: id,
|
|
21
|
+
})) ?? [],
|
|
22
|
+
preparation: ({ form }) => form.scopes.map((d) => d.id),
|
|
23
|
+
render: {
|
|
24
|
+
read: ({ model }) => h("span", model.client?.scopes.join(", ")),
|
|
25
|
+
write: () => h(VelSelect),
|
|
26
|
+
},
|
|
27
|
+
condition: {
|
|
28
|
+
table: false,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
key: "client_id",
|
|
33
|
+
label: "Client ID",
|
|
34
|
+
condition: {
|
|
35
|
+
form: false,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
key: "user_id",
|
|
40
|
+
label: "Created by",
|
|
41
|
+
render: {
|
|
42
|
+
read: ({ model }) => h("span", model?.user?.name ?? "System"),
|
|
43
|
+
},
|
|
44
|
+
condition: {
|
|
45
|
+
form: false,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
key: "access_logs_count",
|
|
50
|
+
label: "API Calls",
|
|
51
|
+
render: {
|
|
52
|
+
read: ({ model }) => h("span", model?.access_logs_count ?? 0),
|
|
53
|
+
},
|
|
54
|
+
condition: {
|
|
55
|
+
form: false,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
];
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { merge } from "lodash";
|
|
2
|
+
import { h, ref } from "vue";
|
|
3
|
+
|
|
4
|
+
import { columns, defaultResource } from "../../../resource/index.js";
|
|
5
|
+
import integrationsColumns from "./columns.js";
|
|
6
|
+
import TokenDisplay from "../../../../components/layout/TokenDisplay.vue";
|
|
7
|
+
|
|
8
|
+
const newToken = ref(null);
|
|
9
|
+
|
|
10
|
+
export default [
|
|
11
|
+
"integrations",
|
|
12
|
+
{
|
|
13
|
+
icon: `icon-keyboard-tab`,
|
|
14
|
+
api: {
|
|
15
|
+
params: {
|
|
16
|
+
index: () => ({ include: "user,client,accessLogsCount" }),
|
|
17
|
+
show: () => ({ include: "user,client,accessLogsCount" }),
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
searchable: {
|
|
21
|
+
value: "name",
|
|
22
|
+
},
|
|
23
|
+
permissions: {
|
|
24
|
+
create: ({ $store }) => $store.getters.can("write integrations"),
|
|
25
|
+
edit: ({ $store }) => $store.getters.can("write integrations"),
|
|
26
|
+
delete: ({ $store }) => $store.getters.can("delete integrations"),
|
|
27
|
+
},
|
|
28
|
+
...merge(columns(integrationsColumns), {
|
|
29
|
+
form: {
|
|
30
|
+
submit: async (props) => {
|
|
31
|
+
const { form, resource, $router, model } = props;
|
|
32
|
+
const hold = JSON.parse(JSON.stringify(form.data()));
|
|
33
|
+
const isEdit = !!model;
|
|
34
|
+
const endpoint = isEdit
|
|
35
|
+
? `${resource.api.endpoint(props)}/${model.id}`
|
|
36
|
+
: `${resource.api.endpoint(props)}`;
|
|
37
|
+
try {
|
|
38
|
+
form.populate(resource.form.preparation(props));
|
|
39
|
+
let res = await form.post(endpoint);
|
|
40
|
+
newToken.value = res.data.token;
|
|
41
|
+
await $router.replace({
|
|
42
|
+
name: `${resource.name}.show`,
|
|
43
|
+
params: {
|
|
44
|
+
integrationsId: res.data.id,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
} catch (e) {
|
|
48
|
+
console.log(e);
|
|
49
|
+
} finally {
|
|
50
|
+
if (
|
|
51
|
+
!form.successful ||
|
|
52
|
+
!form.__options.resetOnSuccess
|
|
53
|
+
) {
|
|
54
|
+
form.populate(hold);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
show: {
|
|
60
|
+
...defaultResource.show,
|
|
61
|
+
layout: [
|
|
62
|
+
...defaultResource.show.layout,
|
|
63
|
+
() =>
|
|
64
|
+
h({
|
|
65
|
+
setup: () => () => {
|
|
66
|
+
if (!newToken.value) return null;
|
|
67
|
+
return h(TokenDisplay, {
|
|
68
|
+
token: newToken.value,
|
|
69
|
+
onClose: () => {
|
|
70
|
+
newToken.value = null;
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
}),
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
}),
|
|
78
|
+
},
|
|
79
|
+
];
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { h } from "vue";
|
|
2
|
+
|
|
3
|
+
import VelSelect from "../../../../components/form/Select.vue";
|
|
4
|
+
import VelFormRole from "../../../../components/layout/FormRole.vue";
|
|
5
|
+
import Chip from "../../../../components/layout/Chip.vue";
|
|
6
|
+
import Chips from "../../../../components/layout/Chips.vue";
|
|
7
|
+
|
|
8
|
+
export default [
|
|
9
|
+
{
|
|
10
|
+
key: "name",
|
|
11
|
+
sortable: true,
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
key: "description",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
key: "company_id",
|
|
18
|
+
label: "Company",
|
|
19
|
+
endpoint: "api/companies",
|
|
20
|
+
labelKey: "name",
|
|
21
|
+
filterable: true,
|
|
22
|
+
searchParam: "name",
|
|
23
|
+
condition: {
|
|
24
|
+
form: {
|
|
25
|
+
write: ({ $route, model }) =>
|
|
26
|
+
!$route.params.companiesId && !model?.company,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
initial: ({ model, $route }) =>
|
|
30
|
+
model?.company ||
|
|
31
|
+
($route.params.companiesId && {
|
|
32
|
+
id: $route.params.companiesId,
|
|
33
|
+
}),
|
|
34
|
+
preparation: ({ form }) => form.company_id?.id,
|
|
35
|
+
render: {
|
|
36
|
+
read: ({ model }) => h("span", model.company.name),
|
|
37
|
+
write: () => h(VelSelect),
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
key: "user_count",
|
|
42
|
+
label: "Users",
|
|
43
|
+
condition: {
|
|
44
|
+
form: false,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
key: "roles",
|
|
49
|
+
initial: ({ model }) => model?.roles.map((val) => val.id) || [],
|
|
50
|
+
preparation: ({ form }) =>
|
|
51
|
+
form.roles?.map((d) => (typeof d === "object" ? d.value : d)),
|
|
52
|
+
render: {
|
|
53
|
+
read: ({ model }) =>
|
|
54
|
+
h(
|
|
55
|
+
!model.overrides_roles_and_permissions ||
|
|
56
|
+
model.roles.length === 1
|
|
57
|
+
? Chip
|
|
58
|
+
: Chips,
|
|
59
|
+
!model.overrides_roles_and_permissions
|
|
60
|
+
? {
|
|
61
|
+
name: "inherited",
|
|
62
|
+
label: "Inherited",
|
|
63
|
+
}
|
|
64
|
+
: model.roles.length === 1
|
|
65
|
+
? {
|
|
66
|
+
name: model.roles[0].name,
|
|
67
|
+
label: model.roles[0].label,
|
|
68
|
+
}
|
|
69
|
+
: { array: model.roles },
|
|
70
|
+
),
|
|
71
|
+
write: ({ model, form }) =>
|
|
72
|
+
h(VelFormRole, {
|
|
73
|
+
overrides: model?.overrides_roles_and_permissions,
|
|
74
|
+
form,
|
|
75
|
+
}),
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
];
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { merge } from "lodash";
|
|
2
|
+
import { h } from "vue";
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
import { throttle } from "lodash";
|
|
5
|
+
|
|
6
|
+
import { columns, defaultResource, meta } from "../../../resource/index.js";
|
|
7
|
+
import userResource from "../PUsers/resource.js";
|
|
8
|
+
import teamsColumns from "./columns.js";
|
|
9
|
+
|
|
10
|
+
import VelFormRole from "../../../../components/layout/FormRole.vue";
|
|
11
|
+
import VelRoleLegend from "../../../../components/layout/RoleLegend.vue";
|
|
12
|
+
import VelTableSorter from "../../../../components/layout/TableSorter.vue";
|
|
13
|
+
import VelButton from "../../../../components/basic/Button.vue";
|
|
14
|
+
import VelCheckbox from "../../../../components/form/Checkbox.vue";
|
|
15
|
+
|
|
16
|
+
export default [
|
|
17
|
+
"teams",
|
|
18
|
+
{
|
|
19
|
+
icon: `icon-account-circle`,
|
|
20
|
+
api: {
|
|
21
|
+
params: {
|
|
22
|
+
index: ({ $route }) => ({
|
|
23
|
+
include: "company",
|
|
24
|
+
"filter[company_id]": $route.params.companiesId,
|
|
25
|
+
}),
|
|
26
|
+
show: () => ({
|
|
27
|
+
include: "company",
|
|
28
|
+
}),
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
auditable: true,
|
|
32
|
+
trashable: true,
|
|
33
|
+
permissions: {
|
|
34
|
+
create: ({ $store }) => $store.getters.can("write teams"),
|
|
35
|
+
edit: ({ $store }) => $store.getters.can("write teams"),
|
|
36
|
+
delete: ({ $store }) => $store.getters.can("delete teams"),
|
|
37
|
+
},
|
|
38
|
+
...merge(columns(teamsColumns), {
|
|
39
|
+
index: {
|
|
40
|
+
layout: [
|
|
41
|
+
...defaultResource.index.layout,
|
|
42
|
+
() =>
|
|
43
|
+
h(VelRoleLegend, {
|
|
44
|
+
class: "mt-5",
|
|
45
|
+
}),
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
show: {
|
|
49
|
+
tabs: [
|
|
50
|
+
...defaultResource.show.tabs,
|
|
51
|
+
({ model }) => ({
|
|
52
|
+
label: "Access control",
|
|
53
|
+
component: h(VelFormRole, {
|
|
54
|
+
overrides: model.overrides_roles_and_permissions,
|
|
55
|
+
form: { roles: model.roles.map((d) => d.id) },
|
|
56
|
+
readonly: true,
|
|
57
|
+
}),
|
|
58
|
+
}),
|
|
59
|
+
(props) => {
|
|
60
|
+
const { model, $store, $router, $route, ...rest } =
|
|
61
|
+
props;
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
label: "Members",
|
|
65
|
+
component: h({
|
|
66
|
+
data: () => ({
|
|
67
|
+
scoped: true,
|
|
68
|
+
}),
|
|
69
|
+
mounted() {
|
|
70
|
+
this.emitter.on("reload-teams", () => {
|
|
71
|
+
this.reload();
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
beforeUnmount() {
|
|
75
|
+
this.emitter.off("reload-teams");
|
|
76
|
+
},
|
|
77
|
+
methods: {
|
|
78
|
+
reload: throttle(function () {
|
|
79
|
+
this.$refs.members.reload();
|
|
80
|
+
this.$refs.users.reload();
|
|
81
|
+
}, 1000),
|
|
82
|
+
},
|
|
83
|
+
render() {
|
|
84
|
+
return h("div", [
|
|
85
|
+
h("h3", "Members"),
|
|
86
|
+
(() => {
|
|
87
|
+
const resource = meta(
|
|
88
|
+
...userResource,
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
resource.api.params.index = ({
|
|
92
|
+
$route,
|
|
93
|
+
}) => ({
|
|
94
|
+
include: "company",
|
|
95
|
+
"filter[teams.id]":
|
|
96
|
+
$route.params.teamsId,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
resource.table.actions = [
|
|
100
|
+
({ model }) =>
|
|
101
|
+
h({
|
|
102
|
+
data: () => ({
|
|
103
|
+
loading: false,
|
|
104
|
+
}),
|
|
105
|
+
render() {
|
|
106
|
+
return h(
|
|
107
|
+
VelButton,
|
|
108
|
+
{
|
|
109
|
+
tag: "a",
|
|
110
|
+
size: "small",
|
|
111
|
+
type: "warning",
|
|
112
|
+
loading:
|
|
113
|
+
this
|
|
114
|
+
.loading,
|
|
115
|
+
onClick:
|
|
116
|
+
async () => {
|
|
117
|
+
this.loading = true;
|
|
118
|
+
|
|
119
|
+
await axios.delete(
|
|
120
|
+
`api/teams/${$route.params.teamsId}/users/${model.id}`,
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
this.emitter.emit(
|
|
124
|
+
"reload-teams",
|
|
125
|
+
);
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
"Remove",
|
|
129
|
+
);
|
|
130
|
+
},
|
|
131
|
+
}),
|
|
132
|
+
];
|
|
133
|
+
|
|
134
|
+
const props = {
|
|
135
|
+
model,
|
|
136
|
+
$store,
|
|
137
|
+
$router,
|
|
138
|
+
$route,
|
|
139
|
+
...rest,
|
|
140
|
+
resource,
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
return h(
|
|
144
|
+
VelTableSorter,
|
|
145
|
+
merge(
|
|
146
|
+
resource.index.structure(
|
|
147
|
+
props,
|
|
148
|
+
),
|
|
149
|
+
{
|
|
150
|
+
ref: "members",
|
|
151
|
+
},
|
|
152
|
+
),
|
|
153
|
+
);
|
|
154
|
+
})(),
|
|
155
|
+
h("h3", "Users"),
|
|
156
|
+
h(VelCheckbox, {
|
|
157
|
+
label: "Only show users from this company",
|
|
158
|
+
class: "mt-2",
|
|
159
|
+
modelValue: this.scoped,
|
|
160
|
+
"onUpdate:modelValue": (value) => {
|
|
161
|
+
this.scoped = value;
|
|
162
|
+
this.$nextTick(() => {
|
|
163
|
+
this.$refs.users.reload();
|
|
164
|
+
});
|
|
165
|
+
},
|
|
166
|
+
}),
|
|
167
|
+
(() => {
|
|
168
|
+
const resource = meta(
|
|
169
|
+
...userResource,
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
resource.api.params.index = ({
|
|
173
|
+
$route,
|
|
174
|
+
}) => ({
|
|
175
|
+
include: "company",
|
|
176
|
+
"filter[company_id]": this
|
|
177
|
+
.scoped
|
|
178
|
+
? $route.params.companiesId
|
|
179
|
+
: null,
|
|
180
|
+
"filter[teams.id]": `!${$route.params.teamsId}`,
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
resource.table.actions = [
|
|
184
|
+
({ model }) =>
|
|
185
|
+
h({
|
|
186
|
+
data: () => ({
|
|
187
|
+
loading: false,
|
|
188
|
+
}),
|
|
189
|
+
render() {
|
|
190
|
+
return h(
|
|
191
|
+
VelButton,
|
|
192
|
+
{
|
|
193
|
+
tag: "a",
|
|
194
|
+
size: "small",
|
|
195
|
+
type: "primary",
|
|
196
|
+
loading:
|
|
197
|
+
this
|
|
198
|
+
.loading,
|
|
199
|
+
onClick:
|
|
200
|
+
async () => {
|
|
201
|
+
this.loading = true;
|
|
202
|
+
|
|
203
|
+
await axios.post(
|
|
204
|
+
`api/teams/${$route.params.teamsId}/users`,
|
|
205
|
+
{
|
|
206
|
+
id: model.id,
|
|
207
|
+
},
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
this.emitter.emit(
|
|
211
|
+
"reload-teams",
|
|
212
|
+
);
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
"Add",
|
|
216
|
+
);
|
|
217
|
+
},
|
|
218
|
+
}),
|
|
219
|
+
];
|
|
220
|
+
|
|
221
|
+
const props = {
|
|
222
|
+
model,
|
|
223
|
+
$store,
|
|
224
|
+
$router,
|
|
225
|
+
$route,
|
|
226
|
+
...rest,
|
|
227
|
+
resource,
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
return h(
|
|
231
|
+
VelTableSorter,
|
|
232
|
+
merge(
|
|
233
|
+
resource.index.structure(
|
|
234
|
+
props,
|
|
235
|
+
),
|
|
236
|
+
{
|
|
237
|
+
ref: "users",
|
|
238
|
+
},
|
|
239
|
+
),
|
|
240
|
+
);
|
|
241
|
+
})(),
|
|
242
|
+
]);
|
|
243
|
+
},
|
|
244
|
+
}),
|
|
245
|
+
};
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
},
|
|
249
|
+
}),
|
|
250
|
+
},
|
|
251
|
+
];
|