@piveau/piveau-hub-ui-modules 4.6.22 → 4.6.24

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.
@@ -1,4 +1,4 @@
1
- import { computed as u, ref as y, watch as E, onMounted as Z, nextTick as N, openBlock as a, createElementBlock as d, createElementVNode as V, toDisplayString as w, createTextVNode as x, withDirectives as O, createVNode as $, unref as T, vShow as U, Fragment as j, renderList as A, createCommentVNode as M } from "vue";
1
+ import { computed as a, ref as y, watch as z, onMounted as Z, nextTick as E, openBlock as d, createElementBlock as m, createElementVNode as V, toDisplayString as w, createTextVNode as k, withDirectives as N, createVNode as O, unref as T, vShow as U, Fragment as j, renderList as A, createCommentVNode as M } from "vue";
2
2
  import { useStore as g } from "vuex";
3
3
  import { getNode as I } from "@formkit/core";
4
4
  import { onClickOutside as ee, useAsyncState as te } from "../../external/@vueuse/core/index";
@@ -14,92 +14,93 @@ const ne = { class: "formkitProperty" }, ie = { class: "position-relative formki
14
14
  context: Object
15
15
  },
16
16
  setup(B) {
17
- const m = B, L = re(), { locale: K, fallbackLocale: Q } = oe({ useScope: "global" }), S = u(() => P.getters["auth/getUserCatalogIds"]), v = y(!1), P = g(), R = y(null), W = le(), C = y(""), b = y(""), D = y(!1);
17
+ const i = B, L = re(), { locale: K, fallbackLocale: Q } = oe({ useScope: "global" }), S = a(() => P.getters["auth/getUserCatalogIds"]), v = y(!1), P = g(), R = y(null), W = le(), C = y(""), b = y(""), D = y(!1);
18
18
  ee(R, (l) => v.value = !1);
19
- const k = async (l) => {
19
+ const x = async (l) => {
20
20
  l.id ? (b.value = l.id, C.value = (l == null ? void 0 : l.name) || l.id) : (b.value = l, C.value = l), v.value = !1;
21
- }, { execute: G, state: n, isReady: F, error: _ } = te(async () => await se.get(W.api.baseUrl + "search?filter=catalogue&limit=1000"), { data: { result: { results: [] } } }, { immediate: !1 }), H = u(() => D.value && !!n.value && F.value);
22
- E(_, () => {
21
+ }, { execute: G, state: n, isReady: F, error: _ } = te(async () => await se.get(W.api.baseUrl + "search?filter=catalogue&limit=1000"), { data: { result: { results: [] } } }, { immediate: !1 }), H = a(() => D.value && !!n.value && F.value);
22
+ z(_, () => {
23
23
  console.error(_.value);
24
24
  });
25
- const z = u(() => {
25
+ const $ = a(() => {
26
26
  var l, e, s, o;
27
27
  return ((o = (s = (e = (l = n == null ? void 0 : n.value) == null ? void 0 : l.data) == null ? void 0 : e.result) == null ? void 0 : s.results) == null ? void 0 : o.length) > 0;
28
- }), J = u(() => {
28
+ }), J = a(() => {
29
29
  var l, e, s, o;
30
- return z && ((o = (s = (e = (l = n == null ? void 0 : n.value) == null ? void 0 : l.data) == null ? void 0 : e.result) == null ? void 0 : s.results) == null ? void 0 : o.length) === 1;
31
- }), h = u(() => {
32
- var o, p, f;
33
- return !z.value || !F.value ? [] : (((f = (p = (o = n.value) == null ? void 0 : o.data) == null ? void 0 : p.result) == null ? void 0 : f.results) || []).filter((t) => {
30
+ return $ && ((o = (s = (e = (l = n == null ? void 0 : n.value) == null ? void 0 : l.data) == null ? void 0 : e.result) == null ? void 0 : s.results) == null ? void 0 : o.length) === 1;
31
+ }), h = a(() => {
32
+ var o, p, c;
33
+ return !$.value || !F.value ? [] : (((c = (p = (o = n.value) == null ? void 0 : o.data) == null ? void 0 : p.result) == null ? void 0 : c.results) || []).filter((t) => {
34
34
  var r;
35
35
  return (r = S.value) == null ? void 0 : r.includes(t.id);
36
36
  }).map((t) => {
37
- var c;
37
+ var f;
38
38
  const r = (t == null ? void 0 : t.id) || "";
39
- let i = "";
40
- return t != null && t.title ? typeof (t == null ? void 0 : t.title) == "string" ? i = t == null ? void 0 : t.title : typeof (t == null ? void 0 : t.title) == "object" && (i = (t == null ? void 0 : t.title[K.value]) || (t == null ? void 0 : t.title[Q.value]) || ((c = Object.values(t == null ? void 0 : t.title)) == null ? void 0 : c[0]) || r) : i = r, { id: r, name: i || r };
39
+ let u = "";
40
+ return t != null && t.title ? typeof (t == null ? void 0 : t.title) == "string" ? u = t == null ? void 0 : t.title : typeof (t == null ? void 0 : t.title) == "object" && (u = (t == null ? void 0 : t.title[K.value]) || (t == null ? void 0 : t.title[Q.value]) || ((f = Object.values(t == null ? void 0 : t.title)) == null ? void 0 : f[0]) || r) : u = r, { id: r, name: u || r };
41
41
  });
42
42
  });
43
- E(J, (l) => {
43
+ z(J, (l) => {
44
44
  if (l) {
45
45
  const e = n.value.data.result.results[0];
46
- k({ id: e.id, name: e.name });
46
+ x({ id: e.id, name: e.name });
47
47
  }
48
48
  }, { immediate: !0 }), Z(async () => {
49
- var s, o, p, f, t, r, i, c;
50
- await G(), await N();
51
- const l = ((s = L.value.edit) == null ? void 0 : s.catalog) || ((p = (o = I) == null ? void 0 : o("catalog")) == null ? void 0 : p.value) || ((t = (f = I) == null ? void 0 : f("dcat:catalog")) == null ? void 0 : t.value) || ((i = (r = I) == null ? void 0 : r("dct:catalog")) == null ? void 0 : i.value) || void 0, e = (c = h.value) == null ? void 0 : c.find((Y) => Y.id === l);
52
- e && k({ id: e.id, name: e.name }), await N(), D.value = !0;
49
+ var s, o, p, c, t, r, u, f;
50
+ await G(), await E();
51
+ const l = ((s = L.value.edit) == null ? void 0 : s.catalog) || ((p = (o = I) == null ? void 0 : o("catalog")) == null ? void 0 : p.value) || ((t = (c = I) == null ? void 0 : c("dcat:catalog")) == null ? void 0 : t.value) || ((u = (r = I) == null ? void 0 : r("dct:catalog")) == null ? void 0 : u.value) || void 0, e = (f = h.value) == null ? void 0 : f.find((Y) => Y.id === l);
52
+ e && x({ id: e.id, name: e.name }), await E(), D.value = !0;
53
53
  });
54
- const X = u(() => {
54
+ const X = a(() => {
55
55
  var s;
56
56
  const l = (s = L.value.edit) == null ? void 0 : s.enabled, e = localStorage == null ? void 0 : localStorage.getItem("dpi_duplicate");
57
57
  return l && !e;
58
58
  });
59
- return (l, e) => (a(), d("div", ne, [
60
- V("h4", null, w(m.context.label), 1),
61
- e[6] || (e[6] = x()),
59
+ return (l, e) => (d(), m("div", ne, [
60
+ V("h4", null, w(i.context.label), 1),
61
+ e[6] || (e[6] = k()),
62
62
  V("div", ie, [
63
- H.value ? (a(), d("div", ue, [
64
- O($(T(q), {
63
+ H.value ? (d(), m("div", ue, [
64
+ N(O(T(q), {
65
65
  modelValue: b.value,
66
66
  "onUpdate:modelValue": e[0] || (e[0] = (s) => b.value = s),
67
- name: `${m.context.node.name}`,
67
+ name: `${i.context.node.name}`,
68
+ id: `${i.context.node.id || i.context.node.name}`,
68
69
  type: "text"
69
- }, null, 8, ["modelValue", "name"]), [
70
+ }, null, 8, ["modelValue", "name", "id"]), [
70
71
  [U, !1]
71
72
  ]),
72
- e[4] || (e[4] = x()),
73
- $(T(q), {
73
+ e[4] || (e[4] = k()),
74
+ O(T(q), {
74
75
  class: "autocompleteInputfield",
75
76
  modelValue: C.value,
76
77
  "onUpdate:modelValue": e[1] || (e[1] = (s) => C.value = s),
77
- placeholder: m.context.attrs.placeholder,
78
+ placeholder: i.context.attrs.placeholder,
78
79
  type: "text",
79
80
  validation: "required",
80
81
  mandatory: "true",
81
82
  "validation-messages": {
82
- required: m.context.attrs.placeholder
83
+ required: i.context.attrs.placeholder
83
84
  },
84
- name: `${m.context.node.name}__displayedValue`,
85
+ name: `${i.context.node.name}__displayedValue`,
85
86
  disabled: X.value,
86
87
  onClick: e[2] || (e[2] = (s) => v.value = !v.value)
87
88
  }, null, 8, ["modelValue", "placeholder", "validation-messages", "name", "disabled"]),
88
- e[5] || (e[5] = x()),
89
- O(V("ul", {
89
+ e[5] || (e[5] = k()),
90
+ N(V("ul", {
90
91
  ref_key: "dropdownList",
91
92
  ref: R,
92
93
  class: "autocompleteResultList selectListFK catSelectList"
93
94
  }, [
94
- (a(!0), d(j, null, A(h.value, (s) => (a(), d("li", {
95
+ (d(!0), m(j, null, A(h.value, (s) => (d(), m("li", {
95
96
  key: s,
96
- onClick: (o) => k(s),
97
+ onClick: (o) => x(s),
97
98
  class: "p-2 border-b border-gray-200 data-[selected=true]:bg-blue-100 choosableItemsAC"
98
99
  }, w(s.name), 9, ae))), 128)),
99
- e[3] || (e[3] = x()),
100
- h.value.length === 0 ? (a(!0), d(j, { key: 0 }, A(S.value, (s) => (a(), d("li", {
100
+ e[3] || (e[3] = k()),
101
+ h.value.length === 0 ? (d(!0), m(j, { key: 0 }, A(S.value, (s) => (d(), m("li", {
101
102
  key: s,
102
- onClick: (o) => k(s),
103
+ onClick: (o) => x(s),
103
104
  class: "p-2 border-b border-gray-200 data-[selected=true]:bg-blue-100 choosableItemsAC"
104
105
  }, w(s), 9, de))), 128)) : M("", !0)
105
106
  ], 512), [
@@ -1 +1 @@
1
- {"version":3,"file":"SimpleSelect.vue.mjs","sources":["../../../lib/data-provider-interface/components/SimpleSelect.vue"],"sourcesContent":["<template>\n <div class=\"formkitProperty\">\n <h4>{{ props.context.label }}</h4>\n <div class=\"position-relative formkitCmpWrap\">\n\n <div v-if=\"isReady\">\n\n <!-- Hidden input that contains the actual catalog id. We rely on that to pass the catalog id to backend later -->\n <FormKit v-show=\"false\" v-model=\"selectedCatalogId\" :name=\"`${props.context.node.name}`\" type=\"text\" />\n\n <!-- User-facing input that displays the name of the selected catalog -->\n <FormKit\n class=\"autocompleteInputfield\"\n v-model=\"selectedCatalogTitle\"\n :placeholder=\"props.context.attrs.placeholder\"\n type=\"text\" \n validation=\"required\"\n mandatory=\"true\"\n :validation-messages=\"{\n required: props.context.attrs.placeholder,\n }\" :name=\"`${props.context.node.name}__displayedValue`\"\n :disabled=\"isDisabled\"\n @click=\"showList = !showList\"\n />\n <ul ref=\"dropdownList\" v-show=\"showList\" class=\"autocompleteResultList selectListFK catSelectList\">\n <li v-for=\"match in authorizedCatalogs\" :key=\"match\" @click=\"setvalue(match)\"\n class=\"p-2 border-b border-gray-200 data-[selected=true]:bg-blue-100 choosableItemsAC\">{{\n match.name }}\n </li>\n <li v-if=\"authorizedCatalogs.length === 0\" v-for=\"idMatch in userCats\" :key=\"idMatch\" @click=\"setvalue(idMatch)\"\n class=\"p-2 border-b border-gray-200 data-[selected=true]:bg-blue-100 choosableItemsAC\">{{\n idMatch }}\n </li>\n </ul>\n </div>\n </div>\n </div>\n\n</template>\n<script setup>\nimport { ref, computed, onMounted, watch, nextTick } from 'vue';\nimport { useStore } from 'vuex';\nimport { getNode } from '@formkit/core'\nimport { onClickOutside } from '@vueuse/core'\nimport axios from 'axios'\nimport { useRuntimeEnv } from \"../../composables/useRuntimeEnv.ts\";\nimport { useI18n } from 'vue-i18n';\nimport { useAsyncState } from '@vueuse/core';\nimport { FormKit } from '@formkit/vue';\nimport { useDpiContext } from '../composables/useDpiContext';\n\nconst props = defineProps({\n context: Object\n})\n\nconst dpiContext = useDpiContext()\nconst { locale, fallbackLocale } = useI18n({ useScope: 'global' })\n\nconst userCats = computed(() => store.getters['auth/getUserCatalogIds']);\nconst showList = ref(false)\nconst store = useStore()\nconst dropdownList = ref(null)\nconst env = useRuntimeEnv()\nconst selectedCatalogTitle = ref('')\nconst selectedCatalogId = ref('')\nconst hasMounted = ref(false)\n\nonClickOutside(dropdownList, event => showList.value = false)\n\nconst setvalue = async (e) => {\n if (e.id) {\n selectedCatalogId.value = e.id\n selectedCatalogTitle.value = e?.name || e.id\n } else {\n selectedCatalogId.value = e\n selectedCatalogTitle.value = e\n }\n\n showList.value = false\n}\n\nconst { execute: filterCatList, state: catalogListData, isReady: isQueryReady, error } = useAsyncState(async () => {\n const catalogListData = await axios.get(env.api.baseUrl + 'search?filter=catalogue&limit=1000')\n return catalogListData\n}, { data: { result: { results: [] } } }, { immediate: false })\n\n// Wait until everything mounted and loaded tu ensure that the catalog list is available and selected catalog from edit mode is available\nconst isReady = computed(() => hasMounted.value && !!catalogListData.value && isQueryReady.value)\n\nwatch(error, () => {\n console.error(error.value)\n})\n\nconst hasResults = computed(() => {\n return catalogListData?.value?.data?.result?.results?.length > 0\n})\n\nconst hasOneResultOnly = computed(() => {\n return hasResults && catalogListData?.value?.data?.result?.results?.length === 1\n})\n\n/**\n * Computes list of users' authorized catalogs in { id: string; name: string } format\n */\nconst authorizedCatalogs = computed(() => {\n if (!hasResults.value || !isQueryReady.value) return []\n\n const allCatalogs = catalogListData.value?.data?.result?.results || []\n const authorizedCatalogs = allCatalogs.filter(catalog => userCats.value?.includes(catalog.id))\n\n // map to { id: string; name: string } pairs\n const authorizedCatalogsDataModel = authorizedCatalogs.map((catalog) => {\n const id = catalog?.id || ''\n let title = ''\n\n if (!catalog?.title) title = id\n else if (typeof catalog?.title === 'string') title = catalog?.title\n else if (typeof catalog?.title === 'object') title =\n catalog?.title[locale.value]\n || catalog?.title[fallbackLocale.value]\n || Object.values(catalog?.title)?.[0]\n || id\n\n return { id, name: title || id }\n });\n return authorizedCatalogsDataModel\n})\n\nwatch(hasOneResultOnly, (yes) => {\n if (yes) {\n const result = catalogListData.value.data.result.results[0]\n setvalue({ id: result.id, name: result.name })\n }\n}, { immediate: true })\n\nonMounted(async () => {\n // When editing, we can restore the selected catalog id immediately, but we rely on fetching from hub-search for its catalog title.\n // So we need to wait until everything is fetched before proceeding further.\n await filterCatList()\n await nextTick()\n const catalogIdToLoadForEdit =\n dpiContext.value.edit?.catalog\n || getNode?.('catalog')?.value\n || getNode?.('dcat:catalog')?.value\n || getNode?.('dct:catalog')?.value\n || undefined\n const maybeFoundCatalogFromQuery = authorizedCatalogs.value?.find(item => item.id === catalogIdToLoadForEdit)\n if (maybeFoundCatalogFromQuery) {\n setvalue({ id: maybeFoundCatalogFromQuery.id, name: maybeFoundCatalogFromQuery.name })\n }\n await nextTick()\n hasMounted.value = true\n});\n\n// Disable select option if in edit mode\n// Note: Decision is made due to a backend limitation that causes dataset duplicates to occur when changing a catalog\nconst isDisabled = computed(() => {\n const isInEditMode = dpiContext.value.edit?.enabled\n\n // If duplicate, do not disable select option so that they can duplicate datasets into different catalogs\n // todo: code debt due to code replication; usage of localStorage kind of weird here -> see DraftsPage for more on this.\n // We use localStorage to track if the intent is to duplicate or not\n const isDuplicate = localStorage?.getItem('dpi_duplicate')\n\n return isInEditMode && !isDuplicate\n})\n\n</script>\n<style>\n.catSelectList {\n width: 97.3% !important;\n margin: 0 1rem;\n}\n\n.selectListFK {\n\n max-height: 20rem;\n overflow: overlay;\n overflow-x: hidden;\n}\n</style>\n"],"names":["props","__props","dpiContext","useDpiContext","locale","fallbackLocale","useI18n","userCats","computed","store","showList","ref","useStore","dropdownList","env","useRuntimeEnv","selectedCatalogTitle","selectedCatalogId","hasMounted","onClickOutside","event","setvalue","e","filterCatList","catalogListData","isQueryReady","error","useAsyncState","axios","isReady","watch","hasResults","_d","_c","_b","_a","hasOneResultOnly","authorizedCatalogs","catalog","id","title","yes","result","onMounted","nextTick","catalogIdToLoadForEdit","getNode","_e","_g","_f","maybeFoundCatalogFromQuery","_h","item","isDisabled","isInEditMode","isDuplicate"],"mappings":";;;;;;;;;;;;;;;;AAmDA,UAAMA,IAAQC,GAIRC,IAAaC,GAAc,GAC3B,EAAE,QAAAC,GAAQ,gBAAAC,EAAgB,IAAGC,GAAQ,EAAE,UAAU,UAAU,GAE3DC,IAAWC,EAAS,MAAMC,EAAM,QAAQ,wBAAwB,CAAC,GACjEC,IAAWC,EAAI,EAAK,GACpBF,IAAQG,EAAS,GACjBC,IAAeF,EAAI,IAAI,GACvBG,IAAMC,GAAc,GACpBC,IAAuBL,EAAI,EAAE,GAC7BM,IAAoBN,EAAI,EAAE,GAC1BO,IAAaP,EAAI,EAAK;AAE5B,IAAAQ,GAAeN,GAAc,CAAAO,MAASV,EAAS,QAAQ,EAAK;AAE5D,UAAMW,IAAW,OAAOC,MAAM;AAC5B,MAAIA,EAAE,MACJL,EAAkB,QAAQK,EAAE,IAC5BN,EAAqB,SAAQM,KAAA,gBAAAA,EAAG,SAAQA,EAAE,OAE1CL,EAAkB,QAAQK,GAC1BN,EAAqB,QAAQM,IAG/BZ,EAAS,QAAQ;AAAA,IACnB,GAEM,EAAE,SAASa,GAAe,OAAOC,GAAiB,SAASC,GAAc,OAAAC,MAAUC,GAAc,YAC7E,MA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OD,KAAgB,CAACC;AAAA,IAC1B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"SimpleSelect.vue.mjs","sources":["../../../lib/data-provider-interface/components/SimpleSelect.vue"],"sourcesContent":["<template>\n <div class=\"formkitProperty\">\n <h4>{{ props.context.label }}</h4>\n <div class=\"position-relative formkitCmpWrap\">\n\n <div v-if=\"isReady\">\n\n <!-- Hidden input that contains the actual catalog id. We rely on that to pass the catalog id to backend later -->\n <FormKit v-show=\"false\" v-model=\"selectedCatalogId\" :name=\"`${props.context.node.name}`\" :id=\"`${props.context.node.id || props.context.node.name}`\" type=\"text\" />\n\n <!-- User-facing input that displays the name of the selected catalog -->\n <FormKit\n class=\"autocompleteInputfield\"\n v-model=\"selectedCatalogTitle\"\n :placeholder=\"props.context.attrs.placeholder\"\n type=\"text\" \n validation=\"required\"\n mandatory=\"true\"\n :validation-messages=\"{\n required: props.context.attrs.placeholder,\n }\" :name=\"`${props.context.node.name}__displayedValue`\"\n :disabled=\"isDisabled\"\n @click=\"showList = !showList\"\n />\n <ul ref=\"dropdownList\" v-show=\"showList\" class=\"autocompleteResultList selectListFK catSelectList\">\n <li v-for=\"match in authorizedCatalogs\" :key=\"match\" @click=\"setvalue(match)\"\n class=\"p-2 border-b border-gray-200 data-[selected=true]:bg-blue-100 choosableItemsAC\">{{\n match.name }}\n </li>\n <li v-if=\"authorizedCatalogs.length === 0\" v-for=\"idMatch in userCats\" :key=\"idMatch\" @click=\"setvalue(idMatch)\"\n class=\"p-2 border-b border-gray-200 data-[selected=true]:bg-blue-100 choosableItemsAC\">{{\n idMatch }}\n </li>\n </ul>\n </div>\n </div>\n </div>\n\n</template>\n<script setup>\nimport { ref, computed, onMounted, watch, nextTick } from 'vue';\nimport { useStore } from 'vuex';\nimport { getNode } from '@formkit/core'\nimport { onClickOutside } from '@vueuse/core'\nimport axios from 'axios'\nimport { useRuntimeEnv } from \"../../composables/useRuntimeEnv.ts\";\nimport { useI18n } from 'vue-i18n';\nimport { useAsyncState } from '@vueuse/core';\nimport { FormKit } from '@formkit/vue';\nimport { useDpiContext } from '../composables/useDpiContext';\n\nconst props = defineProps({\n context: Object\n})\n\nconst dpiContext = useDpiContext()\nconst { locale, fallbackLocale } = useI18n({ useScope: 'global' })\n\nconst userCats = computed(() => store.getters['auth/getUserCatalogIds']);\nconst showList = ref(false)\nconst store = useStore()\nconst dropdownList = ref(null)\nconst env = useRuntimeEnv()\nconst selectedCatalogTitle = ref('')\nconst selectedCatalogId = ref('')\nconst hasMounted = ref(false)\n\nonClickOutside(dropdownList, event => showList.value = false)\n\nconst setvalue = async (e) => {\n if (e.id) {\n selectedCatalogId.value = e.id\n selectedCatalogTitle.value = e?.name || e.id\n } else {\n selectedCatalogId.value = e\n selectedCatalogTitle.value = e\n }\n\n showList.value = false\n}\n\nconst { execute: filterCatList, state: catalogListData, isReady: isQueryReady, error } = useAsyncState(async () => {\n const catalogListData = await axios.get(env.api.baseUrl + 'search?filter=catalogue&limit=1000')\n return catalogListData\n}, { data: { result: { results: [] } } }, { immediate: false })\n\n// Wait until everything mounted and loaded tu ensure that the catalog list is available and selected catalog from edit mode is available\nconst isReady = computed(() => hasMounted.value && !!catalogListData.value && isQueryReady.value)\n\nwatch(error, () => {\n console.error(error.value)\n})\n\nconst hasResults = computed(() => {\n return catalogListData?.value?.data?.result?.results?.length > 0\n})\n\nconst hasOneResultOnly = computed(() => {\n return hasResults && catalogListData?.value?.data?.result?.results?.length === 1\n})\n\n/**\n * Computes list of users' authorized catalogs in { id: string; name: string } format\n */\nconst authorizedCatalogs = computed(() => {\n if (!hasResults.value || !isQueryReady.value) return []\n\n const allCatalogs = catalogListData.value?.data?.result?.results || []\n const authorizedCatalogs = allCatalogs.filter(catalog => userCats.value?.includes(catalog.id))\n\n // map to { id: string; name: string } pairs\n const authorizedCatalogsDataModel = authorizedCatalogs.map((catalog) => {\n const id = catalog?.id || ''\n let title = ''\n\n if (!catalog?.title) title = id\n else if (typeof catalog?.title === 'string') title = catalog?.title\n else if (typeof catalog?.title === 'object') title =\n catalog?.title[locale.value]\n || catalog?.title[fallbackLocale.value]\n || Object.values(catalog?.title)?.[0]\n || id\n\n return { id, name: title || id }\n });\n return authorizedCatalogsDataModel\n})\n\nwatch(hasOneResultOnly, (yes) => {\n if (yes) {\n const result = catalogListData.value.data.result.results[0]\n setvalue({ id: result.id, name: result.name })\n }\n}, { immediate: true })\n\nonMounted(async () => {\n // When editing, we can restore the selected catalog id immediately, but we rely on fetching from hub-search for its catalog title.\n // So we need to wait until everything is fetched before proceeding further.\n await filterCatList()\n await nextTick()\n const catalogIdToLoadForEdit =\n dpiContext.value.edit?.catalog\n || getNode?.('catalog')?.value\n || getNode?.('dcat:catalog')?.value\n || getNode?.('dct:catalog')?.value\n || undefined\n const maybeFoundCatalogFromQuery = authorizedCatalogs.value?.find(item => item.id === catalogIdToLoadForEdit)\n if (maybeFoundCatalogFromQuery) {\n setvalue({ id: maybeFoundCatalogFromQuery.id, name: maybeFoundCatalogFromQuery.name })\n }\n await nextTick()\n hasMounted.value = true\n});\n\n// Disable select option if in edit mode\n// Note: Decision is made due to a backend limitation that causes dataset duplicates to occur when changing a catalog\nconst isDisabled = computed(() => {\n const isInEditMode = dpiContext.value.edit?.enabled\n\n // If duplicate, do not disable select option so that they can duplicate datasets into different catalogs\n // todo: code debt due to code replication; usage of localStorage kind of weird here -> see DraftsPage for more on this.\n // We use localStorage to track if the intent is to duplicate or not\n const isDuplicate = localStorage?.getItem('dpi_duplicate')\n\n return isInEditMode && !isDuplicate\n})\n\n</script>\n<style>\n.catSelectList {\n width: 97.3% !important;\n margin: 0 1rem;\n}\n\n.selectListFK {\n\n max-height: 20rem;\n overflow: overlay;\n overflow-x: hidden;\n}\n</style>\n"],"names":["props","__props","dpiContext","useDpiContext","locale","fallbackLocale","useI18n","userCats","computed","store","showList","ref","useStore","dropdownList","env","useRuntimeEnv","selectedCatalogTitle","selectedCatalogId","hasMounted","onClickOutside","event","setvalue","e","filterCatList","catalogListData","isQueryReady","error","useAsyncState","axios","isReady","watch","hasResults","_d","_c","_b","_a","hasOneResultOnly","authorizedCatalogs","catalog","id","title","yes","result","onMounted","nextTick","catalogIdToLoadForEdit","getNode","_e","_g","_f","maybeFoundCatalogFromQuery","_h","item","isDisabled","isInEditMode","isDuplicate"],"mappings":";;;;;;;;;;;;;;;;AAmDA,UAAMA,IAAQC,GAIRC,IAAaC,GAAc,GAC3B,EAAE,QAAAC,GAAQ,gBAAAC,EAAgB,IAAGC,GAAQ,EAAE,UAAU,UAAU,GAE3DC,IAAWC,EAAS,MAAMC,EAAM,QAAQ,wBAAwB,CAAC,GACjEC,IAAWC,EAAI,EAAK,GACpBF,IAAQG,EAAS,GACjBC,IAAeF,EAAI,IAAI,GACvBG,IAAMC,GAAc,GACpBC,IAAuBL,EAAI,EAAE,GAC7BM,IAAoBN,EAAI,EAAE,GAC1BO,IAAaP,EAAI,EAAK;AAE5B,IAAAQ,GAAeN,GAAc,CAAAO,MAASV,EAAS,QAAQ,EAAK;AAE5D,UAAMW,IAAW,OAAOC,MAAM;AAC5B,MAAIA,EAAE,MACJL,EAAkB,QAAQK,EAAE,IAC5BN,EAAqB,SAAQM,KAAA,gBAAAA,EAAG,SAAQA,EAAE,OAE1CL,EAAkB,QAAQK,GAC1BN,EAAqB,QAAQM,IAG/BZ,EAAS,QAAQ;AAAA,IACnB,GAEM,EAAE,SAASa,GAAe,OAAOC,GAAiB,SAASC,GAAc,OAAAC,MAAUC,GAAc,YAC7E,MAAMC,GAAM,IAAId,EAAI,IAAI,UAAU,oCAAoC,GAE7F,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,GAAI,EAAA,KAAM,EAAE,WAAW,IAAO,GAGxDe,IAAUrB,EAAS,MAAMU,EAAW,SAAS,CAAC,CAACM,EAAgB,SAASC,EAAa,KAAK;AAEhG,IAAAK,EAAMJ,GAAO,MAAM;AACjB,cAAQ,MAAMA,E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AAMC,KAASD,EAAG;AAAA,MACnC,CAAG;AAAA,IAEH,CAAC;AAED,IAAAT,EAAMM,GAAkB,CAACK,MAAQ;AAC/B,UAAIA,GAAK;AACP,cAAMC,IAASlB,EAAgB,MAAM,KAAK,OAAO,QAAQ,CAAC;AAC1D,QAAAH,EAAS,EAAE,IAAIqB,EAAO,IAAI,MAAMA,EAAO,MAAM;AAAA,MAC/C;AAAA,IACF,GAAG,EAAE,WAAW,IAAM,GAEtBC,EAAU,YAAY;;AAGpB,YAAMpB,EAAc,GACpB,MAAMqB,EAAS;AACf,YAAMC,MACJV,IAAAjC,EAAW,MAAM,SAAjB,gBAAAiC,EAAuB,cACpBF,KAAAC,IAAAY,MAAA,gBAAAZ,EAAU,eAAV,gBAAAD,EAAsB,YACtBc,KAAAf,IAAAc,MAAA,gBAAAd,EAAU,oBAAV,gBAAAe,EAA2B,YAC3BC,KAAAC,IAAAH,MAAA,gBAAAG,EAAU,mBAAV,gBAAAD,EAA0B,UAC1B,QACCE,KAA6BC,IAAAd,EAAmB,UAAnB,gBAAAc,EAA0B,KAAK,CAAAC,MAAQA,EAAK,OAAOP;AACtF,MAAIK,KACF7B,EAAS,EAAE,IAAI6B,EAA2B,IAAI,MAAMA,EAA2B,MAAM,GAEvF,MAAMN,EAAS,GACf1B,EAAW,QAAQ;AAAA,IACrB,CAAC;UAIKmC,IAAa7C,EAAS,MAAM;;AAChC,YAAM8C,KAAenB,IAAAjC,EAAW,MAAM,SAAjB,gBAAAiC,EAAuB,SAKtCoB,IAAc,6CAAc,QAAQ;AAE1C,aAAOD,KAAgB,CAACC;AAAA,IAC1B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -979,8 +979,10 @@ const t = {
979
979
  catalog: {
980
980
  identifier: "catalog",
981
981
  $formkit: "simpleSelect",
982
- name: "dcat:catalog",
983
- id: "dcat:catalog",
982
+ // Intentionally not setting something like dcat:catalog here
983
+ // Because we don't neeed catalog to be part of the payload
984
+ name: "catalog",
985
+ id: "catalog",
984
986
  placeholder: "Catalog",
985
987
  classes: { outer: "formkitProperty formkitCmpWrap mx-0 my-3 p-3" }
986
988
  },