@hostlink/nuxt-light 1.32.4 → 1.33.1
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/dist/module.json +1 -1
- package/dist/module.mjs +2 -1
- package/dist/runtime/composables/defineLightModel.d.ts +1 -0
- package/dist/runtime/composables/useAsyncObject.d.ts +1 -0
- package/dist/runtime/composables/useAsyncObject.js +33 -0
- package/dist/runtime/composables/useObject.d.ts +1 -0
- package/dist/runtime/composables/useObject.js +22 -0
- package/dist/runtime/pages/User/_user_id/view.vue +3 -2
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -336,10 +336,11 @@ const module = defineNuxtModule({
|
|
|
336
336
|
});
|
|
337
337
|
addImportsDir(resolver.resolve("./runtime/composables"));
|
|
338
338
|
const files = await resolveFiles(process.cwd() + "/models", ["*"]);
|
|
339
|
+
const files2 = await resolveFiles(process.cwd() + "/app/models", ["*"]);
|
|
339
340
|
nuxt.options.runtimeConfig.public.light = {
|
|
340
341
|
model: []
|
|
341
342
|
};
|
|
342
|
-
for (const file of files) {
|
|
343
|
+
for (const file of [...files, ...files2]) {
|
|
343
344
|
const n1 = "Model_" + file.match(/([a-zA-Z0-9]+)\.ts$/)?.[1];
|
|
344
345
|
addPlugin({
|
|
345
346
|
src: file,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (fields: Object): import("#app").AsyncData<void | null, import("#app").NuxtError<unknown> | null> | undefined;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { toQuery } from "@hostlink/light";
|
|
2
|
+
import { useRoute } from "vue-router";
|
|
3
|
+
import { default as getModelField } from "./getModelField.js";
|
|
4
|
+
import { default as collect } from "./collect.js";
|
|
5
|
+
import { defu } from "defu";
|
|
6
|
+
import { useAsyncData } from "#app";
|
|
7
|
+
export default function(fields) {
|
|
8
|
+
let route = useRoute();
|
|
9
|
+
if (!route.name) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const [module, id_name] = route.name.split("-");
|
|
13
|
+
const id = parseInt(route.params[id_name]);
|
|
14
|
+
let query = {};
|
|
15
|
+
const specialFields = {};
|
|
16
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
17
|
+
const f = getModelField(module, key);
|
|
18
|
+
if (f) {
|
|
19
|
+
query = defu(query, f.getGQLField());
|
|
20
|
+
specialFields[key] = f;
|
|
21
|
+
} else {
|
|
22
|
+
query[key] = value;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return useAsyncData(async () => {
|
|
26
|
+
const data = await collect(module, toQuery(query)).where(id_name, id).first();
|
|
27
|
+
for (const [key, value] of Object.entries(specialFields)) {
|
|
28
|
+
if (value && typeof value === "object" && "field" in value && typeof value.field === "function") {
|
|
29
|
+
data[key] = value.field(data);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (fields: Object): Promise<any>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { toQuery } from "@hostlink/light";
|
|
2
|
+
import { useRoute } from "vue-router";
|
|
3
|
+
import { default as getModelField } from "./getModelField.js";
|
|
4
|
+
import { default as collect } from "./collect.js";
|
|
5
|
+
import { defu } from "defu";
|
|
6
|
+
export default async function(fields) {
|
|
7
|
+
let route = useRoute();
|
|
8
|
+
if (!route.name) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const [module, id_name] = route.name.split("-");
|
|
12
|
+
const id = parseInt(route.params[id_name]);
|
|
13
|
+
let query = {};
|
|
14
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
15
|
+
query[key] = value;
|
|
16
|
+
const f = getModelField(module, key);
|
|
17
|
+
if (f) {
|
|
18
|
+
query = defu(query, f.getGQLField());
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return await collect(module, toQuery(query)).where(id_name, id).first();
|
|
22
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { useLight,
|
|
2
|
+
import { useLight, useAsyncObject, m } from "#imports";
|
|
3
3
|
import { useRoute } from "vue-router";
|
|
4
4
|
import { ref } from "vue";
|
|
5
5
|
const route = useRoute();
|
|
6
|
-
const obj = await
|
|
6
|
+
const { data: obj } = await useAsyncObject({ canUpdate: true, canDelete: true });
|
|
7
7
|
const light = useLight();
|
|
8
8
|
const tab = ref("overview");
|
|
9
9
|
const id = route.params.user_id;
|
|
@@ -39,6 +39,7 @@ const reset2fa = async () => {
|
|
|
39
39
|
label="Change password"></l-btn>
|
|
40
40
|
<l-btn to="update-role" icon="sym_o_people" permission="user.role.add" label="Update role"></l-btn>
|
|
41
41
|
<l-btn label="Reset 2FA" icon="sym_o_key" permission="user.reset2fa" @click="reset2fa"></l-btn>
|
|
42
|
+
|
|
42
43
|
</template>
|
|
43
44
|
|
|
44
45
|
<q-card flat bordered>
|