@verisoft/ui-primeng 18.0.0 → 18.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{src/assets → assets}/sass/base/_typography.scss +2 -2
- package/assets/sass/layout/_button.scss +57 -0
- package/{src/assets → assets}/sass/layout/_sidemenu.scss +1 -15
- package/package.json +4 -3
- package/src/index.ts +2 -4
- package/src/lib/components/breadcrumb/breadcrumb.component.html +2 -2
- package/src/lib/components/breadcrumb/breadcrumb.component.ts +6 -1
- package/src/lib/components/breadcrumb/breadcrumb.pipe.ts +13 -0
- package/src/lib/components/button/button.component.html +2 -2
- package/src/lib/components/button/button.component.ts +7 -1
- package/src/lib/components/button/index.ts +0 -1
- package/src/lib/components/calendar/calendar.component.html +2 -2
- package/src/lib/components/calendar/calendar.component.ts +7 -2
- package/src/lib/components/checkbox/checkbox.component.html +1 -1
- package/src/lib/components/checkbox/checkbox.component.ts +5 -1
- package/src/lib/components/confirm-dialog/confirm-dialog.component.ts +3 -3
- package/src/lib/components/confirm-dialog/index.ts +0 -1
- package/src/lib/components/dropdown/dropdown.component.html +1 -1
- package/src/lib/components/dropdown/dropdown.component.ts +8 -3
- package/src/lib/components/errors/error.component.html +6 -0
- package/src/lib/components/errors/error.component.scss +3 -0
- package/src/lib/components/errors/error.component.ts +35 -0
- package/src/lib/components/errors/index.ts +1 -0
- package/src/lib/components/form-field/form-field.component.html +3 -8
- package/src/lib/components/form-field/form-field.component.ts +17 -13
- package/src/lib/components/header/header.component.html +2 -3
- package/src/lib/components/header/header.component.ts +3 -1
- package/src/lib/components/header/services/header-provider.service.ts +1 -1
- package/src/lib/components/input-group/input-group.component.html +1 -3
- package/src/lib/components/multiselect/multiselect.component.html +2 -1
- package/src/lib/components/multiselect/multiselect.component.ts +5 -3
- package/src/lib/components/number-input/number-input.component.html +1 -1
- package/src/lib/components/number-input/number-input.component.ts +3 -0
- package/src/lib/components/page-header/index.ts +0 -1
- package/src/lib/components/page-header/page-header.component.html +1 -1
- package/src/lib/components/page-header/page-header.component.ts +6 -34
- package/src/lib/components/password/password.component.html +1 -1
- package/src/lib/components/password/password.component.ts +3 -1
- package/src/lib/components/radiobutton/radiobutton.component.html +1 -1
- package/src/lib/components/radiobutton/radiobutton.component.ts +2 -0
- package/src/lib/components/section/section.component.html +1 -2
- package/src/lib/components/section/section.component.ts +4 -2
- package/src/lib/components/{action-button-group → shared-components/action-button-group}/action-button-group.component.html +2 -4
- package/src/lib/components/{action-button-group → shared-components/action-button-group}/action-button-group.component.ts +21 -11
- package/src/lib/components/{action-button-group → shared-components/action-button-group}/components/action-button/action-button.component.html +1 -2
- package/src/lib/components/shared-components/action-button-group/components/action-button/action-button.component.ts +71 -0
- package/src/lib/components/shared-components/dynamic-component/dynamic-component-factory.service.ts +142 -0
- package/src/lib/components/{dynamic-component → shared-components/dynamic-component}/dynamic-component.component.ts +5 -4
- package/src/lib/components/shared-components/dynamic-component/index.ts +2 -0
- package/src/lib/components/shared-components/feature-list/directives/feature-list-column.directive.ts +32 -0
- package/src/lib/components/shared-components/feature-list/directives/feature-list-filter-field.directive.ts +8 -0
- package/src/lib/components/shared-components/feature-list/feature-list-filter.pipe.ts +21 -0
- package/src/lib/components/shared-components/feature-list/feature-list-page.component.ts +31 -0
- package/src/lib/components/shared-components/feature-list/feature-list-page.model.ts +42 -0
- package/src/lib/components/shared-components/feature-list/feature-list.component.html +59 -0
- package/src/lib/components/shared-components/feature-list/feature-list.component.scss +10 -0
- package/src/lib/components/shared-components/feature-list/feature-list.component.ts +342 -0
- package/src/lib/components/shared-components/feature-list/index.ts +5 -0
- package/src/lib/components/shared-components/filter/directives/filter-field.directive.ts +35 -0
- package/src/lib/components/{filter → shared-components/filter}/filter.component.html +8 -7
- package/src/lib/components/{filter → shared-components/filter}/filter.component.ts +53 -26
- package/src/lib/components/shared-components/filter/filter.model.ts +18 -0
- package/src/lib/components/{filter → shared-components/filter}/index.ts +0 -1
- package/src/lib/components/shared-components/generic-field/generic-field.component.html +97 -0
- package/src/lib/components/{generic-field → shared-components/generic-field}/generic-field.component.ts +28 -10
- package/src/lib/components/{generic-field → shared-components/generic-field}/index.ts +0 -1
- package/src/lib/components/shared-components/generic-form/generic-form.component.html +46 -0
- package/src/lib/components/{generic-form → shared-components/generic-form}/generic-form.component.ts +11 -2
- package/src/lib/components/{generic-form → shared-components/generic-form}/generic-form.model.ts +11 -19
- package/src/lib/components/shared-components/index.ts +6 -0
- package/src/lib/components/side-menu/side-menu.component.html +7 -10
- package/src/lib/components/side-menu/side-menu.component.ts +7 -6
- package/src/lib/components/slider/slider.component.html +2 -2
- package/src/lib/components/slider/slider.component.ts +2 -0
- package/src/lib/components/stepper/stepper.component.html +2 -2
- package/src/lib/components/stepper/stepper.component.ts +16 -1
- package/src/lib/components/switch/switch.component.html +1 -2
- package/src/lib/components/switch/switch.component.ts +2 -0
- package/src/lib/components/tab-view/tab-menu.pipe.ts +22 -0
- package/src/lib/components/tab-view/tab-view-item.component.ts +2 -0
- package/src/lib/components/tab-view/tab-view.component.html +2 -3
- package/src/lib/components/tab-view/tab-view.component.ts +4 -4
- package/src/lib/components/tab-view/tab-view.module.ts +2 -1
- package/src/lib/components/table/index.ts +0 -1
- package/src/lib/components/table/table-filter.pipe.ts +59 -0
- package/src/lib/components/table/table.component.html +120 -180
- package/src/lib/components/table/table.component.scss +11 -0
- package/src/lib/components/table/table.component.ts +131 -98
- package/src/lib/components/table/table.models.ts +26 -0
- package/src/lib/components/textarea/textarea.component.html +1 -1
- package/src/lib/components/textarea/textarea.component.ts +2 -0
- package/src/lib/components/textfield/textfield.component.html +1 -1
- package/src/lib/components/textfield/textfield.component.ts +6 -1
- package/src/lib/components/tristatecheckbox/tristatecheckbox.component.html +2 -2
- package/src/lib/components/tristatecheckbox/tristatecheckbox.component.ts +4 -0
- package/src/lib/icons.ts +36 -0
- package/src/lib/pages/not-found-page/not-found-page.component.html +1 -2
- package/src/assets/sass/layout/_button.scss +0 -57
- package/src/lib/components/action-button-group/components/action-button/action-button.component.ts +0 -36
- package/src/lib/components/button/directives/shortcut.directive.ts +0 -37
- package/src/lib/components/confirm-dialog/services/confirm-dialog.service.ts +0 -14
- package/src/lib/components/dynamic-component/dynamic-component-factory.service.ts +0 -90
- package/src/lib/components/filter/directives/filter-field.directive.ts +0 -25
- package/src/lib/components/filter/directives/table-filter.directive.ts +0 -22
- package/src/lib/components/filter/filter.model.ts +0 -18
- package/src/lib/components/generic-field/generic-field.component.html +0 -54
- package/src/lib/components/generic-field/generic-field.model.ts +0 -9
- package/src/lib/components/generic-form/generic-form.component.html +0 -33
- package/src/lib/components/page-header/services/page-header.service.ts +0 -9
- package/src/lib/components/table/directives/table-store.directive.ts +0 -61
- package/src/lib/components/table-filter/filter.component.html +0 -205
- package/src/lib/components/table-filter/filter.component.scss +0 -0
- package/src/lib/components/table-filter/filter.component.spec.ts +0 -21
- package/src/lib/components/table-filter/filter.component.stories.ts +0 -23
- package/src/lib/services/screen-size.service.ts +0 -25
- /package/{src/assets → assets}/.gitkeep +0 -0
- /package/{src/assets → assets}/fonts/orbitron-black.ttf +0 -0
- /package/{src/assets → assets}/fonts/orbitron-bold.otf +0 -0
- /package/{src/assets → assets}/icons/complex/v-logo.svg +0 -0
- /package/{src/assets → assets}/images/_global/elon.jpg +0 -0
- /package/{src/assets → assets}/images/_global/jara.png +0 -0
- /package/{src/assets → assets}/images/_global/logos/v-logo.webp +0 -0
- /package/{src/assets → assets}/sass/base/_scrollbar.scss +0 -0
- /package/{src/assets → assets}/sass/layout/_app.scss +0 -0
- /package/{src/assets → assets}/sass/layout/_checkbox.scss +0 -0
- /package/{src/assets → assets}/sass/layout/_dialog.scss +0 -0
- /package/{src/assets → assets}/sass/layout/_dropdown.scss +0 -0
- /package/{src/assets → assets}/sass/layout/_formField.scss +0 -0
- /package/{src/assets → assets}/sass/layout/_header.scss +0 -0
- /package/{src/assets → assets}/sass/layout/_icons.scss +0 -0
- /package/{src/assets → assets}/sass/layout/_inputSwitch.scss +0 -0
- /package/{src/assets → assets}/sass/layout/_layout.scss +0 -0
- /package/{src/assets → assets}/sass/layout/_loader.scss +0 -0
- /package/{src/assets → assets}/sass/layout/_radiobutton.scss +0 -0
- /package/{src/assets → assets}/sass/layout/_snackbar.scss +0 -0
- /package/{src/assets → assets}/sass/layout/_tables.scss +0 -0
- /package/{src/assets → assets}/sass/layout/_tree.scss +0 -0
- /package/{src/assets → assets}/sass/layout/_tristatecheckbox.scss +0 -0
- /package/{src/assets → assets}/sass/main.scss +0 -0
- /package/{src/assets → assets}/sass/themes/_verisoft_theme.scss +0 -0
- /package/{src/assets → assets}/sass/utils/_mixins.scss +0 -0
- /package/{src/assets → assets}/sass/utils/_utils.scss +0 -0
- /package/{src/assets → assets}/sass/utils/_variables.scss +0 -0
- /package/{src/assets → assets}/sass/vendors/_bootstrap.scss +0 -0
- /package/{src/assets → assets}/sass/vendors/_primeng.scss +0 -0
- /package/src/lib/components/{action-button-group → shared-components/action-button-group}/action-button-group.component.scss +0 -0
- /package/src/lib/components/{action-button-group → shared-components/action-button-group}/action-button-group.component.spec.ts +0 -0
- /package/src/lib/components/{action-button-group → shared-components/action-button-group}/components/action-button/action-button.component.scss +0 -0
- /package/src/lib/components/{action-button-group → shared-components/action-button-group}/components/action-button/action-button.component.spec.ts +0 -0
- /package/src/lib/components/{action-button-group → shared-components/action-button-group}/index.ts +0 -0
- /package/src/lib/components/{filter → shared-components/filter}/filter.component.scss +0 -0
- /package/src/lib/components/{filter → shared-components/filter}/filter.component.spec.ts +0 -0
- /package/src/lib/components/{filter → shared-components/filter}/filter.component.stories.ts +0 -0
- /package/src/lib/components/{generic-field → shared-components/generic-field}/generic-field.component.spec.ts +0 -0
- /package/src/lib/components/{generic-form → shared-components/generic-form}/generic-form.component.spec.ts +0 -0
- /package/src/lib/components/{generic-form → shared-components/generic-form}/generic-form.model.spec.ts +0 -0
- /package/src/lib/components/{generic-form → shared-components/generic-form}/index.ts +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
import { ActivatedRoute } from '@angular/router';
|
|
3
|
+
import {
|
|
4
|
+
FEATURE_LIST_PAGE_CONFIG_PROPERTY,
|
|
5
|
+
FeatureListPageConfig,
|
|
6
|
+
} from './feature-list-page.model';
|
|
7
|
+
import { FeatureListComponent } from './feature-list.component';
|
|
8
|
+
|
|
9
|
+
@Component({
|
|
10
|
+
selector: 'v-feature-list-page',
|
|
11
|
+
standalone: true,
|
|
12
|
+
imports: [FeatureListComponent],
|
|
13
|
+
template: `
|
|
14
|
+
<v-feature-list
|
|
15
|
+
[title]="config.title"
|
|
16
|
+
[tableName]="config.tableName"
|
|
17
|
+
[showAdd]="config.showAdd ?? true"
|
|
18
|
+
[showDownload]="config.showDownload ?? true"
|
|
19
|
+
[showDelete]="config.showDelete ?? true"
|
|
20
|
+
>
|
|
21
|
+
</v-feature-list>
|
|
22
|
+
`,
|
|
23
|
+
})
|
|
24
|
+
export class FeatureListPageComponent {
|
|
25
|
+
config!: FeatureListPageConfig;
|
|
26
|
+
|
|
27
|
+
constructor(activatedRoute: ActivatedRoute) {
|
|
28
|
+
this.config =
|
|
29
|
+
activatedRoute.snapshot.data[FEATURE_LIST_PAGE_CONFIG_PROPERTY];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { Route } from '@angular/router';
|
|
3
|
+
import { ColumnDefinition, GenericFieldTypeType } from '@verisoft/ui-core';
|
|
4
|
+
import { FeatureListPageComponent } from './feature-list-page.component';
|
|
5
|
+
|
|
6
|
+
export interface FeatureListPageConfig {
|
|
7
|
+
title: string;
|
|
8
|
+
datasource: string;
|
|
9
|
+
tableName: string;
|
|
10
|
+
showAdd?: boolean;
|
|
11
|
+
showDownload?: boolean;
|
|
12
|
+
showDelete?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const FEATURE_LIST_PAGE_CONFIG_PROPERTY = 'feature_list_config';
|
|
16
|
+
|
|
17
|
+
export function addFeatureListPage(
|
|
18
|
+
value: Partial<Route> & { config: FeatureListPageConfig }
|
|
19
|
+
): Route {
|
|
20
|
+
const { config, ...route } = value;
|
|
21
|
+
return {
|
|
22
|
+
component: FeatureListPageComponent,
|
|
23
|
+
...route,
|
|
24
|
+
data: {
|
|
25
|
+
[FEATURE_LIST_PAGE_CONFIG_PROPERTY]: config,
|
|
26
|
+
...(route.data ?? {}),
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface FeatureListColumnDefinition<T> extends ColumnDefinition<T> {
|
|
32
|
+
filter?: boolean;
|
|
33
|
+
type?: GenericFieldTypeType;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const FEATURE_LIST_COLUMN_PROVIDER = new InjectionToken(
|
|
37
|
+
'FEATURE_LIST_COLUMN_PROVIDER'
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
export interface FeatureListColumnProvider<T> {
|
|
41
|
+
getDefinition: () => FeatureListColumnDefinition<T>;
|
|
42
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<div class="feature-list__container full-height-container">
|
|
2
|
+
<v-filter
|
|
3
|
+
#filter
|
|
4
|
+
[title]="title"
|
|
5
|
+
[fields]="columns | featureListColumn"
|
|
6
|
+
[filters]="filters"
|
|
7
|
+
[fulltextFieldName]="fulltextFieldName"
|
|
8
|
+
[showFulltext]="showFulltext"
|
|
9
|
+
[showFilters]="showExtendedFilter"
|
|
10
|
+
>
|
|
11
|
+
<v-action-button-group
|
|
12
|
+
[maxItems]="maxVisibleActions"
|
|
13
|
+
[maxItemsMobile]="maxVisibleMobileActions"
|
|
14
|
+
>
|
|
15
|
+
@if (showAdd) {
|
|
16
|
+
<v-action-button
|
|
17
|
+
[icon]="icons.add"
|
|
18
|
+
label="Add"
|
|
19
|
+
[disabled]="!canAdd"
|
|
20
|
+
(click)="addClick.emit()"
|
|
21
|
+
></v-action-button>
|
|
22
|
+
} @if (showDelete){
|
|
23
|
+
<v-action-button
|
|
24
|
+
[icon]="icons.delete"
|
|
25
|
+
label="Delete"
|
|
26
|
+
[disabled]="!canDelete || !selection.length"
|
|
27
|
+
(click)="startDeleteItems()"
|
|
28
|
+
></v-action-button>
|
|
29
|
+
} @if (showDownload){
|
|
30
|
+
<v-action-button
|
|
31
|
+
[icon]="icons.download"
|
|
32
|
+
label="Download"
|
|
33
|
+
[disabled]="!canDownload"
|
|
34
|
+
(click)="startDownload()"
|
|
35
|
+
></v-action-button>
|
|
36
|
+
}
|
|
37
|
+
</v-action-button-group>
|
|
38
|
+
</v-filter>
|
|
39
|
+
<div class="feature-list__table-container full-height-container">
|
|
40
|
+
<div class="full-height-container">
|
|
41
|
+
<v-table
|
|
42
|
+
useDatasource
|
|
43
|
+
useFilter
|
|
44
|
+
[filterComponent]="filter"
|
|
45
|
+
class="full-height-container"
|
|
46
|
+
[selectionMode]="selectionMode"
|
|
47
|
+
[tableName]="tableName"
|
|
48
|
+
[autoBind]="true"
|
|
49
|
+
[datasource]="datasource"
|
|
50
|
+
[columns]="columns"
|
|
51
|
+
[extraFilter]="extraFilter"
|
|
52
|
+
[maximumColumnLength]="maximumColumnLength"
|
|
53
|
+
[disableCustomClicks]="disableCustomClicks"
|
|
54
|
+
(selectionChange)="selectItems($event)"
|
|
55
|
+
>
|
|
56
|
+
</v-table>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import { HttpClient } from '@angular/common/http';
|
|
2
|
+
import {
|
|
3
|
+
AfterViewInit,
|
|
4
|
+
ChangeDetectionStrategy,
|
|
5
|
+
ChangeDetectorRef,
|
|
6
|
+
Component,
|
|
7
|
+
ContentChildren,
|
|
8
|
+
EventEmitter,
|
|
9
|
+
inject,
|
|
10
|
+
Input,
|
|
11
|
+
Output,
|
|
12
|
+
QueryList,
|
|
13
|
+
ViewChild,
|
|
14
|
+
} from '@angular/core';
|
|
15
|
+
import {
|
|
16
|
+
AllDataRequestParams,
|
|
17
|
+
BASE_URL_PATH,
|
|
18
|
+
BaseHttpService,
|
|
19
|
+
convertDatasource,
|
|
20
|
+
DatasourceType,
|
|
21
|
+
DEFAULT_PAGE_SIZE,
|
|
22
|
+
} from '@verisoft/core';
|
|
23
|
+
import {
|
|
24
|
+
ColumnModel,
|
|
25
|
+
DialogService,
|
|
26
|
+
downloadFile,
|
|
27
|
+
GenericFieldDefinition,
|
|
28
|
+
MAX_COLUMN_CHAR_COUNT,
|
|
29
|
+
TableDatasourceDirective,
|
|
30
|
+
TableFilterDirective,
|
|
31
|
+
TableSelectionMode,
|
|
32
|
+
TableSelectionModeType,
|
|
33
|
+
} from '@verisoft/ui-core';
|
|
34
|
+
import { take, switchMap, forkJoin, Observable, of } from 'rxjs';
|
|
35
|
+
import { Icons } from '../../../icons';
|
|
36
|
+
import { TableComponent } from '../../table';
|
|
37
|
+
import {
|
|
38
|
+
ActionButtonComponent,
|
|
39
|
+
ActionButtonGroupComponent,
|
|
40
|
+
} from '../action-button-group';
|
|
41
|
+
import { FilterComponent } from '../filter';
|
|
42
|
+
import { FeatureListFilterFieldDirective } from './directives/feature-list-filter-field.directive';
|
|
43
|
+
import { FeatureListFilterPipe } from './feature-list-filter.pipe';
|
|
44
|
+
import {
|
|
45
|
+
FEATURE_LIST_COLUMN_PROVIDER,
|
|
46
|
+
FeatureListColumnDefinition,
|
|
47
|
+
FeatureListColumnProvider,
|
|
48
|
+
} from './feature-list-page.model';
|
|
49
|
+
|
|
50
|
+
@Component({
|
|
51
|
+
selector: 'v-feature-list',
|
|
52
|
+
imports: [
|
|
53
|
+
TableComponent,
|
|
54
|
+
TableDatasourceDirective,
|
|
55
|
+
FilterComponent,
|
|
56
|
+
TableFilterDirective,
|
|
57
|
+
ActionButtonGroupComponent,
|
|
58
|
+
ActionButtonComponent,
|
|
59
|
+
FeatureListFilterPipe,
|
|
60
|
+
],
|
|
61
|
+
standalone: true,
|
|
62
|
+
templateUrl: './feature-list.component.html',
|
|
63
|
+
styleUrls: ['./feature-list.component.scss'],
|
|
64
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
65
|
+
})
|
|
66
|
+
export class FeatureListComponent<T> implements AfterViewInit {
|
|
67
|
+
@ContentChildren(FEATURE_LIST_COLUMN_PROVIDER) viewColumns!: QueryList<
|
|
68
|
+
FeatureListColumnProvider<T>
|
|
69
|
+
>;
|
|
70
|
+
|
|
71
|
+
@ContentChildren(FeatureListFilterFieldDirective)
|
|
72
|
+
fieldDeclarations!: QueryList<FeatureListFilterFieldDirective>;
|
|
73
|
+
|
|
74
|
+
@ViewChild(TableDatasourceDirective)
|
|
75
|
+
tableDatasourceDirective!: TableDatasourceDirective<T>;
|
|
76
|
+
|
|
77
|
+
@Input() autoBind = true;
|
|
78
|
+
|
|
79
|
+
@Input() title!: string;
|
|
80
|
+
|
|
81
|
+
@Input() columns!: FeatureListColumnDefinition<T>[];
|
|
82
|
+
|
|
83
|
+
@Input() filters!: GenericFieldDefinition[];
|
|
84
|
+
|
|
85
|
+
@Input() maxVisibleActions = 2;
|
|
86
|
+
|
|
87
|
+
@Input({ required: true }) tableName!: string;
|
|
88
|
+
|
|
89
|
+
@Input() ngrxFeatureKey?: string;
|
|
90
|
+
|
|
91
|
+
@Input() maxVisibleMobileActions = 0;
|
|
92
|
+
|
|
93
|
+
@Input() showExtendedFilter = false;
|
|
94
|
+
|
|
95
|
+
@Input() showDownload = false;
|
|
96
|
+
|
|
97
|
+
@Input() showDelete = false;
|
|
98
|
+
|
|
99
|
+
@Input() showAdd = false;
|
|
100
|
+
|
|
101
|
+
@Input() canDownload = true;
|
|
102
|
+
|
|
103
|
+
@Input() canDelete = true;
|
|
104
|
+
|
|
105
|
+
@Input() canAdd = true;
|
|
106
|
+
|
|
107
|
+
@Input() useRouterFilter = true;
|
|
108
|
+
|
|
109
|
+
@Input() fulltextFieldName = 'searchField';
|
|
110
|
+
|
|
111
|
+
@Input() showFulltext = true;
|
|
112
|
+
|
|
113
|
+
@Input() deleteConfirmMessage: string | undefined;
|
|
114
|
+
|
|
115
|
+
@Input() autoDeleteEnabled = true;
|
|
116
|
+
|
|
117
|
+
@Input() autoDownloadEnabled = true;
|
|
118
|
+
|
|
119
|
+
@Input() downloadFileName = 'export.csv';
|
|
120
|
+
|
|
121
|
+
@Input() datasource!: DatasourceType<T>;
|
|
122
|
+
|
|
123
|
+
@Input() extraFilter!: any;
|
|
124
|
+
|
|
125
|
+
@Input() disableCustomClicks = false;
|
|
126
|
+
|
|
127
|
+
@Input() maximumColumnLength = MAX_COLUMN_CHAR_COUNT;
|
|
128
|
+
|
|
129
|
+
@Output() addClick = new EventEmitter();
|
|
130
|
+
|
|
131
|
+
@Output() downloadClick = new EventEmitter();
|
|
132
|
+
|
|
133
|
+
@Output() deleteClick = new EventEmitter<T[]>();
|
|
134
|
+
|
|
135
|
+
@Output() selectionChange = new EventEmitter();
|
|
136
|
+
|
|
137
|
+
@Input() set selectionMode(mode: TableSelectionModeType | undefined) {
|
|
138
|
+
this._selectionMode = mode;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
get selectionMode(): TableSelectionModeType | undefined {
|
|
142
|
+
return this.canDelete
|
|
143
|
+
? TableSelectionMode.single
|
|
144
|
+
: this._selectionMode;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
icons = Icons;
|
|
148
|
+
|
|
149
|
+
private httpClient = inject(HttpClient);
|
|
150
|
+
|
|
151
|
+
private baseUrl: string = inject(BASE_URL_PATH);
|
|
152
|
+
|
|
153
|
+
private _selectionMode: TableSelectionModeType | undefined;
|
|
154
|
+
|
|
155
|
+
private cdRef = inject(ChangeDetectorRef);
|
|
156
|
+
|
|
157
|
+
private dialogService = inject(DialogService);
|
|
158
|
+
|
|
159
|
+
selection: T[] = [];
|
|
160
|
+
|
|
161
|
+
ngAfterViewInit(): void {
|
|
162
|
+
if (this.viewColumns?.length) {
|
|
163
|
+
const vewColumns = this.viewColumns
|
|
164
|
+
?.toArray()
|
|
165
|
+
.map((x) => x.getDefinition());
|
|
166
|
+
this.columns = [...(this.columns ?? []), ...(vewColumns ?? [])];
|
|
167
|
+
this.cdRef.detectChanges();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (this.fieldDeclarations?.length) {
|
|
171
|
+
this.filters = this.fieldDeclarations?.toArray();
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
this.cdRef.detectChanges();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
selectItems(items: T[]) {
|
|
178
|
+
this.selection = items ?? [];
|
|
179
|
+
|
|
180
|
+
if (this.selectionMode !== undefined) {
|
|
181
|
+
this.selectionChange.emit(
|
|
182
|
+
this.selectionMode === 'multiple'
|
|
183
|
+
? this.selection
|
|
184
|
+
: this.selection[0]
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
startDeleteItems() {
|
|
190
|
+
if (!this.selection.length) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (this.deleteConfirmMessage) {
|
|
195
|
+
const message = this.deleteConfirmMessage;
|
|
196
|
+
this.dialogService.showDialog({
|
|
197
|
+
innerHTML: message,
|
|
198
|
+
confirmButtonFn: () => this.deleteItems(this.selection),
|
|
199
|
+
});
|
|
200
|
+
} else {
|
|
201
|
+
this.deleteItems(this.selection);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
startDownload() {
|
|
206
|
+
this.downloadClick.emit();
|
|
207
|
+
if (!this.autoDownloadEnabled) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const dowloadFn = this.createDownloadFn(this.datasource);
|
|
212
|
+
if (dowloadFn) {
|
|
213
|
+
this.tableDatasourceDirective.params$
|
|
214
|
+
.pipe(
|
|
215
|
+
take(1),
|
|
216
|
+
switchMap((params) => dowloadFn(params))
|
|
217
|
+
)
|
|
218
|
+
.subscribe((blob) => {
|
|
219
|
+
downloadFile(this.downloadFileName, blob);
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
private deleteItems(items: T[]) {
|
|
225
|
+
if (!this.autoDeleteEnabled) {
|
|
226
|
+
this.deleteClick.emit(items);
|
|
227
|
+
} else {
|
|
228
|
+
this.forceDelete(items);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
private forceDelete(items: T[]) {
|
|
233
|
+
const deleteFn = this.createDeleteFn(this.datasource);
|
|
234
|
+
if (deleteFn) {
|
|
235
|
+
const deleteMethods = items.map((x) => deleteFn(x));
|
|
236
|
+
forkJoin(deleteMethods)
|
|
237
|
+
.pipe(take(1))
|
|
238
|
+
.subscribe(() => this.finishDeletion(items));
|
|
239
|
+
} else {
|
|
240
|
+
this.finishDeletion(items);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
private createDeleteFn(
|
|
245
|
+
datasource: DatasourceType<T>
|
|
246
|
+
): ((item: T) => Observable<unknown>) | undefined {
|
|
247
|
+
if (!datasource) {
|
|
248
|
+
return undefined;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (typeof datasource === 'string') {
|
|
252
|
+
const service = new BaseHttpService<T>(
|
|
253
|
+
this.httpClient,
|
|
254
|
+
this.baseUrl,
|
|
255
|
+
datasource
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
return (item: T) => service.delete((item as { id: string }).id);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (datasource instanceof BaseHttpService) {
|
|
262
|
+
return (item: T) => datasource.delete((item as { id: string }).id);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return undefined;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
private createDownloadFn(
|
|
269
|
+
datasource: DatasourceType<T>
|
|
270
|
+
): ((request: AllDataRequestParams<T>) => Observable<Blob>) | undefined {
|
|
271
|
+
if (!datasource) {
|
|
272
|
+
return undefined;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (typeof datasource === 'string') {
|
|
276
|
+
const service = new BaseHttpService<T>(
|
|
277
|
+
this.httpClient,
|
|
278
|
+
this.baseUrl,
|
|
279
|
+
datasource
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
return (request: AllDataRequestParams<T>) => service.export(request);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
if (datasource instanceof BaseHttpService) {
|
|
286
|
+
return (request: AllDataRequestParams<T>) => datasource.export(request);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const fetchFunction = convertDatasource(
|
|
290
|
+
datasource,
|
|
291
|
+
this.baseUrl,
|
|
292
|
+
this.httpClient
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
return (request: AllDataRequestParams<T>) => {
|
|
296
|
+
const allData: T[] = [];
|
|
297
|
+
let offset = 0;
|
|
298
|
+
const fetchAllData = (): Observable<Blob> => {
|
|
299
|
+
return fetchFunction({
|
|
300
|
+
...request,
|
|
301
|
+
offset,
|
|
302
|
+
limit: DEFAULT_PAGE_SIZE,
|
|
303
|
+
}).pipe(
|
|
304
|
+
take(1),
|
|
305
|
+
switchMap((response) => {
|
|
306
|
+
allData.push(...response.data);
|
|
307
|
+
if (allData.length < response.total) {
|
|
308
|
+
offset = offset + DEFAULT_PAGE_SIZE;
|
|
309
|
+
return fetchAllData();
|
|
310
|
+
} else {
|
|
311
|
+
return of(this.convertToBlob(allData));
|
|
312
|
+
}
|
|
313
|
+
})
|
|
314
|
+
);
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
return fetchAllData();
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
private finishDeletion(items: T[]) {
|
|
322
|
+
if (this.datasource && Array.isArray(this.datasource)) {
|
|
323
|
+
this.datasource = this.datasource.filter((x) => !items.includes(x));
|
|
324
|
+
} else {
|
|
325
|
+
this.tableDatasourceDirective.reload();
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
this.deleteClick.emit(items);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
private convertToBlob(data: T[]): Blob {
|
|
332
|
+
const columnModel = this.columns.map((x) => new ColumnModel(x));
|
|
333
|
+
const headers = columnModel.map((x, index) => x.headerGetter(x.id, index));
|
|
334
|
+
const dataValues = data.map((row, rowIndex) =>
|
|
335
|
+
columnModel.map((column) => column.valueGetter(row, rowIndex))
|
|
336
|
+
);
|
|
337
|
+
const csvData = [headers, ...dataValues]
|
|
338
|
+
.map((row) => row.join(','))
|
|
339
|
+
.join('\n');
|
|
340
|
+
return new Blob([csvData], { type: 'text/csv' });
|
|
341
|
+
}
|
|
342
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Directive, Input } from '@angular/core';
|
|
2
|
+
import { ValidatorFn } from '@angular/forms';
|
|
3
|
+
import { DatasourceType } from '@verisoft/core';
|
|
4
|
+
import { GenericFieldDefinition, GenericFieldType, GenericFieldTypeType } from '@verisoft/ui-core';
|
|
5
|
+
|
|
6
|
+
@Directive({
|
|
7
|
+
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
8
|
+
selector: 'v-filter-field',
|
|
9
|
+
standalone: true,
|
|
10
|
+
})
|
|
11
|
+
export class FilterFieldDirective implements GenericFieldDefinition {
|
|
12
|
+
@Input({ required: true }) name!: string;
|
|
13
|
+
|
|
14
|
+
@Input() type: GenericFieldTypeType | undefined = GenericFieldType.text;
|
|
15
|
+
|
|
16
|
+
@Input() label: string | undefined;
|
|
17
|
+
|
|
18
|
+
@Input() optionLabel!: string;
|
|
19
|
+
|
|
20
|
+
@Input() optionValue: string | undefined;
|
|
21
|
+
|
|
22
|
+
@Input() options: unknown[] | undefined;
|
|
23
|
+
|
|
24
|
+
@Input() value?: unknown;
|
|
25
|
+
|
|
26
|
+
@Input() validator?: ValidatorFn[];
|
|
27
|
+
|
|
28
|
+
@Input() datasource: DatasourceType<any> | undefined;
|
|
29
|
+
|
|
30
|
+
@Input() filterField?: string;
|
|
31
|
+
|
|
32
|
+
@Input() showFilter?: boolean;
|
|
33
|
+
|
|
34
|
+
@Input() localSearch?: boolean;
|
|
35
|
+
}
|
|
@@ -22,21 +22,22 @@
|
|
|
22
22
|
@if (simpleFormFieldDefinitions$ | async; as declaration){
|
|
23
23
|
@if (showFilters)
|
|
24
24
|
{
|
|
25
|
-
<div class="v-filter_filters d-none d-sm-block">
|
|
25
|
+
<div class="v-filter_filters d-none d-sm-block me-2">
|
|
26
26
|
<v-generic-form
|
|
27
27
|
[fields]="declaration"
|
|
28
28
|
[formGroup]="formGroup"
|
|
29
29
|
></v-generic-form>
|
|
30
|
+
<v-button label="X" class="mt-3" (click)="clear()" />
|
|
30
31
|
</div>
|
|
31
32
|
}
|
|
32
33
|
<div class="v-filter_action-buttons d-flex">
|
|
33
|
-
@if (declaration.length) {
|
|
34
|
-
<
|
|
35
|
-
class="
|
|
36
|
-
|
|
37
|
-
[
|
|
34
|
+
@if (declaration.length && !showFilters) {
|
|
35
|
+
<v-button
|
|
36
|
+
class="me-4"
|
|
37
|
+
[icon]="icons.filter"
|
|
38
|
+
[label]="$any(filledFiltersCount$ | async)"
|
|
38
39
|
(click)="openFilter()"
|
|
39
|
-
|
|
40
|
+
/>
|
|
40
41
|
} @if (!autoBind) {
|
|
41
42
|
<v-button
|
|
42
43
|
useShortCut
|