Merge remote-tracking branch 'origin/feature-19473/VUE_Filter_Navigation_Widgets' into feature-19001/VUE_ROUTER

This commit is contained in:
Werner Masik
2022-08-18 21:31:54 +02:00
3 changed files with 41 additions and 78 deletions
+6 -6
View File
@@ -65,9 +65,9 @@ export const CoreFetchCmpt = {
if (apiFunctionResult instanceof Promise)
{
apiFunctionResult
.then(this.success) // on success
.catch(this.error) // on error
.then(this.finally); // finally in any case
.then(this.successHandler) // on success
.catch(this.errorHandler) // on error
.finally(this.finallyHandler); // finally in any case
}
else // otherwise display an error
{
@@ -90,19 +90,19 @@ export const CoreFetchCmpt = {
/**
*
*/
success: function(response) {
successHandler: function(response) {
this.$emit('dataFetched', response.data); // trigger the event dataFetched
},
/**
*
*/
error: function(error) {
errorHandler: function(error) {
this.setError(error.message);
},
/**
*
*/
finally: function() {
finallyHandler: function() {
this.loading = false; // loading ended
}
},
+32 -71
View File
@@ -37,12 +37,8 @@ export const CoreFilterCmpt = {
},
data: function() {
return {
// Tabulator
tabulator: null,
// FilterCmpt properties
fields: null,
fieldsToDisplay: null,
dataset: null,
datasetMetadata: null,
selectedFields: null,
@@ -63,55 +59,50 @@ export const CoreFilterCmpt = {
updated: function() {
//
let dataset = JSON.parse(JSON.stringify(this.dataset));
let datasetMetadata = JSON.parse(JSON.stringify(this.datasetMetadata));
let fieldsToDisplay = JSON.parse(JSON.stringify(this.fieldsToDisplay));
let fields = JSON.parse(JSON.stringify(this.fields));
let selectedFields = JSON.parse(JSON.stringify(this.selectedFields));
//
let columns = null;
//
// If the tabulator options has been provided and it contains the property columns
if (this.tabulatorOptions != null && this.tabulatorOptions.hasOwnProperty('columns'))
{
columns = this.tabulatorOptions.columns;
}
// If columns is not valid
if (!Array.isArray(columns) || (Array.isArray(columns) && columns.length < datasetMetadata.length))
// If columns is not an array or it is an array with less elements then the array fields
if (!Array.isArray(columns) || (Array.isArray(columns) && columns.length < fields.length))
{
columns = []; //
columns = []; // set it as an empty array
//
for (let i = 0; i < datasetMetadata.length; i++)
// Loop throught all the retrieved columns from database
for (let i = 0; i < fields.length; i++)
{
//
if (fieldsToDisplay.indexOf(datasetMetadata[i].name) != -1)
{
//
columns[i] = {
title: datasetMetadata[i].name,
field: datasetMetadata[i].name
};
}
// Create a new column having the title equal to the field name
let column = {
title: fields[i],
field: fields[i]
};
// If the column has to be displayed or not
selectedFields.indexOf(fields[i]) >= 0 ? column.visible = true : column.visible = false;
// Add the new column to the list of columns
columns.push(column);
}
}
else //
else // the property columns has been provided in the tabulator options
{
let tmpColumns = [];
//
// Loop throught the property columns of the tabulator options
for (let i = 0; i < columns.length; i++)
{
if (selectedFields.indexOf(columns[i].field) != -1)
{
tmpColumns.push(columns[i]);
}
// If the column has to be displayed or not
selectedFields.indexOf(columns[i].field) >= 0 ? columns[i].visible = true : columns[i].visible = false;
}
columns = tmpColumns;
}
//
// Define a default tabulator options in case it was not provided
let tabulatorOptions = {
height: 500,
layout: "fitColumns",
@@ -120,29 +111,30 @@ export const CoreFilterCmpt = {
reactiveData: true
};
//
// If it was provided
if (this.tabulatorOptions != null)
{
// Then copy it...
tabulatorOptions = this.tabulatorOptions;
// ...and overwrite the properties data, reactiveData and columns
tabulatorOptions.data = JSON.parse(JSON.stringify(this.dataset));
tabulatorOptions.reactiveData = true;
tabulatorOptions.columns = columns;
}
//
this.tabulator = new Tabulator(
// Start the tabulator with the buid options
let tabulator = new Tabulator(
"#filterTableDataset",
tabulatorOptions
);
//
// If event handlers have been provided
if (Array.isArray(this.tabulatorEvents) && this.tabulatorEvents.length > 0)
{
//
// Attach all the provided event handlers to the started tabulator
for (let i = 0; i < this.tabulatorEvents.length; i++)
{
//
this.tabulator.on(this.tabulatorEvents[i].event, this.tabulatorEvents[i].handler);
tabulator.on(this.tabulatorEvents[i].event, this.tabulatorEvents[i].handler);
}
}
},
@@ -187,7 +179,6 @@ export const CoreFilterCmpt = {
}
this.notFilterFields = this.fields.filter(x => tmpFilterFields.indexOf(x) === -1);
this.setFieldsToDisplay(data);
this.setSideMenu(data);
}
else
@@ -195,36 +186,6 @@ export const CoreFilterCmpt = {
console.error(CoreRESTClient.getError(response));
}
},
/**
*
*/
setFieldsToDisplay: function(data) {
let arrayFieldsToDisplay = [];
if (data.hasOwnProperty("selectedFields") && Array.isArray(data.selectedFields))
{
if (data.hasOwnProperty("columnsAliases") && Array.isArray(data.columnsAliases))
{
for (let sfc = 0; sfc< data.selectedFields.length; sfc++)
{
for (let fc = 0; fc< data.fields.length; fc++)
{
if (data.selectedFields[sfc] == data.fields[fc])
{
arrayFieldsToDisplay[sfc] = data.columnsAliases[fc];
}
}
}
}
else
{
arrayFieldsToDisplay = data.selectedFields;
}
}
this.fieldsToDisplay = arrayFieldsToDisplay;
},
/**
* Set the menu
*/
@@ -473,7 +434,7 @@ export const CoreFilterCmpt = {
<!-- Filter fields options -->
<div class="filter-options-div">
<div class="filter-dnd-area">
<template v-for="fieldToDisplay in fieldsToDisplay">
<template v-for="fieldToDisplay in selectedFields">
<div
class="filter-dnd-object" draggable="true" @dragover="handlerDragOver">
{{ fieldToDisplay}}
+3 -1
View File
@@ -1105,8 +1105,10 @@ $filters = array(
{"name": "Vorname"},
{"name": "Nachname"},
{"name": "Alias"},
{"name": "Aktiv"},
{"name": "Raum"},
{"name": "Geschlecht"}
{"name": "Geschlecht"},
{"name": "StdKst"}
],
"filters": [
{