@fishawack/lab-velocity 2.0.0-beta.6 → 2.0.0-beta.60

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.
Files changed (111) hide show
  1. package/README.md +467 -36
  2. package/_Build/js/libs/build-id.js +14 -0
  3. package/_Build/js/libs/filters.js +36 -0
  4. package/_Build/js/libs/globals.js +7 -0
  5. package/_Build/js/libs/router.js +22 -0
  6. package/_Build/js/libs/routes.js +29 -0
  7. package/_Build/js/libs/store.js +21 -0
  8. package/_Build/js/libs/utility.js +161 -0
  9. package/_Build/vue/components/basic/Button.vue +1 -1
  10. package/_Build/vue/components/form/Avatar.vue +90 -0
  11. package/_Build/vue/components/form/Checkbox.vue +10 -0
  12. package/_Build/vue/components/form/InputNumber.vue +1 -1
  13. package/_Build/vue/components/form/Select.vue +221 -31
  14. package/_Build/vue/components/form/Wysiwyg2.vue +87 -2
  15. package/_Build/vue/components/form/wysiwyg2-video.js +41 -0
  16. package/_Build/vue/components/layout/Alert.vue +5 -5
  17. package/_Build/vue/components/layout/Audit.vue +158 -0
  18. package/_Build/vue/{modules/AuthModule/components/VBreadcrumbs.vue → components/layout/Breadcrumbs.vue} +4 -4
  19. package/_Build/vue/{modules/AuthModule/components → components/layout}/Chips.vue +2 -2
  20. package/_Build/vue/components/layout/Footer.vue +11 -10
  21. package/_Build/vue/{modules/AuthModule/components/VFormFooter.vue → components/layout/FormFooter.vue} +2 -2
  22. package/_Build/vue/{modules/AuthModule/components → components/layout}/FormRole.vue +8 -8
  23. package/_Build/vue/components/layout/Layout.vue +94 -0
  24. package/_Build/vue/components/layout/Navigation.vue +83 -0
  25. package/_Build/vue/{modules/AuthModule/components/VPageHeader.vue → components/layout/PageHeader.vue} +14 -8
  26. package/_Build/vue/components/layout/SideBar.vue +26 -0
  27. package/_Build/vue/{modules/AuthModule/components/VTable.vue → components/layout/Table.vue} +24 -12
  28. package/_Build/vue/{modules/AuthModule/components/VTableSorter.vue → components/layout/TableSorter.vue} +92 -48
  29. package/_Build/vue/components/layout/TokenDisplay.vue +52 -0
  30. package/_Build/vue/components/layout/pageTitle.vue +1 -1
  31. package/_Build/vue/components/navigation/Menu.vue +6 -1
  32. package/_Build/vue/components/navigation/MenuItem.vue +7 -2
  33. package/_Build/vue/components/navigation/MenuItemGroup.vue +7 -2
  34. package/_Build/vue/modules/AuthModule/js/axios.js +21 -1
  35. package/_Build/vue/modules/AuthModule/js/clear-cookies.js +34 -0
  36. package/_Build/vue/modules/AuthModule/js/guest-request.js +32 -0
  37. package/_Build/vue/modules/AuthModule/js/impersonation-banner.js +102 -0
  38. package/_Build/vue/modules/AuthModule/js/router.js +91 -114
  39. package/_Build/vue/modules/AuthModule/js/store.js +23 -6
  40. package/_Build/vue/modules/AuthModule/routes/PCompanies/columns.js +268 -0
  41. package/_Build/vue/modules/AuthModule/routes/PCompanies/resource.js +213 -0
  42. package/_Build/vue/modules/AuthModule/routes/PIntegrations/columns.js +58 -0
  43. package/_Build/vue/modules/AuthModule/routes/PIntegrations/resource.js +79 -0
  44. package/_Build/vue/modules/AuthModule/routes/PTeams/columns.js +78 -0
  45. package/_Build/vue/modules/AuthModule/routes/PTeams/resource.js +251 -0
  46. package/_Build/vue/modules/AuthModule/routes/PUsers/SetPasswordAction.vue +51 -0
  47. package/_Build/vue/modules/AuthModule/routes/PUsers/SetPasswordDialog.vue +138 -0
  48. package/_Build/vue/modules/AuthModule/routes/PUsers/columns.js +349 -0
  49. package/_Build/vue/modules/AuthModule/routes/PUsers/resource.js +239 -0
  50. package/_Build/vue/modules/AuthModule/routes/account-exists.vue +2 -2
  51. package/_Build/vue/modules/AuthModule/routes/change-password.vue +28 -32
  52. package/_Build/vue/modules/AuthModule/routes/container.vue +2 -11
  53. package/_Build/vue/modules/AuthModule/routes/expired-reset.vue +4 -4
  54. package/_Build/vue/modules/AuthModule/routes/expired-verification.vue +10 -9
  55. package/_Build/vue/modules/AuthModule/routes/force-reset.vue +44 -58
  56. package/_Build/vue/modules/AuthModule/routes/forgot.vue +10 -5
  57. package/_Build/vue/modules/AuthModule/routes/login.vue +12 -19
  58. package/_Build/vue/modules/AuthModule/routes/logincallback.vue +1 -3
  59. package/_Build/vue/modules/AuthModule/routes/loginsso.vue +14 -10
  60. package/_Build/vue/modules/AuthModule/routes/logout.vue +14 -5
  61. package/_Build/vue/modules/AuthModule/routes/logoutheadless.vue +16 -5
  62. package/_Build/vue/modules/AuthModule/routes/register.vue +24 -28
  63. package/_Build/vue/modules/AuthModule/routes/reset.vue +20 -14
  64. package/_Build/vue/modules/AuthModule/routes/success-forgot.vue +14 -8
  65. package/_Build/vue/modules/AuthModule/routes/success-reset.vue +2 -2
  66. package/_Build/vue/modules/AuthModule/routes/success-verify.vue +1 -3
  67. package/_Build/vue/modules/AuthModule/routes/verify.vue +11 -14
  68. package/_Build/vue/modules/resource/Children/create.vue +99 -0
  69. package/_Build/vue/modules/resource/Children/edit.vue +124 -0
  70. package/_Build/vue/modules/resource/Children/index.vue +42 -0
  71. package/_Build/vue/modules/resource/Children/partials/form.vue +111 -0
  72. package/_Build/vue/modules/resource/Children/show.vue +170 -0
  73. package/_Build/vue/modules/resource/index.js +562 -0
  74. package/_Build/vue/modules/resource/parent.vue +63 -0
  75. package/_Build/vue/modules/resource/trashable.js +104 -0
  76. package/_base.scss +0 -1
  77. package/_defaults.scss +2 -2
  78. package/components/_auth.scss +19 -61
  79. package/components/_datepicker.scss +1 -0
  80. package/components/_descriptions.scss +2 -0
  81. package/components/_footer.scss +1 -0
  82. package/components/_form.scss +18 -0
  83. package/components/_header.scss +3 -27
  84. package/components/_layout.scss +56 -0
  85. package/components/_menu.scss +0 -5
  86. package/components/_sidebar.scss +12 -27
  87. package/components/_table.scss +3 -0
  88. package/components/_token-display.scss +41 -0
  89. package/components/_wysiwyg2.scss +10 -0
  90. package/general.scss +1 -0
  91. package/index.js +31 -1
  92. package/package.json +7 -4
  93. package/_Build/vue/components/layout/sideBar.vue +0 -25
  94. package/_Build/vue/modules/AuthModule/adminRoutes/PCompanies/Children/Upload/upload.vue +0 -259
  95. package/_Build/vue/modules/AuthModule/adminRoutes/PCompanies/Children/create.vue +0 -62
  96. package/_Build/vue/modules/AuthModule/adminRoutes/PCompanies/Children/edit.vue +0 -98
  97. package/_Build/vue/modules/AuthModule/adminRoutes/PCompanies/Children/index.vue +0 -90
  98. package/_Build/vue/modules/AuthModule/adminRoutes/PCompanies/Children/partials/form.vue +0 -181
  99. package/_Build/vue/modules/AuthModule/adminRoutes/PCompanies/Children/show.vue +0 -266
  100. package/_Build/vue/modules/AuthModule/adminRoutes/PCompanies/parent.vue +0 -36
  101. package/_Build/vue/modules/AuthModule/adminRoutes/PUsers/Children/create.vue +0 -112
  102. package/_Build/vue/modules/AuthModule/adminRoutes/PUsers/Children/edit.vue +0 -103
  103. package/_Build/vue/modules/AuthModule/adminRoutes/PUsers/Children/index.vue +0 -112
  104. package/_Build/vue/modules/AuthModule/adminRoutes/PUsers/Children/partials/form.vue +0 -173
  105. package/_Build/vue/modules/AuthModule/adminRoutes/PUsers/Children/show.vue +0 -123
  106. package/_Build/vue/modules/AuthModule/adminRoutes/PUsers/parent.vue +0 -36
  107. package/components/_input.scss +0 -0
  108. /package/_Build/vue/{modules/AuthModule/components → components/layout}/AuthModal.vue +0 -0
  109. /package/_Build/vue/{modules/AuthModule/components → components/layout}/Chip.vue +0 -0
  110. /package/_Build/vue/{modules/AuthModule/components/VPasswordValidation.vue → components/layout/PasswordValidation.vue} +0 -0
  111. /package/_Build/vue/{modules/AuthModule/components/VRoleLegend.vue → components/layout/RoleLegend.vue} +0 -0
@@ -1,4 +1,7 @@
1
1
  <script>
2
+ import axios from "axios";
3
+ import clearCookies from "../js/clear-cookies";
4
+
2
5
  export default {
3
6
  metaInfo() {
4
7
  return {
@@ -8,14 +11,20 @@ export default {
8
11
 
9
12
  async mounted() {
10
13
  try {
11
- await this.$store.dispatch("logout", {
12
- errors: this.$root.errors,
13
- });
14
+ await this.$store.dispatch("logout");
15
+ } catch {
16
+ /* empty */
17
+ }
18
+
19
+ await clearCookies();
20
+
21
+ try {
22
+ await axios.get("/sanctum/csrf-cookie");
14
23
  } catch {
15
24
  /* empty */
16
- } finally {
17
- this.$router.push({ name: "auth.login" });
18
25
  }
26
+
27
+ this.$router.push({ name: "auth.login" });
19
28
  },
20
29
  };
21
30
  </script>
@@ -3,6 +3,9 @@
3
3
  </template>
4
4
 
5
5
  <script>
6
+ import axios from "axios";
7
+ import clearCookies from "../js/clear-cookies";
8
+
6
9
  export default {
7
10
  metaInfo() {
8
11
  return {
@@ -16,12 +19,20 @@ export default {
16
19
 
17
20
  async mounted() {
18
21
  try {
19
- await this.$store.dispatch("logout", {
20
- errors: this.$root.errors,
21
- });
22
- } finally {
23
- this.done = true;
22
+ await this.$store.dispatch("logout");
23
+ } catch {
24
+ /* empty */
25
+ }
26
+
27
+ await clearCookies();
28
+
29
+ try {
30
+ await axios.get("/sanctum/csrf-cookie");
31
+ } catch {
32
+ /* empty */
24
33
  }
34
+
35
+ this.done = true;
25
36
  },
26
37
  };
27
38
  </script>
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <h1 class="h2 h2--small">Register</h1>
3
- <p class="AM-mb-3 AM-mt-2">
3
+ <p class="mb-3 mt-2">
4
4
  Please enter your personal details to complete your registration.
5
5
  </p>
6
6
 
@@ -10,7 +10,7 @@
10
10
  id="memberLoginForm"
11
11
  >
12
12
  <el-input
13
- class="AM-mb-2"
13
+ class="mb-2"
14
14
  label="Full name"
15
15
  placeholder="Enter your full name"
16
16
  name="name"
@@ -20,7 +20,7 @@
20
20
  />
21
21
 
22
22
  <el-input
23
- class="AM-mb-2"
23
+ class="mb-2"
24
24
  label="Email"
25
25
  placeholder="Enter your email address"
26
26
  name="email"
@@ -31,7 +31,7 @@
31
31
  />
32
32
 
33
33
  <el-input
34
- class="AM-mb-2"
34
+ class="mb-2"
35
35
  label="Password"
36
36
  name="password"
37
37
  placeholder="Create a unique password"
@@ -42,7 +42,7 @@
42
42
  :error="form.errors"
43
43
  />
44
44
 
45
- <VPasswordValidation
45
+ <VelPasswordValidation
46
46
  :password="form.password"
47
47
  @passwordValid="updatePasswordValidity"
48
48
  />
@@ -72,7 +72,7 @@
72
72
  Register
73
73
  </elButton>
74
74
 
75
- <p class="disclaimer AM-mt-3">
75
+ <p class="disclaimer mt-3">
76
76
  Having trouble registering?
77
77
  <a :href="$store.state.auth.contact" class="underline"
78
78
  >Contact us</a
@@ -83,8 +83,18 @@
83
83
 
84
84
  <script>
85
85
  import Form from "form-backend-validation";
86
+ import { ElNotification } from "element-plus";
87
+ import { guestRequest } from "../js/guest-request";
86
88
 
87
89
  export default {
90
+ components: {
91
+ VelPasswordValidation:
92
+ require("../../../components/layout/PasswordValidation.vue")
93
+ .default,
94
+ elInput: require("../../../components/form/basic.vue").default,
95
+ elButton: require("../../../components/basic/Button.vue").default,
96
+ },
97
+
88
98
  data() {
89
99
  return {
90
100
  form: new Form(
@@ -107,24 +117,19 @@ export default {
107
117
  this.loading = true;
108
118
 
109
119
  try {
110
- const res = await this.form.post("/register");
111
-
112
- if (res["logged-in"]) {
113
- try {
114
- await this.$store.dispatch("logout", {
115
- errors: this.$root.errors,
116
- });
117
- } catch (e) {}
120
+ const res = await guestRequest({
121
+ form: this.form,
122
+ url: "/register",
123
+ store: this.$store,
124
+ });
118
125
 
119
- await this.form.post("/register");
120
- }
121
126
  if (res["redirect"]) {
122
127
  // Redirect here
123
128
  this.$router.push({
124
129
  name: `auth.login`,
125
130
  query: { company: res["company"] },
126
131
  });
127
- this.$notify.error({
132
+ ElNotification.error({
128
133
  title: "Domain is SSO enabled",
129
134
  message: "Sign in with your company email address",
130
135
  duration: 10000,
@@ -133,16 +138,14 @@ export default {
133
138
  await this.postLogin();
134
139
  }
135
140
  } catch (e) {
136
- this.$root.errors(e);
141
+ console.log(e);
137
142
  } finally {
138
143
  this.loading = false;
139
144
  }
140
145
  },
141
146
 
142
147
  async postLogin() {
143
- const { data: user } = await this.$store.dispatch("getUser", {
144
- errors: this.$root.errors,
145
- });
148
+ const { data: user } = await this.$store.dispatch("getUser");
146
149
 
147
150
  if (window.dataLayer) {
148
151
  window.dataLayer.push({ event: "login", user });
@@ -163,12 +166,5 @@ export default {
163
166
  this.isPasswordValid = isValid;
164
167
  },
165
168
  },
166
-
167
- components: {
168
- VPasswordValidation: require("./../components/VPasswordValidation.vue")
169
- .default,
170
- elInput: require("../../../components/form/basic.vue").default,
171
- elButton: require("../../../components/basic/Button.vue").default,
172
- },
173
169
  };
174
170
  </script>
@@ -4,16 +4,16 @@
4
4
  <h1 class="h2 h2--small">Reset password</h1>
5
5
  <form class="form" @submit.prevent="submit">
6
6
  <div v-if="!form.successful">
7
- <p class="AM-mt-2 AM-mb-0 AM-color-highlight">
7
+ <p class="mt-2 mb-0 color-highlight">
8
8
  <strong class="">Email: {{ form?.email }}</strong>
9
9
  </p>
10
- <p class="AM-mt-0.5">
10
+ <p class="mt-0.5">
11
11
  Please create a new password. Passwords you have used
12
12
  previously aren’t permitted.
13
13
  </p>
14
14
  <el-input
15
15
  v-model="form.password"
16
- class="AM-mt-3"
16
+ class="mt-3"
17
17
  label="New Password"
18
18
  placeholder="Enter new password"
19
19
  name="password"
@@ -23,7 +23,7 @@
23
23
  required
24
24
  />
25
25
 
26
- <VPasswordValidation
26
+ <VelPasswordValidation
27
27
  :password="form.password"
28
28
  @passwordValid="updatePasswordValidity"
29
29
  />
@@ -51,7 +51,7 @@
51
51
  <h4 class="mt" v-text="`Success!`" />
52
52
  <p v-text="`Your password has been reset.`" />
53
53
  </div>
54
- <p class="disclaimer AM-mt-3">
54
+ <p class="disclaimer mt-3">
55
55
  <router-link
56
56
  class="color-1 underline"
57
57
  :to="{ name: 'auth.login' }"
@@ -66,8 +66,17 @@
66
66
 
67
67
  <script>
68
68
  import Form from "form-backend-validation";
69
+ import { guestRequest } from "../js/guest-request";
69
70
 
70
71
  export default {
72
+ components: {
73
+ VelPasswordValidation:
74
+ require("../../../components/layout/PasswordValidation.vue")
75
+ .default,
76
+ elInput: require("../../../components/form/basic.vue").default,
77
+ elButton: require("../../../components/basic/Button.vue").default,
78
+ },
79
+
71
80
  data() {
72
81
  return {
73
82
  form: new Form(
@@ -90,7 +99,11 @@ export default {
90
99
  methods: {
91
100
  async onSubmit() {
92
101
  try {
93
- const res = await this.form.post("/reset-password");
102
+ await guestRequest({
103
+ form: this.form,
104
+ url: "/reset-password",
105
+ store: this.$store,
106
+ });
94
107
 
95
108
  this.$router.push({
96
109
  name: "auth.success-reset",
@@ -108,7 +121,7 @@ export default {
108
121
  query: { email: this.form.email },
109
122
  });
110
123
  }
111
- this.$root.errors(e);
124
+ console.log(e);
112
125
  }
113
126
  },
114
127
 
@@ -122,12 +135,5 @@ export default {
122
135
  title: "Reset Password",
123
136
  };
124
137
  },
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
138
  };
133
139
  </script>
@@ -4,15 +4,15 @@
4
4
  <h1 class="h2 h2--small">Reset password</h1>
5
5
 
6
6
  <form class="form" @submit.prevent="submit">
7
- <p class="AM-mt-2 AM-mb-0 AM-color-highlight">
7
+ <p class="mt-2 mb-0 color-highlight">
8
8
  <strong class="">Email: {{ form?.email }}</strong>
9
9
  </p>
10
- <p class="AM-mt">
10
+ <p class="mt">
11
11
  If this account exists we have sent an email containing
12
12
  instructions for resetting the password.
13
13
  <strong>Please check your inbox.</strong>
14
14
  </p>
15
- <p class="AM-mt-3 AM-mb">
15
+ <p class="mt-3 mb">
16
16
  Haven’t received the email after 10 minutes?
17
17
  </p>
18
18
 
@@ -37,7 +37,7 @@
37
37
  Re-send instructions
38
38
  </elButton>
39
39
 
40
- <p class="disclaimer AM-mt-3">
40
+ <p class="disclaimer mt-3">
41
41
  <router-link
42
42
  class="color-1 underline"
43
43
  :to="{ name: `auth.login` }"
@@ -52,6 +52,8 @@
52
52
 
53
53
  <script>
54
54
  import Form from "form-backend-validation";
55
+ import { ElNotification } from "element-plus";
56
+ import { guestRequest } from "../js/guest-request";
55
57
 
56
58
  export default {
57
59
  components: {
@@ -76,9 +78,13 @@ export default {
76
78
  this.notification = null;
77
79
  }
78
80
 
79
- await this.form.post("/forgot-password");
81
+ await guestRequest({
82
+ form: this.form,
83
+ url: "/forgot-password",
84
+ store: this.$store,
85
+ });
80
86
 
81
- this.$notify({
87
+ ElNotification({
82
88
  type: "success",
83
89
  message: "Email has been re-sent",
84
90
  duration: 10000,
@@ -86,14 +92,14 @@ export default {
86
92
  });
87
93
  } catch (e) {
88
94
  if (e.response && e.response.status === 422) {
89
- this.notification = this.$notify({
95
+ this.notification = ElNotification({
90
96
  type: "warning",
91
97
  message: "Please allow 10 minutes before re-requesting",
92
98
  duration: 0,
93
99
  class: "el-notification--warning el-notification--right-override",
94
100
  });
95
101
  } else {
96
- this.$root.errors(e);
102
+ console.log(e);
97
103
  }
98
104
  }
99
105
  },
@@ -3,10 +3,10 @@
3
3
  <section id="resetPasswordForm">
4
4
  <h1 class="h2 h2--small">Success</h1>
5
5
 
6
- <p class="AM-mt-2 AM-mb-0 AM-color-highlight">
6
+ <p class="mt-2 mb-0 color-highlight">
7
7
  <strong class="">Email: {{ $route.query.email }}</strong>
8
8
  </p>
9
- <p class="AM-mt">
9
+ <p class="mt">
10
10
  Your password has been reset. Please sign in to continue.
11
11
  </p>
12
12
 
@@ -20,9 +20,7 @@
20
20
  <script>
21
21
  export default {
22
22
  mounted() {
23
- this.$store.dispatch("getUser", {
24
- errors: this.$root.errors,
25
- });
23
+ this.$store.dispatch("getUser");
26
24
  },
27
25
  components: {
28
26
  elButton: require("../../../components/basic/Button.vue").default,
@@ -2,17 +2,15 @@
2
2
  <h1 class="h2 h2--small">Verify your email address</h1>
3
3
 
4
4
  <form class="form" @submit.prevent="submit">
5
- <p class="AM-mt-2 AM-mb-0 AM-color-highlight">
5
+ <p class="mt-2 mb-0 color-highlight">
6
6
  <strong class="">Email: {{ user?.email }}</strong>
7
7
  </p>
8
- <p class="AM-mt-0.5">
8
+ <p class="mt-0.5">
9
9
  <strong>Please check your inbox</strong> for a Verification email
10
10
  from {{ $root.appName }}. Click the link in that email to verify
11
11
  your email address and complete your registration.
12
12
  </p>
13
- <p class="AM-mt-0.5 AM-mb-0">
14
- Haven’t received the email after 10 minutes?
15
- </p>
13
+ <p class="mt-0.5 mb-0">Haven’t received the email after 10 minutes?</p>
16
14
 
17
15
  <el-input
18
16
  class="hidden"
@@ -26,7 +24,7 @@
26
24
  />
27
25
 
28
26
  <elButton
29
- class="AM-mt AM-mb-3"
27
+ class="mt mb-3"
30
28
  native-type="submit"
31
29
  type="primary"
32
30
  :disabled="form.processing"
@@ -36,7 +34,7 @@
36
34
  Re-send verification link
37
35
  </elButton>
38
36
 
39
- <p class="disclaimer AM-mt-1.5">
37
+ <p class="disclaimer mt-1.5">
40
38
  Having trouble singing in?
41
39
  <a :href="$store.state.auth.contact" class="underline"
42
40
  >Contact us</a
@@ -47,6 +45,7 @@
47
45
 
48
46
  <script>
49
47
  import Form from "form-backend-validation";
48
+ import { ElNotification } from "element-plus";
50
49
 
51
50
  export default {
52
51
  components: {
@@ -74,7 +73,7 @@ export default {
74
73
 
75
74
  await this.form.post("/email/verification-notification");
76
75
 
77
- this.$notify({
76
+ ElNotification({
78
77
  type: "success",
79
78
  message: "Email has been re-sent",
80
79
  duration: 10000,
@@ -82,30 +81,28 @@ export default {
82
81
  });
83
82
  } catch (e) {
84
83
  if (e.response && e.response.status === 429) {
85
- this.notification = this.$notify({
84
+ this.notification = ElNotification({
86
85
  type: "warning",
87
86
  message: "Please allow 10 minutes before re-requesting",
88
87
  duration: 0,
89
88
  class: "el-notification--warning el-notification--right-override",
90
89
  });
91
90
  } else if (e.response && e.response.status === 422) {
92
- this.notification = this.$notify({
91
+ this.notification = ElNotification({
93
92
  type: "error",
94
93
  message: e.response.data.message,
95
94
  duration: 0,
96
95
  class: "el-notification--error el-notification--right-override",
97
96
  });
98
97
  } else {
99
- this.$root.errors(e);
98
+ console.log(e);
100
99
  }
101
100
  }
102
101
  },
103
102
  },
104
103
 
105
104
  async mounted() {
106
- this.user = await this.$store.dispatch("getUser", {
107
- errors: this.$root.errors,
108
- });
105
+ this.user = await this.$store.dispatch("getUser");
109
106
 
110
107
  this.form.email = this.user.email;
111
108
  },
@@ -0,0 +1,99 @@
1
+ <template>
2
+ <div class="container px-6 tablet:px-4 mobile:px-2 mb-8 ml-0 mr-0">
3
+ <div class="grid__1/1">
4
+ <div class="grid__1/1 mb-4">
5
+ <h2 class="h1">Create {{ resource.singular }}</h2>
6
+ </div>
7
+ <div :class="['mt', resource.form.class]">
8
+ <component
9
+ :is="resource.form.component ?? 'XForm'"
10
+ ref="form"
11
+ :form="form"
12
+ :submit="submit"
13
+ :method="method"
14
+ :resource="resource"
15
+ />
16
+ </div>
17
+ </div>
18
+ </div>
19
+ </template>
20
+
21
+ <script>
22
+ import Form from "form-backend-validation";
23
+
24
+ export default {
25
+ components: {
26
+ XForm: require("./partials/form.vue").default,
27
+ },
28
+
29
+ props: {
30
+ resource: {
31
+ type: Object,
32
+ required: true,
33
+ },
34
+ },
35
+
36
+ data() {
37
+ return {
38
+ form: null,
39
+ method: "post",
40
+ };
41
+ },
42
+
43
+ beforeMount() {
44
+ this.form = new Form(this.resource.form.fields(this), {
45
+ resetOnSuccess: false,
46
+ });
47
+ },
48
+
49
+ methods: {
50
+ async submit() {
51
+ if (this.resource.form.submit) {
52
+ await this.resource.form.submit(this);
53
+ } else {
54
+ const hold = { ...this.form.data() };
55
+
56
+ try {
57
+ this.form.populate(this.resource.form.preparation(this));
58
+
59
+ let res = await this.form.post(
60
+ `${this.resource.api.endpoint(this)}`,
61
+ );
62
+
63
+ this.emitter?.emit("resource:saved", {
64
+ resource: this.resource,
65
+ model: res.data,
66
+ });
67
+
68
+ const redirect = this.resource.form.redirect
69
+ ? this.resource.form.redirect({
70
+ resource: this.resource,
71
+ model: res.data,
72
+ form: this.form,
73
+ $store: this.$store,
74
+ $router: this.$router,
75
+ method: this.method,
76
+ })
77
+ : {
78
+ name: `${this.resource.routeName}.show`,
79
+ params: {
80
+ [this.resource.id]: res.data.id,
81
+ },
82
+ };
83
+
84
+ this.$router.replace(redirect);
85
+ } catch (e) {
86
+ console.log(e);
87
+ } finally {
88
+ if (
89
+ !this.form.successful ||
90
+ !this.form.__options.resetOnSuccess
91
+ ) {
92
+ this.form.populate(hold);
93
+ }
94
+ }
95
+ }
96
+ },
97
+ },
98
+ };
99
+ </script>