@fishawack/lab-velocity 2.0.0-beta.40 → 2.0.0-beta.41

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.
@@ -1,17 +1,18 @@
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
+
1
9
  import VelFormRole from "../../../../components/layout/FormRole.vue";
2
10
  import VelButton from "../../../../components/basic/Button.vue";
3
- import Chip from "../../../../components/layout/Chip.vue";
4
- import Chips from "../../../../components/layout/Chips.vue";
5
11
  import VelTableSorter from "../../../../components/layout/TableSorter.vue";
6
12
  import VelRoleLegend from "../../../../components/layout/RoleLegend.vue";
7
- import component from "./form.vue";
13
+
8
14
  import userResource from "../PUsers/resource.js";
9
15
  import teamResource from "../PTeams/resource.js";
10
- import { defaultResource, meta } from "../../../resource/index.js";
11
-
12
- import { ElNotification } from "element-plus";
13
- import { h, resolveComponent } from "vue";
14
- import axios from "axios";
15
16
 
16
17
  export default [
17
18
  "companies",
@@ -33,241 +34,180 @@ export default [
33
34
  },
34
35
  singular: "company",
35
36
  icon: "icon-cases",
36
- form: {
37
- component,
38
- fields: ({ model }) => ({
39
- name: model?.name || null,
40
- primary_contact: model?.primary_contact?.id || null,
41
- domains: model?.domains || [],
42
- seats: model?.seats != null ? model.seats : null,
43
- roles:
44
- model?.roles.map((val) => ({
45
- label: val.label,
46
- value: val.id,
47
- })) || [],
48
- sso_client_id: model?.sso_client_id || undefined,
49
- sso_tenant: model?.sso_tenant || undefined,
50
- sso_client_secret: model?.sso_client_secret || undefined,
51
- sso_type: model?.sso_type || undefined,
52
- }),
53
- preparation: (props) => {
54
- const data = props.form.data();
55
- data.roles = data.roles.map((d) => d.value);
56
- return data;
37
+ ...merge(columns(companiesColumns), {
38
+ index: {
39
+ layout: [
40
+ ...defaultResource.index.layout,
41
+ () =>
42
+ h(VelRoleLegend, {
43
+ class: "mt-5",
44
+ }),
45
+ ],
57
46
  },
58
- },
59
- table: {
60
- structure: () => [
61
- {
62
- key: "name",
63
- sortable: true,
64
- },
65
- {
66
- key: "user_count",
67
- label: "Total users",
68
- width: "150",
69
- },
70
- {
71
- key: "role",
72
- render: ({ model }) =>
47
+ show: {
48
+ actions: [
49
+ ({ model }) =>
50
+ model.primary_contact &&
73
51
  h(
74
- model.roles.length === 1 ? Chip : Chips,
75
- model.roles.length === 1
76
- ? {
77
- name: model.roles[0].name,
78
- label: model.roles[0].label,
79
- }
80
- : { array: model.roles },
81
- ),
82
- },
83
- ],
84
- },
85
- description: {
86
- structure: () => [
87
- {
88
- key: "domains",
89
- render: ({ model }) => h("span", model.domains.join(", ")),
90
- },
91
- {
92
- key: "sso_enabled",
93
- label: "SSO Enabled",
94
- },
95
- {
96
- key: "primary_contact",
97
- label: "Primary Contact",
98
- render: ({ model }) =>
99
- h("span", model.primary_contact?.name),
100
- },
101
- {
102
- key: "primary_contact_email",
103
- label: "Primary Contact Email",
104
- render: ({ model }) =>
105
- h("span", model.primary_contact?.email),
106
- },
107
- {
108
- key: "primary_contact_contacted",
109
- label: "Primary Contact Contacted",
110
- render: ({ model }) =>
111
- h("span", !!model.primary_contact_contacted),
112
- },
113
- {
114
- label: "Total Users",
115
- key: "user_count",
116
- },
117
- {
118
- label: "Available Seats",
119
- key: "seats",
120
- },
121
- ],
122
- },
123
- index: {
124
- layout: [
125
- ...defaultResource.index.layout,
126
- () =>
127
- h(VelRoleLegend, {
128
- class: "mt-5",
129
- }),
130
- ],
131
- },
132
- show: {
133
- actions: [
134
- ({ model }) =>
135
- model.primary_contact &&
136
- h(
137
- VelButton,
138
- {
139
- type: "primary",
140
- async onClick() {
141
- try {
142
- const res = await axios.post(
143
- `/api/companies/${model.id}/welcome`,
144
- );
145
- ElNotification({
146
- title: "Success",
147
- message: res.data.message,
148
- type: "success",
149
- });
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
+ });
150
65
 
151
- model.primary_contact_contacted = true;
152
- } catch (e) {
153
- ElNotification({
154
- title: "Warning",
155
- message:
156
- e.response?.data?.message ||
157
- e.message,
158
- type: "warning",
159
- });
160
- }
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
+ },
161
77
  },
162
- },
163
- "Send welcome email",
164
- ),
165
- ...defaultResource.show.actions,
166
- ],
167
- tabs: [
168
- ...defaultResource.show.tabs,
169
- ({ model }) => ({
170
- label: "Access control",
171
- component: h(VelFormRole, {
172
- overrides: model.overrides_roles_and_permissions,
173
- form: { roles: model.roles.map((d) => d.id) },
174
- readonly: true,
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
+ }),
175
91
  }),
176
- }),
177
- ({ model, $store, $router, $route, ...rest }) => {
178
- const resource = meta(...teamResource);
92
+ ({ model, $store, $router, $route, ...rest }) => {
93
+ const resource = meta(...teamResource);
179
94
 
180
- const props = {
181
- model,
182
- $store,
183
- $router,
184
- $route,
185
- ...rest,
186
- resource,
187
- };
95
+ const props = {
96
+ model,
97
+ $store,
98
+ $router,
99
+ $route,
100
+ ...rest,
101
+ resource,
102
+ };
188
103
 
189
- return {
190
- label: "Teams",
191
- component: h("div", [
192
- h("div", { class: "flex justify-end items-end" }, [
193
- resource.permissions.create(props) &&
194
- h(
195
- VelButton,
196
- {
197
- tag: "a",
198
- type: "primary",
199
- size: "large",
200
- onClick: () => {
201
- $router.push({
202
- name: `companies.${resource.routeName}.create`,
203
- });
204
- },
205
- },
206
- () => [
207
- h(resolveComponent("GIcon"), {
208
- class: "fill-0 mr-0.5 icon--0.5",
209
- name: "icon-plus",
210
- embed: true,
211
- artboard: true,
212
- }),
213
- `Create ${resource.singular}`,
214
- ],
215
- ),
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
+ ),
216
145
  ]),
217
- h(VelTableSorter, resource.index.structure(props)),
218
- ]),
219
- };
220
- },
221
- ({ model, $store, $router, $route, ...rest }) => {
222
- const resource = meta(...userResource);
146
+ };
147
+ },
148
+ ({ model, $store, $router, $route, ...rest }) => {
149
+ const resource = meta(...userResource);
223
150
 
224
- resource.api.params.index = ({ $route }) => ({
225
- include: "company",
226
- "filter[company_id]": $route.params.companiesId,
227
- });
151
+ resource.api.params.index = ({ $route }) => ({
152
+ include: "company",
153
+ "filter[company_id]": $route.params.companiesId,
154
+ });
228
155
 
229
- const props = {
230
- model,
231
- $store,
232
- $router,
233
- $route,
234
- ...rest,
235
- resource,
236
- };
156
+ const props = {
157
+ model,
158
+ $store,
159
+ $router,
160
+ $route,
161
+ ...rest,
162
+ resource,
163
+ };
237
164
 
238
- return {
239
- label: "Users",
240
- component: h("div", [
241
- h("div", { class: "flex justify-end items-end" }, [
242
- resource.permissions.create(props) &&
243
- h(
244
- VelButton,
245
- {
246
- tag: "a",
247
- type: "primary",
248
- size: "large",
249
- onClick: () => {
250
- $router.push({
251
- name: `${resource.slug}.create`,
252
- });
253
- },
254
- },
255
- () => [
256
- h(resolveComponent("GIcon"), {
257
- class: "fill-0 mr-0.5 icon--0.5",
258
- name: "icon-plus",
259
- embed: true,
260
- artboard: true,
261
- }),
262
- `Create ${resource.singular}`,
263
- ],
264
- ),
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
+ ),
265
206
  ]),
266
- h(VelTableSorter, resource.index.structure(props)),
267
- ]),
268
- };
269
- },
270
- ],
271
- },
207
+ };
208
+ },
209
+ ],
210
+ },
211
+ }),
272
212
  },
273
213
  ];