{"version":3,"file":"DataFetchingComponent.vue.mjs","sources":["../../../lib/data-provider-interface/components/DataFetchingComponent.vue"],"sourcesContent":["<template>\n  <div style=\"height:370px;\">\n    <div class=\"spinner\"></div>\n  </div>\n</template>\n\n<script>\nimport { mapActions, mapGetters } from 'vuex';\n\nexport default {\n  props: ['id', 'property', 'catalog'],\n  data() {\n    return {};\n  },\n  computed: {\n    ...mapGetters('auth', [\n      'getIsDraft',\n      'getUserData',\n    ]),\n    token() {\n      return this.getUserData.rtpToken;\n    },\n    redirectUri() {\n      return `${this.$env.content.dataProviderInterface.basePath}/${this.property}?locale=${this.$i18n.locale}`;\n    },\n  },\n  methods: {\n    ...mapActions('auth', [\n      'setIsEditMode',\n      'setIsDraft',\n    ]),\n    ...mapActions('dpiStore', [\n      'convertToInput',\n    ]),\n    async setupEditPage() {\n      this.$router.push({\n        name: 'DataProviderInterface-Input',\n        params: { property: this.property },\n        query: { \n          locale: this.$route.query.locale,\n          edit: true,\n          id: !this.getIsDraft && this.property === 'catalogues'\n            ? this.catalog\n            : this.id,\n          catalog: this.catalog,\n          fromDraft: this.getIsDraft ? 'true' : undefined,\n        },\n      })\n\n      return;\n\n      let endpoint;\n      this.setIsEditMode(true);\n      const specification = this.$env.content.dataProviderInterface.specification;\n\n      if (this.getIsDraft) {\n        this.setIsDraft(true);\n        endpoint = `${this.$env.api.hubUrl}drafts/datasets/${this.id}.nt?catalogue=${this.catalog}`;\n        await this.convertToInput({endpoint, token: this.token, property: this.property, id: this.id, specification: specification });\n      } else {\n        this.setIsDraft(false);\n        if (this.property === 'catalogues') {\n          endpoint = `${this.$env.api.hubUrl}catalogues/${this.catalog}.nt`;\n          await this.convertToInput({endpoint, token: this.token, property: this.property, id: this.catalog, specification: specification });\n        } else {\n          endpoint = `${this.$env.api.hubUrl}datasets/${this.id}.nt?useNormalizedId=true`;\n          await this.convertToInput({endpoint, token: this.token, property: this.property, id: this.id, specification: specification });\n        } \n      }\n\n      this.$router.push(this.redirectUri).catch(() => {});\n    },\n  },\n  beforeRouteEnter(to, from, next) {\n    next(vm => {\n      if (from.fullPath.startsWith(vm.redirectUri)) {\n        vm.$router.go(-1);\n      } else vm.setupEditPage();\n    });\n  },\n};\n</script>\n"],"names":["_sfc_main","mapGetters","mapActions","to","from","next","vm","_hoisted_1","_openBlock","_createElementBlock","_cache","_createElementVNode"],"mappings":";;;AASA,MAAKA,IAAU;AAAA,EACb,OAAO,CAAC,MAAM,YAAY,SAAS;AAAA,EACnC,OAAO;AACL,WAAO;EACR;AAAA,EACD,UAAU;AAAA,IACR,GAAGC,EAAW,QAAQ;AAAA,MACpB;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACD,QAAQ;AACN,aAAO,KAAK,YAAY;AAAA,IACzB;AAAA,IACD,cAAc;AACZ,aAAO,GAAG,KAAK,KAAK,QAAQ,sBAAsB,QAAQ,IAAI,KAAK,QAAQ,WAAW,KAAK,MAAM,MAAM;AAAA,IACxG;AAAA,EACF;AAAA,EACD,SAAS;AAAA,IACP,GAAGC,EAAW,QAAQ;AAAA,MACpB;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACD,GAAGA,EAAW,YAAY;AAAA,MACxB;AAAA,IACF,CAAC;AAAA,IACD,MAAM,gBAAgB;AACpB,WAAK,QAAQ,KAAK;AAAA,QAChB,MAAM;AAAA,QACN,QAAQ,EAAE,UAAU,KAAK,SAAU;AAAA,QACnC,OAAO;AAAA,UACL,QAAQ,KAAK,OAAO,MAAM;AAAA,UAC1B,MAAM;AAAA,UACN,IAAI,CAAC,KAAK,cAAc,KAAK,aAAa,eACtC,KAAK,UACL,KAAK;AAAA,UACT,SAAS,KAAK;AAAA,UACd,WAAW,KAAK,aAAa,SAAS;AAAA,QACvC;AAAA,OACF;AAAA,IAwBF;AAAA,EACF;AAAA,EACD,iBAAiBC,GAAIC,GAAMC,GAAM;AAC/B,IAAAA,EAAK,CAAAC,MAAM;AACT,MAAIF,EAAK,SAAS,WAAWE,EAAG,WAAW,IACzCA,EAA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