@hostlink/nuxt-light 0.0.80 → 0.0.82
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 +3 -2
- package/dist/runtime/components/l-item.vue +7 -3
- package/dist/runtime/components/l-list.vue +47 -1
- package/dist/runtime/lib/{defineType.d.ts → defineObject.d.ts} +1 -1
- package/dist/runtime/lib/defineObject.mjs +5 -0
- package/dist/runtime/lib/getID.mjs +2 -3
- package/dist/runtime/lib/getObject.mjs +11 -1
- package/dist/runtime/lib/getObjectColumn.d.ts +2 -0
- package/dist/runtime/lib/getObjectColumn.mjs +15 -0
- package/dist/runtime/lib/{getTypeColumns.mjs → getObjectColumns.mjs} +1 -1
- package/dist/runtime/lib/index.d.ts +4 -3
- package/dist/runtime/lib/index.mjs +6 -4
- package/dist/runtime/pages/SystemValue/index.vue +2 -2
- package/dist/runtime/pages/User/_user_id/view.vue +11 -18
- package/dist/runtime/pages/User/index.vue +2 -2
- package/dist/runtime/pages/UserLog/index.vue +2 -2
- package/dist/runtime/plugin.mjs +4 -4
- package/dist/runtime/types/User.d.ts +8 -0
- package/dist/runtime/types/User.mjs +13 -3
- package/package.json +1 -1
- package/dist/runtime/lib/defineType.mjs +0 -5
- /package/dist/runtime/lib/{getTypeColumns.d.ts → getObjectColumns.d.ts} +0 -0
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -53,8 +53,9 @@ const module = defineNuxtModule({
|
|
|
53
53
|
{ name: "listObject", from },
|
|
54
54
|
{ name: "useLight", from: index },
|
|
55
55
|
{ name: "isGranted", from },
|
|
56
|
-
{ name: "
|
|
57
|
-
{ name: "
|
|
56
|
+
{ name: "getObjectColumns", from },
|
|
57
|
+
{ name: "defineObject", from },
|
|
58
|
+
{ name: "getObjectColumn", from }
|
|
58
59
|
]);
|
|
59
60
|
addPlugin({
|
|
60
61
|
src: resolver.resolve("./runtime/plugin"),
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
|
|
2
|
+
import { inject } from 'vue'
|
|
3
|
+
const props = defineProps({
|
|
3
4
|
label: {
|
|
4
5
|
type: String,
|
|
5
|
-
required: true
|
|
6
6
|
},
|
|
7
7
|
type: {
|
|
8
8
|
type: String,
|
|
9
9
|
default: "text"
|
|
10
|
+
}, name: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: null
|
|
10
13
|
}
|
|
11
14
|
});
|
|
15
|
+
|
|
16
|
+
|
|
12
17
|
</script>
|
|
13
18
|
<template>
|
|
14
19
|
<q-item>
|
|
15
20
|
<q-item-section>
|
|
16
21
|
<q-item-label>{{ $t(label) }}</q-item-label>
|
|
17
|
-
|
|
18
22
|
<q-item-label caption v-if="type == 'caption'">
|
|
19
23
|
<div style="white-space: pre-wrap;">
|
|
20
24
|
<slot></slot>
|
|
@@ -1,5 +1,51 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
|
|
3
|
+
const props = defineProps({
|
|
4
|
+
modelValue: {
|
|
5
|
+
type: Object
|
|
6
|
+
},
|
|
7
|
+
columns: {
|
|
8
|
+
type: Array
|
|
9
|
+
}
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
const getValue = (column) => {
|
|
13
|
+
|
|
14
|
+
//type of column field is function
|
|
15
|
+
if (column.field && typeof column.field == 'function') {
|
|
16
|
+
return column.field(props.modelValue);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//if field is string
|
|
20
|
+
if (column.field && typeof column.field == 'string') {
|
|
21
|
+
return props.modelValue[column.field];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return props.modelValue[column.name];
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
const getDisplayValue = (column) => {
|
|
28
|
+
const value = getValue(column);
|
|
29
|
+
|
|
30
|
+
if (column.format) {
|
|
31
|
+
return column.format(value);
|
|
32
|
+
}
|
|
33
|
+
return value;
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
</script>
|
|
1
38
|
<template>
|
|
2
39
|
<q-list bordered separator>
|
|
3
|
-
<
|
|
40
|
+
<template v-if="columns">
|
|
41
|
+
<l-item v-for="column in columns" :label="column.label">
|
|
42
|
+
{{ getDisplayValue(column) }}
|
|
43
|
+
</l-item>
|
|
44
|
+
|
|
45
|
+
</template>
|
|
46
|
+
<template v-else>
|
|
47
|
+
<slot></slot>
|
|
48
|
+
</template>
|
|
49
|
+
|
|
4
50
|
</q-list>
|
|
5
51
|
</template>
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { useRoute } from "vue-router";
|
|
2
2
|
const route = useRoute();
|
|
3
3
|
export default () => {
|
|
4
|
-
let
|
|
5
|
-
let name = route2.name?.toString();
|
|
4
|
+
let name = route.name?.toString();
|
|
6
5
|
if (name == void 0)
|
|
7
6
|
return 0;
|
|
8
7
|
let parts = name.split("-");
|
|
9
8
|
const module = parts[0];
|
|
10
9
|
const moduleLower = module.charAt(0).toLowerCase() + module.slice(1);
|
|
11
10
|
const keyname = parts[1];
|
|
12
|
-
return parseInt(
|
|
11
|
+
return parseInt(route.params[keyname]);
|
|
13
12
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useRoute } from "vue-router";
|
|
2
2
|
import loadObject from "./loadObject.mjs";
|
|
3
|
+
import getObjectColumn from "./getObjectColumn.mjs";
|
|
3
4
|
export default async function(fields = []) {
|
|
4
5
|
let route = useRoute();
|
|
5
6
|
if (!route.name) {
|
|
@@ -12,5 +13,14 @@ export default async function(fields = []) {
|
|
|
12
13
|
if (fields instanceof Array && fields.length == 0) {
|
|
13
14
|
fields.push(id_name);
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
+
let fs = fields.map((field) => {
|
|
17
|
+
if (typeof field == "string") {
|
|
18
|
+
const column = getObjectColumn(module, field);
|
|
19
|
+
if (column && column.gqlField) {
|
|
20
|
+
return column.gqlField;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return field;
|
|
24
|
+
});
|
|
25
|
+
return await loadObject(module, filters, fs);
|
|
16
26
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getData } from "./defineObject.mjs";
|
|
2
|
+
export default (type, name) => {
|
|
3
|
+
let data = getData();
|
|
4
|
+
if (!data[type])
|
|
5
|
+
return;
|
|
6
|
+
if (!data[type][name])
|
|
7
|
+
return;
|
|
8
|
+
let options = data[type][name];
|
|
9
|
+
if (!options)
|
|
10
|
+
return;
|
|
11
|
+
if (!options.name) {
|
|
12
|
+
options.name = name;
|
|
13
|
+
}
|
|
14
|
+
return options;
|
|
15
|
+
};
|
|
@@ -15,9 +15,10 @@ import listObject from "./listObject";
|
|
|
15
15
|
import loadObject from "./loadObject";
|
|
16
16
|
import isGranted from "./isGranted";
|
|
17
17
|
import GQLFieldBuilder from "./GQLFieldBuilder";
|
|
18
|
-
import
|
|
18
|
+
import getObjectColumns from "./getObjectColumns";
|
|
19
|
+
import getObjectColumn from './getObjectColumn';
|
|
19
20
|
declare const notify: (message: string, color?: string) => void;
|
|
20
21
|
import getID from "./getID";
|
|
21
22
|
declare const getApiBase: () => {};
|
|
22
|
-
import
|
|
23
|
-
export { addObject, f, getApiUrl, getCurrentUser, getObject, list, listData, m, q, removeObject, t, updateObject, notify, getID, deleteObject, listObject, isGranted, getApiBase, loadObject, GQLFieldBuilder,
|
|
23
|
+
import defineObject from './defineObject';
|
|
24
|
+
export { addObject, f, getApiUrl, getCurrentUser, getObject, list, listData, m, q, removeObject, t, updateObject, notify, getID, deleteObject, listObject, isGranted, getApiBase, loadObject, GQLFieldBuilder, defineObject, getObjectColumns, getObjectColumn };
|
|
@@ -17,7 +17,8 @@ import listObject from "./listObject.mjs";
|
|
|
17
17
|
import loadObject from "./loadObject.mjs";
|
|
18
18
|
import isGranted from "./isGranted.mjs";
|
|
19
19
|
import GQLFieldBuilder from "./GQLFieldBuilder.mjs";
|
|
20
|
-
import
|
|
20
|
+
import getObjectColumns from "./getObjectColumns.mjs";
|
|
21
|
+
import getObjectColumn from "./getObjectColumn.mjs";
|
|
21
22
|
const notify = function(message, color = "green") {
|
|
22
23
|
Notify.create({
|
|
23
24
|
message,
|
|
@@ -30,7 +31,7 @@ const getApiBase = () => {
|
|
|
30
31
|
const config = useRuntimeConfig();
|
|
31
32
|
return config?.public?.apiBase ?? "/api/";
|
|
32
33
|
};
|
|
33
|
-
import
|
|
34
|
+
import defineObject from "./defineObject.mjs";
|
|
34
35
|
export {
|
|
35
36
|
addObject,
|
|
36
37
|
f,
|
|
@@ -52,6 +53,7 @@ export {
|
|
|
52
53
|
getApiBase,
|
|
53
54
|
loadObject,
|
|
54
55
|
GQLFieldBuilder,
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
defineObject,
|
|
57
|
+
getObjectColumns,
|
|
58
|
+
getObjectColumn
|
|
57
59
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { ref } from 'vue'
|
|
3
|
-
import
|
|
3
|
+
import getObjectColumns from "../../lib/getObjectColumns";
|
|
4
4
|
import sv from "../../lib/sv";
|
|
5
|
-
const columns =
|
|
5
|
+
const columns = getObjectColumns("SystemValue", ["name", "value"]);
|
|
6
6
|
</script>
|
|
7
7
|
<template>
|
|
8
8
|
<l-page>
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { getObject,
|
|
2
|
+
import { getObject, getObjectColumns } from '../../../';
|
|
3
3
|
const obj = await getObject(["user_id", "username", "first_name", "last_name", "email", "phone", "roles", 'status', 'join_date']);
|
|
4
|
-
|
|
5
|
-
//await getObject(["user_id", { test: ["username"] }])
|
|
6
|
-
/* const test = async () => {
|
|
7
|
-
console.log(await loadObject("User", { user_id: obj.user_id }, ["username"]));
|
|
8
|
-
}
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
4
|
</script>
|
|
12
5
|
|
|
13
6
|
<template>
|
|
@@ -18,16 +11,16 @@ const obj = await getObject(["user_id", "username", "first_name", "last_name", "
|
|
|
18
11
|
</template>
|
|
19
12
|
|
|
20
13
|
<l-card>
|
|
21
|
-
<l-list
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
14
|
+
<l-list v-model="obj" :columns="getObjectColumns('User', [
|
|
15
|
+
'username',
|
|
16
|
+
'first_name',
|
|
17
|
+
'last_name',
|
|
18
|
+
'email',
|
|
19
|
+
'phone',
|
|
20
|
+
'roles',
|
|
21
|
+
'status',
|
|
22
|
+
'join_date'
|
|
23
|
+
])">
|
|
31
24
|
</l-list>
|
|
32
25
|
</l-card>
|
|
33
26
|
</l-page>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { ref } from 'vue'
|
|
3
|
-
import
|
|
3
|
+
import getObjectColumns from "../../lib/getObjectColumns";
|
|
4
4
|
const onRequest = async (request) => {
|
|
5
5
|
request.loadObjects("User", { status: status.value });
|
|
6
6
|
};
|
|
7
|
-
const columns =
|
|
7
|
+
const columns = getObjectColumns("User", ["username", "first_name", "label_name", "email", "phone", "join_date"]);
|
|
8
8
|
const status = ref("0");
|
|
9
9
|
</script>
|
|
10
10
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import
|
|
3
|
-
const columns =
|
|
2
|
+
import getObjectColumns from "../../lib/getObjectColumns";
|
|
3
|
+
const columns = getObjectColumns("UserLog", ["userlog_id", "username", "login_dt", "logout_dt", "result", "user_agent"]);
|
|
4
4
|
</script>
|
|
5
5
|
<template>
|
|
6
6
|
<l-page>
|
package/dist/runtime/plugin.mjs
CHANGED
|
@@ -7,14 +7,14 @@ import message_en from "./locales/en.json";
|
|
|
7
7
|
import message_zh from "./locales/zh-hk.json";
|
|
8
8
|
import routes from "./routes.mjs";
|
|
9
9
|
localStorage.getItem("locale") || localStorage.setItem("locale", "en");
|
|
10
|
-
import { useLight,
|
|
10
|
+
import { useLight, defineObject } from "./index.mjs";
|
|
11
11
|
import TypeUser from "./types/User.mjs";
|
|
12
12
|
import TypeUserLog from "./types/UserLog.mjs";
|
|
13
13
|
import TypeSystemValue from "./types/SystemValue.mjs";
|
|
14
14
|
export default defineNuxtPlugin((nuxtApp) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
defineObject("User", TypeUser);
|
|
16
|
+
defineObject("UserLog", TypeUserLog);
|
|
17
|
+
defineObject("SystemValue", TypeSystemValue);
|
|
18
18
|
nuxtApp.vueApp.config.errorHandler = (error) => {
|
|
19
19
|
console.log(error);
|
|
20
20
|
const light = useLight();
|
|
@@ -30,5 +30,13 @@ declare const _default: {
|
|
|
30
30
|
searchable: boolean;
|
|
31
31
|
searchType: string;
|
|
32
32
|
};
|
|
33
|
+
roles: {
|
|
34
|
+
label: string;
|
|
35
|
+
format: (value: any) => any;
|
|
36
|
+
};
|
|
37
|
+
status: {
|
|
38
|
+
label: string;
|
|
39
|
+
format: (value: any) => "Active" | "Inactive";
|
|
40
|
+
};
|
|
33
41
|
};
|
|
34
42
|
export default _default;
|
|
@@ -5,12 +5,12 @@ export default {
|
|
|
5
5
|
searchable: true
|
|
6
6
|
},
|
|
7
7
|
first_name: {
|
|
8
|
-
label: "First
|
|
8
|
+
label: "First name",
|
|
9
9
|
sortable: true,
|
|
10
10
|
searchable: true
|
|
11
11
|
},
|
|
12
12
|
last_name: {
|
|
13
|
-
label: "Last
|
|
13
|
+
label: "Last name",
|
|
14
14
|
sortable: true,
|
|
15
15
|
searchable: true
|
|
16
16
|
},
|
|
@@ -25,9 +25,19 @@ export default {
|
|
|
25
25
|
searchable: true
|
|
26
26
|
},
|
|
27
27
|
join_date: {
|
|
28
|
-
label: "Join
|
|
28
|
+
label: "Join date",
|
|
29
29
|
sortable: true,
|
|
30
30
|
searchable: true,
|
|
31
31
|
searchType: "date"
|
|
32
|
+
},
|
|
33
|
+
roles: {
|
|
34
|
+
label: "Roles",
|
|
35
|
+
format: (value) => value.join(", ")
|
|
36
|
+
},
|
|
37
|
+
status: {
|
|
38
|
+
label: "Status",
|
|
39
|
+
format: (value) => {
|
|
40
|
+
return value == 0 ? "Active" : "Inactive";
|
|
41
|
+
}
|
|
32
42
|
}
|
|
33
43
|
};
|
package/package.json
CHANGED
|
File without changes
|