namirasoft-account-react 1.5.13 → 1.5.15
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/dist/App.d.ts +2 -2
- package/dist/FieldCacheService.d.ts +14 -1
- package/dist/FieldCacheService.js +28 -2
- package/dist/FieldCacheService.js.map +1 -1
- package/dist/NSARouterMaker.d.ts +7 -12
- package/dist/NSARouterMaker.js +29 -35
- package/dist/NSARouterMaker.js.map +1 -1
- package/dist/NSARouterMakerProps.d.ts +17 -23
- package/dist/NSARouterMakerResult.d.ts +26 -0
- package/dist/NSARouterMakerResult.js +2 -0
- package/dist/NSARouterMakerResult.js.map +1 -0
- package/dist/NSFRouterMaker.d.ts +10 -0
- package/dist/NSFRouterMaker.js +27 -0
- package/dist/NSFRouterMaker.js.map +1 -0
- package/dist/Router.d.ts +1 -1
- package/dist/Router.js +5 -11
- package/dist/Router.js.map +1 -1
- package/dist/components/NSAAccessListDialog.d.ts +2 -2
- package/dist/components/NSABoxSecret.d.ts +2 -2
- package/dist/components/NSAMasterMenu.d.ts +2 -2
- package/dist/components/NSAMasterMenuItem.d.ts +2 -2
- package/dist/components/NSAMessageListDialog.d.ts +4 -4
- package/dist/components/NSAMessageListDialog.js +2 -2
- package/dist/components/NSAMessageListDialog.js.map +1 -1
- package/dist/components/NSAProductListDialog.d.ts +2 -2
- package/dist/components/NSATable.d.ts +0 -3
- package/dist/components/NSATable.js +3 -34
- package/dist/components/NSATable.js.map +1 -1
- package/dist/components/NSAUserDialog.d.ts +2 -2
- package/dist/components/NSAWorkspaceListDialog.d.ts +2 -2
- package/dist/components/NSFBoxCategoryScope.d.ts +2 -2
- package/dist/components/NSFBoxSlot.d.ts +2 -2
- package/dist/layouts/Actions.d.ts +6 -6
- package/dist/layouts/Actions.js.map +1 -1
- package/dist/layouts/NSALayout.d.ts +2 -7
- package/dist/layouts/NSALayout.js +88 -86
- package/dist/layouts/NSALayout.js.map +1 -1
- package/dist/layouts/NSASectionEdit.d.ts +3 -4
- package/dist/layouts/NSASectionEdit.js.map +1 -1
- package/dist/layouts/NSASectionEditTabPage.d.ts +2 -3
- package/dist/layouts/NSASectionEditTabPage.js +1 -1
- package/dist/layouts/NSASectionEditTabPage.js.map +1 -1
- package/dist/layouts/NSASectionList.d.ts +2 -3
- package/dist/layouts/NSASectionList.js.map +1 -1
- package/dist/layouts/NSASectionView.d.ts +2 -3
- package/dist/layouts/NSASectionView.js.map +1 -1
- package/dist/layouts/NSASectionViewTabMore.d.ts +2 -2
- package/dist/layouts/NSASectionViewTabMore.js +3 -2
- package/dist/layouts/NSASectionViewTabMore.js.map +1 -1
- package/dist/layouts/NSASectionViewTabPage.d.ts +2 -3
- package/dist/layouts/NSASectionViewTabPage.js +1 -1
- package/dist/layouts/NSASectionViewTabPage.js.map +1 -1
- package/dist/main.d.ts +2 -4
- package/dist/main.js +2 -4
- package/dist/main.js.map +1 -1
- package/dist/pages/NSAConsentPage.d.ts +2 -2
- package/dist/pages/NSAEmailVerificationPage.d.ts +2 -2
- package/dist/pages/NSAHomePage.d.ts +3 -3
- package/dist/pages/NSAHomePage.js +5 -5
- package/dist/pages/NSAHomePage.js.map +1 -1
- package/dist/pages/NSAPhoneVerificationPage.d.ts +2 -2
- package/dist/pages/NSAPhoneVerificationPage.js +1 -1
- package/dist/pages/NSAPhoneVerificationPage.js.map +1 -1
- package/dist/pages/NSAVerificationPage.d.ts +3 -3
- package/dist/pages/NSAVerificationPage.js +2 -3
- package/dist/pages/NSAVerificationPage.js.map +1 -1
- package/dist/pages/NSFCategoryEditPage.d.ts +2 -2
- package/dist/pages/NSFCategoryListPage.d.ts +2 -2
- package/dist/pages/NSFCategoryViewPage.d.ts +2 -2
- package/dist/pages/NSFEntities.d.ts +2 -2
- package/dist/pages/NSFEntities.js.map +1 -1
- package/dist/pages/PaymentRequired.d.ts +2 -2
- package/dist/pages/PaymentRequired.js.map +1 -1
- package/package.json +2 -2
- package/src/App.tsx +2 -2
- package/src/FieldCacheService.tsx +85 -0
- package/src/NSARouterMaker.tsx +38 -45
- package/src/NSARouterMakerProps.ts +19 -21
- package/src/NSARouterMakerResult.ts +25 -0
- package/src/NSFRouterMaker.tsx +37 -0
- package/src/Router.tsx +15 -12
- package/src/components/NSAAccessListDialog.tsx +2 -2
- package/src/components/NSABoxSecret.tsx +2 -2
- package/src/components/NSAMasterMenu.tsx +6 -6
- package/src/components/NSAMasterMenuItem.tsx +2 -2
- package/src/components/NSAMessageListDialog.tsx +4 -4
- package/src/components/NSAProductListDialog.tsx +2 -2
- package/src/components/NSATable.tsx +3 -54
- package/src/components/NSAUserDialog.tsx +2 -2
- package/src/components/NSAWorkspaceListDialog.tsx +2 -2
- package/src/components/NSFBoxCategoryScope.tsx +2 -2
- package/src/components/NSFBoxSlot.tsx +2 -2
- package/src/layouts/Actions.ts +6 -6
- package/src/layouts/NSALayout.tsx +159 -161
- package/src/layouts/NSASectionEdit.tsx +3 -4
- package/src/layouts/NSASectionEditTabPage.tsx +3 -4
- package/src/layouts/NSASectionList.tsx +2 -3
- package/src/layouts/NSASectionView.tsx +2 -3
- package/src/layouts/NSASectionViewTabMore.tsx +8 -7
- package/src/layouts/NSASectionViewTabPage.tsx +3 -4
- package/src/main.ts +2 -4
- package/src/pages/NSAConsentPage.tsx +2 -2
- package/src/pages/NSAEmailVerificationPage.tsx +2 -2
- package/src/pages/NSAHomePage.tsx +23 -22
- package/src/pages/NSAPhoneVerificationPage.tsx +3 -3
- package/src/pages/NSAVerificationPage.tsx +4 -5
- package/src/pages/NSFCategoryEditPage.tsx +2 -2
- package/src/pages/NSFCategoryListPage.tsx +2 -2
- package/src/pages/NSFCategoryViewPage.tsx +2 -2
- package/src/pages/NSFEntities.ts +2 -2
- package/src/pages/PaymentRequired.tsx +5 -5
- package/dist/App.css +0 -32
- package/dist/NSARouter.d.ts +0 -16
- package/dist/NSARouter.js +0 -42
- package/dist/NSARouter.js.map +0 -1
- package/dist/NSARouterMakerConfig.d.ts +0 -14
- package/dist/NSARouterMakerConfig.js +0 -2
- package/dist/NSARouterMakerConfig.js.map +0 -1
- package/dist/components/NSAReorderDialog.d.ts +0 -30
- package/dist/components/NSAReorderDialog.js +0 -69
- package/dist/components/NSAReorderDialog.js.map +0 -1
- package/dist/components/NSAReorderDialog.module.css +0 -50
- package/dist/components/NSASortDialog.d.ts +0 -21
- package/dist/components/NSASortDialog.js +0 -61
- package/dist/components/NSASortDialog.js.map +0 -1
- package/dist/layouts/NSARouter.d.ts +0 -16
- package/dist/layouts/NSARouter.js +0 -38
- package/dist/layouts/NSARouter.js.map +0 -1
- package/dist/layouts/NSARouter_Field.d.ts +0 -8
- package/dist/layouts/NSARouter_Field.js +0 -92
- package/dist/layouts/NSARouter_Field.js.map +0 -1
- package/src/App.css +0 -32
- package/src/FieldCacheService.ts +0 -37
- package/src/NSARouter.tsx +0 -69
- package/src/NSARouterMakerConfig.ts +0 -16
- package/src/components/NSAReorderDialog.module.css +0 -50
- package/src/components/NSAReorderDialog.tsx +0 -150
- package/src/components/NSASortDialog.tsx +0 -118
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { SlotEntityType } from 'namirasoft-field';
|
|
3
|
-
import { NSRoutes } from 'namirasoft-site-react';
|
|
4
|
-
import { Component } from 'react';
|
|
5
|
-
import { Route } from 'react-router-dom';
|
|
6
|
-
import { FieldCacheService } from '../FieldCacheService';
|
|
7
|
-
import { NSFRoutes } from '../NSFRoutes';
|
|
8
|
-
import { NSFCategoryEditPage } from '../pages/NSFCategoryEditPage';
|
|
9
|
-
import { NSFCategoryListPage } from '../pages/NSFCategoryListPage';
|
|
10
|
-
import { NSFCategoryViewPage } from '../pages/NSFCategoryViewPage';
|
|
11
|
-
export class NSARouter extends Component {
|
|
12
|
-
constructor(props) {
|
|
13
|
-
super(props);
|
|
14
|
-
this.cache_field = FieldCacheService.get(this.props.account.token_manager, this.props.product_id, this.props.notifier.onError);
|
|
15
|
-
this.state = {
|
|
16
|
-
rows: null,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
componentDidMount() {
|
|
20
|
-
this.cache_field.get().then(rows => {
|
|
21
|
-
this.setState(prev => (Object.assign(Object.assign({}, prev), { rows })));
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
render() {
|
|
25
|
-
var _a;
|
|
26
|
-
const { rows } = this.state;
|
|
27
|
-
const scope_slots = (_a = rows === null || rows === void 0 ? void 0 : rows.slots.filter(s => s.entity_type === SlotEntityType.CategoryScope)) !== null && _a !== void 0 ? _a : [];
|
|
28
|
-
let pairs = scope_slots.map(slot => ({ slot, category_scope: rows === null || rows === void 0 ? void 0 : rows.category_scopes.find(c => c.id === slot.entity_id) })).filter(i => i.category_scope);
|
|
29
|
-
return (_jsxs(NSRoutes, { children: [this.props.children, pairs.flatMap(({ slot, category_scope }) => [
|
|
30
|
-
_jsx(Route, { path: NSFRoutes.CategoryList(slot.id, slot.name), element: _jsx(NSFCategoryListPage, Object.assign({}, this.props, { slot: slot, category_scope: category_scope })) }, `${slot.id}-category-list`),
|
|
31
|
-
_jsx(Route, { path: NSFRoutes.CategoryNew(slot.id, slot.name), element: _jsx(NSFCategoryEditPage, Object.assign({}, this.props, { isEdit: false, slot: slot, category_scope: category_scope })) }, `${slot.id}-category-new`),
|
|
32
|
-
_jsx(Route, { path: NSFRoutes.CategoryCopy(slot.id, slot.name, ":id"), element: _jsx(NSFCategoryEditPage, Object.assign({}, this.props, { isEdit: false, slot: slot, category_scope: category_scope })) }, `${slot.id}-category-copy`),
|
|
33
|
-
_jsx(Route, { path: NSFRoutes.CategoryEdit(slot.id, slot.name, ":id"), element: _jsx(NSFCategoryEditPage, Object.assign({}, this.props, { isEdit: true, slot: slot, category_scope: category_scope })) }, `${slot.id}-category-edit`),
|
|
34
|
-
_jsx(Route, { path: NSFRoutes.CategoryView(slot.id, slot.name, ":id"), element: _jsx(NSFCategoryViewPage, Object.assign({}, this.props, { slot: slot, category_scope: category_scope })) }, `${slot.id}-category-view`),
|
|
35
|
-
])] }));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=NSARouter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NSARouter.js","sourceRoot":"","sources":["../../src/layouts/NSARouter.tsx"],"names":[],"mappings":";AACA,OAAO,EAA8C,cAAc,EAAW,MAAM,kBAAkB,CAAC;AACvG,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAYnE,MAAM,OAAO,SAAU,SAAQ,SAAyC;IAIpE,YAAY,KAAqB;QAE7B,KAAK,CAAC,KAAK,CAAC,CAAC;QAEb,IAAI,CAAC,WAAW,GAAG,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAE/H,IAAI,CAAC,KAAK,GAAG;YACT,IAAI,EAAE,IAAI;SACb,CAAC;IACN,CAAC;IACQ,iBAAiB;QAEtB,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YAE/B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,iCAAM,IAAI,KAA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|
4
|
-
static postprocess(filters: FilterLinkFullRow[], rows: EntityResolveResponseRow | null): FilterLinkFullRow[];
|
|
5
|
-
private static findEntityRow;
|
|
6
|
-
private static make;
|
|
7
|
-
private static walk;
|
|
8
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { NamingConvention } from 'namirasoft-core';
|
|
2
|
-
import { SlotEntityType } from 'namirasoft-field';
|
|
3
|
-
import { NSFRoutes } from '../NSFRoutes';
|
|
4
|
-
export class NSARouter_Field {
|
|
5
|
-
static postprocess(filters, rows) {
|
|
6
|
-
var _a, _b, _c, _d, _e;
|
|
7
|
-
if (!rows || rows.slots.length === 0)
|
|
8
|
-
return filters;
|
|
9
|
-
const result = [...filters];
|
|
10
|
-
const id_counter = { value: -1000000 };
|
|
11
|
-
const matched = new Set();
|
|
12
|
-
NSARouter_Field.walk(filters, null, rows, result, id_counter, matched);
|
|
13
|
-
const fallback_filter_id = (_b = (_a = filters[0]) === null || _a === void 0 ? void 0 : _a.filter_id) !== null && _b !== void 0 ? _b : 0;
|
|
14
|
-
const fallback_filter_ref = (_d = (_c = filters[0]) === null || _c === void 0 ? void 0 : _c.filter) !== null && _d !== void 0 ? _d : null;
|
|
15
|
-
for (const slot of rows.slots) {
|
|
16
|
-
if (matched.has(slot.id))
|
|
17
|
-
continue;
|
|
18
|
-
const parent = NSARouter_Field.make(id_counter, null, fallback_filter_id, fallback_filter_ref, slot.name, (_e = slot.description) !== null && _e !== void 0 ? _e : "", "");
|
|
19
|
-
result.push(parent);
|
|
20
|
-
result.push(NSARouter_Field.make(id_counter, parent.id, fallback_filter_id, fallback_filter_ref, "Create", "", NSFRoutes.CategoryNew(slot.id, slot.name)));
|
|
21
|
-
result.push(NSARouter_Field.make(id_counter, parent.id, fallback_filter_id, fallback_filter_ref, "List", "", NSFRoutes.CategoryList(slot.id, slot.name)));
|
|
22
|
-
}
|
|
23
|
-
return result;
|
|
24
|
-
}
|
|
25
|
-
static findEntityRow(filter_name, rows) {
|
|
26
|
-
var _a;
|
|
27
|
-
const n = NamingConvention.auto.convert((filter_name !== null && filter_name !== void 0 ? filter_name : "").trim(), NamingConvention.lower_case);
|
|
28
|
-
if (n.length === 0)
|
|
29
|
-
return null;
|
|
30
|
-
for (const slot of rows.slots) {
|
|
31
|
-
if (slot.entity_type != SlotEntityType.CategoryScope)
|
|
32
|
-
continue;
|
|
33
|
-
if (NamingConvention.auto.convert(((_a = slot.entity) !== null && _a !== void 0 ? _a : "").trim(), NamingConvention.lower_case) === n)
|
|
34
|
-
return slot;
|
|
35
|
-
}
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
static make(id_counter, parent_id, filter_id, filter_ref, label, description, url) {
|
|
39
|
-
const now = new Date();
|
|
40
|
-
const id = id_counter.value--;
|
|
41
|
-
return {
|
|
42
|
-
id,
|
|
43
|
-
parent_id,
|
|
44
|
-
filter_id,
|
|
45
|
-
link_id: null,
|
|
46
|
-
name: label,
|
|
47
|
-
logo: "https://static.namirasoft.com/image/namirasoft/field/logo/base.png",
|
|
48
|
-
order: 0,
|
|
49
|
-
created_at: now,
|
|
50
|
-
updated_at: now,
|
|
51
|
-
filter: filter_ref,
|
|
52
|
-
link: {
|
|
53
|
-
id: 0,
|
|
54
|
-
category_id: 0,
|
|
55
|
-
domain_id: 0,
|
|
56
|
-
name: label,
|
|
57
|
-
url: url,
|
|
58
|
-
logo: "https://static.namirasoft.com/image/namirasoft/field/logo/base.png",
|
|
59
|
-
public: true,
|
|
60
|
-
private: true,
|
|
61
|
-
importance: 0,
|
|
62
|
-
description,
|
|
63
|
-
created_at: now,
|
|
64
|
-
updated_at: now,
|
|
65
|
-
category: null,
|
|
66
|
-
domain: null,
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
static walk(filters, parent_id, rows, result, id_counter, matched) {
|
|
71
|
-
var _a, _b, _c, _d, _e;
|
|
72
|
-
const children = filters.filter(f => f.parent_id === parent_id);
|
|
73
|
-
for (const filter of children) {
|
|
74
|
-
const filter_name = (_c = (_a = filter.name) !== null && _a !== void 0 ? _a : (_b = filter.link) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : "";
|
|
75
|
-
const slot = NSARouter_Field.findEntityRow(filter_name, rows);
|
|
76
|
-
if (slot) {
|
|
77
|
-
matched.add(slot.id);
|
|
78
|
-
const parent = NSARouter_Field.make(id_counter, filter.parent_id, filter.filter_id, filter.filter, slot.name, (_d = slot.description) !== null && _d !== void 0 ? _d : "", "");
|
|
79
|
-
parent.order = ((_e = filter.order) !== null && _e !== void 0 ? _e : 0) - 1;
|
|
80
|
-
const idx = result.indexOf(filter);
|
|
81
|
-
if (idx >= 0)
|
|
82
|
-
result.splice(idx, 0, parent);
|
|
83
|
-
else
|
|
84
|
-
result.push(parent);
|
|
85
|
-
result.push(NSARouter_Field.make(id_counter, parent.id, filter.filter_id, filter.filter, "Create", "", NSFRoutes.CategoryNew(slot.id, slot.name)));
|
|
86
|
-
result.push(NSARouter_Field.make(id_counter, parent.id, filter.filter_id, filter.filter, "List", "", NSFRoutes.CategoryList(slot.id, slot.name)));
|
|
87
|
-
}
|
|
88
|
-
NSARouter_Field.walk(filters, filter.id, rows, result, id_counter, matched);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
//# sourceMappingURL=NSARouter_Field.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NSARouter_Field.js","sourceRoot":"","sources":["../../src/layouts/NSARouter_Field.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAA4B,cAAc,EAAW,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,OAAO,eAAe;IAExB,MAAM,CAAC,WAAW,CACd,OAA4B,EAC5B,IAAqC;;QAGrC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,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AAM,CAAC,KAAK,mCAAI,CAAC,CAAC,GAAG,CAAC,CAAC;gBACvC,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;gBACnC,IAAI,GAAG,IAAI,CAAC;oBACR,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;;oBAE9B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACxB,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBACnJ,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACtJ,CAAC;YACD,eAAe,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QAChF,CAAC;IACL,CAAC;CACJ"}
|
package/src/App.css
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
@font-face {
|
|
2
|
-
font-family: inter;
|
|
3
|
-
src: url("../src/assets/fonts/Inter-Regular.ttf");
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
body {
|
|
7
|
-
margin: 0;
|
|
8
|
-
font-family: inter;
|
|
9
|
-
-webkit-font-smoothing: antialiased;
|
|
10
|
-
-moz-osx-font-smoothing: grayscale;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
.btn-close {
|
|
15
|
-
background: url(https://static.namirasoft.com/image/concept/close/blue.svg) center/1em auto no-repeat !important;
|
|
16
|
-
opacity: 1 !important;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.nsa_font_16_bold {
|
|
20
|
-
font-size: 16px;
|
|
21
|
-
font-weight: 600;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.nsa_font_13_normal {
|
|
25
|
-
font-size: 13px;
|
|
26
|
-
font-weight: 300;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.nsa_font_12_normal {
|
|
30
|
-
font-size: 12px;
|
|
31
|
-
font-weight: 300;
|
|
32
|
-
}
|
package/src/FieldCacheService.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { TokenManager } from "namirasoft-account";
|
|
2
|
-
import { CacheService, CookieService, EnvService, IStorageLocal } from "namirasoft-core";
|
|
3
|
-
import { EntityResolveResponseRow, NamirasoftFieldHeader, NamirasoftFieldServer } from "namirasoft-field";
|
|
4
|
-
|
|
5
|
-
export class FieldCacheService
|
|
6
|
-
{
|
|
7
|
-
static get(token_manager: TokenManager, product_id: string, onError: (error: Error | string) => void): CacheService<EntityResolveResponseRow>
|
|
8
|
-
{
|
|
9
|
-
// todo this must be owner_id, otherwise switching between owners does not work correctly
|
|
10
|
-
let user_id: string = token_manager?.getUserData(x => x.id, "") ?? "";
|
|
11
|
-
let key_field = `ns-field-user:${user_id}-product:${product_id ?? "*"}`;
|
|
12
|
-
return new CacheService<EntityResolveResponseRow>(key_field, new IStorageLocal(), 24 * 60, async () =>
|
|
13
|
-
{
|
|
14
|
-
let service = new CookieService(document.cookie, NamirasoftFieldHeader.cookie.VERSION());
|
|
15
|
-
return user_id + "" + service.getString();
|
|
16
|
-
}, async () =>
|
|
17
|
-
{
|
|
18
|
-
let REACT_APP_BASE_URL_FIELD = new EnvService("REACT_APP_BASE_URL_FIELD", true).getString();
|
|
19
|
-
let server = new NamirasoftFieldServer(REACT_APP_BASE_URL_FIELD, token_manager, onError);
|
|
20
|
-
let ans: EntityResolveResponseRow = {
|
|
21
|
-
slots: [],
|
|
22
|
-
category_scopes: [],
|
|
23
|
-
categories: [],
|
|
24
|
-
fields: [],
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
try
|
|
28
|
-
{
|
|
29
|
-
ans = await server.entity.Resolve(product_id);
|
|
30
|
-
} catch (error: any)
|
|
31
|
-
{
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return ans;
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}
|
package/src/NSARouter.tsx
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { CacheService, EnvService } from 'namirasoft-core';
|
|
2
|
-
import { CategoryScopeRow, EntityResolveResponseRow, NamirasoftFieldServer, SlotEntityType, SlotRow } from 'namirasoft-field';
|
|
3
|
-
import { NSRoutes } from 'namirasoft-site-react';
|
|
4
|
-
import { Component, ReactNode } from 'react';
|
|
5
|
-
import { Route } from 'react-router-dom';
|
|
6
|
-
import { FieldCacheService } from './FieldCacheService';
|
|
7
|
-
import { NSARouterMakerProps } from './NSARouterMakerProps';
|
|
8
|
-
import { NSFRoutes } from './NSFRoutes';
|
|
9
|
-
import { NSFCategoryEditPage } from './pages/NSFCategoryEditPage';
|
|
10
|
-
import { NSFCategoryListPage } from './pages/NSFCategoryListPage';
|
|
11
|
-
import { NSFCategoryViewPage } from './pages/NSFCategoryViewPage';
|
|
12
|
-
|
|
13
|
-
export interface NSARoutesProps extends NSARouterMakerProps
|
|
14
|
-
{
|
|
15
|
-
children: ReactNode;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface NSARoutesState
|
|
19
|
-
{
|
|
20
|
-
rows: EntityResolveResponseRow | null;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export class NSARouter extends Component<NSARoutesProps, NSARoutesState>
|
|
24
|
-
{
|
|
25
|
-
private cache_field: CacheService<EntityResolveResponseRow>;
|
|
26
|
-
|
|
27
|
-
constructor(props: NSARoutesProps)
|
|
28
|
-
{
|
|
29
|
-
super(props);
|
|
30
|
-
|
|
31
|
-
this.cache_field = FieldCacheService.get(this.props.account.token_manager, this.props.product_id, this.props.notifier.onError);
|
|
32
|
-
|
|
33
|
-
this.state = {
|
|
34
|
-
rows: null,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
override componentDidMount(): void
|
|
38
|
-
{
|
|
39
|
-
this.cache_field.get().then(rows =>
|
|
40
|
-
{
|
|
41
|
-
this.setState(prev => ({ ...prev, rows }));
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
override render()
|
|
45
|
-
{
|
|
46
|
-
const { rows } = this.state;
|
|
47
|
-
const scope_slots = rows?.slots.filter(s => s.entity_type === SlotEntityType.CategoryScope) ?? [];
|
|
48
|
-
let pairs = scope_slots.map(slot => ({ slot, category_scope: rows?.category_scopes.find(c => c.id === slot.entity_id) })).filter(i => i.category_scope) as { slot: SlotRow, category_scope: CategoryScopeRow }[];
|
|
49
|
-
|
|
50
|
-
let REACT_APP_BASE_URL_FIELD = new EnvService("REACT_APP_BASE_URL_FIELD", true).getString();
|
|
51
|
-
let field = new NamirasoftFieldServer(REACT_APP_BASE_URL_FIELD, this.props.account.token_manager, this.props.notifier.onError);
|
|
52
|
-
let servers = { field };
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<NSRoutes>
|
|
56
|
-
{this.props.children}
|
|
57
|
-
{
|
|
58
|
-
pairs.flatMap(({ slot, category_scope }) => [
|
|
59
|
-
<Route key={`${slot.id}-category-list`} path={NSFRoutes.CategoryList(slot.id, slot.name)} element={<NSFCategoryListPage {...this.props} servers={servers} slot={slot} category_scope={category_scope} />} />,
|
|
60
|
-
<Route key={`${slot.id}-category-new`} path={NSFRoutes.CategoryNew(slot.id, slot.name)} element={<NSFCategoryEditPage {...this.props} servers={servers} isEdit={false} slot={slot} category_scope={category_scope} />} />,
|
|
61
|
-
<Route key={`${slot.id}-category-copy`} path={NSFRoutes.CategoryCopy(slot.id, slot.name, ":id")} element={<NSFCategoryEditPage {...this.props} servers={servers} isEdit={false} slot={slot} category_scope={category_scope} />} />,
|
|
62
|
-
<Route key={`${slot.id}-category-edit`} path={NSFRoutes.CategoryEdit(slot.id, slot.name, ":id")} element={<NSFCategoryEditPage {...this.props} servers={servers} isEdit={true} slot={slot} category_scope={category_scope} />} />,
|
|
63
|
-
<Route key={`${slot.id}-category-view`} path={NSFRoutes.CategoryView(slot.id, slot.name, ":id")} element={<NSFCategoryViewPage {...this.props} servers={servers} slot={slot} category_scope={category_scope} />} />,
|
|
64
|
-
])
|
|
65
|
-
}
|
|
66
|
-
</NSRoutes>
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { NSARouterMakerProps } from "./NSARouterMakerProps";
|
|
3
|
-
|
|
4
|
-
export interface NSARouterMakerConfig
|
|
5
|
-
{
|
|
6
|
-
onRenderOnLogin(props: NSARouterMakerProps): React.JSX.Element;
|
|
7
|
-
onRenderOnLogout(props: NSARouterMakerProps, banned: boolean): React.JSX.Element;
|
|
8
|
-
renderOnNSALayout(props: NSARouterMakerProps, children: React.JSX.Element): React.JSX.Element;
|
|
9
|
-
getCustomRender?: (props: NSARouterMakerProps) => React.JSX.Element | null;
|
|
10
|
-
requirement: {
|
|
11
|
-
verification: {
|
|
12
|
-
email: boolean;
|
|
13
|
-
phone: boolean;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
.column_item {
|
|
2
|
-
width: 100%;
|
|
3
|
-
display: flex;
|
|
4
|
-
align-items: center;
|
|
5
|
-
gap: 10px;
|
|
6
|
-
padding: 8px 12px;
|
|
7
|
-
border-radius: 6px;
|
|
8
|
-
border: 2px solid transparent;
|
|
9
|
-
background-color: rgba(20, 27, 92, 0.04);
|
|
10
|
-
cursor: grab;
|
|
11
|
-
user-select: none;
|
|
12
|
-
box-sizing: border-box;
|
|
13
|
-
transition: background-color 0.1s, border-color 0.1s;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.column_item:hover {
|
|
17
|
-
background-color: rgba(20, 27, 92, 0.08);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.column_item_dragging {
|
|
21
|
-
opacity: 0.35;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.column_item_drag_over {
|
|
25
|
-
border-color: rgba(20, 27, 92, 0.45);
|
|
26
|
-
border-style: dashed;
|
|
27
|
-
background-color: rgba(20, 27, 92, 0.1);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.drag_handle {
|
|
31
|
-
color: #bbb;
|
|
32
|
-
font-size: 20px;
|
|
33
|
-
line-height: 1;
|
|
34
|
-
cursor: grab;
|
|
35
|
-
flex-shrink: 0;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.checkbox {
|
|
39
|
-
width: 18px;
|
|
40
|
-
height: 18px;
|
|
41
|
-
cursor: pointer;
|
|
42
|
-
margin: 0;
|
|
43
|
-
flex-shrink: 0;
|
|
44
|
-
accent-color: rgba(20, 27, 92, 1);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.column_label {
|
|
48
|
-
font-size: 14px;
|
|
49
|
-
flex: 1;
|
|
50
|
-
}
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { NSBox, NSButtonBlue, NSColumn, NSDialog, NSTitle, TableColumnInfo } from "namirasoft-site-react";
|
|
2
|
-
import { Component, DragEvent } from "react";
|
|
3
|
-
import Styles from "./NSAReorderDialog.module.css";
|
|
4
|
-
|
|
5
|
-
interface ColumnItem
|
|
6
|
-
{
|
|
7
|
-
key: string;
|
|
8
|
-
text: string;
|
|
9
|
-
checked: boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface NSAReorderDialogProps
|
|
13
|
-
{
|
|
14
|
-
visibleColumnKeys: string[];
|
|
15
|
-
getColumns: () => TableColumnInfo[];
|
|
16
|
-
onCancel: () => void;
|
|
17
|
-
onApply: (orderedKeys: string[]) => void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface NSAReorderDialogState
|
|
21
|
-
{
|
|
22
|
-
columns: ColumnItem[];
|
|
23
|
-
dragFromIndex: number | null;
|
|
24
|
-
dragOverIndex: number | null;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export class NSAReorderDialog extends Component<NSAReorderDialogProps, NSAReorderDialogState>
|
|
28
|
-
{
|
|
29
|
-
constructor(props: NSAReorderDialogProps)
|
|
30
|
-
{
|
|
31
|
-
super(props);
|
|
32
|
-
this.state = {
|
|
33
|
-
columns: this.buildColumnItems(props),
|
|
34
|
-
dragFromIndex: null,
|
|
35
|
-
dragOverIndex: null
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
private buildColumnItems(props: NSAReorderDialogProps): ColumnItem[]
|
|
40
|
-
{
|
|
41
|
-
const allColumns = props.getColumns();
|
|
42
|
-
const visibleKeys = props.visibleColumnKeys;
|
|
43
|
-
|
|
44
|
-
if (visibleKeys.length === 0)
|
|
45
|
-
return allColumns.map(c => ({ key: c.table.name + "." + c.name, text: c.text, checked: true }));
|
|
46
|
-
|
|
47
|
-
const visibleItems: ColumnItem[] = visibleKeys
|
|
48
|
-
.map(k => allColumns.find(c => c.table.name + "." + c.name === k))
|
|
49
|
-
.filter(Boolean)
|
|
50
|
-
.map(c => ({ key: c!.table.name + "." + c!.name, text: c!.text, checked: true }));
|
|
51
|
-
|
|
52
|
-
const hiddenItems: ColumnItem[] = allColumns
|
|
53
|
-
.filter(c => !visibleKeys.includes(c.table.name + "." + c.name))
|
|
54
|
-
.map(c => ({ key: c.table.name + "." + c.name, text: c.text, checked: false }));
|
|
55
|
-
|
|
56
|
-
return [...visibleItems, ...hiddenItems];
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
private onDragStart = (index: number) => this.setState({ dragFromIndex: index });
|
|
60
|
-
|
|
61
|
-
private onDragOver = (e: DragEvent, index: number) =>
|
|
62
|
-
{
|
|
63
|
-
e.preventDefault();
|
|
64
|
-
if (this.state.dragOverIndex !== index)
|
|
65
|
-
this.setState({ dragOverIndex: index });
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
private onDrop = (e: DragEvent, dropIndex: number) =>
|
|
69
|
-
{
|
|
70
|
-
e.preventDefault();
|
|
71
|
-
const { dragFromIndex, columns } = this.state;
|
|
72
|
-
if (dragFromIndex === null || dragFromIndex === dropIndex)
|
|
73
|
-
{
|
|
74
|
-
this.setState({ dragFromIndex: null, dragOverIndex: null });
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const next = [...columns];
|
|
78
|
-
const [moved] = next.splice(dragFromIndex, 1);
|
|
79
|
-
next.splice(dropIndex, 0, moved);
|
|
80
|
-
this.setState({ columns: next, dragFromIndex: null, dragOverIndex: null });
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
private onDragEnd = () => this.setState({ dragFromIndex: null, dragOverIndex: null });
|
|
84
|
-
|
|
85
|
-
private toggleChecked = (key: string) =>
|
|
86
|
-
this.setState(prev => ({
|
|
87
|
-
columns: prev.columns.map(c => c.key === key ? { ...c, checked: !c.checked } : c)
|
|
88
|
-
}));
|
|
89
|
-
|
|
90
|
-
private handleApply = () =>
|
|
91
|
-
{
|
|
92
|
-
const orderedKeys = this.state.columns.filter(c => c.checked).map(c => c.key);
|
|
93
|
-
this.props.onApply(orderedKeys);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
override render()
|
|
97
|
-
{
|
|
98
|
-
const { onCancel } = this.props;
|
|
99
|
-
const { columns, dragFromIndex, dragOverIndex } = this.state;
|
|
100
|
-
|
|
101
|
-
return (
|
|
102
|
-
<NSDialog
|
|
103
|
-
center_dialog
|
|
104
|
-
closeButton={{ show: true }}
|
|
105
|
-
onClose={onCancel}
|
|
106
|
-
style={{ minWidth: NSBox.width.double }}
|
|
107
|
-
>
|
|
108
|
-
<NSColumn classList={["align-items-center"]}>
|
|
109
|
-
<NSTitle title="Columns" style={{ marginBottom: 0, fontSize: 24 }} />
|
|
110
|
-
<NSColumn classList={["gap-1"]}>
|
|
111
|
-
{
|
|
112
|
-
columns.map((col, index) =>
|
|
113
|
-
{
|
|
114
|
-
const isDragging = dragFromIndex === index;
|
|
115
|
-
const isDragOver = dragOverIndex === index && !isDragging;
|
|
116
|
-
let cls = Styles.column_item;
|
|
117
|
-
if (isDragging) cls += " " + Styles.column_item_dragging;
|
|
118
|
-
if (isDragOver) cls += " " + Styles.column_item_drag_over;
|
|
119
|
-
return (
|
|
120
|
-
<div
|
|
121
|
-
key={col.key}
|
|
122
|
-
draggable
|
|
123
|
-
onDragStart={() => this.onDragStart(index)}
|
|
124
|
-
onDragOver={e => this.onDragOver(e, index)}
|
|
125
|
-
onDrop={e => this.onDrop(e, index)}
|
|
126
|
-
onDragEnd={this.onDragEnd}
|
|
127
|
-
className={cls}
|
|
128
|
-
>
|
|
129
|
-
<span className={Styles.drag_handle}>⠿</span>
|
|
130
|
-
<input
|
|
131
|
-
type="checkbox"
|
|
132
|
-
checked={col.checked}
|
|
133
|
-
onChange={() => this.toggleChecked(col.key)}
|
|
134
|
-
className={Styles.checkbox}
|
|
135
|
-
/>
|
|
136
|
-
<span className={Styles.column_label}>{col.text}</span>
|
|
137
|
-
</div>
|
|
138
|
-
);
|
|
139
|
-
})
|
|
140
|
-
}
|
|
141
|
-
</NSColumn>
|
|
142
|
-
<NSButtonBlue
|
|
143
|
-
title="Apply"
|
|
144
|
-
onClick={{ action: this.handleApply, showLoading: false }}
|
|
145
|
-
/>
|
|
146
|
-
</NSColumn>
|
|
147
|
-
</NSDialog>
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { BaseMetaColumn, BaseMetaTable, SortItem } from "namirasoft-core";
|
|
2
|
-
import { NSBoxBaseCombo, NSBoxBoolean, NSBoxCombo, NSButtonBlue, NSColumn, NSDialog, NSTitle, TableColumnInfo } from "namirasoft-site-react";
|
|
3
|
-
import { Component, createRef } from "react";
|
|
4
|
-
|
|
5
|
-
interface NSASortDialogProps
|
|
6
|
-
{
|
|
7
|
-
sorts: SortItem[];
|
|
8
|
-
getColumns: () => TableColumnInfo[];
|
|
9
|
-
onCancel: () => void;
|
|
10
|
-
onApply: (sorts: SortItem[] | null) => void;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface NSASortDialogState
|
|
14
|
-
{
|
|
15
|
-
sortEnabled: boolean;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export class NSASortDialog extends Component<NSASortDialogProps, NSASortDialogState>
|
|
19
|
-
{
|
|
20
|
-
private sortBoolRef = createRef<NSBoxBoolean>();
|
|
21
|
-
private sortColumnRef = createRef<NSBoxBaseCombo<TableColumnInfo>>();
|
|
22
|
-
private sortDirectionRef = createRef<NSBoxCombo>();
|
|
23
|
-
|
|
24
|
-
constructor(props: NSASortDialogProps)
|
|
25
|
-
{
|
|
26
|
-
super(props);
|
|
27
|
-
this.state = { sortEnabled: props.sorts.length > 0 };
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
private handleApply = () =>
|
|
31
|
-
{
|
|
32
|
-
if (!this.sortBoolRef.current?.getValueBool())
|
|
33
|
-
{
|
|
34
|
-
this.props.onApply(null);
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
const column = this.sortColumnRef.current?.getDataOne();
|
|
38
|
-
const direction = this.sortDirectionRef.current?.getValueOne();
|
|
39
|
-
if (column)
|
|
40
|
-
{
|
|
41
|
-
const t = new BaseMetaTable(null, column.table.name, column.table.text);
|
|
42
|
-
const c = new BaseMetaColumn(t, column.name, column.text, "", true);
|
|
43
|
-
const sort = new SortItem(t, c, direction === "true");
|
|
44
|
-
this.props.onApply([sort]);
|
|
45
|
-
}
|
|
46
|
-
else
|
|
47
|
-
this.props.onApply(null);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
override render()
|
|
51
|
-
{
|
|
52
|
-
const { sorts, getColumns, onCancel } = this.props;
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<NSDialog
|
|
56
|
-
center_dialog
|
|
57
|
-
closeButton={{ show: true }}
|
|
58
|
-
onClose={onCancel}
|
|
59
|
-
>
|
|
60
|
-
<NSTitle title="Sort" style={{ marginBottom: 0, fontSize: 24 }} />
|
|
61
|
-
<NSColumn classList={["align-items-center mt-3"]}>
|
|
62
|
-
<NSBoxBoolean
|
|
63
|
-
ref={this.sortBoolRef}
|
|
64
|
-
required
|
|
65
|
-
title="Sort"
|
|
66
|
-
hideHeader={true}
|
|
67
|
-
checked={sorts.length > 0}
|
|
68
|
-
onChanged={() => this.setState(prev => ({ sortEnabled: !prev.sortEnabled }))}
|
|
69
|
-
/>
|
|
70
|
-
<NSBoxBaseCombo<TableColumnInfo>
|
|
71
|
-
ref={this.sortColumnRef}
|
|
72
|
-
title="Column"
|
|
73
|
-
required
|
|
74
|
-
defaultValue={sorts[0]?.column.name}
|
|
75
|
-
getItems={async () =>
|
|
76
|
-
{
|
|
77
|
-
const cs = getColumns();
|
|
78
|
-
return { count: cs.length, rows: cs }
|
|
79
|
-
}}
|
|
80
|
-
getTitle={c => c.text}
|
|
81
|
-
getValue={c => c.name}
|
|
82
|
-
getSort={() => null}
|
|
83
|
-
multiple={false}
|
|
84
|
-
disabled={this.state.sortEnabled}
|
|
85
|
-
menu={{
|
|
86
|
-
builtin: {
|
|
87
|
-
copy: { enabled: false, getValue: () => "" }
|
|
88
|
-
},
|
|
89
|
-
items: []
|
|
90
|
-
}}
|
|
91
|
-
/>
|
|
92
|
-
<NSBoxCombo
|
|
93
|
-
ref={this.sortDirectionRef}
|
|
94
|
-
title="Direction"
|
|
95
|
-
required
|
|
96
|
-
defaultValue={sorts[0]?.ascending + ""}
|
|
97
|
-
getOptions={() => [
|
|
98
|
-
{ value: "true", title: "Ascending" },
|
|
99
|
-
{ value: "false", title: "Descending" }
|
|
100
|
-
]}
|
|
101
|
-
multiple={false}
|
|
102
|
-
disabled={this.state.sortEnabled}
|
|
103
|
-
menu={{
|
|
104
|
-
builtin: {
|
|
105
|
-
copy: { enabled: false, getValue: () => "" }
|
|
106
|
-
},
|
|
107
|
-
items: []
|
|
108
|
-
}}
|
|
109
|
-
/>
|
|
110
|
-
<NSButtonBlue
|
|
111
|
-
title="Apply"
|
|
112
|
-
onClick={{ action: this.handleApply, showLoading: false }}
|
|
113
|
-
/>
|
|
114
|
-
</NSColumn>
|
|
115
|
-
</NSDialog>
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
}
|