@servicemind.tis/angular-smart-data-table 1.0.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/LICENSE +21 -0
- package/README.md +278 -0
- package/fesm2022/servicemind.tis-angular-smart-data-table.mjs +3148 -0
- package/fesm2022/servicemind.tis-angular-smart-data-table.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/angular-smart-data-table.module.d.ts +38 -0
- package/lib/angular-smart-data-table.service.d.ts +6 -0
- package/lib/components/angular-columns-btn/angular-columns-btn.component.d.ts +39 -0
- package/lib/components/angular-smart-data-table/angular-smart-data-table.component.d.ts +205 -0
- package/lib/components/angular-smart-data-table-confirmation-dialog/angular-smart-data-table-confirmation-dialog.component.d.ts +10 -0
- package/lib/components/angular-smart-data-table-error-dialog/angular-smart-data-table-error-dialog.component.d.ts +10 -0
- package/lib/components/create-columns-template/create-columns-template.component.d.ts +42 -0
- package/lib/datasources/api.datasource.d.ts +18 -0
- package/lib/directives/scrolling/scrolling.directive.d.ts +11 -0
- package/lib/helpers/collection.helper.d.ts +92 -0
- package/lib/helpers/date-time.helper.d.ts +39 -0
- package/lib/helpers/filter-display.helper.d.ts +51 -0
- package/lib/helpers/query-params.helper.d.ts +47 -0
- package/lib/helpers/storage-helper.d.ts +3 -0
- package/lib/helpers/timeout-manager.helper.d.ts +72 -0
- package/lib/helpers/url.helper.d.ts +78 -0
- package/lib/helpers/validation.helper.d.ts +73 -0
- package/lib/interfaces/angular-selection-config.type.d.ts +16 -0
- package/lib/interfaces/data-not-found-config.type.d.ts +12 -0
- package/lib/interfaces/index.d.ts +4 -0
- package/lib/interfaces/smart-data-table-wrapper-columns-config.type.d.ts +38 -0
- package/lib/interfaces/url-config.type.d.ts +8 -0
- package/lib/pipes/angular-currency.pipe.d.ts +7 -0
- package/lib/pipes/angular-date-time-with-seconds.pipe.d.ts +7 -0
- package/lib/pipes/angular-date-time.pipe.d.ts +7 -0
- package/lib/pipes/angular-date.pipe.d.ts +7 -0
- package/lib/pipes/money.pipe.d.ts +9 -0
- package/lib/pipes/quantity.pipe.d.ts +9 -0
- package/lib/services/angular-helper.service.d.ts +17 -0
- package/lib/services/api.service.d.ts +11 -0
- package/lib/services/user-customization.service.d.ts +16 -0
- package/package.json +50 -0
- package/public-api.d.ts +4 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Thai Informatics System Co., Ltd.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
|
|
2
|
+
# Angular Smart Data Table
|
|
3
|
+
|
|
4
|
+
`@servicemind.tis/angular-smart-data-table` is an Angular component library that provides a highly configurable and reusable smart table component for enterprise applications.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 🌟 Features
|
|
9
|
+
|
|
10
|
+
- Customizable columns and templates
|
|
11
|
+
- Filter form integration with URL syncing
|
|
12
|
+
- Column customization templates with API integration
|
|
13
|
+
- Internationalization support (e.g., Transloco)
|
|
14
|
+
- Custom row background styling
|
|
15
|
+
- Built-in pagination and sorting
|
|
16
|
+
- Dynamic slot and template injection for full control
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 🚀 Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @servicemind.tis/angular-smart-data-table
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 🔧 Usage Example
|
|
29
|
+
|
|
30
|
+
### `app.component.html`
|
|
31
|
+
|
|
32
|
+
```html
|
|
33
|
+
<ng-container *transloco="let t; read: 'serviceManagement.serviceRequestListComponent'">
|
|
34
|
+
<angular-smart-data-table
|
|
35
|
+
#mainTableWrapper
|
|
36
|
+
[columnCustomizationUrlConfig]="columnCustomizationUrlConfig"
|
|
37
|
+
[t]="t"
|
|
38
|
+
componentName="cm-service-request"
|
|
39
|
+
[mainTitle]="t('list')"
|
|
40
|
+
[breadcrumbs]="[{url: '/admin/service-management/cases', name: t('breadcrumb')}]"
|
|
41
|
+
[columnsCodeMapping]="columnsCodeMapping"
|
|
42
|
+
[searchPlaceholder]="t('searchPlaceholder')"
|
|
43
|
+
[loadDataApiBaseUrl]="loadDataApiBaseUrl"
|
|
44
|
+
[(pageSize)]="pageSize"
|
|
45
|
+
[(pageIndex)]="pageIndex"
|
|
46
|
+
[hideHeader]="true"
|
|
47
|
+
[rowsConfig]="rowsConfig"
|
|
48
|
+
[filterFormGroup]="filterFormGroup"
|
|
49
|
+
[keepFilterInUrl]="false"
|
|
50
|
+
[dataNotFoundConfig]="{
|
|
51
|
+
title: t('noDataFound'),
|
|
52
|
+
desc: t('noDataFoundDescription'),
|
|
53
|
+
btnText: t('addNew'),
|
|
54
|
+
btnUrl: '/admin/service-management/cases/add'
|
|
55
|
+
}"
|
|
56
|
+
>
|
|
57
|
+
<!-- Custom slots like filter buttons, filter section, templates, etc. -->
|
|
58
|
+
</angular-smart-data-table>
|
|
59
|
+
</ng-container>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### `app.component.ts`
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
import { Component, TemplateRef, ViewChild } from '@angular/core';
|
|
66
|
+
import { FormGroup, FormControl } from '@angular/forms';
|
|
67
|
+
import {
|
|
68
|
+
SmartTableWrapperColumnsConfig,
|
|
69
|
+
SmartTableWrapperRowsConfig,
|
|
70
|
+
AngularSmartDataTableComponent,
|
|
71
|
+
ColumnCustomizationUrlConfig
|
|
72
|
+
} from 'angular-smart-data-table';
|
|
73
|
+
|
|
74
|
+
@Component({
|
|
75
|
+
selector: 'app-root',
|
|
76
|
+
templateUrl: './app.component.html',
|
|
77
|
+
styleUrls: ['./app.component.scss']
|
|
78
|
+
})
|
|
79
|
+
export class AppComponent {
|
|
80
|
+
@ViewChild('mainTableWrapper') tableListViewWrapperComponent!: AngularSmartDataTableComponent;
|
|
81
|
+
|
|
82
|
+
columnsCodeMapping: SmartTableWrapperColumnsConfig[] = [
|
|
83
|
+
{ name: 'action', serverKeyCode: 'action', type: 'action', sort: false, template: this.actionColumnTemplate },
|
|
84
|
+
{ name: 'description', serverKeyCode: 'description', type: 'string', sort: true, template: this.descriptionColumnTemplate },
|
|
85
|
+
{ name: 'sourceOfRequest', serverKeyCode: 'sourceOfRequest', type: 'string', template: this.sourceOfReColumnTemplate },
|
|
86
|
+
{ name: 'status', serverKeyCode: 'cmStatusId', type: 'string', template: this.statusColumnTemplate },
|
|
87
|
+
// Add more columns as needed...
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
@ViewChild('actionColumnTemplate') set actionColumnTemplate(tpl: TemplateRef<any>) {
|
|
91
|
+
this.setColumnTemplate('action', tpl);
|
|
92
|
+
}
|
|
93
|
+
@ViewChild('descriptionColumnTemplate') set descriptionColumnTemplate(tpl: TemplateRef<any>) {
|
|
94
|
+
this.setColumnTemplate('description', tpl);
|
|
95
|
+
}
|
|
96
|
+
@ViewChild('sourceOfReColumnTemplate') set sourceOfReColumnTemplate(tpl: TemplateRef<any>) {
|
|
97
|
+
this.setColumnTemplate('sourceOfRequest', tpl);
|
|
98
|
+
}
|
|
99
|
+
@ViewChild('statusColumnTemplate') set statusColumnTemplate(tpl: TemplateRef<any>) {
|
|
100
|
+
this.setColumnTemplate('status', tpl);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
filterFormGroup!: FormGroup;
|
|
104
|
+
isShowFilter = false;
|
|
105
|
+
pageSize = 10;
|
|
106
|
+
pageIndex = 0;
|
|
107
|
+
loadDataApiBaseUrl = 'https://mocki.io/v1/2f34e933-74dc-4433-83ac-b66991f7e472';
|
|
108
|
+
columnCustomizationUrlConfig: ColumnCustomizationUrlConfig = {
|
|
109
|
+
list: '/user-customization/get-columns-templates',
|
|
110
|
+
add: '/user-customization/add-columns-template',
|
|
111
|
+
update: '/user-customization/update-columns-template',
|
|
112
|
+
delete: '/user-customization/delete-columns-template',
|
|
113
|
+
getSelectedTemplate: '/user-customization/get-selected-columns-template',
|
|
114
|
+
updateSelectedTemplate: '/user-customization/update-selected-columns-template'
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
rowsConfig: SmartTableWrapperRowsConfig = {
|
|
118
|
+
backgroundApplyFunction: (row: any) => row.viewsCount === 0 ? '#f2f6fc' : null
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
ngOnInit() {
|
|
122
|
+
this.filterFormGroup = new FormGroup({
|
|
123
|
+
type: new FormControl(null)
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
setColumnTemplate(name: string, template: TemplateRef<any>) {
|
|
128
|
+
const col = this.columnsCodeMapping.find(c => c.name === name);
|
|
129
|
+
if (col) col.template = template;
|
|
130
|
+
this.columnsCodeMapping = [...this.columnsCodeMapping];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
filterRecords() {
|
|
134
|
+
this.tableListViewWrapperComponent.filterRecords();
|
|
135
|
+
this.changeFilterVisibility();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
changeFilterVisibility() {
|
|
139
|
+
this.isShowFilter = !this.isShowFilter;
|
|
140
|
+
this.tableListViewWrapperComponent.isShowFilter = this.isShowFilter;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
onReset() {
|
|
144
|
+
this.filterFormGroup.reset();
|
|
145
|
+
this.filterRecords();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## 🧠 Key Interfaces
|
|
153
|
+
|
|
154
|
+
### `SmartTableWrapperColumnsConfig`
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
export interface SmartTableWrapperColumnsConfig {
|
|
158
|
+
name: string;
|
|
159
|
+
type: 'string' | 'number' | 'quantity' | 'money' | 'date' | 'date-time' | 'date-time-with-seconds' | 'action';
|
|
160
|
+
align?: 'left' | 'right' | 'center' | null;
|
|
161
|
+
serverKeyCode: string;
|
|
162
|
+
valueKey?: string;
|
|
163
|
+
template?: TemplateRef<any>;
|
|
164
|
+
sort: boolean;
|
|
165
|
+
clickFn?: (rec: any, event?: MouseEvent) => void;
|
|
166
|
+
filterFormKey?: string;
|
|
167
|
+
transformQueryParamFn?: Function;
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### `SmartTableWrapperRowsConfig`
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
export interface SmartTableWrapperRowsConfig {
|
|
175
|
+
backgroundApplyFunction?: (row: any) => string | null;
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### `SelectedFilterDisplayValueType`
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
export type SelectedFilterDisplayValueType = {
|
|
183
|
+
value: any | any[] | null;
|
|
184
|
+
labelKey?: string | number | null;
|
|
185
|
+
valueKey: any | null;
|
|
186
|
+
formControlName: string;
|
|
187
|
+
formControlType: 'input' | 'radio' | 'date' | 'date-time' | 'toggle' | 'checkbox' | 'chip' | 'select' | 'search-select';
|
|
188
|
+
isSingleValue?: boolean;
|
|
189
|
+
selectedObjData?: any;
|
|
190
|
+
};
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### `SelectedFilterDisplayValuesType`
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
export type SelectedFilterDisplayValuesType = SelectedFilterDisplayValueType[];
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### `AnyKeyValueObject`
|
|
200
|
+
|
|
201
|
+
```ts
|
|
202
|
+
export type AnyKeyValueObject = Record<string, any>;
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### `SelectedFiltersGroupedValuesType`
|
|
206
|
+
|
|
207
|
+
```ts
|
|
208
|
+
export type SelectedFiltersGroupedValuesType = {
|
|
209
|
+
formControlName: string;
|
|
210
|
+
formControlType: string;
|
|
211
|
+
arrValues: SelectedFilterDisplayValueType[];
|
|
212
|
+
};
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### `ColumnCustomizationUrlConfig`
|
|
216
|
+
|
|
217
|
+
```ts
|
|
218
|
+
export interface ColumnCustomizationUrlConfig {
|
|
219
|
+
list: string;
|
|
220
|
+
add: string;
|
|
221
|
+
update: string;
|
|
222
|
+
delete: string;
|
|
223
|
+
getSelectedTemplate: string;
|
|
224
|
+
updateSelectedTemplate: string;
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### `DataNotFoundConfig`
|
|
229
|
+
|
|
230
|
+
```ts
|
|
231
|
+
export type DataNotFoundConfig = {
|
|
232
|
+
title: string;
|
|
233
|
+
desc: string;
|
|
234
|
+
btnText?: string | null;
|
|
235
|
+
btnUrl?: string | null;
|
|
236
|
+
btnClick?: null | ((rec: any, event?: MouseEvent) => void);
|
|
237
|
+
secondBtnText?: string | null;
|
|
238
|
+
secondBtnUrl?: string | null;
|
|
239
|
+
secondBtnClick?: null | ((rec: any, event?: MouseEvent) => void);
|
|
240
|
+
};
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## 📦 Module Setup
|
|
246
|
+
|
|
247
|
+
Make sure to import `AngularSmartDataTableModule` and necessary Angular Material modules in your app module or standalone components.
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
## 🤝 Contributing
|
|
253
|
+
|
|
254
|
+
1. Clone the repo
|
|
255
|
+
2. Run `npm install`
|
|
256
|
+
3. Use the demo app to test (`projects/` directory)
|
|
257
|
+
4. Submit a PR or issue with details
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## 🚀 Publishing to npm
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
git tag v1.0.0
|
|
265
|
+
git push origin v1.0.0
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
GitHub Actions will build and publish to npm automatically if configured.
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
## 📬 Support / Questions
|
|
273
|
+
|
|
274
|
+
For bugs, suggestions, or feature requests, please open an issue on the [GitHub repository](https://github.com/Thai-Informatics-System/angular-smart-data-table).
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
> Made with ❤️ by [Thai Informatic Systems Co. Ltd](https://tis.co.th/)
|