mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-16 22:42:16 +00:00
Add search from url functionality
This commit is contained in:
@@ -148,6 +148,44 @@ const router = VueRouter.createRouter({
|
||||
next();
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'search',
|
||||
path: `/${ciPath}/studentenverwaltung/:studiensemester_kurzbz/search/:searchstr`,
|
||||
component: FhcStudentenverwaltung,
|
||||
props(route) {
|
||||
return {
|
||||
url_studiensemester_kurzbz: route.params.studiensemester_kurzbz,
|
||||
url_mode: 'search',
|
||||
url_prestudent_id: route.params.searchstr
|
||||
};
|
||||
},
|
||||
beforeEnter(to, from, next) {
|
||||
const isSemester = /^[WS]S\d{4}$/.test(to.params.studiensemester_kurzbz);
|
||||
if (!isSemester) {
|
||||
return next({name: 'index'});
|
||||
}
|
||||
next();
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'search_w_types',
|
||||
path: `/${ciPath}/studentenverwaltung/:studiensemester_kurzbz/search/:types/:searchstr`,
|
||||
component: FhcStudentenverwaltung,
|
||||
props(route) {
|
||||
return {
|
||||
url_studiensemester_kurzbz: route.params.studiensemester_kurzbz,
|
||||
url_mode: 'search',
|
||||
url_prestudent_id: route.params.type + '/' + route.params.searchstr
|
||||
};
|
||||
},
|
||||
beforeEnter(to, from, next) {
|
||||
const isSemester = /^[WS]S\d{4}$/.test(to.params.studiensemester_kurzbz);
|
||||
if (!isSemester) {
|
||||
return next({name: 'index'});
|
||||
}
|
||||
next();
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/:pathMatch(.*)*',
|
||||
redirect: {
|
||||
|
||||
@@ -144,6 +144,9 @@ export default {
|
||||
},
|
||||
'url_mode': function () {
|
||||
this.handlePersonUrl();
|
||||
},
|
||||
url_prestudent_id() {
|
||||
this.handlePersonUrl();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -247,6 +250,21 @@ export default {
|
||||
ApiStv.students.person(this.$route.params.person_id, 'CURRENT_SEMESTER'),
|
||||
true
|
||||
);
|
||||
} else if (this.$route.params.searchstr) {
|
||||
const searchsettings = {
|
||||
searchstr: this.$route.params.searchstr,
|
||||
types: this.$route.params.types?.split('+') || []
|
||||
};
|
||||
|
||||
// init into student list
|
||||
this.$refs.stvList.updateUrl(
|
||||
ApiStv.students.search(searchsettings, this.studiensemesterKurzbz)
|
||||
);
|
||||
|
||||
// init into searchbar
|
||||
this.$refs.searchbar.searchsettings.searchstr = searchsettings.searchstr;
|
||||
this.$refs.searchbar.searchsettings.types = searchsettings.types;
|
||||
this.$nextTick(this.blurSearchbar);
|
||||
}
|
||||
},
|
||||
checkUrlStudiengang() {
|
||||
@@ -269,15 +287,40 @@ export default {
|
||||
}
|
||||
},
|
||||
onSearch(e) {
|
||||
const searchsettings = this.$refs.searchbar.searchsettings;
|
||||
const searchsettings = { ...this.$refs.searchbar.searchsettings };
|
||||
if (searchsettings.searchstr.length >= 2) {
|
||||
this.$refs.stvList.updateUrl(
|
||||
ApiStv.students.search(searchsettings, this.studiensemesterKurzbz)
|
||||
);
|
||||
this.$refs.searchbar.$refs.input.blur();
|
||||
this.$refs.searchbar.abort();
|
||||
this.$refs.searchbar.hideresult();
|
||||
this.blurSearchbar();
|
||||
|
||||
if (!searchsettings.types.length || searchsettings.types.length == this.$refs.searchbar.types.length) {
|
||||
this.$router.push({
|
||||
name: 'search',
|
||||
params: {
|
||||
studiensemester_kurzbz: this.studiensemesterKurzbz,
|
||||
searchstr: searchsettings.searchstr
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.$router.push({
|
||||
name: 'search_w_types',
|
||||
params: {
|
||||
studiensemester_kurzbz: this.studiensemesterKurzbz,
|
||||
searchstr: searchsettings.searchstr,
|
||||
types: searchsettings.types.join('+')
|
||||
}
|
||||
});
|
||||
}
|
||||
/*this.$nextTick(() => {console.log(searchsettings);
|
||||
this.$refs.stvList.updateUrl(
|
||||
ApiStv.students.search(searchsettings, this.studiensemesterKurzbz)
|
||||
);
|
||||
|
||||
});*/
|
||||
}
|
||||
},
|
||||
blurSearchbar() {
|
||||
this.$refs.searchbar.$refs.input.blur();
|
||||
this.$refs.searchbar.abort();
|
||||
this.$refs.searchbar.hideresult();
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
||||
@@ -119,7 +119,12 @@ export default {
|
||||
{
|
||||
return Promise.resolve({ data: []});
|
||||
}
|
||||
return this.$api.call({...config, url, params});
|
||||
/**
|
||||
* NOTE(chris): Because of a bug in Tabulator
|
||||
* we need to get the params from elsewhere.
|
||||
* @see https://github.com/olifolkerd/tabulator/issues/4318
|
||||
*/
|
||||
return this.$api.call({...config, url, params: this.tabulatorOptions.ajaxParams});
|
||||
},
|
||||
ajaxResponse: (url, params, response) => {
|
||||
return response?.data;
|
||||
@@ -214,9 +219,9 @@ export default {
|
||||
encodeURIComponent(this.currentSemester)
|
||||
);
|
||||
|
||||
let params = {}, filter = {}, method = 'get';
|
||||
var params = {}, filter = {}, method = 'get';
|
||||
if (endpoint.params)
|
||||
params = endpoint.params;
|
||||
params = { ...endpoint.params };
|
||||
if (endpoint.method)
|
||||
method = endpoint.method;
|
||||
|
||||
@@ -228,15 +233,15 @@ export default {
|
||||
if (filter.konto_count_0 || filter.konto_missing_counter)
|
||||
params.filter = filter;
|
||||
|
||||
this.tabulatorOptions.ajaxURL = endpoint.url;
|
||||
this.tabulatorOptions.ajaxParams = { ...params };
|
||||
this.tabulatorOptions.ajaxConfig = method;
|
||||
if (!this.$refs.table.tableBuilt) {
|
||||
if (!this.$refs.table.tabulator) {
|
||||
this.tabulatorOptions.ajaxURL = endpoint.url;
|
||||
this.tabulatorOptions.ajaxParams = params;
|
||||
this.tabulatorOptions.ajaxConfig = method;
|
||||
} else
|
||||
if (this.$refs.table.tabulator) {
|
||||
this.$refs.table.tabulator.on("tableBuilt", () => {
|
||||
this.$refs.table.tabulator.setData(endpoint.url, params, method);
|
||||
});
|
||||
}
|
||||
} else
|
||||
this.$refs.table.tabulator.setData(endpoint.url, params, method);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user