@hostlink/nuxt-light 1.8.10 → 1.8.12

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "light",
3
3
  "configKey": "light",
4
- "version": "1.8.10"
4
+ "version": "1.8.12"
5
5
  }
package/dist/module.mjs CHANGED
@@ -26,6 +26,8 @@ const module = defineNuxtModule({
26
26
  const index = resolver.resolve("./runtime/index");
27
27
  const SystemValue = resolver.resolve("./runtime/lib/SystemValue");
28
28
  addImports([
29
+ { name: "id", from },
30
+ { name: "getID", from },
29
31
  { name: "addObject", from },
30
32
  { name: "f", from },
31
33
  { name: "getApiUrl", from },
@@ -1,15 +1,67 @@
1
1
  <script setup>
2
+ import { animations } from "@formkit/drag-and-drop";
3
+ import { getCurrentInstance, watch } from 'vue'
4
+ import { useDragAndDrop } from '@formkit/drag-and-drop/vue'
2
5
  const model = defineModel();
3
-
4
- const props=defineProps({
5
- slots: Array
6
+
7
+ const props = defineProps({
8
+ name: String
9
+ })
10
+
11
+
12
+ //find the parent component l-drop-drop-group
13
+
14
+ const doFind = (instance) => {
15
+ if (instance.type.__name === "l-drag-drop-group") {
16
+ return instance;
17
+ }
18
+ if (instance.parent) {
19
+ return doFind(instance.parent);
20
+ }
21
+ return null;
22
+ }
23
+
24
+ const group = doFind(getCurrentInstance());
25
+
26
+ const allItems = group.exposed.findAllItems();
27
+ const group_name = group.exposed.getGroupName();
28
+ const group_model = group.exposed.getModelByName(props.name);
29
+
30
+
31
+ console.log(props.name)
32
+ if (model.value == undefined) {
33
+ model.value = group_model;
34
+ console.log(model.value)
35
+ }
36
+
37
+
38
+ //filter items by model
39
+ const filteredItem = allItems.filter((item) => {
40
+ return model.value.includes(item.props.name);
6
41
  })
7
42
 
8
43
 
44
+ const [parent, items] = useDragAndDrop(filteredItem, {
45
+ plugins: [animations()],
46
+ group: group_name,
47
+ dragHandle: group.props.dragHandle
48
+ });
49
+
50
+ watch(items, () => {
51
+ model.value = items.value.map((item) => {
52
+ return item.props.name ?? Symbol();
53
+ })
54
+
55
+ group.exposed.updateModel(props.name, model.value);
56
+
57
+ })
58
+
9
59
 
10
60
  </script>
11
61
  <template>
12
- <div>
13
- <component :is="slot" v-for="slot in slots" />
62
+ <div ref="parent" style="min-height: 150px;">
63
+ <template v-for="item in items" :key="item">
64
+ <component :is="item" />
65
+ </template>
14
66
  </div>
15
67
  </template>
@@ -1,17 +1,37 @@
1
1
  <script setup>
2
- import { useSlots } from 'vue'
2
+ import { useSlots, defineExpose } from 'vue'
3
+
4
+ const model = defineModel();
5
+ console.log(model);
6
+
3
7
  const slots = useSlots().default();
4
8
 
5
9
  //fine component by name
6
-
7
10
  const DragDropContainer = resolveComponent("l-drag-drop-container")
8
-
11
+ const group_name = Symbol();
12
+ defineExpose({
13
+ updateModel: (name, value) => {
14
+ model.value[name] = value;
15
+ },
16
+ getModelByName: (name) => {
17
+ return model.value[name]
18
+ },
19
+ getGroupName: () => {
20
+ return group_name;
21
+ },
22
+
23
+ findAllItems: () => {
24
+ const containers = getContainers(slots);
25
+ const items = getItems(containers);
26
+ return items;
27
+ }
28
+ });
9
29
 
10
30
  //find all l-drag-drop-container (include children)
11
31
  function getContainers(nodes) {
12
32
  const containers = [];
13
33
  for (const node of nodes) {
14
- console.log(node)
34
+ //console.log(node)
15
35
 
16
36
  //check node is l-drag-drop-container
17
37
 
@@ -24,6 +44,7 @@ function getContainers(nodes) {
24
44
  if (node.children) {
25
45
  if (node.children.default) {
26
46
  containers.push(...getContainers(node.children.default()));
47
+
27
48
  }
28
49
 
29
50
  }
@@ -32,8 +53,6 @@ function getContainers(nodes) {
32
53
  return containers;
33
54
  }
34
55
 
35
- const containers = getContainers(slots);
36
-
37
56
 
38
57
  //get all containers children and join them
39
58
  function getItems(containers) {
@@ -44,12 +63,9 @@ function getItems(containers) {
44
63
  return items;
45
64
  }
46
65
 
47
- const items = getItems(containers);
48
66
 
49
67
 
50
68
  </script>
51
69
  <template>
52
- <div>
53
- <slot></slot>
54
- </div>
70
+ <slot></slot>
55
71
  </template>
@@ -7,7 +7,7 @@ const slots = useSlots();
7
7
  const model = defineModel()
8
8
 
9
9
  const props = defineProps<{
10
- group?: string
10
+ group?: string|symbol,
11
11
  dragHandle?: string
12
12
  }>()
13
13
 
@@ -37,7 +37,7 @@ watch(items, () => {
37
37
 
38
38
  </script>
39
39
  <template>
40
-
40
+
41
41
 
42
42
 
43
43
  <div ref="parent">
@@ -9,12 +9,10 @@ const props = defineProps({
9
9
  });
10
10
 
11
11
  const node = props.context.node;
12
- console.log(node);
13
12
  const min = props.context.node.props.min ?? 1;
14
13
  const max = props.context.node.props.max ?? Infinity;
15
14
  const sortable = (props.context.node.props.sortable !== undefined) ? props.context.node.props.sortable : true;
16
15
 
17
- console.log(sortable);
18
16
  const [parent, localValue] = useDragAndDrop(props.context.value, {
19
17
  dragHandle: ".l-repeater-handle",
20
18
  plugins: [animations()]
@@ -18,5 +18,6 @@ export { default as sv } from "./sv";
18
18
  export { default as model } from "./model";
19
19
  export declare const notify: (message: string, color?: string) => void;
20
20
  export { default as getID } from "./getID";
21
+ export { default as id } from "./getID";
21
22
  export declare const getApiBase: () => {};
22
23
  export { getGQLFields } from '@hostlink/light';
@@ -26,6 +26,7 @@ export const notify = function(message, color = "positive") {
26
26
  });
27
27
  };
28
28
  export { default as getID } from "./getID.mjs";
29
+ export { default as id } from "./getID.mjs";
29
30
  export const getApiBase = () => {
30
31
  const config = useRuntimeConfig();
31
32
  return config?.public?.apiBase ?? "/api/";
@@ -1,17 +1,23 @@
1
1
  <script setup>
2
- import { useLight } from "#imports";
2
+ import { useLight, getObject } from "#imports";
3
3
  import { useRoute } from "vue-router"
4
4
  import { ref } from 'vue';
5
5
 
6
+
7
+ const obj = await getObject(["canUpdate"]);
8
+
6
9
  const route = useRoute();
7
10
  const light = useLight();
8
11
 
9
12
  const tab = ref('overview');
10
13
  const id = route.params.user_id;
14
+
15
+
11
16
  </script>
12
17
 
13
18
  <template>
14
- <l-page edit-btn>
19
+ <l-page :edit-btn="obj.canUpdate">
20
+
15
21
  <template #header>
16
22
  <l-btn to="change-password" icon="sym_o_key" permission="user.changePassword"
17
23
  label="Change password"></l-btn>
@@ -21,8 +27,10 @@ const id = route.params.user_id;
21
27
  <q-card flat bordered>
22
28
  <q-tabs v-model="tab" :active-color="$light.color" inline-label align="justify">
23
29
  <q-tab name="overview" icon="sym_o_person" label="Overview" />
24
- <q-tab name="userlog" icon="sym_o_description" label="User log" />
25
- <q-tab name="eventlog" icon="sym_o_description" label="Event log" />
30
+ <q-tab name="userlog" icon="sym_o_description" label="User log"
31
+ v-if="$light.isGranted('userlog.list')" />
32
+ <q-tab name="eventlog" icon="sym_o_description" label="Event log"
33
+ v-if="$light.isGranted('eventlog.list')" />
26
34
  </q-tabs>
27
35
 
28
36
  <l-user-overview v-if="tab === 'overview'" :id="id" />
@@ -67,6 +67,12 @@ const setDefault = async () => {
67
67
 
68
68
 
69
69
  }
70
+
71
+ const columns = [
72
+ { name: 'action' },
73
+ { name: 'name', label: 'Name', align: 'left', field: 'name', sortable: true },
74
+ { name: 'phone', label: 'Phone', align: 'left', field: 'phone', sortable: true },
75
+ ]
70
76
  </script>
71
77
  <template>
72
78
  <div class="q-pa-md">
@@ -140,15 +146,31 @@ const setDefault = async () => {
140
146
  <q-input label="Input" :filled="styles.inputFilled" :outlined="styles.inputOutlined"
141
147
  :standout="styles.inputStandout" :rounded="styles.inputRounded"
142
148
  :dense="styles.inputDense" :square="styles.inputSquare"
143
- :stack-label="styles.inputStackLabel">
144
- ></q-input>
149
+ :stack-label="styles.inputStackLabel" />
145
150
 
146
- <q-table :rows="[
151
+ <q-select label="Select" :filled="styles.inputFilled" :outlined="styles.inputOutlined"
152
+ :standout="styles.inputStandout" :rounded="styles.inputRounded"
153
+ :dense="styles.inputDense" :square="styles.inputSquare"
154
+ :stack-label="styles.inputStackLabel" :options="[
155
+ { label: 'A', value: 'a' },
156
+ { label: 'B', value: 'b' },
157
+ { label: 'C', value: 'c' }
158
+ ]"
159
+ />
160
+
161
+ <q-table :columns="columns" :rows="[
147
162
  { name: 'A', phone: '123' },
148
163
  { name: 'B', phone: '456' },
149
164
  { name: 'C', phone: '789' },
150
165
  ]" :flat="styles.tableFlat" :bordered="styles.tableBorder" :dense="styles.tableDense"
151
- :separator="styles.tableSeparator"></q-table>
166
+ :separator="styles.tableSeparator">
167
+
168
+ <template #body-cell-action="props">
169
+ <q-td auto-width>
170
+ <q-btn flat dense round icon="sym_o_search"></q-btn>
171
+ </q-td>
172
+ </template>
173
+ </q-table>
152
174
 
153
175
  </div>
154
176
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "1.8.10",
3
+ "version": "1.8.12",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": "@hostlink/nuxt-light",
6
6
  "license": "MIT",