UNPKG

@europeana/portal

Version:
2 lines 5.2 kB
(window.webpackJsonp=window.webpackJsonp||[]).push([[113,5],{1164:function(t,e,n){"use strict";n.r(e);var r=n(2),o=n(23),table=(n(75),n(10),n(43),n(46),n(41),n(47),n(208),n(60),n(30),n(16),n(15),n(13),n(19),n(14),n(20),n(1125)),l=n(729),c=n(203),f=n(726),d=n(31);function y(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 h(t){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?y(Object(source),!0).forEach((function(e){Object(r.a)(t,e,source[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(source)):y(Object(source)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(source,e))}))}return t}var m={name:"EntityTable",components:{AlertMessage:function(){return n.e(4).then(n.bind(null,727))},BTable:table.a,LoadingSpinner:l.default,SmartLink:c.a},mixins:[f.a],props:{type:{type:String,required:!0}},data:function(){return{collections:null,sortBy:"prefLabel",fields:[{key:"prefLabel",sortable:!0,label:this.$t("pages.collections.table.name")},"organisations"===this.type&&{key:"recordCount",sortable:!0,sortDirection:"desc",label:this.$t("pages.collections.table.items"),class:"text-right"}],typeSingular:this.type.slice(0,-1)}},fetch:function(){var t=this;return Object(o.a)(regeneratorRuntime.mark((function e(){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t.$axios.get(t.apiEndpoint,{baseURL:window.location.origin});case 3:n=e.sent,r=n.data,"organisations"===t.type&&(r=r.map(t.organisationData)),t.collections=r.map(Object.freeze),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(0),console.error({statusCode:500,message:e.t0.toString()});case 12:case"end":return e.stop()}}),e,null,[[0,9]])})))()},fetchOnServer:!1,computed:{apiEndpoint:function(){return"organisations"===this.type?"/_api/cache/collections/organisations":"/_api/cache/".concat(this.$i18n.locale,"/collections/").concat(this.type)}},methods:{organisationData:function(t){var e=this.organizationEntityNativeName(h(h({},t),{},{type:"Organization"})),n=Object(d.h)(e,this.$i18n.locale),r=this.organizationEntityNonNativeEnglishName(h(h({},t),{},{type:"Organization"})),o=r&&Object(d.h)(r,this.$i18n.locale);return h(h({},t),{},{prefLabel:n.values[0],prefLabelLang:n.code,altLabel:null==o?void 0:o.values[0],altLabelLang:null==o?void 0:o.code})},entityRoute:function(t){return"/collections/".concat(this.typeSingular,"/").concat(t)}}},v=n(59),component=Object(v.a)(m,(function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",[t.$fetchState.error?n("b-row",{staticClass:"flex-md-row py-4"},[n("b-col",{attrs:{cols:"12"}},[n("AlertMessage",{attrs:{error:t.$fetchState.error.message}})],1)],1):t._e(),t._v(" "),n("b-table",{staticClass:"borderless",attrs:{fields:t.fields,items:t.collections,"sort-by":t.sortBy,busy:t.$fetchState.pending,striped:""},on:{"update:sortBy":function(e){t.sortBy=e},"update:sort-by":function(e){t.sortBy=e}},scopedSlots:t._u([{key:"table-busy",fn:function(){return[n("div",{staticClass:"text-center my-2"},[n("LoadingSpinner"),t._v("\n "+t._s(t.$t("loading"))+"\n ")],1)]},proxy:!0},{key:"cell(prefLabel)",fn:function(data){return[n("SmartLink",{attrs:{destination:t.entityRoute(data.item.slug)}},["organisations"===t.type?[n("strong",{attrs:{lang:data.item.prefLabelLang}},[t._v(t._s(data.item.prefLabel))]),t._v(" "),data.item.altLabel?n("span",{attrs:{lang:data.item.altLabelLang}},[t._v("\n "+t._s(data.item.altLabel)+"\n ")]):t._e()]:n("span",[t._v("\n "+t._s(data.item.prefLabel)+"\n ")])],2)]}},"organisations"===t.type?{key:"cell(recordCount)",fn:function(data){return[n("span",[t._v("\n "+t._s(t._f("localise")(data.item.recordCount))+"\n ")])]}}:null],null,!0)})],1)}),[],!1,null,null,null);e.default=component.exports},726:function(t,e,n){"use strict";var r=n(2),o=(n(80),n(10),n(16),"en");e.a={methods:{isNamedOrganizationEntity:function(t){return"Organization"===(null==t?void 0:t.type)&&!!t.prefLabel},organizationEntityNativeName:function(t){if(!this.isNamedOrganizationEntity(t))return null;var e=Object.keys(t.prefLabel).find((function(t){return t!==o}))||o;return Object(r.a)({},e,t.prefLabel[e])},organizationEntityNonNativeEnglishName:function(t){return!this.isNamedOrganizationEntity(t)||Object.keys(t.prefLabel).length<2?null:Object(r.a)({},o,t.prefLabel.en)}}}},729:function(t,e,n){"use strict";n.r(e);var r={name:"LoadingSpinner",props:{statusMessage:{type:String,default:null}}},o=n(59),component=Object(o.a)(r,(function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("span",{attrs:{role:"status","data-qa":"loading spinner"}},[n("span",{staticClass:"visually-hidden"},[t._v("\n "+t._s(t.statusMessage||t.$t("loading"))+"\n ")]),t._v(" "),n("span",{staticClass:"spinner-border spinner-border-sm",attrs:{"aria-hidden":"true"}})])}),[],!1,null,null,null);e.default=component.exports}}]); //# sourceMappingURL=4fa923b.js.map