{"version":3,"file":"InfoSlot.vue.mjs","sources":["../../../lib/data-provider-interface/components/InfoSlot.vue"],"sourcesContent":["<template>\n  <label :for=\"context.id\" class=\"w-100\">\n    <button\n      class=\"btn p-0 w-100 d-flex align-items-center justify-content-between\"\n      data-cy=\"collapsible-input-group-button\"\n      @click.prevent.stop=\"toggleCollapse\"\n    >\n      <div class=\"\">\n        <span class=\"form-label\">{{ context.label }}</span>\n        <a v-if=\"info\" class=\"infoButton\"><i class=\"material-icons\" :title=\"info\"\n          data-toggle=\"tooltip\"\n          data-placement=\"top\">info</i>\n        </a>\n      </div>\n      <i\n        v-if=\"!context.isSubField()\"\n        class=\"material-icons\">\n        {{ isCollapsed ? 'expand_more' : 'expand_less' }}\n      </i>\n    </button>\n  </label>\n</template>\n\n<script>\nimport { mapGetters } from 'vuex';\nimport {\n  has,\n  isArray,\n  isEmpty,\n} from 'lodash';\nconst COLLAPSED_CLASS_NAME = 'collapsed';\n\nexport default {\n  data: () => ({\n    isCollapsed: false,\n  }),\n  props: {\n    context: {\n      type: Object,\n      required: true,\n    },\n    info: {\n      type: [String, Boolean],\n      default: false,\n    },\n    collapsed: {\n      // if true, the fieldset will be collapsed by default\n      type: Boolean,\n      default: false,\n    },\n  },\n  computed: {\n    ...mapGetters('dpiStore', [\n      'getData',\n    ]),\n    propertyIsEmpty() {\n      let property;\n      let data = this.getData(this.$route.params.property);\n      if (this.$route.params.property === 'distributions')  data = data[this.$route.params.id];\n\n      property = data[this.context.name];\n\n      if (!isEmpty(property)) {\n        if (has(property, 'skos:exactMatch') && has(property['skos:exactMatch'], '@id') && isEmpty(property['skos:exactMatch']['@id'])) return true\n        if (has(property, '@language') && has(property, '@value')) return isEmpty(property['@value']);\n        if (isArray(property)) {\n          return property\n          .map(el => {\n            if (has(el, '@language') && has(el, '@value') && isEmpty(el['@value'])) return true;\n            if (!isEmpty(el)) return false;\n            return true;\n          })\n          .reduce((a,b) => {\n            return a && b;\n          }, true);\n        }\n        return false;\n      } else return true;\n    },\n  },\n  mounted() {\n    if (this.collapsed && this.propertyIsEmpty) {\n      this.toggleCollapse();\n    }\n  },\n  methods: {\n    toggleCollapse() {\n      // Collapse the input fields using DOM manipulation.\n      // todo: find a more elegant way to do this using vue.\n\n      const element = this.$el;\n      for (const sibling of element.parentNode.children) {\n        // Siblings only with the exception of elements with class=\"formkit-input-help\"\n        if (sibling !== element && !sibling.classList.contains('formkit-input-help')) {\n          // toggle display:none!important on sibling\n          sibling.classList.toggle('d-none');\n        }\n      }\n      // add collapse class to the element\n      element.parentNode.classList.toggle(COLLAPSED_CLASS_NAME);\n      this.isCollapsed = !this.isCollapsed;\n    },\n  },\n};\n</script>\n\n<style>\n  .collapsed .d-none {\n    display: none !important;\n  }\n</style>\n\n<style scoped>\n.infoButton{\n  border-radius: 5px;\n  cursor: pointer;\n}\n\n.infoButton .material-icons {\n  font-size: 20px;\n  vertical-align: text-bottom;\n  margin-left: 5px;\n  margin-bottom: 1px;\n}\n\n.form-label {\n  font-size: 20px;\n}\n</style>\n"],"names":["COLLAPSED_CLASS_NAME","_sfc_main","mapGetters","property","data","isEmpty","has","isArray","el","a","b","element","sibling","_hoisted_2","_hoisted_3","_createElementBlock","$props","_createElementVNode","$options","args","_toDisplayString","_openBlock","_hoisted_4","_hoisted_5","_hoisted_6","_ctx"],"mappings":";;;;;;AA8BA,MAAMA,IAAuB,aAExBC,IAAU;AAAA,EACb,MAAM,OAAO;AAAA,IACX,aAAa;AAAA,EACf;AAAA,EACA,OAAO;AAAA,IACL,SAAS;AAAA,MACP,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACD,MAAM;AAAA,MACJ,MAAM,CAAC,QAAQ,OAAO;AAAA,MACtB,SAAS;AAAA,IACV;AAAA,IACD,WAAW;AAAA;AAAA,MAET,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,EACF;AAAA,EACD,UAAU;AAAA,IACR,GAAGC,EAAW,YAAY;AAAA,MACxB;AAAA,IACF,CAAC;AAAA,IAC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