UNPKG

@europeana/portal

Version:
180 lines (147 loc) 5.51 kB
exports.ids = [108]; exports.modules = { /***/ 588: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./src/components/entity/EntityUpdateModal.vue?vue&type=template&id=1db6356a& var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('b-modal',{attrs:{"id":"entityUpdateModal","title":_vm.$t('collections.actions.edit'),"static":_vm.modalStatic,"hide-footer":"","hide-header-close":""}},[_c('b-form',{on:{"submit":function($event){$event.stopPropagation();$event.preventDefault();return _vm.submitForm.apply(null, arguments)}}},[_c('b-form-group',{attrs:{"label":_vm.$t('collections.form.description'),"label-for":"entity-description"}},[_c('b-form-textarea',{attrs:{"id":"entity-description","maxlength":"240","rows":"4"},model:{value:(_vm.descriptionValue),callback:function ($$v) {_vm.descriptionValue=$$v},expression:"descriptionValue"}})],1),_vm._v(" "),_c('div',{staticClass:"modal-footer pt-2"},[_c('b-button',{attrs:{"variant":"outline-primary"},on:{"click":function($event){return _vm.$bvModal.hide('entityUpdateModal')}}},[_vm._v("\n "+_vm._s(_vm.$t('actions.close'))+"\n ")]),_vm._v(" "),_c('b-button',{attrs:{"variant":"primary","type":"submit","disabled":_vm.disableSubmit,"data-qa":"submit button"}},[_vm._v("\n "+_vm._s(_vm.$t('collections.actions.update'))+"\n ")])],1)],1)],1)} var staticRenderFns = [] // CONCATENATED MODULE: ./src/components/entity/EntityUpdateModal.vue?vue&type=template&id=1db6356a& // EXTERNAL MODULE: ./src/mixins/makeToast.js var makeToast = __webpack_require__(53); // CONCATENATED MODULE: ./node_modules/babel-loader/lib??ref--2-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/entity/EntityUpdateModal.vue?vue&type=script&lang=js& // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // /* harmony default export */ var EntityUpdateModalvue_type_script_lang_js_ = ({ name: 'EntityUpdateModal', mixins: [makeToast["a" /* default */]], props: { id: { type: String, required: true }, description: { type: String, default: null }, modalStatic: { type: Boolean, default: false } }, data() { return { descriptionValue: this.description, entity: null, toastMsg: this.$t('collections.notifications.update') }; }, computed: { disableSubmit() { // Disable submit button when description is not changed return this.descriptionValue === '' && this.description === null || this.descriptionValue === this.description; }, descriptionFieldName() { return this.id.includes('/concept/') ? 'note' : 'description'; }, descriptionFieldIsArray() { return Array.isArray(this.entity[this.descriptionFieldName][this.$i18n.locale]); }, descriptionFieldValue() { return this.descriptionFieldIsArray ? [this.descriptionValue] : this.descriptionValue; }, europeanaProxy() { var _this$entity, _this$entity$proxies; return (_this$entity = this.entity) === null || _this$entity === void 0 ? void 0 : (_this$entity$proxies = _this$entity.proxies) === null || _this$entity$proxies === void 0 ? void 0 : _this$entity$proxies.find(proxy => proxy.id.endsWith('#proxy_europeana')); }, updatedBody() { const body = {}; // NOTE: exactMatch & sameAs handling are workarounds until the upstream // Europeana proxies always include those fields. See // https://europeana.atlassian.net/browse/EA-3103 if (this.entity.exactMatch) { body.exactMatch = this.entity.exactMatch; } if (this.entity.sameAs) { body.sameAs = this.entity.sameAs; } return { ...body, ...this.europeanaProxy, [this.descriptionFieldName]: { ...(this.europeanaProxy[this.descriptionFieldName] || {}), [this.$i18n.locale]: this.descriptionFieldValue } }; } }, methods: { async updateEntity() { // First fetch the entity to get its Europeana proxy to avoid data loss this.entity = await this.$apis.entityManagement.get(this.id); return this.$apis.entityManagement.update(this.id, this.updatedBody); }, async submitForm() { await this.updateEntity(); this.$bvModal.hide('entityUpdateModal'); this.makeToast(this.toastMsg); this.$emit('updated'); } } }); // CONCATENATED MODULE: ./src/components/entity/EntityUpdateModal.vue?vue&type=script&lang=js& /* harmony default export */ var entity_EntityUpdateModalvue_type_script_lang_js_ = (EntityUpdateModalvue_type_script_lang_js_); // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js var componentNormalizer = __webpack_require__(3); // CONCATENATED MODULE: ./src/components/entity/EntityUpdateModal.vue /* normalize component */ var component = Object(componentNormalizer["a" /* default */])( entity_EntityUpdateModalvue_type_script_lang_js_, render, staticRenderFns, false, null, null, "3f94758e" ) /* harmony default export */ var EntityUpdateModal = __webpack_exports__["default"] = (component.exports); /***/ }) };; //# sourceMappingURL=108.js.map