@fishawack/lab-velocity 2.0.0-beta.5 → 2.0.0-beta.50
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/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 +17 -5
- package/_Build/vue/modules/AuthModule/routes/logoutheadless.vue +1 -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 +7 -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,51 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<vel-button @click="visible = true">Set Password</vel-button>
|
|
3
|
+
|
|
4
|
+
<SetPasswordDialog
|
|
5
|
+
v-if="visible"
|
|
6
|
+
:user-id="userId"
|
|
7
|
+
@close="visible = false"
|
|
8
|
+
@success="onSuccess"
|
|
9
|
+
/>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script>
|
|
13
|
+
import VelButton from "../../../../components/basic/Button.vue";
|
|
14
|
+
import SetPasswordDialog from "./SetPasswordDialog.vue";
|
|
15
|
+
import { ElNotification } from "element-plus";
|
|
16
|
+
|
|
17
|
+
export default {
|
|
18
|
+
components: {
|
|
19
|
+
VelButton,
|
|
20
|
+
SetPasswordDialog,
|
|
21
|
+
},
|
|
22
|
+
props: {
|
|
23
|
+
userId: {
|
|
24
|
+
type: [Number, String],
|
|
25
|
+
required: true,
|
|
26
|
+
},
|
|
27
|
+
model: {
|
|
28
|
+
type: Object,
|
|
29
|
+
required: true,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
data() {
|
|
33
|
+
return {
|
|
34
|
+
visible: false,
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
methods: {
|
|
38
|
+
onSuccess(data) {
|
|
39
|
+
this.visible = false;
|
|
40
|
+
|
|
41
|
+
Object.assign(this.model, data);
|
|
42
|
+
|
|
43
|
+
ElNotification({
|
|
44
|
+
title: "Success",
|
|
45
|
+
message: "Password updated",
|
|
46
|
+
type: "success",
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
</script>
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-dialog
|
|
3
|
+
:model-value="true"
|
|
4
|
+
title="Set Password"
|
|
5
|
+
width="500px"
|
|
6
|
+
@close="$emit('close')"
|
|
7
|
+
>
|
|
8
|
+
<vel-basic
|
|
9
|
+
v-model="password"
|
|
10
|
+
name="password"
|
|
11
|
+
type="password"
|
|
12
|
+
label="Password"
|
|
13
|
+
placeholder="Enter new password"
|
|
14
|
+
class="AM-mb-2"
|
|
15
|
+
/>
|
|
16
|
+
|
|
17
|
+
<vel-basic
|
|
18
|
+
v-model="passwordConfirmation"
|
|
19
|
+
name="password_confirmation"
|
|
20
|
+
type="password"
|
|
21
|
+
label="Confirm Password"
|
|
22
|
+
placeholder="Confirm new password"
|
|
23
|
+
class="AM-mb-2"
|
|
24
|
+
/>
|
|
25
|
+
|
|
26
|
+
<div class="AM-mb-2">
|
|
27
|
+
<p class="font-700 AM-mb-0.5">Password must contain:</p>
|
|
28
|
+
<p class="m-0">
|
|
29
|
+
{{ passwordLengthValid ? "✓" : "✗" }} At least 8 characters
|
|
30
|
+
</p>
|
|
31
|
+
<p class="m-0">{{ hasLetter ? "✓" : "✗" }} At least one letter</p>
|
|
32
|
+
<p class="m-0">
|
|
33
|
+
{{ hasNumberOrSymbol ? "✓" : "✗" }} At least one number or
|
|
34
|
+
symbol
|
|
35
|
+
</p>
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
<template #footer>
|
|
39
|
+
<el-button @click="$emit('close')">Cancel</el-button>
|
|
40
|
+
<el-button
|
|
41
|
+
type="primary"
|
|
42
|
+
:disabled="!canSubmit"
|
|
43
|
+
:loading="loading"
|
|
44
|
+
@click="submit"
|
|
45
|
+
>
|
|
46
|
+
Set Password
|
|
47
|
+
</el-button>
|
|
48
|
+
</template>
|
|
49
|
+
</el-dialog>
|
|
50
|
+
</template>
|
|
51
|
+
|
|
52
|
+
<script>
|
|
53
|
+
import { ElDialog, ElButton, ElNotification } from "element-plus";
|
|
54
|
+
import VelBasic from "../../../../components/form/basic.vue";
|
|
55
|
+
import axios from "axios";
|
|
56
|
+
|
|
57
|
+
export default {
|
|
58
|
+
components: {
|
|
59
|
+
ElDialog,
|
|
60
|
+
ElButton,
|
|
61
|
+
VelBasic,
|
|
62
|
+
},
|
|
63
|
+
props: {
|
|
64
|
+
userId: {
|
|
65
|
+
type: [Number, String],
|
|
66
|
+
required: true,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
emits: ["close", "success"],
|
|
70
|
+
data() {
|
|
71
|
+
return {
|
|
72
|
+
password: "",
|
|
73
|
+
passwordConfirmation: "",
|
|
74
|
+
loading: false,
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
computed: {
|
|
78
|
+
passwordLengthValid() {
|
|
79
|
+
return this.password.length >= 8;
|
|
80
|
+
},
|
|
81
|
+
hasLetter() {
|
|
82
|
+
return /[a-zA-Z]/.test(this.password);
|
|
83
|
+
},
|
|
84
|
+
hasNumberOrSymbol() {
|
|
85
|
+
return (
|
|
86
|
+
/[0-9]/.test(this.password) ||
|
|
87
|
+
/[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/.test(this.password)
|
|
88
|
+
);
|
|
89
|
+
},
|
|
90
|
+
passwordValid() {
|
|
91
|
+
return (
|
|
92
|
+
this.passwordLengthValid &&
|
|
93
|
+
this.hasLetter &&
|
|
94
|
+
this.hasNumberOrSymbol
|
|
95
|
+
);
|
|
96
|
+
},
|
|
97
|
+
canSubmit() {
|
|
98
|
+
return (
|
|
99
|
+
this.passwordValid &&
|
|
100
|
+
this.password === this.passwordConfirmation &&
|
|
101
|
+
this.password.length > 0
|
|
102
|
+
);
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
methods: {
|
|
106
|
+
async submit() {
|
|
107
|
+
this.loading = true;
|
|
108
|
+
|
|
109
|
+
try {
|
|
110
|
+
const res = await axios.post(
|
|
111
|
+
`/api/users/${this.userId}/set-password`,
|
|
112
|
+
{
|
|
113
|
+
password: this.password,
|
|
114
|
+
password_confirmation: this.passwordConfirmation,
|
|
115
|
+
},
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
this.$emit("success", res.data.data);
|
|
119
|
+
} catch (e) {
|
|
120
|
+
if (e.response?.status === 422) {
|
|
121
|
+
const errors = e.response.data.errors || {};
|
|
122
|
+
const message =
|
|
123
|
+
Object.values(errors).flat().join("\n") ||
|
|
124
|
+
e.response.data.message;
|
|
125
|
+
|
|
126
|
+
ElNotification({
|
|
127
|
+
title: "Validation Error",
|
|
128
|
+
message,
|
|
129
|
+
type: "error",
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
} finally {
|
|
133
|
+
this.loading = false;
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
</script>
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import { h, resolveComponent, ref } from "vue";
|
|
2
|
+
import { debounce } from "lodash";
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
|
|
5
|
+
import VelBasic from "../../../../components/form/basic.vue";
|
|
6
|
+
import VelButton from "../../../../components/basic/Button.vue";
|
|
7
|
+
import VelCheckbox from "../../../../components/form/Checkbox.vue";
|
|
8
|
+
import VelFormRole from "../../../../components/layout/FormRole.vue";
|
|
9
|
+
import Chip from "../../../../components/layout/Chip.vue";
|
|
10
|
+
import Chips from "../../../../components/layout/Chips.vue";
|
|
11
|
+
|
|
12
|
+
import companyResource from "../PCompanies/resource.js";
|
|
13
|
+
import { meta } from "../../../resource/index.js";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Shared reactive state for SSO company detection.
|
|
17
|
+
* Used by the email column's render.write and by form.submit in resource.js.
|
|
18
|
+
*/
|
|
19
|
+
export const detectedCompany = ref(null);
|
|
20
|
+
|
|
21
|
+
const debouncedFetchCompany = debounce((domain) => {
|
|
22
|
+
if (domain) {
|
|
23
|
+
axios
|
|
24
|
+
.get("/api/companies", {
|
|
25
|
+
params: {
|
|
26
|
+
"filter[domains.domain]": domain,
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
.then((res) => {
|
|
30
|
+
detectedCompany.value = res.data.data[0] || null;
|
|
31
|
+
})
|
|
32
|
+
.catch(() => {
|
|
33
|
+
detectedCompany.value = null;
|
|
34
|
+
});
|
|
35
|
+
} else {
|
|
36
|
+
detectedCompany.value = null;
|
|
37
|
+
}
|
|
38
|
+
}, 500);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Hoisted inline component for the email column's render.write.
|
|
42
|
+
* Must be a stable reference so Vue doesn't remount on every render.
|
|
43
|
+
*/
|
|
44
|
+
const EmailField = {
|
|
45
|
+
props: ["form"],
|
|
46
|
+
data() {
|
|
47
|
+
return {
|
|
48
|
+
company: detectedCompany.value,
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
watch: {
|
|
52
|
+
"form.email": {
|
|
53
|
+
handler(val) {
|
|
54
|
+
const domain = val?.split("@")[1];
|
|
55
|
+
debouncedFetchCompany(domain);
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
created() {
|
|
60
|
+
this.$watch(
|
|
61
|
+
() => detectedCompany.value,
|
|
62
|
+
(val) => {
|
|
63
|
+
this.company = val;
|
|
64
|
+
},
|
|
65
|
+
);
|
|
66
|
+
},
|
|
67
|
+
render() {
|
|
68
|
+
const form = this.form;
|
|
69
|
+
const company = this.company;
|
|
70
|
+
const isSSOCompany = !!company?.sso_enabled;
|
|
71
|
+
|
|
72
|
+
return h("div", [
|
|
73
|
+
h(VelBasic, {
|
|
74
|
+
modelValue: form.email,
|
|
75
|
+
"onUpdate:modelValue": (val) => {
|
|
76
|
+
form.email = val;
|
|
77
|
+
},
|
|
78
|
+
placeholder: "Email",
|
|
79
|
+
label: "Email",
|
|
80
|
+
type: "text",
|
|
81
|
+
name: "email",
|
|
82
|
+
error: form.errors,
|
|
83
|
+
}),
|
|
84
|
+
h("p", { class: "mb-1" }, ["Company: ", h("span", company?.name)]),
|
|
85
|
+
h("hr", { class: "my-3 hr-muted" }),
|
|
86
|
+
isSSOCompany
|
|
87
|
+
? h("p", { class: "mb-3" }, [
|
|
88
|
+
"This user belongs to an SSO-enabled company. They will authenticate via SSO on first login. No password is required.",
|
|
89
|
+
])
|
|
90
|
+
: h("div", [
|
|
91
|
+
h(VelCheckbox, {
|
|
92
|
+
modelValue: form.notify_user,
|
|
93
|
+
"onUpdate:modelValue": (val) => {
|
|
94
|
+
form.notify_user = val;
|
|
95
|
+
},
|
|
96
|
+
name: "notify_user",
|
|
97
|
+
error: form.errors,
|
|
98
|
+
label: "Send email to notify user of account and password",
|
|
99
|
+
}),
|
|
100
|
+
h(VelCheckbox, {
|
|
101
|
+
modelValue: form.force_password_change,
|
|
102
|
+
"onUpdate:modelValue": (val) => {
|
|
103
|
+
form.force_password_change = val;
|
|
104
|
+
},
|
|
105
|
+
name: "force_password_change",
|
|
106
|
+
error: form.errors,
|
|
107
|
+
label: "Force password change on first login",
|
|
108
|
+
}),
|
|
109
|
+
h(VelCheckbox, {
|
|
110
|
+
modelValue: form.set_password,
|
|
111
|
+
"onUpdate:modelValue": (val) => {
|
|
112
|
+
form.set_password = val;
|
|
113
|
+
},
|
|
114
|
+
name: "set_password",
|
|
115
|
+
error: form.errors,
|
|
116
|
+
label: "Auto generate password",
|
|
117
|
+
}),
|
|
118
|
+
!form.set_password &&
|
|
119
|
+
h("div", [
|
|
120
|
+
h(VelBasic, {
|
|
121
|
+
modelValue: form.password,
|
|
122
|
+
"onUpdate:modelValue": (val) => {
|
|
123
|
+
form.password = val;
|
|
124
|
+
},
|
|
125
|
+
name: "password",
|
|
126
|
+
error: form.errors,
|
|
127
|
+
type: "password",
|
|
128
|
+
placeholder: "Password",
|
|
129
|
+
label: "Password",
|
|
130
|
+
}),
|
|
131
|
+
h(VelBasic, {
|
|
132
|
+
modelValue: form.password_confirmation,
|
|
133
|
+
"onUpdate:modelValue": (val) => {
|
|
134
|
+
form.password_confirmation = val;
|
|
135
|
+
},
|
|
136
|
+
name: "password_confirmation",
|
|
137
|
+
error: form.errors,
|
|
138
|
+
type: "password",
|
|
139
|
+
placeholder: "Password Confirmation",
|
|
140
|
+
label: "Password Confirmation",
|
|
141
|
+
}),
|
|
142
|
+
]),
|
|
143
|
+
]),
|
|
144
|
+
h("hr", { class: "my-5 hr-muted" }),
|
|
145
|
+
]);
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Hoisted inline component for the roles column's render.write.
|
|
151
|
+
* Must be a stable reference so Vue doesn't remount on every render.
|
|
152
|
+
*/
|
|
153
|
+
const RolesField = {
|
|
154
|
+
props: ["form"],
|
|
155
|
+
data() {
|
|
156
|
+
return {
|
|
157
|
+
enableRoles: null,
|
|
158
|
+
};
|
|
159
|
+
},
|
|
160
|
+
watch: {
|
|
161
|
+
"form.roles": {
|
|
162
|
+
immediate: true,
|
|
163
|
+
handler(newVal) {
|
|
164
|
+
if (this.enableRoles === null) {
|
|
165
|
+
this.enableRoles = newVal && newVal.length > 0;
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
render() {
|
|
171
|
+
const form = this.form;
|
|
172
|
+
|
|
173
|
+
if (this.enableRoles) {
|
|
174
|
+
return h("div", [
|
|
175
|
+
h(
|
|
176
|
+
VelButton,
|
|
177
|
+
{
|
|
178
|
+
onClick: () => {
|
|
179
|
+
form.roles = [];
|
|
180
|
+
this.enableRoles = false;
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
"Reset roles",
|
|
184
|
+
),
|
|
185
|
+
h(VelFormRole, { form }),
|
|
186
|
+
h("hr", { class: "my-5 hr-muted" }),
|
|
187
|
+
]);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return h("div", [
|
|
191
|
+
h(
|
|
192
|
+
VelButton,
|
|
193
|
+
{
|
|
194
|
+
onClick: () => {
|
|
195
|
+
this.enableRoles = true;
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
() => [
|
|
199
|
+
h(resolveComponent("GIcon"), {
|
|
200
|
+
name: "icon-plus",
|
|
201
|
+
embed: true,
|
|
202
|
+
asis: true,
|
|
203
|
+
class: "fill-0 icon--0.5 mr",
|
|
204
|
+
}),
|
|
205
|
+
"Override roles",
|
|
206
|
+
],
|
|
207
|
+
),
|
|
208
|
+
h("p", { class: "mt-2" }, [
|
|
209
|
+
"Roles will be inherited from the company level.",
|
|
210
|
+
]),
|
|
211
|
+
h("hr", { class: "my-5 hr-muted" }),
|
|
212
|
+
]);
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
export default [
|
|
217
|
+
{
|
|
218
|
+
key: "name",
|
|
219
|
+
sortable: true,
|
|
220
|
+
condition: {
|
|
221
|
+
form: {
|
|
222
|
+
write: ({ method }) => method === "post",
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
key: "email",
|
|
228
|
+
condition: {
|
|
229
|
+
form: {
|
|
230
|
+
write: ({ method }) => method === "post",
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
render: {
|
|
234
|
+
write: ({ form }) => h(EmailField, { form }),
|
|
235
|
+
},
|
|
236
|
+
initial: ({ model }) => model?.email ?? null,
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
key: "company",
|
|
240
|
+
sortable: true,
|
|
241
|
+
condition: {
|
|
242
|
+
form: false,
|
|
243
|
+
},
|
|
244
|
+
render: {
|
|
245
|
+
read: ({ model }) =>
|
|
246
|
+
!model.company
|
|
247
|
+
? h("span", "")
|
|
248
|
+
: model.company.deleted_at
|
|
249
|
+
? h(
|
|
250
|
+
"span",
|
|
251
|
+
{ class: "vel-basic__error" },
|
|
252
|
+
model.company.name,
|
|
253
|
+
)
|
|
254
|
+
: h(resolveComponent("router-link"), {
|
|
255
|
+
class: "underline",
|
|
256
|
+
to: {
|
|
257
|
+
name: "companies.show",
|
|
258
|
+
params: {
|
|
259
|
+
[meta(...companyResource).id]:
|
|
260
|
+
model.company_id,
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
text: model.company.name,
|
|
264
|
+
}),
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
key: "email_verified_at",
|
|
269
|
+
label: "Email Verified",
|
|
270
|
+
condition: {
|
|
271
|
+
table: false,
|
|
272
|
+
form: false,
|
|
273
|
+
},
|
|
274
|
+
render: {
|
|
275
|
+
read: ({ model }) =>
|
|
276
|
+
h(
|
|
277
|
+
"span",
|
|
278
|
+
{},
|
|
279
|
+
model.email_verified_at
|
|
280
|
+
? new Date(model.email_verified_at).toLocaleString()
|
|
281
|
+
: "Not verified",
|
|
282
|
+
),
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
key: "verified",
|
|
287
|
+
label: "Verified",
|
|
288
|
+
condition: {
|
|
289
|
+
description: false,
|
|
290
|
+
form: false,
|
|
291
|
+
},
|
|
292
|
+
render: {
|
|
293
|
+
read: ({ model }) =>
|
|
294
|
+
h(
|
|
295
|
+
"span",
|
|
296
|
+
{
|
|
297
|
+
title: model.email_verified_at
|
|
298
|
+
? `Verified: ${new Date(model.email_verified_at).toLocaleString()}`
|
|
299
|
+
: "Not verified",
|
|
300
|
+
style: {
|
|
301
|
+
color: model.email_verified_at ? "green" : "red",
|
|
302
|
+
fontSize: "18px",
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
model.email_verified_at ? "✓" : "✗",
|
|
306
|
+
),
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
key: "roles",
|
|
311
|
+
label: "Role",
|
|
312
|
+
condition: {
|
|
313
|
+
description: false,
|
|
314
|
+
form: {
|
|
315
|
+
write: ({ $store }) => $store.getters.can("edit roles"),
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
initial: ({ model }) =>
|
|
319
|
+
model?.overrides_roles_and_permissions
|
|
320
|
+
? model?.roles.map((val) => ({
|
|
321
|
+
label: val.label,
|
|
322
|
+
value: val.id,
|
|
323
|
+
}))
|
|
324
|
+
: [],
|
|
325
|
+
preparation: ({ form }) =>
|
|
326
|
+
form.roles.map((d) => (typeof d === "object" ? d.value : d)),
|
|
327
|
+
render: {
|
|
328
|
+
read: ({ model }) =>
|
|
329
|
+
h(
|
|
330
|
+
!model.overrides_roles_and_permissions ||
|
|
331
|
+
model.roles.length === 1
|
|
332
|
+
? Chip
|
|
333
|
+
: Chips,
|
|
334
|
+
!model.overrides_roles_and_permissions
|
|
335
|
+
? {
|
|
336
|
+
name: "inherited",
|
|
337
|
+
label: "Inherited",
|
|
338
|
+
}
|
|
339
|
+
: model.roles.length === 1
|
|
340
|
+
? {
|
|
341
|
+
name: model.roles[0].name,
|
|
342
|
+
label: model.roles[0].label,
|
|
343
|
+
}
|
|
344
|
+
: { array: model.roles },
|
|
345
|
+
),
|
|
346
|
+
write: ({ model, form }) => h(RolesField, { form }),
|
|
347
|
+
},
|
|
348
|
+
},
|
|
349
|
+
];
|