namirasoft-account-react 1.4.433 → 1.4.435

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