UNPKG

@europeana/portal

Version:
2 lines 7 kB
(window.webpackJsonp=window.webpackJsonp||[]).push([[108],{1007:function(t,e,n){"use strict";n(825)},1008:function(t,e,n){var l=n(105)(!1);l.push([t.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}",""]),t.exports=l},1116:function(t,e,n){"use strict";n.r(e);var l=n(6),c=n(16);n(55),n(14),n(28),n(21),n(42),n(22),n(58),n(38),n(43);function o(object,t){var e=Object.keys(object);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(object);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(object,t).enumerable}))),e.push.apply(e,n)}return e}function r(t){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?o(Object(source),!0).forEach((function(e){Object(l.a)(t,e,source[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(source)):o(Object(source)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(source,e))}))}return t}var d={name:"ItemPinModal",mixins:[n(254).a],props:{identifier:{type:String,required:!0},entities:{type:Array,required:!0},modalId:{type:String,default:"pin-modal"},modalStatic:{type:Boolean,default:!1}},data(){return{fetched:!1,selected:null,sets:this.entities.reduce(((t,e)=>(t[e.about]=this.setFactory(),t)),{})}},computed:{infoText(){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(){return this.selected&&this.pinnedTo(this.selected)},selectedIsFull(){var t,e;return this.selected&&(null===(t=this.selectedEntitySet)||void 0===t||null===(e=t.pinned)||void 0===e?void 0:e.length)>=24},selectedLink(){return{name:"set-all",params:{pathMatch:this.selected&&this.selectedEntitySet.id.replace("http://data.europeana.eu/set/","")}}},selectedEntityPrefLabel(){var t,e,n;return null===(t=this.selectedEntity)||void 0===t||null===(e=t.prefLabel)||void 0===e||null===(n=e.en)||void 0===n?void 0:n[0]},selectedEntity(){return this.entities.find((t=>t.about===this.selected))},selectedEntitySet(){return this.sets[this.selected]}},methods:{setFactory:()=>({id:null,pinned:[]}),fetchEntityBestItemsSets(){var t=this;return Object(c.a)((function*(){if(!t.fetched){var e={query:"type:EntityBestItemsSet",profile:"minimal",pageSize:1};yield Promise.all(t.entities.map(function(){var n=Object(c.a)((function*(n){var l,c=n.about,o=yield t.$apis.set.search(r(r({},e),{},{qf:"subject:".concat(c)}));(null===(l=o.data)||void 0===l?void 0:l.total)>0&&(yield t.getOneSet(o.data.items[0].split("/").pop()))}));return function(t){return n.apply(this,arguments)}}())),t.fetched=!0}}))()},getOneSet(t){var e=this;return Object(c.a)((function*(){var n=yield e.$apis.set.get(t,{profile:"standard",pageSize:100}),l=n.subject[0];e.sets[l]={id:t,pinned:(n.items||[]).map((t=>t.replace("http://data.europeana.eu/item",""))).slice(0,n.pinned)}}))()},ensureSelectedSetExists(){var t=this;return Object(c.a)((function*(){var e;if(null===(e=t.selectedEntitySet)||void 0===e||!e.id){var n={type:"EntityBestItemsSet",title:{en:"".concat(t.selectedEntityPrefLabel," Page")},subject:[t.selected]},l=yield t.$apis.set.create(n);t.selectedEntitySet.id=l.id}}))()},pin(){var t=this;return Object(c.a)((function*(){yield t.ensureSelectedSetExists(),yield t.$apis.set.modifyItems("add",t.selectedEntitySet.id,t.identifier,!0),t.selectedEntitySet.pinned.push(t.identifier),t.makeToast(t.$t("entity.notifications.pinned",{entity:t.selectedEntityPrefLabel})),t.hide()}))()},unpin(){var t=this;return Object(c.a)((function*(){try{yield t.$apis.set.modifyItems("delete",t.selectedEntitySet.id,t.identifier),t.selectedEntitySet.pinned=t.selectedEntitySet.pinned.filter((e=>e!==t.identifier)),t.makeToast(t.$t("entity.notifications.unpinned"))}catch(e){t.makeToast(t.$t("entity.notifications.error.unpin"))}t.hide()}))()},selectEntity(t){this.selected=t},pinnedTo(t){var e,n;return null===(e=this.sets[t])||void 0===e||null===(n=e.pinned)||void 0===n?void 0:n.includes(this.identifier)},togglePin(){var t=this;return Object(c.a)((function*(){yield t.selectedIsPinned?t.unpin():t.pin()}))()},hide(){this.selected=null,this.$bvModal.hide(this.modalId)}}},f=d,y=(n(1007),n(40)),component=Object(y.a)(f,(function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("b-modal",{attrs:{id:t.modalId,title:t.$t("record.actions.pin"),"hide-footer":"","hide-header-close":"",static:t.modalStatic},on:{show:t.fetchEntityBestItemsSets}},[t._l(t.entities,(function(e,l){return n("b-button",{key:l,staticClass:"btn-collection w-100 text-left d-flex",attrs:{disabled:!t.fetched,pressed:t.selected===e.about,"data-qa":"pin item to entity choice"},on:{click:function(n){return t.selectEntity(e.about)}}},[n("span",{staticClass:"mr-auto"},[t._v("\n "+t._s(e.prefLabel.en[0])+"\n ")]),t._v(" "),n("span",{staticClass:"icons text-left d-flex justify-content-end"},[t.selected===e.about?n("span",{staticClass:"icon-check-circle d-inline-flex ml-auto"}):t._e(),t._v(" "),t.pinnedTo(e.about)?n("span",{staticClass:"icon-push-pin d-inline-flex"}):t._e()])])})),t._v(" "),n("div",{staticClass:"modal-footer"},[n("span",{staticClass:"w-100 help"},[n("span",{staticClass:"icon icon-info-outline d-inline-flex"}),t._v(t._s(t.infoText)+"\n ")]),t._v(" "),n("b-button",{attrs:{variant:"outline-primary","data-qa":"cancel button"},on:{click:t.hide}},[t._v("\n "+t._s(t.$t("entity.actions.cancel"))+"\n ")]),t._v(" "),t.selectedIsPinned||!t.selectedIsFull?n("b-button",{attrs:{disabled:!t.selected,variant:"primary","data-qa":"toggle pin button"},on:{click:t.togglePin}},[t._v("\n "+t._s(t.selectedIsPinned?t.$t("entity.actions.unpin"):t.$t("entity.actions.pin"))+"\n ")]):t.selectedIsFull?n("span",[n("b-button",{attrs:{"data-qa":"go to set link",to:t.$path(t.selectedLink),variant:"primary"}},[t._v("\n "+t._s(t.$t("entity.actions.viewPinned"))+"\n ")])],1):t._e()],1)],2)}),[],!1,null,"b292b77a",null);e.default=component.exports},825:function(t,e,n){var content=n(1008);content.__esModule&&(content=content.default),"string"==typeof content&&(content=[[t.i,content,""]]),content.locals&&(t.exports=content.locals);(0,n(106).default)("fc0d17f6",content,!0,{sourceMap:!1})}}]); //# sourceMappingURL=faa0c18.modern.js.map