@europeana/portal
Version:
Europeana Portal
274 lines (240 loc) • 7.85 kB
JavaScript
exports.ids = [6];
exports.modules = {
/***/ 574:
/***/ (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/set/SetFormModal.vue?vue&type=template&id=0ab0c940&
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('b-container',{staticClass:"p-0"},[_c('b-modal',{attrs:{"id":_vm.modalId,"title":_vm.modalTitle,"static":_vm.modalStatic,"hide-footer":"","hide-header-close":""},on:{"show":_vm.init,"hide":function($event){return _vm.$emit('response', 'cancel')}}},[_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('set.form.title'),"label-for":"set-title"}},[_c('b-form-input',{attrs:{"id":"set-title","type":"text","maxlength":"35","required":"","aria-describedby":"input-live-help"},model:{value:(_vm.titleValue),callback:function ($$v) {_vm.titleValue=$$v},expression:"titleValue"}}),_vm._v(" "),_c('b-form-text',{attrs:{"id":"input-live-help"}},[_vm._v("\n "+_vm._s(_vm.$t('set.form.required'))+"\n ")])],1),_vm._v(" "),_c('b-form-group',{attrs:{"label":_vm.$t('set.form.description'),"label-for":"set-description"}},[_c('b-form-textarea',{attrs:{"id":"set-description","maxlength":"500","rows":"4"},model:{value:(_vm.descriptionValue),callback:function ($$v) {_vm.descriptionValue=$$v},expression:"descriptionValue"}})],1),_vm._v(" "),_c('b-form-group',{staticClass:"mb-2 mt-4"},[_c('b-form-checkbox',{attrs:{"id":"set-private"},model:{value:(_vm.isPrivate),callback:function ($$v) {_vm.isPrivate=$$v},expression:"isPrivate"}},[_vm._v("\n "+_vm._s(_vm.$t('set.form.private'))+"\n ")])],1),_vm._v(" "),_c('div',{staticClass:"modal-footer"},[_c('b-button',{attrs:{"variant":"outline-primary","data-qa":"close button"},on:{"click":function($event){return _vm.hide('cancel')}}},[_vm._v("\n "+_vm._s(_vm.isNew && _vm.itemContext ? _vm.$t('actions.goBack') : _vm.$t('actions.close'))+"\n ")]),_vm._v(" "),_c('div',{staticClass:"d-flex"},[(!_vm.isNew)?_c('b-button',{attrs:{"variant":"danger","data-qa":"delete button"},on:{"click":_vm.clickDelete}},[_vm._v("\n "+_vm._s(_vm.$t('set.actions.delete'))+"\n ")]):_vm._e(),_vm._v(" "),_c('b-button',{attrs:{"variant":"primary","type":"submit","disabled":_vm.disableSubmitButton,"data-qa":"submit button"}},[_vm._v("\n "+_vm._s(_vm.isNew ? _vm.$t('set.actions.create') : _vm.$t('set.actions.update'))+"\n ")])],1)],1)],1)],1),_vm._v(" "),(!_vm.isNew)?_c('DeleteSetModal',{attrs:{"set-id":_vm.setId,"modal-id":_vm.deleteSetModalId,"modal-static":_vm.modalStatic},on:{"cancel":_vm.cancelDelete}}):_vm._e()],1)}
var staticRenderFns = []
// CONCATENATED MODULE: ./src/components/set/SetFormModal.vue?vue&type=template&id=0ab0c940&
// CONCATENATED MODULE: ./node_modules/babel-loader/lib??ref--2-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/set/SetFormModal.vue?vue&type=script&lang=js&
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/* harmony default export */ var SetFormModalvue_type_script_lang_js_ = ({
name: 'SetFormModal',
components: {
DeleteSetModal: () => __webpack_require__.e(/* import() */ 112).then(__webpack_require__.bind(null, 590))
},
props: {
modalId: {
type: String,
default: 'set-form-modal'
},
modalStatic: {
type: Boolean,
default: false
},
setId: {
type: String,
default: null
},
title: {
type: Object,
default: () => ({})
},
description: {
type: Object,
default: () => ({})
},
visibility: {
type: String,
default: 'public'
},
type: {
type: String,
default: 'Collection'
},
itemContext: {
type: String,
default: null
}
},
data() {
return {
titleValue: '',
descriptionValue: '',
isPrivate: false,
submissionPending: false,
deleteSetModalId: `delete-set-modal-${this.setId}`
};
},
computed: {
setBody() {
const setBody = {
type: this.type,
title: { ...this.title
},
description: { ...this.description
},
visibility: this.isPrivate ? 'private' : 'public'
};
if (this.isNew && this.itemContext) {
setBody.items = ['http://data.europeana.eu/item' + this.itemContext];
}
setBody.title[this.$i18n.locale] = this.titleValue;
setBody.description[this.$i18n.locale] = this.descriptionValue;
return setBody;
},
isNew() {
return this.setId === null;
},
modalTitle() {
return this.isNew ? this.$t('set.actions.create') : this.$t('set.actions.edit');
},
disableSubmitButton() {
// Disable submit button when no title (required field)
return !this.titleValue || // Or when none of the fields have changed
this.titleValue === this.title[this.$i18n.locale] && (this.descriptionValue === this.description[this.$i18n.locale] || // Needed for the case a user starts typing a description but then removes it again.
// The value is still changed from undefined to empty string.
this.descriptionValue === '' && this.description[this.$i18n.locale] === undefined) && (this.isPrivate && this.visibility === 'private' || !this.isPrivate && this.visibility === 'public');
}
},
created() {
this.init();
},
methods: {
// TODO: how to handle existing set having title/description in other languages?
init() {
this.titleValue = (this.title || {})[this.$i18n.locale];
this.descriptionValue = (this.description || {})[this.$i18n.locale];
this.isPrivate = this.visibility === 'private';
},
// TODO: error handling
submitForm() {
if (this.submissionPending) {
return Promise.resolve();
}
this.submissionPending = true;
const handler = this.isNew ? this.$store.dispatch('set/createSet', this.setBody) : this.$store.dispatch('set/update', {
id: this.setId,
body: this.setBody
});
return handler.then(() => {
this.hide(this.isNew ? 'create' : 'update');
}).then(() => {
this.submissionPending = false;
});
},
show() {
this.$bvModal.show(this.modalId);
},
hide(signalType) {
this.$emit('response', signalType);
this.$bvModal.hide(this.modalId);
},
clickDelete() {
this.$bvModal.hide(this.modalId);
this.$bvModal.show(this.deleteSetModalId);
},
cancelDelete() {
this.show();
}
}
});
// CONCATENATED MODULE: ./src/components/set/SetFormModal.vue?vue&type=script&lang=js&
/* harmony default export */ var set_SetFormModalvue_type_script_lang_js_ = (SetFormModalvue_type_script_lang_js_);
// EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
var componentNormalizer = __webpack_require__(3);
// CONCATENATED MODULE: ./src/components/set/SetFormModal.vue
/* normalize component */
var component = Object(componentNormalizer["a" /* default */])(
set_SetFormModalvue_type_script_lang_js_,
render,
staticRenderFns,
false,
null,
null,
"3390ed8d"
)
/* harmony default export */ var SetFormModal = __webpack_exports__["default"] = (component.exports);
/***/ })
};;
//# sourceMappingURL=6.js.map