UNPKG

@europeana/portal

Version:
2 lines 8.64 kB
(window.webpackJsonp=window.webpackJsonp||[]).push([[107],{1076:function(e,t,n){"use strict";n(898)},1077:function(e,t,n){var r=n(137)(!1);r.push([e.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}",""]),e.exports=r},1187:function(e,t,n){"use strict";n.r(t);n(16),n(15),n(19),n(14),n(20);var r=n(2),c=n(23);n(75),n(10),n(21),n(37),n(80),n(43),n(46),n(47),n(81),n(52),n(41),n(13),n(58),n(62);function o(object,e){var t=Object.keys(object);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(object);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(object,e).enumerable}))),t.push.apply(t,n)}return t}function l(e){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?o(Object(source),!0).forEach((function(t){Object(r.a)(e,t,source[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(source)):o(Object(source)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(source,t))}))}return e}var d={name:"ItemPinModal",mixins:[n(317).a],props:{identifier:{type:String,required:!0},entities:{type:Array,required:!0},modalId:{type:String,default:"pin-modal"},modalStatic:{type:Boolean,default:!1}},data:function(){var e=this;return{fetched:!1,selected:null,sets:this.entities.reduce((function(t,n){return t[n.about]=e.setFactory(),t}),{})}},computed:{infoText:function(){return this.selectedIsFull?this.selectedIsPinned?this.$t("entity.notifications.unpin",{entity:this.selectedEntityPrefLabel}):this.$t("entity.notifications.pinLimit.body"):this.selectedIsPinned?this.$t("entity.notifications.unpin",{entity:this.selectedEntityPrefLabel}):this.selected?this.$t("entity.notifications.pin",{entity:this.selectedEntityPrefLabel}):this.$t("entity.notifications.select")},selectedIsPinned:function(){return this.selected&&this.pinnedTo(this.selected)},selectedIsFull:function(){var e,t;return this.selected&&(null===(e=this.selectedEntitySet)||void 0===e||null===(t=e.pinned)||void 0===t?void 0:t.length)>=24},selectedLink:function(){return{name:"set-all",params:{pathMatch:this.selected&&this.selectedEntitySet.id.replace("http://data.europeana.eu/set/","")}}},selectedEntityPrefLabel:function(){var e,t,n;return null===(e=this.selectedEntity)||void 0===e||null===(t=e.prefLabel)||void 0===t||null===(n=t.en)||void 0===n?void 0:n[0]},selectedEntity:function(){var e=this;return this.entities.find((function(t){return t.about===e.selected}))},selectedEntitySet:function(){return this.sets[this.selected]}},methods:{setFactory:function(){return{id:null,pinned:[]}},fetchEntityBestItemsSets:function(){var e=this;return Object(c.a)(regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!e.fetched){t.next=2;break}return t.abrupt("return");case 2:return n={query:"type:EntityBestItemsSet",profile:"minimal",pageSize:1},t.next=5,Promise.all(e.entities.map(function(){var t=Object(c.a)(regeneratorRuntime.mark((function t(r){var c,o,d;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=r.about,t.next=3,e.$apis.set.search(l(l({},n),{},{qf:"subject:".concat(o)}));case 3:if(d=t.sent,!((null===(c=d.data)||void 0===c?void 0:c.total)>0)){t.next=7;break}return t.next=7,e.getOneSet(d.data.items[0].split("/").pop());case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 5:e.fetched=!0;case 6:case"end":return t.stop()}}),t)})))()},getOneSet:function(e){var t=this;return Object(c.a)(regeneratorRuntime.mark((function n(){var r,c,o;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r={profile:"standard",pageSize:100},n.next=3,t.$apis.set.get(e,r);case 3:c=n.sent,o=c.subject[0],t.sets[o]={id:e,pinned:(c.items||[]).map((function(e){return e.replace("http://data.europeana.eu/item","")})).slice(0,c.pinned)};case 6:case"end":return n.stop()}}),n)})))()},ensureSelectedSetExists:function(){var e=this;return Object(c.a)(regeneratorRuntime.mark((function t(){var n,r,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!==(n=e.selectedEntitySet)&&void 0!==n&&n.id){t.next=6;break}return r={type:"EntityBestItemsSet",title:{en:"".concat(e.selectedEntityPrefLabel," Page")},subject:[e.selected]},t.next=4,e.$apis.set.create(r);case 4:c=t.sent,e.selectedEntitySet.id=c.id;case 6:case"end":return t.stop()}}),t)})))()},pin:function(){var e=this;return Object(c.a)(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.ensureSelectedSetExists();case 2:return t.next=4,e.$apis.set.modifyItems("add",e.selectedEntitySet.id,e.identifier,!0);case 4:e.selectedEntitySet.pinned.push(e.identifier),e.makeToast(e.$t("entity.notifications.pinned",{entity:e.selectedEntityPrefLabel})),e.hide();case 7:case"end":return t.stop()}}),t)})))()},unpin:function(){var e=this;return Object(c.a)(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.$apis.set.modifyItems("delete",e.selectedEntitySet.id,e.identifier);case 3:e.selectedEntitySet.pinned=e.selectedEntitySet.pinned.filter((function(t){return t!==e.identifier})),e.makeToast(e.$t("entity.notifications.unpinned")),t.next=10;break;case 7:t.prev=7,t.t0=t.catch(0),e.makeToast(e.$t("entity.notifications.error.unpin"));case 10:e.hide();case 11:case"end":return t.stop()}}),t,null,[[0,7]])})))()},selectEntity:function(e){this.selected=e},pinnedTo:function(e){var t,n;return null===(t=this.sets[e])||void 0===t||null===(n=t.pinned)||void 0===n?void 0:n.includes(this.identifier)},togglePin:function(){var e=this;return Object(c.a)(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.selectedIsPinned?e.unpin():e.pin();case 2:case"end":return t.stop()}}),t)})))()},hide:function(){this.selected=null,this.$bvModal.hide(this.modalId)}}},f=d,h=(n(1076),n(59)),component=Object(h.a)(f,(function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("b-modal",{attrs:{id:e.modalId,title:e.$t("record.actions.pin"),"hide-footer":"","hide-header-close":"",static:e.modalStatic},on:{show:e.fetchEntityBestItemsSets}},[e._l(e.entities,(function(t,r){return n("b-button",{key:r,staticClass:"btn-collection w-100 text-left d-flex",attrs:{disabled:!e.fetched,pressed:e.selected===t.about,"data-qa":"pin item to entity choice"},on:{click:function(n){return e.selectEntity(t.about)}}},[n("span",{staticClass:"mr-auto"},[e._v("\n "+e._s(t.prefLabel.en[0])+"\n ")]),e._v(" "),n("span",{staticClass:"icons text-left d-flex justify-content-end"},[e.selected===t.about?n("span",{staticClass:"icon-check-circle d-inline-flex ml-auto"}):e._e(),e._v(" "),e.pinnedTo(t.about)?n("span",{staticClass:"icon-push-pin d-inline-flex"}):e._e()])])})),e._v(" "),n("div",{staticClass:"modal-footer"},[n("span",{staticClass:"w-100 help"},[n("span",{staticClass:"icon icon-info-outline d-inline-flex"}),e._v(e._s(e.infoText)+"\n ")]),e._v(" "),n("b-button",{attrs:{variant:"outline-primary","data-qa":"cancel button"},on:{click:e.hide}},[e._v("\n "+e._s(e.$t("entity.actions.cancel"))+"\n ")]),e._v(" "),e.selectedIsPinned||!e.selectedIsFull?n("b-button",{attrs:{disabled:!e.selected,variant:"primary","data-qa":"toggle pin button"},on:{click:e.togglePin}},[e._v("\n "+e._s(e.selectedIsPinned?e.$t("entity.actions.unpin"):e.$t("entity.actions.pin"))+"\n ")]):e.selectedIsFull?n("span",[n("b-button",{attrs:{"data-qa":"go to set link",to:e.$path(e.selectedLink),variant:"primary"}},[e._v("\n "+e._s(e.$t("entity.actions.viewPinned"))+"\n ")])],1):e._e()],1)],2)}),[],!1,null,"b292b77a",null);t.default=component.exports},898:function(e,t,n){var content=n(1077);content.__esModule&&(content=content.default),"string"==typeof content&&(content=[[e.i,content,""]]),content.locals&&(e.exports=content.locals);(0,n(138).default)("fc0d17f6",content,!0,{sourceMap:!1})}}]); //# sourceMappingURL=121828a.js.map