UNPKG

@europeana/portal

Version:
2 lines 4.71 kB
(window.webpackJsonp=window.webpackJsonp||[]).push([[59],{1142:function(t,e,n){"use strict";n.r(e);n(41),n(34),n(68),n(43),n(21),n(15),n(64),n(71),n(46);var r=n(23);n(75),n(58),n(62),n(47),n(50),n(80),n(10),n(13),n(30);function o(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return c(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return c(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,l=!0,f=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return l=t.done,t},e:function(t){f=!0,o=t},f:function(){try{l||null==n.return||n.return()}finally{if(f)throw o}}}}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}var l={name:"ContentfulCategorySuggestPage",layout:"contentful",data:function(){return{value:[],searchText:null,suggestions:[],contentfulExtensionSdk:null}},head:function(){return{title:this.$pageHeadTitle("Category suggest - Contentful app")}},watch:{value:"updateContentfulField"},mounted:function(){var t=this;window.contentfulExtension.init((function(e){t.contentfulExtensionSdk=e,e.location.is(window.contentfulExtension.locations.LOCATION_ENTRY_FIELD)&&(e.window.startAutoResizer(),t.findCategories())}))},methods:{isSelected:function(t){return this.value.map((function(t){return t.sys.id})).includes(t.sys.id)},suggestCategories:function(text){var t=this;return Object(r.a)(regeneratorRuntime.mark((function e(){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(text.length<2)){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,t.contentfulExtensionSdk.space.getEntries({content_type:"category","fields.name[match]":text});case 4:n=e.sent,t.suggestions=n.items;case 6:case"end":return e.stop()}}),e)})))()},findCategories:function(){var t=this;return Object(r.a)(regeneratorRuntime.mark((function e(){var n,r,c,l,f,d;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((n=(t.contentfulExtensionSdk.field.getValue()||[]).map((function(link){return link.sys.id}))).length>0)){e.next=9;break}return e.next=4,t.contentfulExtensionSdk.space.getEntries({"sys.id[in]":n.join(",")});case 4:r=e.sent,c=[],l=o(n);try{for(d=function(){var t=f.value,e=r.items.find((function(e){return e.sys.id===t}));e&&c.push(e)},l.s();!(f=l.n()).done;)d()}catch(t){l.e(t)}finally{l.f()}t.value=c;case 9:case"end":return e.stop()}}),e)})))()},removeSelection:function(t){this.value=this.value.filter((function(e){return e.sys.id!==t.sys.id}))},selectSuggestion:function(select){this.value=this.value.concat(select)},updateContentfulField:function(){this.contentfulExtensionSdk.field.setValue(this.value.map((function(t){return{sys:{type:"Link",linkType:"Entry",id:t.sys.id}}})))}}},f=(n(940),n(59)),component=Object(f.a)(l,(function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"contentful"},[n("b-form-group",t._l(t.value,(function(e){return n("b-button",{key:e.sys.id,staticClass:"mb-2",on:{click:function(n){return t.removeSelection(e)}}},[t._v("\n "+t._s(e.fields.name["en-GB"])+"\n ")])})),1),t._v(" "),n("b-form",[n("b-form-group",[n("b-form-input",{attrs:{type:"search",autocomplete:"off",placeholder:"Search for categories"},on:{input:t.suggestCategories},model:{value:t.searchText,callback:function(e){t.searchText=e},expression:"searchText"}})],1),t._v(" "),n("b-form-group",t._l(t.suggestions,(function(e){return n("b-button",{key:e.sys.id,staticClass:"mb-2",attrs:{disabled:t.isSelected(e)},on:{click:function(n){return t.selectSuggestion(e)}}},[t._v("\n "+t._s(e.fields.name["en-GB"])+"\n ")])})),1)],1)],1)}),[],!1,null,"85501a7a",null);e.default=component.exports},847:function(t,e,n){var content=n(941);content.__esModule&&(content=content.default),"string"==typeof content&&(content=[[t.i,content,""]]),content.locals&&(t.exports=content.locals);(0,n(138).default)("fbd2802c",content,!0,{sourceMap:!1})},940:function(t,e,n){"use strict";n(847)},941:function(t,e,n){var r=n(137)(!1);r.push([t.i,".contentful button[data-v-85501a7a]{margin-right:1rem}",""]),t.exports=r}}]); //# sourceMappingURL=0530ecd.js.map