Skip to content

Commit

Permalink
globalFilter - edit fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Alloza committed Apr 7, 2024
1 parent 4429762 commit 5d103d1
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,13 @@ <h4 i18n="@@seleccionH4" i18n-title="@@seleccionTitle" title="Para lanzar una co
<p *ngIf="currentQuery.length < 1" class="fieldsInfo">{{draggFields}}</p>
<div *ngFor="let item of currentQuery"
class="select-box col-3 col-md-2 p-1"
(click)="openColumnDialog(item)"
(mouseover)="showDescription(item)"
(mouseout)="description = ''"
[cdkDragData]="column"
cdkDrag>

<span class="close-thin pointer" style="z-index: 9999;" (click)="removeColumn( item, 'select' )"></span>

<span class="select-box-overlay" (click)="openColumnDialog(item)"></span>
<span class="close-thin pointer" (click)="removeColumn( item, 'select' )"></span>
<span *ngIf='item.column_type == "text" ' class="mdi mdi-alphabetical" style="margin-right:4px;"></span>
<span *ngIf='item.column_type == "date" ' class="mdi mdi-calendar-text" style="margin-right:4px;"></span>
<span *ngIf='item.column_type == "numeric" ' class="mdi mdi-numeric" style="margin-right:4px;"></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -745,30 +745,17 @@ export class EdaBlankPanelComponent implements OnInit {
*/
public setGlobalFilter(_filter: any) {
const globalFilter = _.cloneDeep(_filter);
globalFilter.joins = _filter.pathList[this.panel.id].path
globalFilter.filter_table = _filter.pathList[this.panel.id].table_id;

if (_filter.filter_elements[0].value1.length === 0) {
this.globalFilters = this.globalFilters.filter(f => f.filter_id !== _filter.filter_id);
if (_filter.pathList) {
globalFilter.joins = _filter.pathList[this.panel.id].path
globalFilter.filter_table = _filter.pathList[this.panel.id].table_id;
}
const filterInx = this.globalFilters.findIndex((gf: any) => gf.filter_id === globalFilter.filter_id)

if (filterInx != -1) {
this.globalFilters.splice(this.globalFilters.indexOf(filterInx), 1, globalFilter);
} else {
// this.globalFilters = this.globalFilters.filter(f => f.filter_id !== _filter.filter_id)
// this.globalFilters.push(_filter)



if (this.globalFilters.some((gf: any) => gf.filter_id === globalFilter.filter_id)) {
const _globalFilters = _.cloneDeep(this.globalFilters);
this.globalFilters = [];
for (const gf of _globalFilters) {
if (gf.filter_id === globalFilter.filter_id) {
this.globalFilters.push(globalFilter);
} else {
this.globalFilters.push(gf)
}
}
} else {
this.globalFilters.push(globalFilter);
}
this.globalFilters.push(globalFilter);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,6 @@ export const PanelInteractionUtils = {


if (!ebp.rootTreeTable) {
console.log(c);
ebp.rootTreeTable = ebp.tables.find((table) => table.table_name == c.table_id);
}

Expand Down Expand Up @@ -655,7 +654,6 @@ export const PanelInteractionUtils = {
*/
removeColumn: (ebp: EdaBlankPanelComponent, c: Column, list?: string) => {
ebp.disableBtnSave();

// Busca de l'array index, la columna a borrar i ho fa
if (list === 'select') {
if (ebp.selectedQueryMode == 'EDA2') {
Expand All @@ -667,7 +665,8 @@ export const PanelInteractionUtils = {
// If only there is 1 column of rootTable, check if panel have any globalFilter linked it.
if (ebp.currentQuery.map((query) => query.table_id == rootTable).length <= 1) {
if (ebp.globalFilters.some((filter) => filter.filter_table === rootTable)) {
return ebp.alertService.addError(`[Error]: Can not remove this column cause there is a GlobalFilter linked.`);
ebp.alertService.addError(`[Error]: Can not remove this column cause there is a GlobalFilter linked.`);
throw '[Error]: Can not remove this column cause there is a GlobalFilter linked.'
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ export const QueryUtils = {
switchAndRun: async (ebp: EdaBlankPanelComponent, query: Query) => {
try {
if (ebp.selectedQueryMode != 'SQL') {
const response = await ebp.dashboardService.executeQuery(query).toPromise();
const queryData = JSON.parse(JSON.stringify(query));
queryData.query.filters = query.query.filters.filter((f) => f.filter_elements[0].value1 && f.filter_elements[0].value1.length !== 0);
const response = await ebp.dashboardService.executeQuery(queryData).toPromise();
return response;
} else {
const response = await ebp.dashboardService.executeSqlQuery(query).toPromise();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const TableUtils = {
* @param vMap Map() to keep tracking visited nodes -> first call is just a new Map()
*/
findRelationsRecursive: (tables: any, table: any, vMap: any) => {
console.log(table);
vMap.set(table.table_name, table);

table.relations.filter(r => r.visible !== false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ export class GlobalFilterComponent implements OnInit {
}

// If default values are selected filter is applied
if (this.globalFilter.selectedItems.length > 0) {
// if (this.globalFilter.selectedItems.length > 0) {
this.applyGlobalFilter(this.globalFilter);
}
// }

// If filter apply to all panels and this dashboard hasn't any 'apllyToAllFilter' new 'apllyToAllFilter' is set
// if (this.globalFilter.applyToAll && (this.applyToAllfilter.present === false)) {
Expand Down Expand Up @@ -196,7 +196,7 @@ export class GlobalFilterComponent implements OnInit {
this.applyGlobalFilter(filter);
this.removeGlobalFilter(filter);
} else {
let existFilter = this.globalFilters.find((f) => f.id === `${targetTable}_${filter.column.value?.column_name}`);
let existFilter = this.globalFilters.find((f) => f.id === filter.id);

if (existFilter) {
existFilter.selectedItems = filter.selectedItems;
Expand All @@ -210,11 +210,9 @@ export class GlobalFilterComponent implements OnInit {
} else {
await this.loadGlobalFiltersData(filter);
}

// If default values are selected filter is applied
if (filter.selectedItems.length > 0) {
this.applyGlobalFilter(filter);
}

// Apply globalFilter to linkedPanels
this.applyGlobalFilter(filter);

// If filter apply to all panels and this dashboard hasn't any 'apllyToAllFilter' new 'apllyToAllFilter' is set
if (filter.applyToAll && (this.dashboard.applyToAllfilter.present === false)) {
Expand Down Expand Up @@ -347,7 +345,7 @@ export class GlobalFilterComponent implements OnInit {
} else {
targetTable = globalFilter.table.value;
targetColumn = globalFilter.column.value;
targetColumn.column.value.ordenation_type = 'ASC';
targetColumn.ordenation_type = 'ASC';
}

const queryParams = {
Expand Down
4 changes: 3 additions & 1 deletion eda/eda_app/src/app/services/utils/query-builder.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ export class QueryBuilderService extends ApiService {
labels.push(select[i].column_name);
}

const filters = params.filters.filter((f) => f.filter_elements[0].value1 && f.filter_elements[0].value1.length !== 0);

return {
id: '1',
model_id: params.dataSource,
Expand All @@ -119,7 +121,7 @@ export class QueryBuilderService extends ApiService {
},
query: {
fields: queryColumns,
filters: params.filters,
filters,
simple: false,
queryMode,
// modeSQL : modeSQL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,14 @@ body .ui-accordion .ui-accordion-header a {
z-index: 99999 !important;
}

.select-box-overlay {
width: 92%;
height: 100%;
position: absolute;
left: 0;
top: 0;
}

.table-box:active {
box-shadow: 0 2px #666;
transform: translateY(2px);
Expand Down

0 comments on commit 5d103d1

Please sign in to comment.