Skip to content

Commit

Permalink
display selected filter paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Alloza committed May 18, 2024
1 parent 141cc95 commit 0503274
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -433,17 +433,21 @@ <h5 i18n="@@resumenAtrH6">
Resumen de atributos
</h5>

<div *ngFor="let column of this.currentQuery">
<span> <strong>{{ getColumnJoins(column) }}</strong> </span>

<span> <strong>{{ getNiceTableName(column.table_id) }}</strong> → {{column.display_name.default}}</span>
<div *ngFor="let column of currentQuery" class="d-flex align-items-center">

<strong class="d-flex align-items-center" [innerHTML]="getColumnJoins(column)"></strong>

<span class="d-flex align-items-center">
<strong> {{ getNiceTableName(column.table_id) }} </strong>
<i class="pi pi-angle-right"></i>
{{column.display_name.default}}
</span>

<span *ngFor="let aggregation of column.aggregation_type">
<span
*ngIf="aggregation.selected && aggregation.display_name !== 'no'">
<ng-container *ngFor="let aggregation of column.aggregation_type">
<span *ngIf="aggregation.selected && aggregation.display_name !== 'no'" class="d-flex align-items-center">
( {{aggregation.display_name}} )
</span>
</span>
</ng-container>

</div>
</div>
Expand All @@ -454,9 +458,12 @@ <h5 i18n="@@resumenFiltrosPanelH6">
Resumen de filtros del panel
</h5>

<div *ngFor="let filter of this.selectedFilters">
<span> {{filter.filter_table}} . {{filter.filter_column}} (
{{filter.filter_type}} )</span>


<div *ngFor="let filter of selectedFilters" class="d-flex align-items-center">
<strong class="d-flex align-items-center" [innerHTML]="getFilterJoins(filter)"></strong>

<span class="d-flex align-items-center" [innerHTML]="getDisplayFilterStr(filter)"></span>
</div>
</div>

Expand All @@ -465,9 +472,10 @@ <h5 i18n="@@resumenFiltrosInformeH6">
Resumen de filtros del informe
</h5>

<div *ngFor="let filter of this.globalFilters">
<span> {{filter.filter_table}} . {{filter.filter_column}} (
{{filter.filter_type}} )</span>
<div *ngFor="let filter of globalFilters" class="d-flex align-items-center">
<strong class="d-flex align-items-center" [innerHTML]="getFilterJoins(filter)"></strong>

<span class="d-flex align-items-center" [innerHTML]="getDisplayFilterStr(filter)"></span>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -827,9 +827,10 @@ export class EdaBlankPanelComponent implements OnInit {
this.display_v.saved_panel = false;
this.columns = [];
this.currentQuery = [];
if (this.panelDeepCopy.query) {

if (this.panelDeepCopy.query) {
this.panelDeepCopy.query.query.filters = this.mergeFilters(this.panelDeepCopy.query.query.filters, this.globalFilters);

this.filtredColumns = [];
//Reassing sqlQuery -if exists
this.currentSQLQuery = this.panelDeepCopy.query.query.SQLexpression;
Expand Down Expand Up @@ -1176,7 +1177,7 @@ export class EdaBlankPanelComponent implements OnInit {
let tableName = this.getNiceTableName(table);
if (!tableName) tableName = this.getNiceTableName(table.split('.')[0]);

pathStr += ` ${tableName} `;
pathStr += ` ${tableName} <i class="pi pi-angle-right"></i> `;
}
} else if (column.valueListSource) {
const tableName = this.getNiceTableName(column.valueListSource.target_table);
Expand All @@ -1186,6 +1187,63 @@ export class EdaBlankPanelComponent implements OnInit {
return pathStr
}

public getFilterJoins(filter: any) {
let pathStr = '';
if (filter.joins?.length > 0) {

for (const path of filter.joins) {
const table = (path[0]||'');
let tableName = this.getNiceTableName(table);
if (!tableName) tableName = this.getNiceTableName(table.split('.')[0]);

pathStr += ` ${tableName} <i class="pi pi-angle-right"></i> `;
}
} else if (filter.valueListSource) {
const tableName = this.getNiceTableName(filter.valueListSource.target_table);
if (tableName) pathStr += ` ${tableName} → `;
}

return pathStr
}

public getDisplayFilterStr(filter: any) {
let str = '';

const table = this.findTable(filter.filter_table.split('.')[0]);

if (table.table_name) {
const tableName = table.display_name?.default;
const columnName = table.columns.find((c) => c.column_name == filter.filter_column)?.display_name?.default;

const values = filter.filter_elements[0]?.value1;
const values2 = filter.filter_elements[1]?.value2;
let valueStr = '';

if (values) {
if (values.length == 1 && !['in', 'not_in'].includes(filter.filter_type)) {
valueStr = `"${values[0]}"`;
} else if (values.length > 1 || ['in', 'not_in'].includes(filter.filter_type)) {
valueStr = `[${values.map((v: string) => (`"${v}"`) ).join(', ')}]`;
}

if (values2) {
if (values2.length == 1) {
valueStr = `AND "${values2[0]}"`;
} else if (values2.length > 1) {
valueStr = `AND [${values2.map((v: string) => (`"${v}"`) ).join(', ')}]`;
}
}

}


str = `<strong>${tableName}</strong>&nbsp[${columnName}]&nbsp<strong>${filter.filter_type}</strong>&nbsp${valueStr}`;
}


return str;
}

/* SDA CUSTOM */ public showIdForHiddenMode() {
/* SDA CUSTOM */ if (this.inject.dataSource._id == "111111111111111111111111") {
/* SDA CUSTOM */ this.showHiddId = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@
(onNodeExpand)="onNodeExpand(panel, $event)"
(onNodeSelect)="onNodeSelect(panel, $event)" appendTo="body"
[disabled]="!panel.active || !panel.avaliable">

<ng-template pTemplate="value">
<span class="d-flex align-items-center" [innerHTML]="getDisplayPathStr(globalFilter.pathList[panel.id].selectedTableNodes)"></span>
</ng-template>

<ng-template let-node pTemplate="child">
<span [ngClass]="checkNodeSelected(globalFilter.pathList[panel.id].selectedTableNodes, node) ? 'font-weight-bold' : ''"> {{node.label}} </span>
</ng-template>

<ng-template let-node pTemplate="default">
<b>{{node.label}}</b>
</ng-template>
</p-treeSelect>
</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,44 @@ export class GlobalFilterDialogComponent implements OnInit, OnDestroy {
}
}

public checkNodeSelected(selectedPath: any, node: any) {
if (node?.child_id) {
let selected = false;
for (const join of selectedPath.joins) {
if (join[1] == node.child_id) {
selected = true;
}
}
return selected;
} else {
return false;
}
}

private findTable(tableName: string) {
return this.modelTables.find((table: any) => table.table_name === tableName);
}

public getDisplayPathStr(node: any) {
let str = '';

if ((node.joins||[]).length > 0) {
for (const join of node.joins) {
const table = this.findTable(join[0]?.split('.')[0]);

if (table) {
str += `<strong>${table.display_name.default}</strong>&nbsp <i class="pi pi-angle-right"></i>`
}
}

str += `<strong>${node.label}</strong>`;
} else {
str = `<strong>${node.label}</strong>`;
}

return str;
}

public onApply(): void {
if (this.validateGlobalFilter()) {
this.globalFilterChange.emit(this.globalFilter);
Expand Down

0 comments on commit 0503274

Please sign in to comment.