UNPKG

@europeana/portal

Version:
392 lines (326 loc) 14.4 kB
exports.ids = [96]; exports.modules = { /***/ 364: /***/ (function(module, exports, __webpack_require__) { // style-loader: Adds some css to the DOM by adding a <style> tag // load the styles var content = __webpack_require__(493); if(content.__esModule) content = content.default; if(typeof content === 'string') content = [[module.i, content, '']]; if(content.locals) module.exports = content.locals; // add CSS to SSR context var add = __webpack_require__(13).default module.exports.__inject__ = function (context) { add("fc0d17f6", content, true, context) }; /***/ }), /***/ 492: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _node_modules_vue_style_loader_index_js_ref_7_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_7_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_sass_loader_dist_cjs_js_ref_7_oneOf_1_2_node_modules_vue_loader_lib_index_js_vue_loader_options_ItemPinModal_vue_vue_type_style_index_0_id_b292b77a_lang_scss_scoped_true___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(364); /* harmony import */ var _node_modules_vue_style_loader_index_js_ref_7_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_7_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_sass_loader_dist_cjs_js_ref_7_oneOf_1_2_node_modules_vue_loader_lib_index_js_vue_loader_options_ItemPinModal_vue_vue_type_style_index_0_id_b292b77a_lang_scss_scoped_true___WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_vue_style_loader_index_js_ref_7_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_7_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_sass_loader_dist_cjs_js_ref_7_oneOf_1_2_node_modules_vue_loader_lib_index_js_vue_loader_options_ItemPinModal_vue_vue_type_style_index_0_id_b292b77a_lang_scss_scoped_true___WEBPACK_IMPORTED_MODULE_0__); /* harmony reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in _node_modules_vue_style_loader_index_js_ref_7_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_7_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_sass_loader_dist_cjs_js_ref_7_oneOf_1_2_node_modules_vue_loader_lib_index_js_vue_loader_options_ItemPinModal_vue_vue_type_style_index_0_id_b292b77a_lang_scss_scoped_true___WEBPACK_IMPORTED_MODULE_0__) if(["default"].indexOf(__WEBPACK_IMPORT_KEY__) < 0) (function(key) { __webpack_require__.d(__webpack_exports__, key, function() { return _node_modules_vue_style_loader_index_js_ref_7_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_7_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_sass_loader_dist_cjs_js_ref_7_oneOf_1_2_node_modules_vue_loader_lib_index_js_vue_loader_options_ItemPinModal_vue_vue_type_style_index_0_id_b292b77a_lang_scss_scoped_true___WEBPACK_IMPORTED_MODULE_0__[key]; }) }(__WEBPACK_IMPORT_KEY__)); /***/ }), /***/ 493: /***/ (function(module, exports, __webpack_require__) { // Imports var ___CSS_LOADER_API_IMPORT___ = __webpack_require__(12); var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false); // Module ___CSS_LOADER_EXPORT___.push([module.i, ".help[data-v-b292b77a]{font-size:.75rem;color:#4d4d4d;display:flex;align-items:center;margin-bottom:1.25rem}.help span[data-v-b292b77a]{display:inline-block;margin-right:.5rem}.btn-collection[data-v-b292b77a]{border:0;font-size:1rem;font-weight:500;margin-bottom:.5rem;padding:1rem;position:relative;text-transform:none}.btn-collection span[data-v-b292b77a]{position:relative;z-index:10}.btn-collection span.icon-check-circle[data-v-b292b77a],.btn-collection span.icon-push-pin[data-v-b292b77a]{margin-left:auto;font-size:1.5rem}", ""]); // Exports module.exports = ___CSS_LOADER_EXPORT___; /***/ }), /***/ 593: /***/ (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/item/ItemPinModal.vue?vue&type=template&id=b292b77a&scoped=true& var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('b-modal',{attrs:{"id":_vm.modalId,"title":_vm.$t('record.actions.pin'),"hide-footer":"","hide-header-close":"","static":_vm.modalStatic},on:{"show":_vm.fetchEntityBestItemsSets}},[_vm._l((_vm.entities),function(entity,index){return _c('b-button',{key:index,staticClass:"btn-collection w-100 text-left d-flex",attrs:{"disabled":!_vm.fetched,"pressed":_vm.selected === entity.about,"data-qa":"pin item to entity choice"},on:{"click":function($event){return _vm.selectEntity(entity.about)}}},[_c('span',{staticClass:"mr-auto"},[_vm._v("\n "+_vm._s(entity.prefLabel.en[0])+"\n ")]),_vm._v(" "),_c('span',{staticClass:"icons text-left d-flex justify-content-end"},[(_vm.selected === entity.about)?_c('span',{staticClass:"icon-check-circle d-inline-flex ml-auto"}):_vm._e(),_vm._v(" "),(_vm.pinnedTo(entity.about))?_c('span',{staticClass:"icon-push-pin d-inline-flex"}):_vm._e()])])}),_vm._v(" "),_c('div',{staticClass:"modal-footer"},[_c('span',{staticClass:"w-100 help"},[_c('span',{staticClass:"icon icon-info-outline d-inline-flex"}),_vm._v(_vm._s(_vm.infoText)+"\n ")]),_vm._v(" "),_c('b-button',{attrs:{"variant":"outline-primary","data-qa":"cancel button"},on:{"click":_vm.hide}},[_vm._v("\n "+_vm._s(_vm.$t('entity.actions.cancel'))+"\n ")]),_vm._v(" "),(_vm.selectedIsPinned || !_vm.selectedIsFull)?_c('b-button',{attrs:{"disabled":!_vm.selected,"variant":"primary","data-qa":"toggle pin button"},on:{"click":_vm.togglePin}},[_vm._v("\n "+_vm._s(_vm.selectedIsPinned ? _vm.$t('entity.actions.unpin') : _vm.$t('entity.actions.pin'))+"\n ")]):(_vm.selectedIsFull)?_c('span',[_c('b-button',{attrs:{"data-qa":"go to set link","to":_vm.$path(_vm.selectedLink),"variant":"primary"}},[_vm._v("\n "+_vm._s(_vm.$t('entity.actions.viewPinned'))+"\n ")])],1):_vm._e()],1)],2)} var staticRenderFns = [] // CONCATENATED MODULE: ./src/components/item/ItemPinModal.vue?vue&type=template&id=b292b77a&scoped=true& // 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/item/ItemPinModal.vue?vue&type=script&lang=js& // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // /* harmony default export */ var ItemPinModalvue_type_script_lang_js_ = ({ name: 'ItemPinModal', mixins: [makeToast["a" /* default */]], props: { /** * Identifier of the item */ identifier: { type: String, required: true }, /** * Entities associated with the item, to which it may be pinned * @example * [ * { about: 'entityUri1', prefLabel: { en: 'entity en label 1' } }, * { about: 'entityUri2', prefLabel: { en: 'entity en label 2' } } * ] */ entities: { type: Array, required: true }, modalId: { type: String, default: 'pin-modal' }, /** * Used for testing, in order to render the modal. */ modalStatic: { type: Boolean, default: false } }, data() { return { fetched: false, selected: null, /** * EntityBestItemsSet-type sets for the item's entities * @example * { * 'entityUri1': { id: 'setId1', pinned: ['itemUri1'] }, * 'entityUri2': { id: 'setId2', pinned: ['itemUri1', 'itemUri2'] }, * } */ sets: this.entities.reduce((memo, entity) => { memo[entity.about] = this.setFactory(); return memo; }, {}) }; }, computed: { infoText() { if (this.selectedIsFull) { return this.selectedIsPinned ? this.$t('entity.notifications.unpin', { entity: this.selectedEntityPrefLabel }) : this.$t('entity.notifications.pinLimit.body'); } if (this.selectedIsPinned) { return this.$t('entity.notifications.unpin', { entity: this.selectedEntityPrefLabel }); } return this.selected ? this.$t('entity.notifications.pin', { entity: this.selectedEntityPrefLabel }) : this.$t('entity.notifications.select'); }, selectedIsPinned() { return this.selected && this.pinnedTo(this.selected); }, selectedIsFull() { var _this$selectedEntityS, _this$selectedEntityS2; return this.selected && ((_this$selectedEntityS = this.selectedEntitySet) === null || _this$selectedEntityS === void 0 ? void 0 : (_this$selectedEntityS2 = _this$selectedEntityS.pinned) === null || _this$selectedEntityS2 === void 0 ? void 0 : _this$selectedEntityS2.length) >= 24; }, selectedLink() { return { name: 'set-all', params: { pathMatch: this.selected && this.selectedEntitySet.id.replace('http://data.europeana.eu/set/', '') } }; }, selectedEntityPrefLabel() { var _this$selectedEntity, _this$selectedEntity$, _this$selectedEntity$2; return (_this$selectedEntity = this.selectedEntity) === null || _this$selectedEntity === void 0 ? void 0 : (_this$selectedEntity$ = _this$selectedEntity.prefLabel) === null || _this$selectedEntity$ === void 0 ? void 0 : (_this$selectedEntity$2 = _this$selectedEntity$.en) === null || _this$selectedEntity$2 === void 0 ? void 0 : _this$selectedEntity$2[0]; }, selectedEntity() { return this.entities.find(entity => entity.about === this.selected); }, selectedEntitySet() { return this.sets[this.selected]; } }, methods: { setFactory() { return { id: null, pinned: [] }; }, async fetchEntityBestItemsSets() { if (this.fetched) { return; } const searchParams = { query: 'type:EntityBestItemsSet', profile: 'minimal', pageSize: 1 }; await Promise.all(this.entities.map(async entity => { var _searchResponse$data; const entityUri = entity.about; // TODO: "OR" the ids to avoid multiple requests, but doesn't seem supported. const searchResponse = await this.$apis.set.search({ ...searchParams, qf: `subject:${entityUri}` }); if (((_searchResponse$data = searchResponse.data) === null || _searchResponse$data === void 0 ? void 0 : _searchResponse$data.total) > 0) { await this.getOneSet(searchResponse.data.items[0].split('/').pop()); } // TODO: Should an else block actually be RESETTING the data to empty values? })); this.fetched = true; }, async getOneSet(setId) { const options = { profile: 'standard', pageSize: 100 }; const response = await this.$apis.set.get(setId, options); const entityUri = response.subject[0]; this.sets[entityUri] = { id: setId, // When pins exist, they need to be sliced from the items, as sets may in future contain recommended items too. pinned: (response.items || []).map(item => item.replace('http://data.europeana.eu/item', '')).slice(0, response.pinned) }; }, async ensureSelectedSetExists() { var _this$selectedEntityS3; if (!((_this$selectedEntityS3 = this.selectedEntitySet) !== null && _this$selectedEntityS3 !== void 0 && _this$selectedEntityS3.id)) { const setBody = { type: 'EntityBestItemsSet', title: { 'en': `${this.selectedEntityPrefLabel} Page` }, subject: [this.selected] }; const response = await this.$apis.set.create(setBody); this.selectedEntitySet.id = response.id; } }, async pin() { await this.ensureSelectedSetExists(); await this.$apis.set.modifyItems('add', this.selectedEntitySet.id, this.identifier, true); this.selectedEntitySet.pinned.push(this.identifier); this.makeToast(this.$t('entity.notifications.pinned', { entity: this.selectedEntityPrefLabel })); this.hide(); }, async unpin() { try { await this.$apis.set.modifyItems('delete', this.selectedEntitySet.id, this.identifier); this.selectedEntitySet.pinned = this.selectedEntitySet.pinned.filter(itemId => itemId !== this.identifier); this.makeToast(this.$t('entity.notifications.unpinned')); } catch { this.makeToast(this.$t('entity.notifications.error.unpin')); } this.hide(); }, selectEntity(id) { this.selected = id; }, pinnedTo(entityUri) { var _this$sets$entityUri, _this$sets$entityUri$; return (_this$sets$entityUri = this.sets[entityUri]) === null || _this$sets$entityUri === void 0 ? void 0 : (_this$sets$entityUri$ = _this$sets$entityUri.pinned) === null || _this$sets$entityUri$ === void 0 ? void 0 : _this$sets$entityUri$.includes(this.identifier); }, async togglePin() { await (this.selectedIsPinned ? this.unpin() : this.pin()); }, hide() { this.selected = null; this.$bvModal.hide(this.modalId); } } }); // CONCATENATED MODULE: ./src/components/item/ItemPinModal.vue?vue&type=script&lang=js& /* harmony default export */ var item_ItemPinModalvue_type_script_lang_js_ = (ItemPinModalvue_type_script_lang_js_); // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js var componentNormalizer = __webpack_require__(3); // CONCATENATED MODULE: ./src/components/item/ItemPinModal.vue function injectStyles (context) { var style0 = __webpack_require__(492) if (style0.__inject__) style0.__inject__(context) } /* normalize component */ var component = Object(componentNormalizer["a" /* default */])( item_ItemPinModalvue_type_script_lang_js_, render, staticRenderFns, false, injectStyles, "b292b77a", "5901ee44" ) /* harmony default export */ var ItemPinModal = __webpack_exports__["default"] = (component.exports); /***/ }) };; //# sourceMappingURL=96.js.map