text: (window.webpackJsonp=window.webpackJsonp||[]).push([[17],{"0QnR":function(t,e,s){"use strict";function r(t,e,s,r,o,n,a){try{var i=t[n](a),c=i.value}catch(t){return void s(t)}i.done?e(c):Promise.resolve(c).then(r,o)}function o(t){return function(){var e=this,s=arguments;return new Promise(function(o,n){function a(t){r(c,o,n,a,i,"next",t)}function i(t){r(c,o,n,a,i,"throw",t)}var c=t.apply(e,s);a(void 0)})}}s.r(e);var n=s("o0o1"),a=s.n(n),i=s("vDqi"),c=s.n(i),u=s("k4Da"),l=s.n(u),p=s("qPyV"),g=s.n(p),h=s("k8Y/"),d=s.n(h),f={name:"uc-grouplist",components:{ucPager:function(){return s.e(23).then(s.bind(null,"cVDb"))},ucDropdown:function(){return s.e(9).then(s.bind(null,"P8gK"))}},props:{endpoint:{type:String,default:"/it/showcase/endpoint/grouplist-endpoint"}},data:function(){return{groups:[],results:[],pagedResults:[],search:"",isSearchResults:!1,noResults:!1,pagination:{currentIndex:0,currentPage:1,totalPages:1,totalPerPage:10,totalResults:0,currentResults:0},isDropdownSort:!1,topicDropdownOptions:[],topicDropdownSelected:"All"}},mounted:function(){var t=o(a.a.mark(function t(){var e;return a.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return null!==(e=this).$route.query.search&&e.$route.query.search&&(e.search=e.$route.query.search),null!==e.$route.query.topic&&e.$route.query.topic&&(e.topicDropdownSelected=e.$route.query.topic),t.next=5,e.initialize();case 5:e.loadTopicDropdown();case 6:case"end":return t.stop()}},t,this)}));return function(){return t.apply(this,arguments)}}(),methods:{initialize:function(){var t=o(a.a.mark(function t(){var e,s;return a.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=this,t.prev=1,t.next=4,c.a.get(e.endpoint);case 4:s=t.sent,e.groups=e.normalize(s.data.items),e.results=e.groups,t.next=12;break;case 9:t.prev=9,t.t0=t.catch(1),e.log(t.t0,"error");case 12:e.getPagedResults(1),e.getPaginationInfo(),e.queryHasValue()&&e.searchGroups();case 15:case"end":return t.stop()}},t,this,[[1,9]])}));return function(){return t.apply(this,arguments)}}(),searchGroups:function(){var t=this;t.updateQueryString(),t.isSearchResults=!1;var e=t.groups;if(t.queryHasValue()){t.isSearchResults=!0;var s=t.search.toLowerCase().split(" ");e=l()(t.groups,function(t){var e=!1,r=[];return r=r.concat(t.name.toLowerCase().replace(/[,.]/g,"").split(" ")),t.topics&&t.topics.forEach(function(t){r=r.concat(t.toLowerCase().split(" "))}),(r=g()(r)).some(function(t){if(s.some(function(s){if(t===s)return e=!0,!0}),e)return!0}),e})}t.isSearchResults?0===e.length?(t.noResults=!0,t.results=[]):(t.noResults=!1,t.results=e):(t.noResults=!1,t.results=t.groups),t.getPagedResults(1),t.getPaginationInfo()},normalize:function(t){var e=[];return t.forEach(function(t){var s={};s.name=t.name,s.sort_name=t.sort_name,s.url=t.url,s.url_target=t.url_target,s.image=t.image,s.members=t.members,s.description=t.description,s.topics=t.topics,s.latestPublication=t.latest_publication,e.push(s)}),e},getPagedResults:function(t){var e=this,s=1===t?0:(t-1)*e.pagination.totalPerPage,r=s+e.pagination.totalPerPage;e.pagedResults=e.results.slice(s,r)},getPaginationInfo:function(){var t=this;t.pagination.totalPages=Math.ceil(t.results.length/t.pagination.totalPerPage)},loadTopicDropdown:function(){var t=this,e=[{name:"All Topics",value:"All"}];t.groups.forEach(function(t){t.topics&&t.topics.forEach(function(t){e.push({name:t,value:t})})}),e=g()(e,"name"),e=d()(e,"name"),t.topicDropdownOptions=e,"All"!==t.topicDropdownSelected&&t.$refs.dropdownTopic.handleSelect({name:t.topicDropdownSelected,value:t.topicDropdownSelected},!1)},handlePage:function(t){this.scrollToTop(),this.getPagedResults(t)},handleTopicDropdownChange:function(t){var e=this;e.resetSearch(),e.isSearchResults=!1,e.isDropdownSort=!0;var s=e.groups;"All"!==t&&(s=l()(e.groups,function(e){if(e.topics&&e.topics.includes(t))return!0})),e.results=s,e.getPagedResults(1),e.getPaginationInfo()},resetSearch:function(){var t=this;t.search="",t.isSearchResults=!1,t.removeRouterQuery("search")},resetTopicDropdown:function(){this.$refs.dropdownTopic.reset(),this.removeRouterQuery("topic")},removeRouterQuery:function(t){var e=Object.assign({},this.$route.query);delete e[t],this.$router.replace({query:e})},scrollToTop:function(){var t=document.documentElement.scrollTop||document.body.scrollTop,e=this.$el.offsetTop-40;t>e&&(window.requestAnimationFrame(this.scrollToTop),window.scrollTo(e,t-t/15)),this.focusTop()},focusTop:function(){var t=this;setTimeout(function(){var e=t.$el.querySelector(".c-grouplist a");e&&e.focus()},150)},queryHasValue:function(){return""!==this.search},updateQueryString:function(){""===this.query?this.removeRouterQuery("search"):this.$router.replace({query:{search:this.search}})},log:function(t){var e="GroupList";"error"===(1<arguments.length&&void 0!==arguments[1]?arguments[1]:"info")?console.error("".concat(e,": ").concat(t)):console.log("".concat(e,": ").concat(t))}}},v=s("KHd+"),_=Object(v.a)(f,function(){var t=this,e=t.$createElement,s=t._self._c||e;return s("div",{staticClass:"c-grouplist"},[s("div",{ref:"controls",staticClass:"c-grouplist__controls"},[s("div",{staticClass:"c-searchform c-grouplist__searchform"},[s("form",{attrs:{autocomplete:"off","accept-charset":"UTF-8"},on:{submit:function(e){return e.preventDefault(),t.searchGroups(e)}}},[s("div",{staticClass:"c-searchform__input_container"},[s("input",{directives:[{name:"model",rawName:"v-model",value:t.search,expression:"search"}],attrs:{type:"text",name:"search",placeholder:"Search"},domProps:{value:t.search},on:{input:function(e){e.target.composing||(t.search=e.target.value)}}}),t._v(" "),s("button",{attrs:{type:"submit"},on:{click:function(e){return e.preventDefault(),t.searchGroups(e)}}},[s("uc-icon",{attrs:{glyph:"search"}})],1)])])]),t._v(" "),s("uc-dropdown",{ref:"dropdownTopic",staticClass:"c-grouplist__dropdown",attrs:{options:t.topicDropdownOptions,"default-selection":t.topicDropdownSelected,"on-select":t.handleTopicDropdownChange,"display-name":"All Topics",name:"topic"}})],1),t._v(" "),s("section",{staticClass:"c-grouplist__search-info"},[t.noResults&&t.isSearchResults?s("div",{staticClass:"c-grouplist__noresults"},[s("h2",[t._v("No results found.")])]):t.isSearchResults?s("p",{staticClass:"c-grouplist__search-summary"},[t._v("\n      Displaying "+t._s(t.results.length)+" results for "),s("strong",[t._v(t._s(t.$route.query.search))])]):t._e()]),t._v(" "),t.noResults?t._e():s("ol",{staticClass:"c-grouplist__results-list"},t._l(t.pagedResults,function(e){return s("li",{staticClass:"c-grouplist__result"},[s("div",{staticClass:"c-grouplist__result-image"},[s("div",{staticClass:"c-grouplist__result-imagewrap"},[s("svg",{staticClass:"c-icon"},[s("use",{attrs:{"xlink:href":"/themes/custom/uccollege/dist/icons.svg#phoenix"}})]),t._v(" "),e.image?s("img",{staticClass:"lazyload",attrs:{"data-src":e.image,alt:e.name}}):t._e()])]),t._v(" "),s("div",{staticClass:"c-grouplist__result-content"},[s("h3",{staticClass:"c-grouplist__result-name"},[s("a",{attrs:{href:e.url,target:e.url_target}},[t._v(t._s(e.name))])]),t._v(" "),e.latestPublication?s("p",{staticClass:"c-grouplist__result-publication"},[s("strong",[t._v("Latest Publication:")]),t._v(" "),s("a",{attrs:{href:e.latestPublication.url,target:e.latestPublication.url_target}},[t._v(t._s(e.latestPublication.name))])]):t._e(),t._v(" "),0<e.topics.length?s("p",{staticClass:"c-grouplist__result-topics"},[s("strong",[t._v("Tags: ")]),t._v("\n          "+t._s(e.topics.join(", "))+"\n        ")]):t._e(),t._v(" "),s("div",{staticClass:"c-grouplist__result-desc",domProps:{innerHTML:t._s(e.description)}})])])}),0),t._v(" "),s("uc-pager",{directives:[{name:"show",rawName:"v-show",value:1<t.pagination.totalPages,expression:"pagination.totalPages > 1"}],ref:"pager",staticClass:"c-list__pager",attrs:{"on-page":t.handlePage,page:t.pagination.currentPage,total:t.pagination.totalPages}})],1)},[],!1,null,null,null);e.default=_.exports}}]);