working Onesearch widget

This commit is contained in:
Mark Eaton
2023-07-01 16:49:10 -04:00
parent f03c8e346a
commit 63fee0b01d
+70 -71
View File
@@ -97,7 +97,7 @@ const onesearchComponent = {
<a v-for="(item, itemName) in materialtype" <a v-for="(item, itemName) in materialtype"
:key="item.id" :key="item.id"
class="searchmenu" class="searchmenu"
@click="selectDropdown(item, itemName)" @click="selectdropdown(item, itemName)"
> >
<div class="highlight-menu-item bigger-fancy-text"> <div class="highlight-menu-item bigger-fancy-text">
<strong>{{ item.fullName }}</strong> <strong>{{ item.fullName }}</strong>
@@ -131,7 +131,75 @@ const onesearchComponent = {
</div> </div>
</div> </div>
</form>`, </form>`,
props: ['selecteditem', 'searchstring', 'placeholderstring', 'displayeditem', 'materialtype'] methods: {
selectdropdown(item, itemName) {
this.displayeditem = itemName; // swap in current item at the top of the dropdown
this.selecteditem = item; // store the data from the dropdown selection
this.placeholderstring = 'Enter search term here';
},
submitSearch() {
if (this.displayeditem === 'Define Your Search') {
this.placeholderstring = 'Please make a selection';
this.searchstring = ''; // remove the search string
if (!this.$refs.blueBorder1.classList.contains('open')) { // if the dropdown is not open
this.$refs.oneSearchMenu.click(); // open the dropdown
}
} else {
this.$refs.primoQueryString.value = `any,contains,${this.$refs.primoQueryTempString.value.replace(/[,]/g, ' ')}`; // vueified OLS widget code
this.$refs.oneSearchForm.submit(); // submit the form
}
},
},
data() {
return {
selecteditem: {}, // initialize the data from the dropdown selection
searchstring: '', // initialize an empty search string
placeholderstring: 'Enter search term here', // initialize the placeholder
displayeditem: 'Define Your Search', // the text displayed a the top of the OneSearch dropdown
materialtype: {
Books: {
fullName: 'Books',
baseUrl: 'https://cuny-kb.primo.exlibrisgroup.com/discovery/search',
tab: 'Everything',
searchScope: 'IZ_CI_AW',
input: '<input name="facet" value="rtype,include,books" type="hidden" />',
id: 1,
},
Articles: {
fullName: 'Articles (Peer reviewed)',
baseUrl: 'https://cuny-kb.primo.exlibrisgroup.com/discovery/search',
tab: 'Everything',
searchScope: 'IZ_CI_AW',
input: '<input name="mfacet" value="rtype,include,articles,1" type="hidden" /><input name="facet" value="tlevel,include,peer_reviewed" type="hidden" />',
id: 2,
},
Reserves: {
fullName: 'Course reserves',
baseUrl: 'https://cuny-kb.primo.exlibrisgroup.com/discovery/search',
tab: 'CourseReserves',
searchScope: 'CourseReserves',
input: '',
id: 3,
},
Newspapers: {
fullName: 'Newspapers and Magazines',
baseUrl: 'https://cuny-kb.primo.exlibrisgroup.com/discovery/npsearch',
tab: 'Everything',
searchScope: 'IZ_CI_AW',
input: '',
id: 4,
},
Journals: {
fullName: 'Journals',
baseUrl: 'https://cuny-kb.primo.exlibrisgroup.com/discovery/jsearch',
tab: 'jsearch_slot',
searchScope: 'IZ_CI_AW',
input: '',
id: 5,
}
}
}
}
} }
const { createApp } = Vue const { createApp } = Vue
@@ -370,74 +438,5 @@ const app2 = createApp({
components: { components: {
'onesearch-component': onesearchComponent 'onesearch-component': onesearchComponent
}, },
methods: {
selectDropdown(item, itemName) {
this.displayeditem = itemName; // swap in current item at the top of the dropdown
this.selecteditem = item; // store the data from the dropdown selection
this.placeholderstring = 'Enter search term here';
},
submitSearch() {
if (this.displayeditem === 'Define Your Search') {
this.placeholderstring = 'Please make a selection';
this.searchstring = ''; // remove the search string
if (!this.$refs.blueBorder1.classList.contains('open')) { // if the dropdown is not open
this.$refs.oneSearchMenu.click(); // open the dropdown
}
} else {
this.$refs.primoQueryString.value = `any,contains,${this.$refs.primoQueryTempString.value.replace(/[,]/g, ' ')}`; // vueified OLS widget code
this.$refs.oneSearchForm.submit(); // submit the form
}
},
},
data() {
return {
selecteditem: {}, // initialize the data from the dropdown selection
searchstring: '', // initialize an empty search string
placeholderstring: 'Enter search term here', // initialize the placeholder
displayeditem: 'Define Your Search', // the text displayed a the top of the OneSearch dropdown
materialtype: {
Books: {
fullName: 'Books',
baseUrl: 'https://cuny-kb.primo.exlibrisgroup.com/discovery/search',
tab: 'Everything',
searchScope: 'IZ_CI_AW',
input: '<input name="facet" value="rtype,include,books" type="hidden" />',
id: 1,
},
Articles: {
fullName: 'Articles (Peer reviewed)',
baseUrl: 'https://cuny-kb.primo.exlibrisgroup.com/discovery/search',
tab: 'Everything',
searchScope: 'IZ_CI_AW',
input: '<input name="mfacet" value="rtype,include,articles,1" type="hidden" /><input name="facet" value="tlevel,include,peer_reviewed" type="hidden" />',
id: 2,
},
Reserves: {
fullName: 'Course reserves',
baseUrl: 'https://cuny-kb.primo.exlibrisgroup.com/discovery/search',
tab: 'CourseReserves',
searchScope: 'CourseReserves',
input: '',
id: 3,
},
Newspapers: {
fullName: 'Newspapers and Magazines',
baseUrl: 'https://cuny-kb.primo.exlibrisgroup.com/discovery/npsearch',
tab: 'Everything',
searchScope: 'IZ_CI_AW',
input: '',
id: 4,
},
Journals: {
fullName: 'Journals',
baseUrl: 'https://cuny-kb.primo.exlibrisgroup.com/discovery/jsearch',
tab: 'jsearch_slot',
searchScope: 'IZ_CI_AW',
input: '',
id: 5,
}
}
}
}
}) })
app2.mount('#app2'); app2.mount('#app2');