Skip to content

Commit f26aa8b

Browse files
committed
Move custom changes to schematic generation
1 parent d68457a commit f26aa8b

File tree

5 files changed

+25
-8
lines changed

5 files changed

+25
-8
lines changed

libs/schematic/generators/ng-generate/components/shared/generators/components/command-bar/files/__name@dasherize__-command-bar.component.scss.template

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
align-items: center;
55
max-width: unset;
66

7+
.command-bar-number-of-items {
8+
display: flex;
9+
}
10+
711
mat-toolbar {
812
overflow: hidden;
913
}

libs/schematic/generators/ng-generate/components/shared/generators/language/files/__name@dasherize__.translation.json.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@
164164
"export": "Export",
165165
"noLink": "No link",
166166
"toolbar": {
167+
"item": "Item",
168+
"item.plural": "Items",
167169
"sorted_tooltip": "Sort data by property",
168170
"sort_dir_tooltip": "Sort data direction",
169171
"sort_by": "Sorted by",

libs/schematic/generators/ng-generate/components/shared/methods/remote-handling/imports.ts.template

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@
66
<% } %>
77

88
import {AbstractArrayNode, AbstractNode, And, Eq, Limit, Query, QueryStringifier, Sort} from 'rollun-ts-rql';
9-
// TODO check on working example
10-
// import {SortOptions} from "rollun-ts-rql/dist/nodes/Sort";
9+
import {SortOptions} from "rollun-ts-rql/dist/nodes/Sort";

libs/schematic/generators/ng-generate/components/shared/methods/remote-handling/requestData.ts.template

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ private requestData() {
3030
const sortProperty = this.filterService.sortedProperty;
3131
const sortDirection = this.filterService.sortCard === SortCard.ASCENDING ? 1 : -1;
3232

33-
queryOption.setSort(new Sort({[sortProperty]: sortDirection}));
33+
queryOption.setSort(new Sort(<SortOptions>{[sortProperty]: sortDirection}));
3434
}
3535
<% } else { %>
3636
if (this.sort.active) {
3737
const sortProperty = this.sort.active;
3838
const sortDirection = this.sort.direction === 'asc' ? 1 : -1;
3939

40-
queryOption.setSort(new Sort({[sortProperty]: sortDirection}));
40+
queryOption.setSort(new Sort(<SortOptions>{[sortProperty]: sortDirection}));
4141
}
4242
<% } %>
4343

@@ -87,6 +87,8 @@ private requestData() {
8787
this.requestSubscription = this.tableService.requestData(this.remoteAPI, {query: rqlStringTemp})
8888
.pipe(
8989
tap((response: Response<Entity>) => {
90+
this.updateHighlightString();
91+
9092
this.dataLoadError = false;
9193
this.totalItems =
9294
response.totalItems !== null && response.totalItems !== undefined

libs/schematic/generators/ng-generate/components/table/generators/components/table/files/__name@dasherize__.component.ts.template

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import { MatTable, MatTableModule } from '@angular/material/table';
3232

3333
<% if (options.hasFilters || options.hasSearchBar) { %>
3434
import {<%= options.filterServiceName %>} from './<%= cmpFileName %>-filter.service';
35-
import {EsmfChipListComponent, EsmfTableCellComponent} from '@esmf/semantic-ui-schematic';
35+
import {EsmfChipListComponent, EsmfTableCellComponent, FilterEnums} from '@esmf/semantic-ui-schematic';
3636
<% } %>
3737

3838
<% if (options.addCommandBar) { %>
@@ -391,6 +391,10 @@ export class <%= classify(name) %>Component implements OnInit, AfterViewInit, Af
391391
this.applyFilters();
392392
}
393393

394+
public trackBy = (_index: number, item: Entity): string => {
395+
return item.toString() + this.highlightString.join();
396+
};
397+
394398
rowClicked(row: any, $event: MouseEvent): boolean {
395399
if (this.highlightSelectedRow) {
396400
this.checkboxClicked(row);
@@ -542,9 +546,7 @@ export class <%= classify(name) %>Component implements OnInit, AfterViewInit, Af
542546

543547
<% if (options.hasSearchBar) { %>
544548
dataTemp = this.filterService.applyStringSearchFilter(dataTemp);
545-
this.highlightString = this.filterService.activeFilters
546-
.filter(elem => elem.type === FilterEnums.Search && elem.filterValue !== undefined)
547-
.map(elem => elem.filterValue as string);
549+
this.updateHighlightString();
548550
<% } %>
549551

550552
<% if (options.isDateQuickFilter) { %>
@@ -697,4 +699,12 @@ export class <%= classify(name) %>Component implements OnInit, AfterViewInit, Af
697699
private isAvailableDataColumn(column: <%= tableColumnsEnumName %>): boolean {
698700
return !(Array.isArray(this.hideColumns) && this.hideColumns.includes(column)) && !NON_DATA_COLUMNS.includes(column);
699701
}
702+
703+
private updateHighlightString(): void {
704+
this.highlightString = this.filterService.activeFilters
705+
.filter(({type, filterValue}) => type === FilterEnums.Search && !!filterValue)
706+
.map(filter => {
707+
return filter.filterValue;
708+
});
709+
}
700710
}

0 commit comments

Comments
 (0)