@hostlink/nuxt-light 1.44.0 → 1.45.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "light",
3
3
  "configKey": "light",
4
- "version": "1.44.0",
4
+ "version": "1.45.1",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -1,4 +1,15 @@
1
1
  import { default as api } from "./api.js";
2
+ import { default as model } from "./model.js";
2
3
  export default (name, fields) => {
3
- return api.collect(name, fields);
4
+ const m = model(name);
5
+ const f = {};
6
+ Object.entries(fields).forEach(([key, value]) => {
7
+ const field = m.field(key);
8
+ if (field && field.getGQLField() && value === true) {
9
+ f[key] = field.getGQLField();
10
+ } else {
11
+ f[key] = value;
12
+ }
13
+ });
14
+ return api.collect(name, f);
4
15
  };
@@ -26,12 +26,26 @@ if (props.context.attrs.onSubmitted) {
26
26
  if (!props.context.onSubmit) {
27
27
  props.context.node.props.onSubmit = async function() {
28
28
  const [module, id_name] = route.name.split("-");
29
- const v = {};
30
- for (const [key, value] of Object.entries(props.context.value)) {
31
- if (value !== void 0) {
32
- v[key] = value;
29
+ const removeUndefined = (obj) => {
30
+ if (obj === null || obj === void 0) {
31
+ return obj;
33
32
  }
34
- }
33
+ if (Array.isArray(obj)) {
34
+ return obj.map((item) => removeUndefined(item)).filter((item) => item !== void 0);
35
+ }
36
+ if (typeof obj === "object") {
37
+ const result = {};
38
+ for (const [key, value] of Object.entries(obj)) {
39
+ const cleanedValue = removeUndefined(value);
40
+ if (cleanedValue !== void 0) {
41
+ result[key] = cleanedValue;
42
+ }
43
+ }
44
+ return result;
45
+ }
46
+ return obj;
47
+ };
48
+ const v = removeUndefined(props.context.value);
35
49
  try {
36
50
  if (route.params[id_name]) {
37
51
  if (await model(module).update(parseInt(route.params[id_name]), v)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "1.44.0",
3
+ "version": "1.45.1",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": {
6
6
  "type": "git",