namirasoft-account-react 1.4.430 → 1.4.431
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/.env.template +15 -15
- package/SKILLS.md +514 -514
- package/config-overrides.js +72 -72
- package/dist/App.css +32 -0
- package/dist/App.d.ts +1 -1
- package/dist/UseParams.d.ts +1 -1
- package/dist/components/NSAAccessListDialog.d.ts +2 -2
- package/dist/components/NSAAccessListDialog.module.css +71 -71
- package/dist/components/NSAMasterMenu.d.ts +1 -1
- package/dist/components/NSAMasterMenu.module.css +248 -248
- package/dist/components/NSAMasterMenuItem.d.ts +1 -1
- package/dist/components/NSAMessageListDialog.d.ts +1 -1
- package/dist/components/NSAMessageListDialog.module.css +99 -99
- package/dist/components/NSAProductListDialog.d.ts +1 -1
- package/dist/components/NSAProductListDialog.module.css +44 -44
- package/dist/components/NSAReorderDialog.d.ts +1 -1
- package/dist/components/NSAReorderDialog.module.css +49 -49
- package/dist/components/NSASortDialog.d.ts +1 -1
- package/dist/components/NSAUserDialog.d.ts +1 -1
- package/dist/components/NSAUserDialog.module.css +67 -67
- package/dist/components/NSAWorkspaceListDialog.d.ts +1 -1
- package/dist/components/NSAWorkspaceListDialog.module.css +41 -41
- package/dist/components/NSBoxSecret.d.ts +1 -1
- package/dist/components/NSBoxSecret.module.css +23 -23
- package/dist/components/NSLabelSecret.d.ts +1 -1
- package/dist/components/quickfilter/NSAFilterBoxEnum.module.css +45 -0
- package/dist/components/quickfilter/NSAQuickFilterBar.d.ts +1 -1
- package/dist/components/quickfilter/NSAQuickFilterBar.module.css +20 -0
- package/dist/components/quickfilter/NSAQuickFilterDialog.d.ts +1 -1
- package/dist/components/quickfilter/NSAQuickFilterDialog.module.css +75 -0
- package/dist/index.css +0 -0
- package/dist/layouts/NSALayout.d.ts +1 -1
- package/dist/layouts/NSASectionEdit.d.ts +1 -1
- package/dist/layouts/NSASectionEditTabPage.d.ts +1 -1
- package/dist/layouts/NSASectionEditTabPage.module.css +4 -4
- package/dist/layouts/NSASectionList.d.ts +1 -1
- package/dist/layouts/NSASectionList.module.css +31 -31
- package/dist/layouts/NSASectionView.d.ts +1 -1
- package/dist/layouts/NSASectionViewTabMore.d.ts +1 -1
- package/dist/layouts/NSASectionViewTabPage.d.ts +1 -1
- package/dist/layouts/NSASectionViewTabPage.module.css +47 -47
- package/dist/pages/NSAConsentPage.module.css +26 -26
- package/dist/pages/NSAEmailVerificationPage.d.ts +1 -1
- package/dist/pages/NSAHomePage.d.ts +1 -1
- package/dist/pages/NSAHomePage.module.css +41 -41
- package/dist/pages/NSALoginPage.d.ts +1 -1
- package/dist/pages/NSALoginPage.module.css +26 -26
- package/dist/pages/NSAPhoneVerificationPage.d.ts +1 -1
- package/dist/pages/NSAVerificationPage.d.ts +1 -1
- package/dist/pages/NSAVerificationPage.module.css +31 -31
- package/package.json +94 -94
- package/public/index.html +21 -21
- package/src/App.css +31 -31
- package/src/App.tsx +19 -19
- package/src/CTFRow.ts +7 -7
- package/src/IEntityInfo.ts +33 -33
- package/src/NSACacheService.ts +120 -120
- package/src/NSAFilterOperators.ts +92 -92
- package/src/NSARouterMaker.tsx +139 -139
- package/src/NSARouterMakerConfig.ts +15 -15
- package/src/NSARouterMakerProps.ts +22 -22
- package/src/Router.tsx +45 -45
- package/src/UseParams.tsx +18 -18
- package/src/components/NSAAccessListDialog.module.css +71 -71
- package/src/components/NSAAccessListDialog.tsx +178 -178
- package/src/components/NSAMasterMenu.module.css +248 -248
- package/src/components/NSAMasterMenu.tsx +169 -169
- package/src/components/NSAMasterMenuItem.tsx +250 -250
- package/src/components/NSAMessageListDialog.module.css +99 -99
- package/src/components/NSAMessageListDialog.tsx +141 -141
- package/src/components/NSAProductListDialog.module.css +44 -44
- package/src/components/NSAProductListDialog.tsx +88 -88
- package/src/components/NSAReorderDialog.module.css +49 -49
- package/src/components/NSAReorderDialog.tsx +149 -149
- package/src/components/NSASortDialog.tsx +117 -117
- package/src/components/NSATable.tsx +489 -489
- package/src/components/NSAUserDialog.module.css +67 -67
- package/src/components/NSAUserDialog.tsx +122 -122
- package/src/components/NSAWorkspaceListDialog.module.css +41 -41
- package/src/components/NSAWorkspaceListDialog.tsx +147 -147
- package/src/components/NSBoxSecret.module.css +23 -23
- package/src/components/NSBoxSecret.tsx +258 -258
- package/src/components/NSLabelSecret.tsx +37 -37
- package/src/components/quickfilter/NSAFilterBoxBase.tsx +55 -55
- package/src/components/quickfilter/NSAFilterBoxBoolean.tsx +54 -54
- package/src/components/quickfilter/NSAFilterBoxDate.tsx +104 -104
- package/src/components/quickfilter/NSAFilterBoxDateTime.tsx +105 -105
- package/src/components/quickfilter/NSAFilterBoxEnum.module.css +44 -44
- package/src/components/quickfilter/NSAFilterBoxEnum.tsx +79 -79
- package/src/components/quickfilter/NSAFilterBoxNumber.tsx +136 -136
- package/src/components/quickfilter/NSAFilterBoxString.tsx +81 -81
- package/src/components/quickfilter/NSAFilterBoxTime.tsx +101 -101
- package/src/components/quickfilter/NSAQuickFilterBar.module.css +19 -19
- package/src/components/quickfilter/NSAQuickFilterBar.tsx +114 -114
- package/src/components/quickfilter/NSAQuickFilterDialog.module.css +74 -74
- package/src/components/quickfilter/NSAQuickFilterDialog.tsx +260 -260
- package/src/css.d.ts +13 -13
- package/src/formatters/SecretFormatter.tsx +24 -24
- package/src/index.tsx +24 -24
- package/src/layouts/Actions.ts +145 -145
- package/src/layouts/CFTUtil.ts +18 -18
- package/src/layouts/NSALayout.tsx +841 -841
- package/src/layouts/NSASectionEdit.tsx +260 -260
- package/src/layouts/NSASectionEditTabPage.module.css +4 -4
- package/src/layouts/NSASectionEditTabPage.tsx +250 -250
- package/src/layouts/NSASectionList.module.css +31 -31
- package/src/layouts/NSASectionList.tsx +149 -149
- package/src/layouts/NSASectionView.tsx +100 -100
- package/src/layouts/NSASectionViewTabMore.tsx +77 -77
- package/src/layouts/NSASectionViewTabPage.module.css +47 -47
- package/src/layouts/NSASectionViewTabPage.tsx +419 -419
- package/src/main.ts +46 -46
- package/src/pages/NSAConsentPage.module.css +26 -26
- package/src/pages/NSAConsentPage.tsx +120 -120
- package/src/pages/NSAEmailVerificationPage.tsx +30 -30
- package/src/pages/NSAHomePage.module.css +41 -41
- package/src/pages/NSAHomePage.tsx +102 -102
- package/src/pages/NSALoginPage.module.css +26 -26
- package/src/pages/NSALoginPage.tsx +87 -87
- package/src/pages/NSAPhoneVerificationPage.tsx +94 -94
- package/src/pages/NSAVerificationPage.module.css +31 -31
- package/src/pages/NSAVerificationPage.tsx +186 -186
- package/src/pages/PaymentRequired.tsx +74 -74
- package/tsconfig.json +43 -43
|
@@ -1,251 +1,251 @@
|
|
|
1
|
-
import { CategoryRow, EntityCategoryInputRow, EntityFieldInputRow, EntityTagInputRow, FieldRow } from "namirasoft-field";
|
|
2
|
-
import { IBaseComponentProps, NSBoxBooleans, NSBoxDynamic, NSColumn, NSRepeaterNSTag, NSRow, NSTabPage, NSTabPageTab } from "namirasoft-site-react";
|
|
3
|
-
import { Component, createRef, ReactNode } from "react";
|
|
4
|
-
import { CTFRow } from "../CTFRow";
|
|
5
|
-
import { IEntityInfo } from "../IEntityInfo";
|
|
6
|
-
import { NSARouterMakerProps } from "../NSARouterMakerProps";
|
|
7
|
-
import { CFTUtil } from "./CFTUtil";
|
|
8
|
-
import Styles from "./NSASectionEditTabPage.module.css";
|
|
9
|
-
import { NSASectionViewTabMore } from "./NSASectionViewTabMore";
|
|
10
|
-
|
|
11
|
-
export interface NSASectionEditTabPageUIProps
|
|
12
|
-
{
|
|
13
|
-
edit_tab_page?: IBaseComponentProps;
|
|
14
|
-
tab_main?: IBaseComponentProps;
|
|
15
|
-
extra_tabs?: NSTabPageTab[];
|
|
16
|
-
}
|
|
17
|
-
export interface NSASectionEditTabPageEditorProps<RowType extends { id: string }, RowTypeInput = RowType>
|
|
18
|
-
{
|
|
19
|
-
getInputRow: (row: RowType | null) => RowTypeInput | Promise<RowTypeInput>;
|
|
20
|
-
setRow: (row: RowType) => void;
|
|
21
|
-
}
|
|
22
|
-
export interface NSASectionEditTabPageCustomProps<RowType extends { id: string }, RowTypeInput = RowType>
|
|
23
|
-
{
|
|
24
|
-
ui?: NSASectionEditTabPageUIProps;
|
|
25
|
-
editor: NSASectionEditTabPageEditorProps<RowType, RowTypeInput>;
|
|
26
|
-
onRowLoaded?: (item: RowType) => void;
|
|
27
|
-
children: ReactNode;
|
|
28
|
-
}
|
|
29
|
-
export interface NSASectionEditTabPageProps<RowType extends { id: string }, RowTypeInput = RowType>
|
|
30
|
-
extends NSARouterMakerProps, NSASectionEditTabPageCustomProps<RowType, RowTypeInput>
|
|
31
|
-
{
|
|
32
|
-
entity: IEntityInfo<RowType & { id: string }, RowTypeInput>;
|
|
33
|
-
ctf: {
|
|
34
|
-
enabled: boolean;
|
|
35
|
-
fields: FieldRow[] | null;
|
|
36
|
-
categories: CategoryRow[] | null;
|
|
37
|
-
}
|
|
38
|
-
model: {
|
|
39
|
-
id: string | null;
|
|
40
|
-
row: RowType | null;
|
|
41
|
-
};
|
|
42
|
-
deleteFieldCache: () => void;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
interface NSASectionEditTabPageState<RowType>
|
|
46
|
-
{
|
|
47
|
-
row: RowType | null;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export class NSASectionEditTabPage<RowType extends { id: string }, RowTypeInput = RowType> extends Component<NSASectionEditTabPageProps<RowType, RowTypeInput>, NSASectionEditTabPageState<RowType>>
|
|
51
|
-
{
|
|
52
|
-
private Fields_Refs: { [id: string]: React.RefObject<NSBoxDynamic> } = {};
|
|
53
|
-
private Categories_Refs: { [group: string]: React.RefObject<NSBoxBooleans> } = {};
|
|
54
|
-
private Tags_Refs = createRef<NSRepeaterNSTag>();
|
|
55
|
-
|
|
56
|
-
constructor(props: NSASectionEditTabPageProps<RowType, RowTypeInput>)
|
|
57
|
-
{
|
|
58
|
-
super(props);
|
|
59
|
-
|
|
60
|
-
this.state = { row: props.model.row };
|
|
61
|
-
|
|
62
|
-
if (props.ctf.enabled)
|
|
63
|
-
{
|
|
64
|
-
props.ctf.fields?.forEach(field => this.Fields_Refs[field.id] = createRef<NSBoxDynamic>());
|
|
65
|
-
props.ctf.categories?.forEach(category =>
|
|
66
|
-
{
|
|
67
|
-
if (!this.Categories_Refs[category.group])
|
|
68
|
-
this.Categories_Refs[category.group] = createRef<NSBoxBooleans>()
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
this.reload = this.reload.bind(this);
|
|
73
|
-
this.getRow = this.getRow.bind(this);
|
|
74
|
-
this.setRow = this.setRow.bind(this);
|
|
75
|
-
this.getInputRow = this.getInputRow.bind(this);
|
|
76
|
-
this.getFields = this.getFields.bind(this);
|
|
77
|
-
this.setFields = this.setFields.bind(this);
|
|
78
|
-
}
|
|
79
|
-
reload()
|
|
80
|
-
{
|
|
81
|
-
this.setState(prev => ({ ...prev, row: null }));
|
|
82
|
-
if (this.props.model.id)
|
|
83
|
-
if (this.props.entity.server.get)
|
|
84
|
-
this.props.entity.server.get(this.props.model.id).then(row =>
|
|
85
|
-
{
|
|
86
|
-
this.setRow(row);
|
|
87
|
-
}).catch(() => { });
|
|
88
|
-
}
|
|
89
|
-
getRow()
|
|
90
|
-
{
|
|
91
|
-
return this.state.row;
|
|
92
|
-
}
|
|
93
|
-
setRow(row: RowType)
|
|
94
|
-
{
|
|
95
|
-
this.setState(prev => { return { ...prev, row } }, () =>
|
|
96
|
-
{
|
|
97
|
-
this.props.onRowLoaded?.(row);
|
|
98
|
-
this.props.editor.setRow(row);
|
|
99
|
-
if (this.props.ctf.enabled)
|
|
100
|
-
this.setFields(CFTUtil.get(this.props.entity.name, row));
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
async getInputRow(): Promise<RowTypeInput>
|
|
104
|
-
{
|
|
105
|
-
let row = await this.props.editor.getInputRow(this.state.row);
|
|
106
|
-
if (this.props.ctf.enabled)
|
|
107
|
-
CFTUtil.set(this.props.entity.name, row, this.getFields());
|
|
108
|
-
return row;
|
|
109
|
-
}
|
|
110
|
-
private getFields(): CTFRow
|
|
111
|
-
{
|
|
112
|
-
let fields: EntityFieldInputRow[] = [];
|
|
113
|
-
let categories: EntityCategoryInputRow[] = [];
|
|
114
|
-
let tags: EntityTagInputRow[] = [];
|
|
115
|
-
|
|
116
|
-
if (this.props.ctf.fields)
|
|
117
|
-
for (let field of this.props.ctf.fields)
|
|
118
|
-
{
|
|
119
|
-
let ref = this.Fields_Refs[field.id];
|
|
120
|
-
if (ref.current)
|
|
121
|
-
fields.push({ field_id: field.id, value: ref.current.getValue() });
|
|
122
|
-
}
|
|
123
|
-
for (let group in this.Categories_Refs)
|
|
124
|
-
{
|
|
125
|
-
let ref = this.Categories_Refs[group];
|
|
126
|
-
if (ref.current)
|
|
127
|
-
categories.push(...ref.current?.getValues().map(x => { return { category_id: x } }));
|
|
128
|
-
}
|
|
129
|
-
if (this.Tags_Refs.current)
|
|
130
|
-
tags = this.Tags_Refs.current.getValue().map(x => { return { name: x.name, value: x.value } });
|
|
131
|
-
|
|
132
|
-
return { categories, fields, tags };
|
|
133
|
-
}
|
|
134
|
-
private setFields(ctf: CTFRow)
|
|
135
|
-
{
|
|
136
|
-
for (let field of ctf.fields)
|
|
137
|
-
{
|
|
138
|
-
let ref = this.Fields_Refs[field.field_id];
|
|
139
|
-
if (ref?.current)
|
|
140
|
-
ref.current.setValue(field.value);
|
|
141
|
-
}
|
|
142
|
-
for (let key of Object.keys(this.Categories_Refs))
|
|
143
|
-
{
|
|
144
|
-
let ref = this.Categories_Refs[key];
|
|
145
|
-
if (ref.current)
|
|
146
|
-
ref.current.setValues(ctf.categories.map(x => x.category_id));
|
|
147
|
-
}
|
|
148
|
-
if (this.Tags_Refs.current)
|
|
149
|
-
this.Tags_Refs.current.setValue(ctf.tags.map(x => { return { name: x.name, value: x.value ?? "" } }));
|
|
150
|
-
}
|
|
151
|
-
override componentDidMount()
|
|
152
|
-
{
|
|
153
|
-
if (this.props.model.id)
|
|
154
|
-
if (!this.props.model.row || this.props.model.row.id !== this.props.model.id)
|
|
155
|
-
{
|
|
156
|
-
this.reload();
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
if (this.props.model.row)
|
|
160
|
-
this.setRow(this.props.model.row);
|
|
161
|
-
}
|
|
162
|
-
override render()
|
|
163
|
-
{
|
|
164
|
-
let groups_fields = Array.from(new Set(this.props.ctf.fields?.map(x => x.group) ?? []));
|
|
165
|
-
let groups_categories = Array.from(new Set(this.props.ctf.categories?.map(x => x.group) ?? []));
|
|
166
|
-
|
|
167
|
-
let tabs: NSTabPageTab[] = [{
|
|
168
|
-
title: "General",
|
|
169
|
-
clicked: true,
|
|
170
|
-
getContent: () => <NSColumn
|
|
171
|
-
{...this.props.ui?.tab_main}
|
|
172
|
-
>
|
|
173
|
-
{this.props.children}
|
|
174
|
-
</NSColumn>
|
|
175
|
-
}];
|
|
176
|
-
this.props.ui?.extra_tabs?.forEach(tab => tabs.push(tab));
|
|
177
|
-
if (this.props.ctf.enabled)
|
|
178
|
-
{
|
|
179
|
-
groups_fields.forEach(group =>
|
|
180
|
-
{
|
|
181
|
-
tabs.push({
|
|
182
|
-
title: group,
|
|
183
|
-
clicked: true,
|
|
184
|
-
getContent: () => <NSColumn
|
|
185
|
-
classList={[`${Styles.nsa_section_edit_tab_page}`]}
|
|
186
|
-
>
|
|
187
|
-
<NSRow>
|
|
188
|
-
{
|
|
189
|
-
this.props.ctf.fields?.filter(x => x.group === group).map((field, index) =>
|
|
190
|
-
<NSBoxDynamic
|
|
191
|
-
key={`NSASectionViewTabPage_NSBoxDynamic_${index}`}
|
|
192
|
-
ref={this.Fields_Refs[field.id]}
|
|
193
|
-
name={field.id}
|
|
194
|
-
title={field.name}
|
|
195
|
-
variable={field.type}
|
|
196
|
-
/>
|
|
197
|
-
)
|
|
198
|
-
}
|
|
199
|
-
</NSRow>
|
|
200
|
-
</NSColumn>
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
groups_categories.forEach(group =>
|
|
204
|
-
{
|
|
205
|
-
let items = this.props.ctf.categories?.filter(x => x.group === group).map(category => { return { value: category.id, text: category.name } }) ?? [];
|
|
206
|
-
tabs.push({
|
|
207
|
-
title: group,
|
|
208
|
-
clicked: true,
|
|
209
|
-
getContent: () => <NSColumn
|
|
210
|
-
classList={[`${Styles.nsa_section_edit_tab_page}`]}
|
|
211
|
-
>
|
|
212
|
-
<NSRow>
|
|
213
|
-
<NSBoxBooleans
|
|
214
|
-
ref={this.Categories_Refs[group]}
|
|
215
|
-
box_all={{ hideHeader: true }}
|
|
216
|
-
items={items}
|
|
217
|
-
></NSBoxBooleans>
|
|
218
|
-
</NSRow>
|
|
219
|
-
</NSColumn>
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
tabs.push({
|
|
223
|
-
title: "Tags",
|
|
224
|
-
clicked: true,
|
|
225
|
-
getContent: () => <NSColumn
|
|
226
|
-
classList={[`${Styles.nsa_section_edit_tab_page}`]}
|
|
227
|
-
>
|
|
228
|
-
<NSRepeaterNSTag
|
|
229
|
-
ref={this.Tags_Refs}
|
|
230
|
-
name="Tags"
|
|
231
|
-
title="Tags"
|
|
232
|
-
required={false}
|
|
233
|
-
/>
|
|
234
|
-
</NSColumn>
|
|
235
|
-
});
|
|
236
|
-
tabs.push({
|
|
237
|
-
title: "More",
|
|
238
|
-
clicked: true,
|
|
239
|
-
getContent: () => <NSASectionViewTabMore
|
|
240
|
-
deleteFieldCache={this.props.deleteFieldCache}
|
|
241
|
-
/>
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
return (
|
|
245
|
-
<NSTabPage
|
|
246
|
-
{...this.props.ui?.edit_tab_page}
|
|
247
|
-
tabs={tabs}
|
|
248
|
-
/>
|
|
249
|
-
);
|
|
250
|
-
}
|
|
1
|
+
import { CategoryRow, EntityCategoryInputRow, EntityFieldInputRow, EntityTagInputRow, FieldRow } from "namirasoft-field";
|
|
2
|
+
import { IBaseComponentProps, NSBoxBooleans, NSBoxDynamic, NSColumn, NSRepeaterNSTag, NSRow, NSTabPage, NSTabPageTab } from "namirasoft-site-react";
|
|
3
|
+
import { Component, createRef, ReactNode } from "react";
|
|
4
|
+
import { CTFRow } from "../CTFRow";
|
|
5
|
+
import { IEntityInfo } from "../IEntityInfo";
|
|
6
|
+
import { NSARouterMakerProps } from "../NSARouterMakerProps";
|
|
7
|
+
import { CFTUtil } from "./CFTUtil";
|
|
8
|
+
import Styles from "./NSASectionEditTabPage.module.css";
|
|
9
|
+
import { NSASectionViewTabMore } from "./NSASectionViewTabMore";
|
|
10
|
+
|
|
11
|
+
export interface NSASectionEditTabPageUIProps
|
|
12
|
+
{
|
|
13
|
+
edit_tab_page?: IBaseComponentProps;
|
|
14
|
+
tab_main?: IBaseComponentProps;
|
|
15
|
+
extra_tabs?: NSTabPageTab[];
|
|
16
|
+
}
|
|
17
|
+
export interface NSASectionEditTabPageEditorProps<RowType extends { id: string }, RowTypeInput = RowType>
|
|
18
|
+
{
|
|
19
|
+
getInputRow: (row: RowType | null) => RowTypeInput | Promise<RowTypeInput>;
|
|
20
|
+
setRow: (row: RowType) => void;
|
|
21
|
+
}
|
|
22
|
+
export interface NSASectionEditTabPageCustomProps<RowType extends { id: string }, RowTypeInput = RowType>
|
|
23
|
+
{
|
|
24
|
+
ui?: NSASectionEditTabPageUIProps;
|
|
25
|
+
editor: NSASectionEditTabPageEditorProps<RowType, RowTypeInput>;
|
|
26
|
+
onRowLoaded?: (item: RowType) => void;
|
|
27
|
+
children: ReactNode;
|
|
28
|
+
}
|
|
29
|
+
export interface NSASectionEditTabPageProps<RowType extends { id: string }, RowTypeInput = RowType>
|
|
30
|
+
extends NSARouterMakerProps, NSASectionEditTabPageCustomProps<RowType, RowTypeInput>
|
|
31
|
+
{
|
|
32
|
+
entity: IEntityInfo<RowType & { id: string }, RowTypeInput>;
|
|
33
|
+
ctf: {
|
|
34
|
+
enabled: boolean;
|
|
35
|
+
fields: FieldRow[] | null;
|
|
36
|
+
categories: CategoryRow[] | null;
|
|
37
|
+
}
|
|
38
|
+
model: {
|
|
39
|
+
id: string | null;
|
|
40
|
+
row: RowType | null;
|
|
41
|
+
};
|
|
42
|
+
deleteFieldCache: () => void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface NSASectionEditTabPageState<RowType>
|
|
46
|
+
{
|
|
47
|
+
row: RowType | null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export class NSASectionEditTabPage<RowType extends { id: string }, RowTypeInput = RowType> extends Component<NSASectionEditTabPageProps<RowType, RowTypeInput>, NSASectionEditTabPageState<RowType>>
|
|
51
|
+
{
|
|
52
|
+
private Fields_Refs: { [id: string]: React.RefObject<NSBoxDynamic> } = {};
|
|
53
|
+
private Categories_Refs: { [group: string]: React.RefObject<NSBoxBooleans> } = {};
|
|
54
|
+
private Tags_Refs = createRef<NSRepeaterNSTag>();
|
|
55
|
+
|
|
56
|
+
constructor(props: NSASectionEditTabPageProps<RowType, RowTypeInput>)
|
|
57
|
+
{
|
|
58
|
+
super(props);
|
|
59
|
+
|
|
60
|
+
this.state = { row: props.model.row };
|
|
61
|
+
|
|
62
|
+
if (props.ctf.enabled)
|
|
63
|
+
{
|
|
64
|
+
props.ctf.fields?.forEach(field => this.Fields_Refs[field.id] = createRef<NSBoxDynamic>());
|
|
65
|
+
props.ctf.categories?.forEach(category =>
|
|
66
|
+
{
|
|
67
|
+
if (!this.Categories_Refs[category.group])
|
|
68
|
+
this.Categories_Refs[category.group] = createRef<NSBoxBooleans>()
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
this.reload = this.reload.bind(this);
|
|
73
|
+
this.getRow = this.getRow.bind(this);
|
|
74
|
+
this.setRow = this.setRow.bind(this);
|
|
75
|
+
this.getInputRow = this.getInputRow.bind(this);
|
|
76
|
+
this.getFields = this.getFields.bind(this);
|
|
77
|
+
this.setFields = this.setFields.bind(this);
|
|
78
|
+
}
|
|
79
|
+
reload()
|
|
80
|
+
{
|
|
81
|
+
this.setState(prev => ({ ...prev, row: null }));
|
|
82
|
+
if (this.props.model.id)
|
|
83
|
+
if (this.props.entity.server.get)
|
|
84
|
+
this.props.entity.server.get(this.props.model.id).then(row =>
|
|
85
|
+
{
|
|
86
|
+
this.setRow(row);
|
|
87
|
+
}).catch(() => { });
|
|
88
|
+
}
|
|
89
|
+
getRow()
|
|
90
|
+
{
|
|
91
|
+
return this.state.row;
|
|
92
|
+
}
|
|
93
|
+
setRow(row: RowType)
|
|
94
|
+
{
|
|
95
|
+
this.setState(prev => { return { ...prev, row } }, () =>
|
|
96
|
+
{
|
|
97
|
+
this.props.onRowLoaded?.(row);
|
|
98
|
+
this.props.editor.setRow(row);
|
|
99
|
+
if (this.props.ctf.enabled)
|
|
100
|
+
this.setFields(CFTUtil.get(this.props.entity.name, row));
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
async getInputRow(): Promise<RowTypeInput>
|
|
104
|
+
{
|
|
105
|
+
let row = await this.props.editor.getInputRow(this.state.row);
|
|
106
|
+
if (this.props.ctf.enabled)
|
|
107
|
+
CFTUtil.set(this.props.entity.name, row, this.getFields());
|
|
108
|
+
return row;
|
|
109
|
+
}
|
|
110
|
+
private getFields(): CTFRow
|
|
111
|
+
{
|
|
112
|
+
let fields: EntityFieldInputRow[] = [];
|
|
113
|
+
let categories: EntityCategoryInputRow[] = [];
|
|
114
|
+
let tags: EntityTagInputRow[] = [];
|
|
115
|
+
|
|
116
|
+
if (this.props.ctf.fields)
|
|
117
|
+
for (let field of this.props.ctf.fields)
|
|
118
|
+
{
|
|
119
|
+
let ref = this.Fields_Refs[field.id];
|
|
120
|
+
if (ref.current)
|
|
121
|
+
fields.push({ field_id: field.id, value: ref.current.getValue() });
|
|
122
|
+
}
|
|
123
|
+
for (let group in this.Categories_Refs)
|
|
124
|
+
{
|
|
125
|
+
let ref = this.Categories_Refs[group];
|
|
126
|
+
if (ref.current)
|
|
127
|
+
categories.push(...ref.current?.getValues().map(x => { return { category_id: x } }));
|
|
128
|
+
}
|
|
129
|
+
if (this.Tags_Refs.current)
|
|
130
|
+
tags = this.Tags_Refs.current.getValue().map(x => { return { name: x.name, value: x.value } });
|
|
131
|
+
|
|
132
|
+
return { categories, fields, tags };
|
|
133
|
+
}
|
|
134
|
+
private setFields(ctf: CTFRow)
|
|
135
|
+
{
|
|
136
|
+
for (let field of ctf.fields)
|
|
137
|
+
{
|
|
138
|
+
let ref = this.Fields_Refs[field.field_id];
|
|
139
|
+
if (ref?.current)
|
|
140
|
+
ref.current.setValue(field.value);
|
|
141
|
+
}
|
|
142
|
+
for (let key of Object.keys(this.Categories_Refs))
|
|
143
|
+
{
|
|
144
|
+
let ref = this.Categories_Refs[key];
|
|
145
|
+
if (ref.current)
|
|
146
|
+
ref.current.setValues(ctf.categories.map(x => x.category_id));
|
|
147
|
+
}
|
|
148
|
+
if (this.Tags_Refs.current)
|
|
149
|
+
this.Tags_Refs.current.setValue(ctf.tags.map(x => { return { name: x.name, value: x.value ?? "" } }));
|
|
150
|
+
}
|
|
151
|
+
override componentDidMount()
|
|
152
|
+
{
|
|
153
|
+
if (this.props.model.id)
|
|
154
|
+
if (!this.props.model.row || this.props.model.row.id !== this.props.model.id)
|
|
155
|
+
{
|
|
156
|
+
this.reload();
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (this.props.model.row)
|
|
160
|
+
this.setRow(this.props.model.row);
|
|
161
|
+
}
|
|
162
|
+
override render()
|
|
163
|
+
{
|
|
164
|
+
let groups_fields = Array.from(new Set(this.props.ctf.fields?.map(x => x.group) ?? []));
|
|
165
|
+
let groups_categories = Array.from(new Set(this.props.ctf.categories?.map(x => x.group) ?? []));
|
|
166
|
+
|
|
167
|
+
let tabs: NSTabPageTab[] = [{
|
|
168
|
+
title: "General",
|
|
169
|
+
clicked: true,
|
|
170
|
+
getContent: () => <NSColumn
|
|
171
|
+
{...this.props.ui?.tab_main}
|
|
172
|
+
>
|
|
173
|
+
{this.props.children}
|
|
174
|
+
</NSColumn>
|
|
175
|
+
}];
|
|
176
|
+
this.props.ui?.extra_tabs?.forEach(tab => tabs.push(tab));
|
|
177
|
+
if (this.props.ctf.enabled)
|
|
178
|
+
{
|
|
179
|
+
groups_fields.forEach(group =>
|
|
180
|
+
{
|
|
181
|
+
tabs.push({
|
|
182
|
+
title: group,
|
|
183
|
+
clicked: true,
|
|
184
|
+
getContent: () => <NSColumn
|
|
185
|
+
classList={[`${Styles.nsa_section_edit_tab_page}`]}
|
|
186
|
+
>
|
|
187
|
+
<NSRow>
|
|
188
|
+
{
|
|
189
|
+
this.props.ctf.fields?.filter(x => x.group === group).map((field, index) =>
|
|
190
|
+
<NSBoxDynamic
|
|
191
|
+
key={`NSASectionViewTabPage_NSBoxDynamic_${index}`}
|
|
192
|
+
ref={this.Fields_Refs[field.id]}
|
|
193
|
+
name={field.id}
|
|
194
|
+
title={field.name}
|
|
195
|
+
variable={field.type}
|
|
196
|
+
/>
|
|
197
|
+
)
|
|
198
|
+
}
|
|
199
|
+
</NSRow>
|
|
200
|
+
</NSColumn>
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
groups_categories.forEach(group =>
|
|
204
|
+
{
|
|
205
|
+
let items = this.props.ctf.categories?.filter(x => x.group === group).map(category => { return { value: category.id, text: category.name } }) ?? [];
|
|
206
|
+
tabs.push({
|
|
207
|
+
title: group,
|
|
208
|
+
clicked: true,
|
|
209
|
+
getContent: () => <NSColumn
|
|
210
|
+
classList={[`${Styles.nsa_section_edit_tab_page}`]}
|
|
211
|
+
>
|
|
212
|
+
<NSRow>
|
|
213
|
+
<NSBoxBooleans
|
|
214
|
+
ref={this.Categories_Refs[group]}
|
|
215
|
+
box_all={{ hideHeader: true }}
|
|
216
|
+
items={items}
|
|
217
|
+
></NSBoxBooleans>
|
|
218
|
+
</NSRow>
|
|
219
|
+
</NSColumn>
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
tabs.push({
|
|
223
|
+
title: "Tags",
|
|
224
|
+
clicked: true,
|
|
225
|
+
getContent: () => <NSColumn
|
|
226
|
+
classList={[`${Styles.nsa_section_edit_tab_page}`]}
|
|
227
|
+
>
|
|
228
|
+
<NSRepeaterNSTag
|
|
229
|
+
ref={this.Tags_Refs}
|
|
230
|
+
name="Tags"
|
|
231
|
+
title="Tags"
|
|
232
|
+
required={false}
|
|
233
|
+
/>
|
|
234
|
+
</NSColumn>
|
|
235
|
+
});
|
|
236
|
+
tabs.push({
|
|
237
|
+
title: "More",
|
|
238
|
+
clicked: true,
|
|
239
|
+
getContent: () => <NSASectionViewTabMore
|
|
240
|
+
deleteFieldCache={this.props.deleteFieldCache}
|
|
241
|
+
/>
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
return (
|
|
245
|
+
<NSTabPage
|
|
246
|
+
{...this.props.ui?.edit_tab_page}
|
|
247
|
+
tabs={tabs}
|
|
248
|
+
/>
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
251
|
}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
.nsa_section_list_btn {
|
|
2
|
-
width: 48px;
|
|
3
|
-
border: 1px solid #a0a0a0;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.nsa_section_list_btn img {
|
|
7
|
-
width: 24px;
|
|
8
|
-
height: 24px;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.nsa_section_list_actions {
|
|
12
|
-
display: flex;
|
|
13
|
-
flex-direction: row;
|
|
14
|
-
flex-wrap: nowrap;
|
|
15
|
-
justify-content: flex-end;
|
|
16
|
-
align-items: center;
|
|
17
|
-
gap: 8px;
|
|
18
|
-
flex-shrink: 0;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@media screen and (min-width: 992px) {
|
|
22
|
-
.nsa_table {
|
|
23
|
-
display: flex;
|
|
24
|
-
flex-direction: column;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.nsa_table table {
|
|
28
|
-
flex: 1 1 auto;
|
|
29
|
-
min-height: 0;
|
|
30
|
-
max-height: none;
|
|
31
|
-
}
|
|
1
|
+
.nsa_section_list_btn {
|
|
2
|
+
width: 48px;
|
|
3
|
+
border: 1px solid #a0a0a0;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.nsa_section_list_btn img {
|
|
7
|
+
width: 24px;
|
|
8
|
+
height: 24px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.nsa_section_list_actions {
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: row;
|
|
14
|
+
flex-wrap: nowrap;
|
|
15
|
+
justify-content: flex-end;
|
|
16
|
+
align-items: center;
|
|
17
|
+
gap: 8px;
|
|
18
|
+
flex-shrink: 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@media screen and (min-width: 992px) {
|
|
22
|
+
.nsa_table {
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.nsa_table table {
|
|
28
|
+
flex: 1 1 auto;
|
|
29
|
+
min-height: 0;
|
|
30
|
+
max-height: none;
|
|
31
|
+
}
|
|
32
32
|
}
|