mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-16 22:42:16 +00:00
Merge branch 'feature-40841/SearchBarChanges' into feature-25999/C4
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
),
|
||||
'customCSSs' => array(
|
||||
'public/css/components/verticalsplit.css',
|
||||
'public/css/components/searchbar.css',
|
||||
'public/css/components/searchbar/searchbar.css',
|
||||
'public/css/components/primevue.css',
|
||||
),
|
||||
'customJSModules' => array('public/js/apps/TestSearch.js')
|
||||
|
||||
@@ -31,6 +31,7 @@ if (!isset($menu)) {
|
||||
<button id="nav-main-btn" class="navbar-toggler" type="button" data-bs-toggle="offcanvas" data-bs-target="#nav-main" aria-controls="nav-main" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<fhc-searchbar id="nav-search" class=" fhc-searchbar w-100" @updatesearchtypes="updatesearchtypes" :selectedtypes="selectedtypes" :searchoptions="searchbaroptions" :searchfunction="searchfunction"></fhc-searchbar>
|
||||
<a id="nav-logo" href="<?= site_url(''); ?>">
|
||||
<img src="<?= base_url('/public/images/logo-300x160.png'); ?>" alt="Logo">
|
||||
</a>
|
||||
@@ -41,7 +42,7 @@ if (!isset($menu)) {
|
||||
<i class="fa fa-arrow-circle-left"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="p-0">
|
||||
<div class="offcanvas-body p-0">
|
||||
<fhc-searchbar id="nav-search" class="fhc-searchbar w-100" :searchoptions="searchbaroptions" :searchfunction="searchfunction"></fhc-searchbar>
|
||||
<button id="nav-user-btn" class="btn btn-link rounded-0" type="button" data-bs-toggle="collapse" data-bs-target="#nav-user-menu" aria-expanded="false" aria-controls="nav-user-menu">
|
||||
<img src="<?= site_url('Cis/Pub/bild/person/' . getAuthPersonId()); ?>" class="avatar rounded-circle"/>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* basic */
|
||||
@import '../components/searchbar.css';
|
||||
@import '../components/searchbar/searchbar.css';
|
||||
html {
|
||||
font-size: 0.875em;
|
||||
}
|
||||
|
||||
+16
-4
@@ -3,12 +3,17 @@
|
||||
Author : bambi
|
||||
*/
|
||||
|
||||
@import url(./switches.css);
|
||||
|
||||
#search-filter{
|
||||
border: 1px solid #ced4da;
|
||||
}
|
||||
|
||||
|
||||
.searchbar_settings {
|
||||
position: absolute;
|
||||
z-index: 9999;
|
||||
background-color: #fff;
|
||||
border: 2px solid #666;
|
||||
padding: 1rem;
|
||||
background-color: #343a40;
|
||||
}
|
||||
|
||||
.searchbar_results {
|
||||
@@ -92,4 +97,11 @@
|
||||
|
||||
.searchbar_inline_ul li {
|
||||
list-style: none;
|
||||
}
|
||||
}
|
||||
|
||||
.non-selectable {
|
||||
user-select: none;
|
||||
-webkit-user-select: none; /* Safari */
|
||||
-moz-user-select: none; /* Firefox */
|
||||
-ms-user-select: none; /* IE/Edge */
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
.fhc-switches:checked {
|
||||
background-color: white !important;
|
||||
border-color: white !important;
|
||||
background-position: right center !important;
|
||||
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23000000'/%3e%3c/svg%3e") !important;
|
||||
}
|
||||
|
||||
.fhc-switches {
|
||||
background-color: var(--bs-gray-600) !important;
|
||||
border-color: var(--bs-gray-600) !important;
|
||||
background-position: left center !important;
|
||||
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%238e99a3'/%3e%3c/svg%3e") !important;
|
||||
}
|
||||
|
||||
.fhc-switches:focus {
|
||||
box-shadow: 0 0 0 .25rem rgba(108, 117, 125,.25);
|
||||
}
|
||||
|
||||
/*.form-switch .form-check-input:checked {
|
||||
|
||||
|
||||
rgb(52, 58, 64)*/
|
||||
|
||||
+11
-1
@@ -11,6 +11,11 @@ Vue.createApp({
|
||||
},
|
||||
data: function() {
|
||||
return {
|
||||
selectedtypes:[
|
||||
"mitarbeiter",
|
||||
"raum",
|
||||
"organisationunit"
|
||||
],
|
||||
searchbaroptions: {
|
||||
types: [
|
||||
"mitarbeiter",
|
||||
@@ -71,6 +76,11 @@ Vue.createApp({
|
||||
methods: {
|
||||
searchfunction: function(searchsettings) {
|
||||
return Vue.$fhcapi.Search.search(searchsettings);
|
||||
}
|
||||
},
|
||||
updatesearchtypes: function(newValues){
|
||||
console.log(newValues,"this are the new values")
|
||||
this.selectedtypes= newValues;
|
||||
|
||||
},
|
||||
}
|
||||
}).mount('#cis-header');
|
||||
@@ -28,6 +28,7 @@ export default {
|
||||
<button id="nav-main-btn" class="navbar-toggler" type="button" data-bs-toggle="offcanvas" data-bs-target="#nav-main" aria-controls="nav-main" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
|
||||
<a id="nav-logo" :href="rootUrl">
|
||||
<img :src="logoUrl" alt="Logo">
|
||||
</a>
|
||||
|
||||
@@ -6,7 +6,8 @@ import student from "./student.js";
|
||||
import prestudent from "./prestudent.js";
|
||||
|
||||
export default {
|
||||
props: [ "searchoptions", "searchfunction" ],
|
||||
props: [ "searchoptions", "searchfunction","selectedtypes" ],
|
||||
|
||||
data: function() {
|
||||
return {
|
||||
searchtimer: null,
|
||||
@@ -14,12 +15,12 @@ export default {
|
||||
showsettings: false,
|
||||
searchsettings: {
|
||||
searchstr: '',
|
||||
types: []
|
||||
types: [],
|
||||
},
|
||||
showresult: false,
|
||||
searchresult: [],
|
||||
showresult: false,
|
||||
searching: false,
|
||||
error: null
|
||||
error: null,
|
||||
};
|
||||
},
|
||||
components: {
|
||||
@@ -30,14 +31,17 @@ export default {
|
||||
student: student,
|
||||
prestudent: prestudent
|
||||
},
|
||||
template: `
|
||||
|
||||
template: /*html*/`
|
||||
<form ref="searchform" class="d-flex me-3" action="javascript:void(0);"
|
||||
@focusin="this.searchfocusin" @focusout="this.searchfocusout">
|
||||
<div class="input-group me-2 bg-white">
|
||||
|
||||
<div class="h-100 input-group me-2 bg-white">
|
||||
|
||||
<input ref="searchbox" @keyup="this.search" @focus="this.showsearchresult"
|
||||
v-model="this.searchsettings.searchstr" class="form-control"
|
||||
type="search" placeholder="Search" aria-label="Search">
|
||||
<button ref="settingsbutton" @click="this.togglesettings" class="btn btn-outline-secondary" type="button" id="search-filter"><i class="fas fa-cog"></i></button>
|
||||
type="search" :placeholder="'Search: '+ searchsettings.types.join(' / ')" aria-label="Search">
|
||||
<button data-bs-toggle="collapse" data-bs-target="#searchSettings" aria-expanded="false" aria-controls="searchSettings" ref="settingsbutton" class="btn btn-outline-secondary" type="button" id="search-filter"><i class="fas fa-cog"></i></button>
|
||||
</div>
|
||||
|
||||
<div v-show="this.showresult" ref="result"
|
||||
@@ -46,8 +50,8 @@ export default {
|
||||
<i class="fas fa-spinner fa-spin fa-2x"></i>
|
||||
</div>
|
||||
<div v-else-if="this.error !== null">{{ this.error }}</div>
|
||||
<div v-else-if="this.searchresult.length < 1">Es wurden keine Ergebnisse gefunden.</div>
|
||||
<template v-else="" v-for="res in this.searchresult">
|
||||
<div v-else-if="searchresult.length < 1">Es wurden keine Ergebnisse gefunden.</div>
|
||||
<template v-else="" v-for="res in searchresult">
|
||||
<person v-if="res.type === 'person'" :res="res" :actions="this.searchoptions.actions.person" @actionexecuted="this.hideresult"></person>
|
||||
<student v-else-if="res.type === 'student'" :res="res" :actions="this.searchoptions.actions.student" @actionexecuted="this.hideresult"></student>
|
||||
<prestudent v-else-if="res.type === 'prestudent'" :res="res" :actions="this.searchoptions.actions.prestudent" @actionexecuted="this.hideresult"></prestudent>
|
||||
@@ -57,28 +61,49 @@ export default {
|
||||
<div v-else="">Unbekannter Ergebnistyp: '{{ res.type }}'.</div>
|
||||
</template>
|
||||
</div>
|
||||
<div v-show="this.showsettings" ref="settings"
|
||||
class="searchbar_settings" tabindex="-1">
|
||||
<div class="btn-group" v-if="this.searchoptions.types.length > 0">
|
||||
<template v-for="(type, index) in this.searchoptions.types" :key="type">
|
||||
<input type="checkbox" class="btn-check" :id="this.$.uid + 'search_type_' + index" :value="type" v-model="this.searchsettings.types"/>
|
||||
<label class="btn btn-outline-secondary" :for="this.$.uid + 'search_type_' + index">{{ type }}</label>
|
||||
|
||||
<div id="searchSettings" ref="settings"
|
||||
class="top-100 end-0 searchbar_settings text-white collapse" tabindex="-1">
|
||||
<div class="d-flex flex-column m-3" v-if="this.searchoptions.types.length > 0">
|
||||
<span class="fw-light mb-2">Suche filtern nach:</span>
|
||||
<template v-for="(type, index) in this.searchoptions.types" :key="type">
|
||||
<div class="form-check form-switch">
|
||||
<input class="fhc-switches form-check-input" type="checkbox" role="switch" :id="this.$.uid + 'search_type_' + index" :value="type" v-model="searchsettings.types" />
|
||||
<label class="ps-2 form-check-label non-selectable" :for="this.$.uid + 'search_type_' + index">{{ type }}</label>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<div class="mb-2"></div>
|
||||
<button ref="settingsrefreshsearch" @click="this.refreshsearch" class="btn btn-primary" type="button">Übernehmen</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
`,
|
||||
watch:{
|
||||
'searchsettings.types'(newValue){
|
||||
this.search();
|
||||
|
||||
|
||||
},
|
||||
|
||||
},
|
||||
beforeMount: function() {
|
||||
this.updateSearchOptions();
|
||||
|
||||
},
|
||||
mounted(){
|
||||
window.addEventListener('resize', (event) =>{
|
||||
console.log(this.$refs.settings,"this is the refs of the settings")
|
||||
this.$refs.settings.hide();
|
||||
console.log("resizing")
|
||||
});
|
||||
//console.log(this.$refs.settings.show,"this are the refs")
|
||||
},
|
||||
methods: {
|
||||
|
||||
|
||||
updateSearchOptions: function() {
|
||||
this.searchsettings.types = [];
|
||||
for( const idx in this.searchoptions.types ) {
|
||||
this.searchsettings.types.push(this.searchoptions.types[idx]);
|
||||
for( const idx in this.selectedtypes ) {
|
||||
this.searchsettings.types.push(this.selectedtypes[idx]);
|
||||
}
|
||||
},
|
||||
calcSearchResultExtent: function() {
|
||||
@@ -104,43 +129,32 @@ export default {
|
||||
}
|
||||
},
|
||||
callsearchapi: function() {
|
||||
var that = this;
|
||||
this.error = null;
|
||||
this.searchresult = [];
|
||||
this.searchresult.splice(0,this.searchresult.length);
|
||||
this.searching = true;
|
||||
this.showsearchresult();
|
||||
this.searchfunction(this.searchsettings)
|
||||
.then(function(response) {
|
||||
.then(response=>{
|
||||
if( response.data?.error === 1 ) {
|
||||
that.error = 'Bei der Suche ist ein Fehler aufgetreten.';
|
||||
this.error = 'Bei der Suche ist ein Fehler aufgetreten.';
|
||||
} else {
|
||||
that.searchresult = response.data.data;
|
||||
for(let element of response.data.data){
|
||||
this.searchresult.push(element);
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(function(error) {
|
||||
that.error = 'Bei der Suche ist ein Fehler aufgetreten.'
|
||||
.catch(error=> {
|
||||
this.error = 'Bei der Suche ist ein Fehler aufgetreten.'
|
||||
+ ' ' + error.message;
|
||||
})
|
||||
.finally(function() {
|
||||
that.searching = false;
|
||||
.finally(()=> {
|
||||
this.searching = false;
|
||||
});
|
||||
},
|
||||
refreshsearch: function() {
|
||||
this.search();
|
||||
this.togglesettings();
|
||||
},
|
||||
calcSearchSettingsExtent: function() {
|
||||
var rect = this.$refs.settingsbutton.getBoundingClientRect();
|
||||
//console.log(window.innerWidth + ' ' + window.innerHeight + ' ' + JSON.stringify(rect));
|
||||
this.$refs.settings.style.top = Math.floor(rect.bottom + 3) + 'px';
|
||||
this.$refs.settings.style.right = Math.floor(window.innerWidth - rect.right) + 'px';
|
||||
this.$refs.settings.style.width = Math.floor(window.innerWidth * 0.5) + 'px';
|
||||
//this.$refs.settings.style.height = Math.floor(window.innerHeight * 0.5) + 'px';
|
||||
},
|
||||
togglesettings: function() {
|
||||
this.showsettings = !this.showsettings;
|
||||
this.calcSearchSettingsExtent();
|
||||
},
|
||||
hideresult: function() {
|
||||
this.showresult = false;
|
||||
window.removeEventListener('resize', this.calcSearchResultExtent);
|
||||
|
||||
Reference in New Issue
Block a user