namirasoft-account-react 1.5.38 → 1.5.39

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.
Files changed (145) hide show
  1. package/.env.template +15 -15
  2. package/SKILL.md +514 -514
  3. package/config-overrides.js +72 -72
  4. package/dist/App.d.ts +1 -1
  5. package/dist/FieldCacheService.js +4 -0
  6. package/dist/FieldCacheService.js.map +1 -1
  7. package/dist/NSARouterMaker.js +1 -1
  8. package/dist/NSARouterMaker.js.map +1 -1
  9. package/dist/Router.d.ts +1 -1
  10. package/dist/UseParams.d.ts +1 -1
  11. package/dist/components/NSAAccessListDialog.d.ts +2 -2
  12. package/dist/components/NSAAccessListDialog.module.css +71 -71
  13. package/dist/components/NSABoxSecret.d.ts +1 -1
  14. package/dist/components/NSABoxSecret.module.css +23 -23
  15. package/dist/components/NSAMasterMenu.d.ts +1 -1
  16. package/dist/components/NSAMasterMenu.js +4 -0
  17. package/dist/components/NSAMasterMenu.js.map +1 -1
  18. package/dist/components/NSAMasterMenu.module.css +250 -250
  19. package/dist/components/NSAMasterMenuItem.d.ts +1 -1
  20. package/dist/components/NSAMessageListDialog.d.ts +1 -1
  21. package/dist/components/NSAMessageListDialog.module.css +99 -99
  22. package/dist/components/NSANavigationGuard.d.ts +1 -1
  23. package/dist/components/NSAProductListDialog.d.ts +1 -1
  24. package/dist/components/NSAProductListDialog.module.css +44 -44
  25. package/dist/components/NSATaskBar.d.ts +1 -1
  26. package/dist/components/NSATaskBar.module.css +57 -57
  27. package/dist/components/NSAUserDialog.d.ts +1 -1
  28. package/dist/components/NSAUserDialog.module.css +67 -67
  29. package/dist/components/NSAWorkspaceListDialog.d.ts +1 -1
  30. package/dist/components/NSAWorkspaceListDialog.module.css +41 -41
  31. package/dist/components/NSFBoxCategoryScope.d.ts +1 -1
  32. package/dist/components/NSFBoxField.d.ts +1 -1
  33. package/dist/components/NSFBoxSlot.d.ts +1 -1
  34. package/dist/components/NSFBoxWrapper.d.ts +1 -1
  35. package/dist/components/NSLabelSecret.d.ts +1 -1
  36. package/dist/components/quickfilter/NSAFilterBoxEnum.module.css +51 -51
  37. package/dist/components/quickfilter/NSAQuickFilterBar.d.ts +1 -1
  38. package/dist/components/quickfilter/NSAQuickFilterBar.module.css +20 -20
  39. package/dist/components/quickfilter/NSAQuickFilterDialog.d.ts +1 -1
  40. package/dist/components/quickfilter/NSAQuickFilterDialog.module.css +74 -74
  41. package/dist/layouts/NSALayout.d.ts +1 -1
  42. package/dist/layouts/NSASectionEdit.d.ts +1 -1
  43. package/dist/layouts/NSASectionEditTabPage.d.ts +1 -1
  44. package/dist/layouts/NSASectionEditTabPage.module.css +4 -4
  45. package/dist/layouts/NSASectionList.d.ts +1 -1
  46. package/dist/layouts/NSASectionList.module.css +24 -24
  47. package/dist/layouts/NSASectionView.d.ts +1 -1
  48. package/dist/layouts/NSASectionViewTabMore.d.ts +1 -1
  49. package/dist/layouts/NSASectionViewTabPage.d.ts +1 -1
  50. package/dist/layouts/NSASectionViewTabPage.module.css +47 -47
  51. package/dist/pages/NSAConsentPage.module.css +26 -26
  52. package/dist/pages/NSAEmailVerificationPage.d.ts +1 -1
  53. package/dist/pages/NSAHomePage.d.ts +1 -1
  54. package/dist/pages/NSAHomePage.module.css +41 -41
  55. package/dist/pages/NSALoginPage.d.ts +1 -1
  56. package/dist/pages/NSALoginPage.module.css +26 -26
  57. package/dist/pages/NSAPhoneVerificationPage.d.ts +1 -1
  58. package/dist/pages/NSAVerificationPage.d.ts +1 -1
  59. package/dist/pages/NSAVerificationPage.module.css +31 -31
  60. package/package.json +94 -94
  61. package/public/index.html +21 -21
  62. package/src/App.tsx +72 -72
  63. package/src/CTFRow.ts +7 -7
  64. package/src/FieldCacheService.tsx +113 -108
  65. package/src/IEntityInfo.ts +33 -33
  66. package/src/NSACacheService.ts +126 -126
  67. package/src/NSAFilterOperators.ts +94 -94
  68. package/src/NSARouterMaker.tsx +141 -141
  69. package/src/NSARouterMakerProps.ts +23 -23
  70. package/src/NSARouterMakerResult.ts +24 -24
  71. package/src/NSFRouterMaker.tsx +35 -35
  72. package/src/NSFRouterProps.ts +7 -7
  73. package/src/NSFRoutes.ts +30 -30
  74. package/src/Router.tsx +48 -48
  75. package/src/UseParams.tsx +17 -17
  76. package/src/components/NSAAccessListDialog.module.css +71 -71
  77. package/src/components/NSAAccessListDialog.tsx +178 -178
  78. package/src/components/NSABoxSecret.module.css +23 -23
  79. package/src/components/NSABoxSecret.tsx +264 -264
  80. package/src/components/NSAMasterMenu.module.css +250 -250
  81. package/src/components/NSAMasterMenu.tsx +174 -169
  82. package/src/components/NSAMasterMenuItem.tsx +250 -250
  83. package/src/components/NSAMessageListDialog.module.css +99 -99
  84. package/src/components/NSAMessageListDialog.tsx +144 -144
  85. package/src/components/NSANavigationGuard.tsx +79 -79
  86. package/src/components/NSAProductListDialog.module.css +44 -44
  87. package/src/components/NSAProductListDialog.tsx +88 -88
  88. package/src/components/NSATable.tsx +494 -494
  89. package/src/components/NSATaskBar.module.css +57 -57
  90. package/src/components/NSATaskBar.tsx +193 -193
  91. package/src/components/NSAUserDialog.module.css +67 -67
  92. package/src/components/NSAUserDialog.tsx +122 -122
  93. package/src/components/NSAWorkspaceListDialog.module.css +41 -41
  94. package/src/components/NSAWorkspaceListDialog.tsx +147 -147
  95. package/src/components/NSFBoxCategoryScope.tsx +52 -52
  96. package/src/components/NSFBoxField.tsx +37 -37
  97. package/src/components/NSFBoxSlot.tsx +73 -73
  98. package/src/components/NSFBoxWrapper.tsx +69 -69
  99. package/src/components/NSLabelSecret.tsx +37 -37
  100. package/src/components/quickfilter/NSAFilterBoxBase.tsx +110 -110
  101. package/src/components/quickfilter/NSAFilterBoxBoolean.tsx +72 -72
  102. package/src/components/quickfilter/NSAFilterBoxDate.tsx +110 -110
  103. package/src/components/quickfilter/NSAFilterBoxDateTime.tsx +110 -110
  104. package/src/components/quickfilter/NSAFilterBoxEnum.module.css +51 -51
  105. package/src/components/quickfilter/NSAFilterBoxEnum.tsx +103 -103
  106. package/src/components/quickfilter/NSAFilterBoxNumber.tsx +145 -145
  107. package/src/components/quickfilter/NSAFilterBoxString.tsx +83 -83
  108. package/src/components/quickfilter/NSAFilterBoxTime.tsx +106 -106
  109. package/src/components/quickfilter/NSAQuickFilterBar.module.css +20 -20
  110. package/src/components/quickfilter/NSAQuickFilterBar.tsx +142 -142
  111. package/src/components/quickfilter/NSAQuickFilterDialog.module.css +74 -74
  112. package/src/components/quickfilter/NSAQuickFilterDialog.tsx +297 -297
  113. package/src/css.d.ts +13 -13
  114. package/src/formatters/SecretFormatter.tsx +24 -24
  115. package/src/index.tsx +27 -27
  116. package/src/layouts/Actions.ts +146 -146
  117. package/src/layouts/CFTUtil.ts +18 -18
  118. package/src/layouts/NSALayout.tsx +750 -750
  119. package/src/layouts/NSALayout_Field.ts +125 -125
  120. package/src/layouts/NSASectionEdit.tsx +279 -279
  121. package/src/layouts/NSASectionEditTabPage.module.css +4 -4
  122. package/src/layouts/NSASectionEditTabPage.tsx +256 -256
  123. package/src/layouts/NSASectionList.module.css +24 -24
  124. package/src/layouts/NSASectionList.tsx +165 -165
  125. package/src/layouts/NSASectionView.tsx +98 -98
  126. package/src/layouts/NSASectionViewTabMore.tsx +78 -78
  127. package/src/layouts/NSASectionViewTabPage.module.css +47 -47
  128. package/src/layouts/NSASectionViewTabPage.tsx +400 -400
  129. package/src/main.ts +52 -52
  130. package/src/pages/NSAConsentPage.module.css +26 -26
  131. package/src/pages/NSAConsentPage.tsx +120 -120
  132. package/src/pages/NSAEmailVerificationPage.tsx +30 -30
  133. package/src/pages/NSAHomePage.module.css +41 -41
  134. package/src/pages/NSAHomePage.tsx +113 -113
  135. package/src/pages/NSALoginPage.module.css +26 -26
  136. package/src/pages/NSALoginPage.tsx +87 -87
  137. package/src/pages/NSAPhoneVerificationPage.tsx +106 -106
  138. package/src/pages/NSAVerificationPage.module.css +31 -31
  139. package/src/pages/NSAVerificationPage.tsx +185 -185
  140. package/src/pages/NSFCategoryEditPage.tsx +87 -87
  141. package/src/pages/NSFCategoryListPage.tsx +23 -23
  142. package/src/pages/NSFCategoryViewPage.tsx +23 -23
  143. package/src/pages/NSFEntities.ts +58 -58
  144. package/src/pages/PaymentRequired.tsx +80 -80
  145. package/tsconfig.json +43 -43
@@ -1,495 +1,495 @@
1
- import { EncodingOperation, FilterItem, FilterItemColumnType, NamingConvention, ObjectService, SearchOperation, SortItem } from "namirasoft-core";
2
- import { EntityResolveResponseRow } from "namirasoft-field";
3
- import { FilterItemColumnTypeBuilder, VariableType } from "namirasoft-schema";
4
- import { IBaseComponentProps, NSButtonProps, NSFilterBox, NSFilterBoxItems, NSFilterBoxProps_Table, NSSpace, NSSpaceSizeType, NSTable, TableColumnInfo, TableRowInfo } from "namirasoft-site-react";
5
- import { Component, ReactNode, createRef } from "react";
6
- import { IEntityInfo } from "../IEntityInfo";
7
- import { NSACacheService } from "../NSACacheService";
8
- import { NSAQuickFilterBar } from "./quickfilter/NSAQuickFilterBar";
9
- import { NSAQuickFilterDialog, QuickFilterConfig } from "./quickfilter/NSAQuickFilterDialog";
10
-
11
- export interface NSATableUIProps<RowType>
12
- {
13
- getRowAttributes?: (row_value: RowType, row_index: number, res: { rows: RowType[]; count: number; } | null) => { [key: string]: any };
14
- getColumnAttributes?: (column: TableColumnInfo) => { [key: string]: any };
15
- getCellFormattedValue?: (value: any, column: TableColumnInfo, row: TableRowInfo<RowType>) => any;
16
- search_box?: {
17
- exclude?: {
18
- show?: {
19
- table?: (table: string) => boolean;
20
- column?: (table: string, column: string) => boolean;
21
- },
22
- load_value?: (table: string, column: string) => boolean;
23
- }
24
- };
25
- }
26
-
27
- export interface NSATableProps<RowType extends { id: string }, RowTypeInput = RowType> extends IBaseComponentProps
28
- {
29
- entity: IEntityInfo<RowType, RowTypeInput>;
30
- ctf: {
31
- enabled: boolean;
32
- rows: EntityResolveResponseRow | null;
33
- };
34
- url: { getQuery(name: string, base64?: boolean, remove?: boolean): string };
35
- ui?: NSATableUIProps<RowType>;
36
- checkbox?: boolean;
37
- buttons?: NSButtonProps[];
38
- onSelectionChanged?: () => void;
39
- }
40
-
41
- interface NSATableState<RowType>
42
- {
43
- res: { rows: RowType[]; count: number; } | null;
44
- visible_column_keys: string[];
45
- quick_filter_configs: QuickFilterConfig[];
46
- show_quick_filter_dialog: boolean;
47
- filter_revision: number;
48
- }
49
-
50
- export class NSATable<RowType extends { id: string }, RowTypeInput = RowType>
51
- extends Component<NSATableProps<RowType, RowTypeInput>, NSATableState<RowType>>
52
- {
53
- public NSTable_Main = createRef<NSTable<RowType>>();
54
- public NSFilterBox_Top = createRef<NSFilterBox>();
55
- public NSAQuickFilterBar_Ref = createRef<NSAQuickFilterBar>();
56
-
57
- constructor(props: NSATableProps<RowType, RowTypeInput>)
58
- {
59
- super(props);
60
-
61
- const quick_filter_configs = NSACacheService.loadQuickFilters(props.entity.name) ?? this.buildDefaultQuickFilters();
62
- this.state = {
63
- res: null,
64
- visible_column_keys: [],
65
- quick_filter_configs,
66
- show_quick_filter_dialog: false,
67
- filter_revision: 0,
68
- };
69
- }
70
-
71
- override componentDidMount()
72
- {
73
- const visible = this.NSTable_Main.current?.getVisibleColumns() ?? [];
74
- if (visible.length > 0)
75
- this.setState({ visible_column_keys: visible.map(v => v.table + "." + v.column) });
76
-
77
- this.setState(prev => ({ filter_revision: prev.filter_revision + 1 }));
78
- }
79
-
80
- private getColumns(): TableColumnInfo[]
81
- {
82
- let columns = Object.values(this.props.entity.client.getColumns()).flat();
83
- columns.forEach(col =>
84
- {
85
- col.text = NamingConvention.auto.convert(col.text, NamingConvention.Pascal_Case_Space);
86
- });
87
- return columns;
88
- }
89
-
90
- private buildDefaultQuickFilters(): QuickFilterConfig[]
91
- {
92
- const getDefaults = this.props.entity.client.getQuickFilters;
93
- if (!getDefaults)
94
- return [];
95
-
96
- const columns = this.getColumns();
97
- const ans: QuickFilterConfig[] = [];
98
- for (const def of getDefaults())
99
- {
100
- const col = columns.find(c => c.name === def.column);
101
- if (!col)
102
- continue;
103
- const columnType = new ObjectService(col.type).getEnum(VariableType, VariableType.Any);
104
- ans.push({
105
- id: `default-${col.table.name}-${col.name}`,
106
- title: def.title,
107
- column: {
108
- table: { name: col.table.name, text: col.table.text },
109
- name: col.name,
110
- text: col.text,
111
- type: col.type,
112
- columnType,
113
- },
114
- operatorName: (def as { operator?: string }).operator,
115
- });
116
- }
117
- return ans;
118
- }
119
-
120
- private filterItemTypeConverter(type: string): FilterItemColumnType
121
- {
122
- let t = new ObjectService(type).getEnum(VariableType, VariableType.Any);
123
- let builder = new FilterItemColumnTypeBuilder(t);
124
- return builder.runSynch(() => { }) ?? FilterItemColumnType.Unknown;
125
- }
126
-
127
- private getIncomingFilterItems(): FilterItem[] | undefined
128
- {
129
- try
130
- {
131
- let encoded = this.props.url.getQuery("filters");
132
- if (encoded)
133
- return FilterItem.decode(encoded) ?? undefined;
134
- } catch (error)
135
- {
136
- }
137
- return undefined;
138
- }
139
-
140
- private itemMatchesQuickFilter(item: FilterItem): boolean
141
- {
142
- return this.state.quick_filter_configs.some(c =>
143
- c.column.table.name === item.table.name && c.column.name === item.column.name);
144
- }
145
- private getIncomingBoxItems(): FilterItem[] | undefined
146
- {
147
- let items = this.getIncomingFilterItems();
148
- if (!items)
149
- return undefined;
150
- return items.filter(i => !this.itemMatchesQuickFilter(i));
151
- }
152
- private getIncomingQuickItems(): FilterItem[]
153
- {
154
- let items = this.getIncomingFilterItems();
155
- if (!items)
156
- return [];
157
- return items.filter(i => this.itemMatchesQuickFilter(i));
158
- }
159
-
160
- private encodeFilters(items: FilterItem[]): string
161
- {
162
- let command = items.map(item =>
163
- {
164
- let key = item.operator.name.replace(/\s+/g, "").toLowerCase();
165
- let values = item.values.map(v => (v ?? "").toString().replace(/;/g, "\\;"));
166
- return [item.table.name, item.column.name, item.not ? "1" : "0", key, ...values].join(";");
167
- }).join(";");
168
- return EncodingOperation.Base64Encode(command);
169
- }
170
-
171
- private syncQueryFromFilters()
172
- {
173
- let items = this.getFilterItems();
174
- let url = new URL(window.location.href);
175
- let encoded = items.length > 0 ? this.encodeFilters(items) : "";
176
- if (encoded)
177
- url.searchParams.set("filters", encoded);
178
- else
179
- url.searchParams.delete("filters");
180
- window.history.replaceState({}, "", url.toString());
181
- }
182
-
183
- public reload(page: number | null, size: number | null): Promise<void> | undefined
184
- {
185
- return this.NSTable_Main.current?.reload(page, size);
186
- }
187
- public getSelectedIDs(): string[]
188
- {
189
- return this.NSTable_Main.current?.getSelectedIDs() ?? [];
190
- }
191
- public getSelectedRows(): RowType[]
192
- {
193
- return this.NSTable_Main.current?.getSelectedRows() ?? [];
194
- }
195
- public setSelectedIDs(ids: string[], rows: RowType[], callback?: () => void)
196
- {
197
- this.NSTable_Main.current?.setSelectedIDs(ids, rows, callback);
198
- }
199
- public getSortItems(): SortItem[]
200
- {
201
- return this.NSTable_Main.current?.getSortItems() ?? [];
202
- }
203
- public setSortItems(items: SortItem[] | null)
204
- {
205
- this.NSTable_Main.current?.setSortItems(items);
206
- }
207
- public getVisibleColumns(): { table: string, column: string }[]
208
- {
209
- return this.NSTable_Main.current?.getVisibleColumns() ?? [];
210
- }
211
- public setVisibleColumns(visible_columns: { table: string, column: string }[])
212
- {
213
- this.NSTable_Main.current?.setVisibleColumns(visible_columns);
214
- }
215
- public getFilterBoxItems(): FilterItem[]
216
- {
217
- return this.NSFilterBox_Top.current?.getFilterItems() ?? [];
218
- }
219
- public getQuickFilterItems(): FilterItem[]
220
- {
221
- return this.NSAQuickFilterBar_Ref.current?.getFilterItems() ?? [];
222
- }
223
- public getFilterItems(): FilterItem[]
224
- {
225
- return [...this.getFilterBoxItems(), ...this.getQuickFilterItems()];
226
- }
227
-
228
- private reloadFromFilters()
229
- {
230
- this.syncQueryFromFilters();
231
- this.NSTable_Main.current?.setSelectedIDs([], []);
232
- this.NSTable_Main.current?.reload(null, null);
233
- }
234
-
235
- private onFilterBoxChanged = () =>
236
- {
237
- this.reloadFromFilters();
238
- this.setState(prev => ({ filter_revision: prev.filter_revision + 1 }));
239
- };
240
-
241
- private buildButtons(): NSButtonProps[]
242
- {
243
- const buttons: NSButtonProps[] = [
244
- {
245
- title: "",
246
- icon: { src: "https://static.namirasoft.com/image/concept/sliders/blue.svg", alt: "filter" },
247
- attributes: { title: "Quick Filters" },
248
- onClick: {
249
- action: () => this.setState({ show_quick_filter_dialog: true }),
250
- showLoading: false,
251
- },
252
- },
253
- ];
254
- return [...buttons, ...(this.props.buttons ?? [])];
255
- }
256
-
257
- private renderFilterHeader(): ReactNode
258
- {
259
- return (
260
- <NSFilterBox
261
- ref={this.NSFilterBox_Top}
262
- filterItems={this.getIncomingBoxItems()}
263
- getTables={() =>
264
- {
265
- return this.props.entity.tables.map(table =>
266
- {
267
- let columns = table.table.getColumns().map(c => ({ id: c.name, ...c, type: this.filterItemTypeConverter(c.type) }));
268
- columns = columns.filter(c =>
269
- {
270
- if (this.props.ui?.search_box?.exclude?.show?.column)
271
- if (this.props.ui?.search_box?.exclude.show?.column(table.table.name, c.name))
272
- return false;
273
- return true;
274
- });
275
- return { name: table.table.name, text: table.table.text, columns, required: table.required };
276
- }).filter(t =>
277
- {
278
- if (this.props.ui?.search_box?.exclude?.show?.table)
279
- if (this.props.ui?.search_box?.exclude.show.table(t.name))
280
- return false;
281
- return true;
282
- });
283
- }}
284
- getMoreTables={async () =>
285
- {
286
- let ans: NSFilterBoxProps_Table[] = [];
287
- if (this.props.ctf.enabled)
288
- try
289
- {
290
- if (this.props.ctf.rows?.fields)
291
- if (this.props.ctf.rows.fields.length > 0)
292
- {
293
- let name = this.props.entity.name + "_field";
294
- ans.push({
295
- name,
296
- text: "Fields",
297
- columns: [{
298
- id: "field_id",
299
- name: "field_id",
300
- text: "ID",
301
- type: FilterItemColumnType.Unknown,
302
- getValues: async (search) =>
303
- {
304
- return this.props.ctf.rows?.fields?.filter(c => SearchOperation.match(c.id, search)).map(c => { return { value: c.id, title: c.id } }) ?? [];
305
- }
306
- }, {
307
- id: "field_name",
308
- name: "field_id",
309
- text: "Name",
310
- type: FilterItemColumnType.Unknown,
311
- getValues: async (search) =>
312
- {
313
- return this.props.ctf.rows?.fields?.filter(c => SearchOperation.match(c.name, search)).map(c => { return { value: c.id, title: c.name } }) ?? [];
314
- }
315
- }, {
316
- id: "field_value",
317
- name: "value",
318
- text: "Value",
319
- type: FilterItemColumnType.Unknown
320
- },
321
- ...this.props.ctf.rows?.fields.map(f =>
322
- {
323
- return {
324
- id: f.id,
325
- name: f.id,
326
- text: f.name,
327
- type: this.filterItemTypeConverter(f.type.type.type),
328
- getValues: async (search: string) =>
329
- {
330
- let values = await this.props.entity.server.value_list(name, "value", search, f.id, null);
331
- return values.map(v => { return { value: v, title: v } });
332
- }
333
- };
334
- }),],
335
- required: false
336
- });
337
- }
338
-
339
- if (this.props.ctf.rows?.categories)
340
- if (this.props.ctf.rows?.categories.length > 0)
341
- ans.push({
342
- name: this.props.entity.name + "_category",
343
- text: "Categories",
344
- columns: [{
345
- id: "category_id",
346
- name: "category_id",
347
- text: "ID",
348
- type: FilterItemColumnType.Unknown,
349
- getValues: async (search) =>
350
- {
351
- return this.props.ctf.rows?.categories?.filter(c => SearchOperation.match(c.id, search)).map(c => { return { value: c.id, title: c.id } }) ?? [];
352
- }
353
- }, {
354
- id: "category_name",
355
- name: "category_id",
356
- text: "Name",
357
- type: FilterItemColumnType.Unknown,
358
- getValues: async (search) =>
359
- {
360
- return this.props.ctf.rows?.categories?.filter(c => SearchOperation.match(c.name, search)).map(c => { return { value: c.id, title: c.name } }) ?? [];
361
- }
362
- }],
363
- required: false
364
- });
365
-
366
- } catch (error)
367
- {
368
- }
369
- // todo add tags
370
- return ans;
371
- }}
372
- getValues={async (table, column, value) =>
373
- {
374
- if (this.props.ui?.search_box?.exclude?.load_value)
375
- if (this.props.ui?.search_box?.exclude?.load_value(table.name, column.name))
376
- return [];
377
- if (column.type === FilterItemColumnType.Boolean)
378
- {
379
- const col = this.getColumns().find(c => c.table.name === table.name && c.name === column.name);
380
- return [true, false].map(b =>
381
- {
382
- const formatted = col ? col.formatter.format(b, col, { value: {} } as any, true) : null;
383
- return { value: String(b), title: formatted != null ? String(formatted) : String(b) };
384
- });
385
- }
386
- let values = await this.props.entity.server.value_list(table.name, column.name, value, null, null);
387
- return values.map(v => { return { value: v, title: v } });
388
- }}
389
- onChanged={this.onFilterBoxChanged}
390
- />
391
- );
392
- }
393
-
394
- private getOrderedColumns(): TableColumnInfo[]
395
- {
396
- const all = this.getColumns();
397
- const vk = this.state.visible_column_keys;
398
- if (vk.length === 0)
399
- return all;
400
- const ordered = vk.map(k => all.find(c => c.table.name + "." + c.name === k)).filter((c): c is TableColumnInfo => !!c);
401
- const rest = all.filter(c => !vk.includes(c.table.name + "." + c.name));
402
- return [...ordered, ...rest];
403
- }
404
-
405
- override render(): ReactNode
406
- {
407
- const filterBoxItems = this.NSFilterBox_Top.current?.getFilterItems() ?? [];
408
- const filterChips = filterBoxItems.length > 0 && (
409
- <>
410
- <NSFilterBoxItems
411
- filterItems={filterBoxItems}
412
- onClearFilterItems={() => this.NSFilterBox_Top.current?.setFilterItems([])}
413
- onRemoveFilterItem={(item) => this.NSFilterBox_Top.current?.removeFilterItem(item)}
414
- />
415
- <NSSpace size={NSSpaceSizeType.MINI} />
416
- </>
417
- );
418
-
419
- const quickFilterBar = this.state.quick_filter_configs.length > 0 && (
420
- <NSAQuickFilterBar
421
- key={this.state.quick_filter_configs.map(c => c.id).join("-")}
422
- ref={this.NSAQuickFilterBar_Ref}
423
- configs={this.state.quick_filter_configs}
424
- initialItems={this.getIncomingQuickItems()}
425
- getValues={async (tableName, columnName, search) =>
426
- {
427
- const values = await this.props.entity.server.value_list(tableName, columnName, search, null, null);
428
- const col = this.getColumns().find(c => c.table.name === tableName && c.name === columnName);
429
- return values.map(v =>
430
- {
431
- const formatted = col ? col.formatter.format(v, col, { value: {} } as any, true) : null;
432
- return { value: v, title: formatted != null ? String(formatted) : v };
433
- });
434
- }}
435
- onChanged={() => this.reloadFromFilters()}
436
- />
437
- );
438
-
439
- return (
440
- <>
441
- <NSTable<RowType>
442
- id={this.props.id}
443
- classList={this.props.classList}
444
- style={this.props.style}
445
- ref={this.NSTable_Main}
446
- name={NamingConvention.lower_case_dash.convert(this.props.entity.name, NamingConvention.Pascal_Case_Space)}
447
- checkbox={this.props.checkbox ?? true}
448
- headerChildren={this.renderFilterHeader()}
449
- buttons={this.buildButtons()}
450
- columns={this.getOrderedColumns()}
451
- getRows={async (page, size, sorts) =>
452
- {
453
- let res: { rows: RowType[], count: number } = { rows: [], count: 0 };
454
- if (this.props.entity.server.list)
455
- res = await this.props.entity.server.list(this.getFilterItems(), page, size, sorts, null);
456
- this.setState({ res });
457
- return res;
458
- }}
459
- getRowKey={(row) => row.value.id.toString()}
460
- sort={{
461
- onSort: () => { this.NSTable_Main.current?.reload(null, null); },
462
- }}
463
- getRowAttributes={(row_value, row_index) => this.props.ui?.getRowAttributes?.(row_value, row_index, this.state.res) ?? {}}
464
- getColumnAttributes={this.props.ui?.getColumnAttributes}
465
- getCellFormattedValue={this.props.ui?.getCellFormattedValue}
466
- onVisibleColumnsChanged={(visible_columns) => this.setState({ visible_column_keys: visible_columns.map(c => c.table + "." + c.column) })}
467
- onSelectedIDsChanged={() => this.props.onSelectionChanged?.()}
468
- >
469
- {filterChips}
470
- {quickFilterBar}
471
- </NSTable>
472
- {
473
- this.state.show_quick_filter_dialog &&
474
- <NSAQuickFilterDialog
475
- configs={this.state.quick_filter_configs}
476
- defaults={this.buildDefaultQuickFilters()}
477
- getColumns={() => this.getColumns()}
478
- typeConverter={(type: string) => new ObjectService(type).getEnum(VariableType, VariableType.Any)}
479
- onSave={configs =>
480
- {
481
- NSACacheService.saveQuickFilters(this.props.entity.name, configs);
482
- this.setState({ quick_filter_configs: configs }, () => this.reloadFromFilters());
483
- }}
484
- onConfirm={configs =>
485
- {
486
- NSACacheService.saveQuickFilters(this.props.entity.name, configs);
487
- this.setState({ quick_filter_configs: configs, show_quick_filter_dialog: false }, () => this.reloadFromFilters());
488
- }}
489
- onClose={() => this.setState({ show_quick_filter_dialog: false })}
490
- />
491
- }
492
- </>
493
- );
494
- }
1
+ import { EncodingOperation, FilterItem, FilterItemColumnType, NamingConvention, ObjectService, SearchOperation, SortItem } from "namirasoft-core";
2
+ import { EntityResolveResponseRow } from "namirasoft-field";
3
+ import { FilterItemColumnTypeBuilder, VariableType } from "namirasoft-schema";
4
+ import { IBaseComponentProps, NSButtonProps, NSFilterBox, NSFilterBoxItems, NSFilterBoxProps_Table, NSSpace, NSSpaceSizeType, NSTable, TableColumnInfo, TableRowInfo } from "namirasoft-site-react";
5
+ import { Component, ReactNode, createRef } from "react";
6
+ import { IEntityInfo } from "../IEntityInfo";
7
+ import { NSACacheService } from "../NSACacheService";
8
+ import { NSAQuickFilterBar } from "./quickfilter/NSAQuickFilterBar";
9
+ import { NSAQuickFilterDialog, QuickFilterConfig } from "./quickfilter/NSAQuickFilterDialog";
10
+
11
+ export interface NSATableUIProps<RowType>
12
+ {
13
+ getRowAttributes?: (row_value: RowType, row_index: number, res: { rows: RowType[]; count: number; } | null) => { [key: string]: any };
14
+ getColumnAttributes?: (column: TableColumnInfo) => { [key: string]: any };
15
+ getCellFormattedValue?: (value: any, column: TableColumnInfo, row: TableRowInfo<RowType>) => any;
16
+ search_box?: {
17
+ exclude?: {
18
+ show?: {
19
+ table?: (table: string) => boolean;
20
+ column?: (table: string, column: string) => boolean;
21
+ },
22
+ load_value?: (table: string, column: string) => boolean;
23
+ }
24
+ };
25
+ }
26
+
27
+ export interface NSATableProps<RowType extends { id: string }, RowTypeInput = RowType> extends IBaseComponentProps
28
+ {
29
+ entity: IEntityInfo<RowType, RowTypeInput>;
30
+ ctf: {
31
+ enabled: boolean;
32
+ rows: EntityResolveResponseRow | null;
33
+ };
34
+ url: { getQuery(name: string, base64?: boolean, remove?: boolean): string };
35
+ ui?: NSATableUIProps<RowType>;
36
+ checkbox?: boolean;
37
+ buttons?: NSButtonProps[];
38
+ onSelectionChanged?: () => void;
39
+ }
40
+
41
+ interface NSATableState<RowType>
42
+ {
43
+ res: { rows: RowType[]; count: number; } | null;
44
+ visible_column_keys: string[];
45
+ quick_filter_configs: QuickFilterConfig[];
46
+ show_quick_filter_dialog: boolean;
47
+ filter_revision: number;
48
+ }
49
+
50
+ export class NSATable<RowType extends { id: string }, RowTypeInput = RowType>
51
+ extends Component<NSATableProps<RowType, RowTypeInput>, NSATableState<RowType>>
52
+ {
53
+ public NSTable_Main = createRef<NSTable<RowType>>();
54
+ public NSFilterBox_Top = createRef<NSFilterBox>();
55
+ public NSAQuickFilterBar_Ref = createRef<NSAQuickFilterBar>();
56
+
57
+ constructor(props: NSATableProps<RowType, RowTypeInput>)
58
+ {
59
+ super(props);
60
+
61
+ const quick_filter_configs = NSACacheService.loadQuickFilters(props.entity.name) ?? this.buildDefaultQuickFilters();
62
+ this.state = {
63
+ res: null,
64
+ visible_column_keys: [],
65
+ quick_filter_configs,
66
+ show_quick_filter_dialog: false,
67
+ filter_revision: 0,
68
+ };
69
+ }
70
+
71
+ override componentDidMount()
72
+ {
73
+ const visible = this.NSTable_Main.current?.getVisibleColumns() ?? [];
74
+ if (visible.length > 0)
75
+ this.setState({ visible_column_keys: visible.map(v => v.table + "." + v.column) });
76
+
77
+ this.setState(prev => ({ filter_revision: prev.filter_revision + 1 }));
78
+ }
79
+
80
+ private getColumns(): TableColumnInfo[]
81
+ {
82
+ let columns = Object.values(this.props.entity.client.getColumns()).flat();
83
+ columns.forEach(col =>
84
+ {
85
+ col.text = NamingConvention.auto.convert(col.text, NamingConvention.Pascal_Case_Space);
86
+ });
87
+ return columns;
88
+ }
89
+
90
+ private buildDefaultQuickFilters(): QuickFilterConfig[]
91
+ {
92
+ const getDefaults = this.props.entity.client.getQuickFilters;
93
+ if (!getDefaults)
94
+ return [];
95
+
96
+ const columns = this.getColumns();
97
+ const ans: QuickFilterConfig[] = [];
98
+ for (const def of getDefaults())
99
+ {
100
+ const col = columns.find(c => c.name === def.column);
101
+ if (!col)
102
+ continue;
103
+ const columnType = new ObjectService(col.type).getEnum(VariableType, VariableType.Any);
104
+ ans.push({
105
+ id: `default-${col.table.name}-${col.name}`,
106
+ title: def.title,
107
+ column: {
108
+ table: { name: col.table.name, text: col.table.text },
109
+ name: col.name,
110
+ text: col.text,
111
+ type: col.type,
112
+ columnType,
113
+ },
114
+ operatorName: (def as { operator?: string }).operator,
115
+ });
116
+ }
117
+ return ans;
118
+ }
119
+
120
+ private filterItemTypeConverter(type: string): FilterItemColumnType
121
+ {
122
+ let t = new ObjectService(type).getEnum(VariableType, VariableType.Any);
123
+ let builder = new FilterItemColumnTypeBuilder(t);
124
+ return builder.runSynch(() => { }) ?? FilterItemColumnType.Unknown;
125
+ }
126
+
127
+ private getIncomingFilterItems(): FilterItem[] | undefined
128
+ {
129
+ try
130
+ {
131
+ let encoded = this.props.url.getQuery("filters");
132
+ if (encoded)
133
+ return FilterItem.decode(encoded) ?? undefined;
134
+ } catch (error)
135
+ {
136
+ }
137
+ return undefined;
138
+ }
139
+
140
+ private itemMatchesQuickFilter(item: FilterItem): boolean
141
+ {
142
+ return this.state.quick_filter_configs.some(c =>
143
+ c.column.table.name === item.table.name && c.column.name === item.column.name);
144
+ }
145
+ private getIncomingBoxItems(): FilterItem[] | undefined
146
+ {
147
+ let items = this.getIncomingFilterItems();
148
+ if (!items)
149
+ return undefined;
150
+ return items.filter(i => !this.itemMatchesQuickFilter(i));
151
+ }
152
+ private getIncomingQuickItems(): FilterItem[]
153
+ {
154
+ let items = this.getIncomingFilterItems();
155
+ if (!items)
156
+ return [];
157
+ return items.filter(i => this.itemMatchesQuickFilter(i));
158
+ }
159
+
160
+ private encodeFilters(items: FilterItem[]): string
161
+ {
162
+ let command = items.map(item =>
163
+ {
164
+ let key = item.operator.name.replace(/\s+/g, "").toLowerCase();
165
+ let values = item.values.map(v => (v ?? "").toString().replace(/;/g, "\\;"));
166
+ return [item.table.name, item.column.name, item.not ? "1" : "0", key, ...values].join(";");
167
+ }).join(";");
168
+ return EncodingOperation.Base64Encode(command);
169
+ }
170
+
171
+ private syncQueryFromFilters()
172
+ {
173
+ let items = this.getFilterItems();
174
+ let url = new URL(window.location.href);
175
+ let encoded = items.length > 0 ? this.encodeFilters(items) : "";
176
+ if (encoded)
177
+ url.searchParams.set("filters", encoded);
178
+ else
179
+ url.searchParams.delete("filters");
180
+ window.history.replaceState({}, "", url.toString());
181
+ }
182
+
183
+ public reload(page: number | null, size: number | null): Promise<void> | undefined
184
+ {
185
+ return this.NSTable_Main.current?.reload(page, size);
186
+ }
187
+ public getSelectedIDs(): string[]
188
+ {
189
+ return this.NSTable_Main.current?.getSelectedIDs() ?? [];
190
+ }
191
+ public getSelectedRows(): RowType[]
192
+ {
193
+ return this.NSTable_Main.current?.getSelectedRows() ?? [];
194
+ }
195
+ public setSelectedIDs(ids: string[], rows: RowType[], callback?: () => void)
196
+ {
197
+ this.NSTable_Main.current?.setSelectedIDs(ids, rows, callback);
198
+ }
199
+ public getSortItems(): SortItem[]
200
+ {
201
+ return this.NSTable_Main.current?.getSortItems() ?? [];
202
+ }
203
+ public setSortItems(items: SortItem[] | null)
204
+ {
205
+ this.NSTable_Main.current?.setSortItems(items);
206
+ }
207
+ public getVisibleColumns(): { table: string, column: string }[]
208
+ {
209
+ return this.NSTable_Main.current?.getVisibleColumns() ?? [];
210
+ }
211
+ public setVisibleColumns(visible_columns: { table: string, column: string }[])
212
+ {
213
+ this.NSTable_Main.current?.setVisibleColumns(visible_columns);
214
+ }
215
+ public getFilterBoxItems(): FilterItem[]
216
+ {
217
+ return this.NSFilterBox_Top.current?.getFilterItems() ?? [];
218
+ }
219
+ public getQuickFilterItems(): FilterItem[]
220
+ {
221
+ return this.NSAQuickFilterBar_Ref.current?.getFilterItems() ?? [];
222
+ }
223
+ public getFilterItems(): FilterItem[]
224
+ {
225
+ return [...this.getFilterBoxItems(), ...this.getQuickFilterItems()];
226
+ }
227
+
228
+ private reloadFromFilters()
229
+ {
230
+ this.syncQueryFromFilters();
231
+ this.NSTable_Main.current?.setSelectedIDs([], []);
232
+ this.NSTable_Main.current?.reload(null, null);
233
+ }
234
+
235
+ private onFilterBoxChanged = () =>
236
+ {
237
+ this.reloadFromFilters();
238
+ this.setState(prev => ({ filter_revision: prev.filter_revision + 1 }));
239
+ };
240
+
241
+ private buildButtons(): NSButtonProps[]
242
+ {
243
+ const buttons: NSButtonProps[] = [
244
+ {
245
+ title: "",
246
+ icon: { src: "https://static.namirasoft.com/image/concept/sliders/blue.svg", alt: "filter" },
247
+ attributes: { title: "Quick Filters" },
248
+ onClick: {
249
+ action: () => this.setState({ show_quick_filter_dialog: true }),
250
+ showLoading: false,
251
+ },
252
+ },
253
+ ];
254
+ return [...buttons, ...(this.props.buttons ?? [])];
255
+ }
256
+
257
+ private renderFilterHeader(): ReactNode
258
+ {
259
+ return (
260
+ <NSFilterBox
261
+ ref={this.NSFilterBox_Top}
262
+ filterItems={this.getIncomingBoxItems()}
263
+ getTables={() =>
264
+ {
265
+ return this.props.entity.tables.map(table =>
266
+ {
267
+ let columns = table.table.getColumns().map(c => ({ id: c.name, ...c, type: this.filterItemTypeConverter(c.type) }));
268
+ columns = columns.filter(c =>
269
+ {
270
+ if (this.props.ui?.search_box?.exclude?.show?.column)
271
+ if (this.props.ui?.search_box?.exclude.show?.column(table.table.name, c.name))
272
+ return false;
273
+ return true;
274
+ });
275
+ return { name: table.table.name, text: table.table.text, columns, required: table.required };
276
+ }).filter(t =>
277
+ {
278
+ if (this.props.ui?.search_box?.exclude?.show?.table)
279
+ if (this.props.ui?.search_box?.exclude.show.table(t.name))
280
+ return false;
281
+ return true;
282
+ });
283
+ }}
284
+ getMoreTables={async () =>
285
+ {
286
+ let ans: NSFilterBoxProps_Table[] = [];
287
+ if (this.props.ctf.enabled)
288
+ try
289
+ {
290
+ if (this.props.ctf.rows?.fields)
291
+ if (this.props.ctf.rows.fields.length > 0)
292
+ {
293
+ let name = this.props.entity.name + "_field";
294
+ ans.push({
295
+ name,
296
+ text: "Fields",
297
+ columns: [{
298
+ id: "field_id",
299
+ name: "field_id",
300
+ text: "ID",
301
+ type: FilterItemColumnType.Unknown,
302
+ getValues: async (search) =>
303
+ {
304
+ return this.props.ctf.rows?.fields?.filter(c => SearchOperation.match(c.id, search)).map(c => { return { value: c.id, title: c.id } }) ?? [];
305
+ }
306
+ }, {
307
+ id: "field_name",
308
+ name: "field_id",
309
+ text: "Name",
310
+ type: FilterItemColumnType.Unknown,
311
+ getValues: async (search) =>
312
+ {
313
+ return this.props.ctf.rows?.fields?.filter(c => SearchOperation.match(c.name, search)).map(c => { return { value: c.id, title: c.name } }) ?? [];
314
+ }
315
+ }, {
316
+ id: "field_value",
317
+ name: "value",
318
+ text: "Value",
319
+ type: FilterItemColumnType.Unknown
320
+ },
321
+ ...this.props.ctf.rows?.fields.map(f =>
322
+ {
323
+ return {
324
+ id: f.id,
325
+ name: f.id,
326
+ text: f.name,
327
+ type: this.filterItemTypeConverter(f.type.type.type),
328
+ getValues: async (search: string) =>
329
+ {
330
+ let values = await this.props.entity.server.value_list(name, "value", search, f.id, null);
331
+ return values.map(v => { return { value: v, title: v } });
332
+ }
333
+ };
334
+ }),],
335
+ required: false
336
+ });
337
+ }
338
+
339
+ if (this.props.ctf.rows?.categories)
340
+ if (this.props.ctf.rows?.categories.length > 0)
341
+ ans.push({
342
+ name: this.props.entity.name + "_category",
343
+ text: "Categories",
344
+ columns: [{
345
+ id: "category_id",
346
+ name: "category_id",
347
+ text: "ID",
348
+ type: FilterItemColumnType.Unknown,
349
+ getValues: async (search) =>
350
+ {
351
+ return this.props.ctf.rows?.categories?.filter(c => SearchOperation.match(c.id, search)).map(c => { return { value: c.id, title: c.id } }) ?? [];
352
+ }
353
+ }, {
354
+ id: "category_name",
355
+ name: "category_id",
356
+ text: "Name",
357
+ type: FilterItemColumnType.Unknown,
358
+ getValues: async (search) =>
359
+ {
360
+ return this.props.ctf.rows?.categories?.filter(c => SearchOperation.match(c.name, search)).map(c => { return { value: c.id, title: c.name } }) ?? [];
361
+ }
362
+ }],
363
+ required: false
364
+ });
365
+
366
+ } catch (error)
367
+ {
368
+ }
369
+ // todo add tags
370
+ return ans;
371
+ }}
372
+ getValues={async (table, column, value) =>
373
+ {
374
+ if (this.props.ui?.search_box?.exclude?.load_value)
375
+ if (this.props.ui?.search_box?.exclude?.load_value(table.name, column.name))
376
+ return [];
377
+ if (column.type === FilterItemColumnType.Boolean)
378
+ {
379
+ const col = this.getColumns().find(c => c.table.name === table.name && c.name === column.name);
380
+ return [true, false].map(b =>
381
+ {
382
+ const formatted = col ? col.formatter.format(b, col, { value: {} } as any, true) : null;
383
+ return { value: String(b), title: formatted != null ? String(formatted) : String(b) };
384
+ });
385
+ }
386
+ let values = await this.props.entity.server.value_list(table.name, column.name, value, null, null);
387
+ return values.map(v => { return { value: v, title: v } });
388
+ }}
389
+ onChanged={this.onFilterBoxChanged}
390
+ />
391
+ );
392
+ }
393
+
394
+ private getOrderedColumns(): TableColumnInfo[]
395
+ {
396
+ const all = this.getColumns();
397
+ const vk = this.state.visible_column_keys;
398
+ if (vk.length === 0)
399
+ return all;
400
+ const ordered = vk.map(k => all.find(c => c.table.name + "." + c.name === k)).filter((c): c is TableColumnInfo => !!c);
401
+ const rest = all.filter(c => !vk.includes(c.table.name + "." + c.name));
402
+ return [...ordered, ...rest];
403
+ }
404
+
405
+ override render(): ReactNode
406
+ {
407
+ const filterBoxItems = this.NSFilterBox_Top.current?.getFilterItems() ?? [];
408
+ const filterChips = filterBoxItems.length > 0 && (
409
+ <>
410
+ <NSFilterBoxItems
411
+ filterItems={filterBoxItems}
412
+ onClearFilterItems={() => this.NSFilterBox_Top.current?.setFilterItems([])}
413
+ onRemoveFilterItem={(item) => this.NSFilterBox_Top.current?.removeFilterItem(item)}
414
+ />
415
+ <NSSpace size={NSSpaceSizeType.MINI} />
416
+ </>
417
+ );
418
+
419
+ const quickFilterBar = this.state.quick_filter_configs.length > 0 && (
420
+ <NSAQuickFilterBar
421
+ key={this.state.quick_filter_configs.map(c => c.id).join("-")}
422
+ ref={this.NSAQuickFilterBar_Ref}
423
+ configs={this.state.quick_filter_configs}
424
+ initialItems={this.getIncomingQuickItems()}
425
+ getValues={async (tableName, columnName, search) =>
426
+ {
427
+ const values = await this.props.entity.server.value_list(tableName, columnName, search, null, null);
428
+ const col = this.getColumns().find(c => c.table.name === tableName && c.name === columnName);
429
+ return values.map(v =>
430
+ {
431
+ const formatted = col ? col.formatter.format(v, col, { value: {} } as any, true) : null;
432
+ return { value: v, title: formatted != null ? String(formatted) : v };
433
+ });
434
+ }}
435
+ onChanged={() => this.reloadFromFilters()}
436
+ />
437
+ );
438
+
439
+ return (
440
+ <>
441
+ <NSTable<RowType>
442
+ id={this.props.id}
443
+ classList={this.props.classList}
444
+ style={this.props.style}
445
+ ref={this.NSTable_Main}
446
+ name={NamingConvention.lower_case_dash.convert(this.props.entity.name, NamingConvention.Pascal_Case_Space)}
447
+ checkbox={this.props.checkbox ?? true}
448
+ headerChildren={this.renderFilterHeader()}
449
+ buttons={this.buildButtons()}
450
+ columns={this.getOrderedColumns()}
451
+ getRows={async (page, size, sorts) =>
452
+ {
453
+ let res: { rows: RowType[], count: number } = { rows: [], count: 0 };
454
+ if (this.props.entity.server.list)
455
+ res = await this.props.entity.server.list(this.getFilterItems(), page, size, sorts, null);
456
+ this.setState({ res });
457
+ return res;
458
+ }}
459
+ getRowKey={(row) => row.value.id.toString()}
460
+ sort={{
461
+ onSort: () => { this.NSTable_Main.current?.reload(null, null); },
462
+ }}
463
+ getRowAttributes={(row_value, row_index) => this.props.ui?.getRowAttributes?.(row_value, row_index, this.state.res) ?? {}}
464
+ getColumnAttributes={this.props.ui?.getColumnAttributes}
465
+ getCellFormattedValue={this.props.ui?.getCellFormattedValue}
466
+ onVisibleColumnsChanged={(visible_columns) => this.setState({ visible_column_keys: visible_columns.map(c => c.table + "." + c.column) })}
467
+ onSelectedIDsChanged={() => this.props.onSelectionChanged?.()}
468
+ >
469
+ {filterChips}
470
+ {quickFilterBar}
471
+ </NSTable>
472
+ {
473
+ this.state.show_quick_filter_dialog &&
474
+ <NSAQuickFilterDialog
475
+ configs={this.state.quick_filter_configs}
476
+ defaults={this.buildDefaultQuickFilters()}
477
+ getColumns={() => this.getColumns()}
478
+ typeConverter={(type: string) => new ObjectService(type).getEnum(VariableType, VariableType.Any)}
479
+ onSave={configs =>
480
+ {
481
+ NSACacheService.saveQuickFilters(this.props.entity.name, configs);
482
+ this.setState({ quick_filter_configs: configs }, () => this.reloadFromFilters());
483
+ }}
484
+ onConfirm={configs =>
485
+ {
486
+ NSACacheService.saveQuickFilters(this.props.entity.name, configs);
487
+ this.setState({ quick_filter_configs: configs, show_quick_filter_dialog: false }, () => this.reloadFromFilters());
488
+ }}
489
+ onClose={() => this.setState({ show_quick_filter_dialog: false })}
490
+ />
491
+ }
492
+ </>
493
+ );
494
+ }
495
495
  }