+
+
-
+
0){
return this.searchsettings.types.join(' / ');
@@ -105,8 +106,8 @@ export default {
this.searchsettings.types = this.allSearchTypes();
}
// stores the search types in the localstorage, only if the newValue is also an array
- if(Array.isArray(newValue)){
- localStorage.setItem('searchtypes', JSON.stringify(newValue));
+ if(Array.isArray(newValue) && this.searchoptions.origin){
+ localStorage.setItem(`${this.searchoptions.origin}_searchtypes`, JSON.stringify(newValue));
}
this.search();
});
@@ -115,6 +116,10 @@ export default {
this.settingsDropdown = new bootstrap.Collapse(this.$refs.settings, {
toggle: false
});
+
+ if (!this.searchoptions.origin){
+ console.warn("No origin defined in the searchoptions for the searchbar, please define the origin property in the searchbaroptions to allow reliable storage of searchstr and searchtypes accross applications.");
+ }
},
updated() {
if(this.showresult) {
@@ -126,8 +131,11 @@ export default {
methods: {
getSearchTypes: function () {
let result = this.allSearchTypes();
- if (localStorage.getItem('searchtypes')) {
- result = JSON.parse(localStorage.getItem('searchtypes'));
+ if (this.searchoptions.origin) {
+ let localStorageValue = localStorage.getItem(`${this.searchoptions.origin}_searchtypes`);
+ if (localStorageValue) {
+ result = JSON.parse(localStorageValue);
+ }
}
return result;
},
@@ -139,7 +147,9 @@ export default {
return allTypes;
},
getSearchStr: function(){
- return sessionStorage.getItem('searchstr') ?? '';
+ if (!this.searchoptions.origin)
+ return '';
+ return sessionStorage.getItem(`${this.searchoptions.origin}_searchstr`) ?? '';
},
checkSettingsVisibility: function(event) {
// hides the settings collapsible if the user clicks somewhere else