namirasoft-account-react 1.3.59 → 1.3.61

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.
@@ -11,6 +11,7 @@ export interface IEntityInfo<EntityType extends {
11
11
  }>;
12
12
  create: (entity: EntityTypeInput) => Promise<EntityType>;
13
13
  update: (id: string, entity: EntityTypeInput) => Promise<EntityType>;
14
+ delete: (id: string) => Promise<void>;
14
15
  };
15
16
  client: {
16
17
  getListURL: () => string;
@@ -7,5 +7,5 @@ export declare class Actions {
7
7
  static viewHistory(getIDs: () => string[]): INSActionMenuProps;
8
8
  static copy(props: INSARouterProps, entity: IEntityInfo<any>, getIDs: () => string[]): INSActionMenuProps;
9
9
  static edit(props: INSARouterProps, entity: IEntityInfo<any>, getIDs: () => string[]): INSActionMenuProps;
10
- static delete(getIDs: () => string[]): INSActionMenuProps;
10
+ static delete(getIDs: () => string[], showDeleteModal: () => void): INSActionMenuProps;
11
11
  }
@@ -54,12 +54,11 @@ export class Actions {
54
54
  isActive() { return getIDs().length == 1; }
55
55
  };
56
56
  }
57
- static delete(getIDs) {
57
+ static delete(getIDs, showDeleteModal) {
58
58
  return {
59
59
  id: "5",
60
60
  menu_item: "Delete",
61
- handler: () => {
62
- },
61
+ handler: showDeleteModal,
63
62
  isActive() { return getIDs().length != 0; }
64
63
  };
65
64
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Actions.js","sourceRoot":"","sources":["../../src/layouts/Actions.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,OAAO;IAEhB,MAAM,CAAC,KAAK,CAAC,OAAmB;QAE5B,OAAO;YACH,EAAE,EAAE,GAAG;YACP,SAAS,EAAE,OAAO;YAClB,OAAO;YACP,QAAQ,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC;SAC9B,CAAA;IACL,CAAC;IACD,MAAM,CAAC,IAAI,CAAC,KAAsB,EAAE,MAAwB,EAAE,MAAsB;QAEhF,OAAO;YACH,EAAE,EAAE,GA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AAC;YACD,QAAQ,KAAK,OAAO,MAAM,EAAE,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;SAC9C,CAAC;IACN,CAAC;IACD,MAAM,CAAC,IAAI,CAAC,KAAsB,EAAE,MAAwB,EAAE,MAAsB;QAEhF,OAAO;YACH,EAAE,EAAE,GAAG;YACP,SAAS,EAAE,MAAM;YACjB,OAAO,EAAE,GAAG,EAAE;gBAEV,IAAI,GAAG,GAAG,MAAM,EAAE,CAAC;gBACnB,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBACnE,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YAChC,CAAC;YACD,QAAQ,KAAK,OAAO,MAAM,EAAE,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;SAC9C,CAAC;IACN,CAAC;IACD,MAAM,CAAC,MAAM,CAAC,MAAsB,EAAE,eAA2B;QAE7D,OAAO;YACH,EAAE,EAAE,GAAG;YACP,SAAS,EAAE,QAAQ;YACnB,OAAO,EAAE,eAAe;YACxB,QAAQ,KAAK,OAAO,MAAM,EAAE,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;SAC9C,CAAA;IACL,CAAC;CACJ"}
@@ -5,6 +5,7 @@ import { NSASectionViewProps } from './NSASectionView';
5
5
  import { IHeaderProps } from 'namirasoft-site-react';
6
6
  import { ReactNode } from 'react';
7
7
  import { INSARouterProps } from '../INSARouterProps';
8
+ import { IEntityInfo } from '../IEntityInfo';
8
9
  export interface NSALayoutProps<EntityType extends {
9
10
  id: string;
10
11
  }, EntityTypeInput = EntityType> extends IBaseComponentProps, INSARouterProps {
@@ -17,12 +18,28 @@ export interface NSALayoutProps<EntityType extends {
17
18
  banner?: INSBarHeroBannerProps;
18
19
  title?: INSBarTitleProps;
19
20
  pages?: {
20
- list?: NSASectionListProps<EntityType>;
21
+ entity: IEntityInfo<EntityType, EntityTypeInput>;
22
+ ui?: {
23
+ action?: {
24
+ menus: {
25
+ view?: boolean;
26
+ viewHistory?: boolean;
27
+ copy?: boolean;
28
+ edit?: boolean;
29
+ delete?: boolean;
30
+ apply?: boolean;
31
+ };
32
+ };
33
+ };
34
+ list?: NSASectionListProps;
21
35
  edit?: NSASectionEditProps<EntityType, EntityTypeInput>;
22
36
  view?: NSASectionViewProps<EntityType>;
23
37
  };
24
38
  children: ReactNode;
25
39
  }
40
+ export interface NSALayoutState {
41
+ showDeleteModal: boolean;
42
+ }
26
43
  export declare function NSALayout<EntityType extends {
27
44
  id: string;
28
45
  }, EntityTypeInput = EntityType>(props: NSALayoutProps<EntityType, EntityTypeInput>): import("react/jsx-runtime").JSX.Element;
@@ -7,16 +7,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { jsx as _jsx } from "react/jsx-runtime";
10
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
+ import { NSButtonRed, NSModal } from 'namirasoft-site-react';
11
12
  import { NSLayout } from 'namirasoft-site-react';
12
13
  import { NSASectionList } from './NSASectionList';
13
14
  import { NSASectionEdit, onApply as NSASectionEdit_onApply } from './NSASectionEdit';
14
15
  import { NSASectionView } from './NSASectionView';
16
+ import { useState } from 'react';
15
17
  import { Actions } from './Actions';
16
18
  import { useParams } from 'react-router-dom';
17
19
  import { NamingConvention } from 'namirasoft-core';
18
20
  export function NSALayout(props) {
19
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10;
21
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6;
20
22
  const onLogout = () => __awaiter(this, void 0, void 0, function* () {
21
23
  props.account.server.session.Logout().then(() => {
22
24
  props.notifier.onSuccess("You have successfully logged out");
@@ -26,79 +28,96 @@ export function NSALayout(props) {
26
28
  const onNotiffication = () => {
27
29
  console.log("clicked");
28
30
  };
31
+ const [state, setState] = useState({ showDeleteModal: false });
32
+ const hideDeleteModal = () => { setState(prevState => (Object.assign(Object.assign({}, prevState), { showDeleteModal: false }))); };
33
+ const showDeleteModal = () => { setState(prevState => (Object.assign(Object.assign({}, prevState), { showDeleteModal: true }))); };
29
34
  let icons = [
30
35
  { src: "https://static.namirasoft.com/image/concept/logout/white.svg", alt: "Logout", onClicked: onLogout, },
31
36
  { src: "https://static.namirasoft.com/image/concept/message/white.svg", alt: "Message", onClicked: onNotiffication, count: 1 },
32
37
  { src: "https://static.namirasoft.com/image/concept/message/white.svg", alt: "Access", onClicked: onNotiffication },
33
38
  ];
39
+ let name = "";
40
+ if (props.pages)
41
+ name = NamingConvention.Pascal_Case.convert(props.pages.entity.name, NamingConvention.Pascal_Case_Space);
34
42
  let user_name = props.account.token_manager.getUserData(user => [user.first_name, user.last_name].filter(n => n).join(" "), "");
35
43
  let action = props.action;
36
44
  if (!action)
37
45
  action = { title: "", description: "", menus: {} };
38
- let name_actions = "Actions";
39
46
  let name_apply = "Apply";
47
+ let name_actions = "Actions";
40
48
  if (((_a = props.pages) === null || _a === void 0 ? void 0 : _a.list) || ((_b = props.pages) === null || _b === void 0 ? void 0 : _b.edit))
41
49
  if (!action.menus[name_actions])
42
50
  action.menus[name_actions] = [];
43
- if ((_c = props.pages) === null || _c === void 0 ? void 0 : _c.list) {
44
- let getIDs = () => [].filter(id => id);
45
- if ((_e = (_d = props.pages.list.ui.action) === null || _d === void 0 ? void 0 : _d.menus.view) !== null && _e !== void 0 ? _e : true)
46
- action.menus[name_actions].push(Actions.view(props, props.pages.list.entity, getIDs));
47
- if ((_g = (_f = props.pages.list.ui.action) === null || _f === void 0 ? void 0 : _f.menus.viewHistory) !== null && _g !== void 0 ? _g : true)
48
- action.menus[name_actions].push(Actions.viewHistory(getIDs));
49
- if ((_j = (_h = props.pages.list.ui.action) === null || _h === void 0 ? void 0 : _h.menus.copy) !== null && _j !== void 0 ? _j : true)
50
- action.menus[name_actions].push(Actions.copy(props, props.pages.list.entity, getIDs));
51
- if ((_l = (_k = props.pages.list.ui.action) === null || _k === void 0 ? void 0 : _k.menus.edit) !== null && _l !== void 0 ? _l : true)
52
- action.menus[name_actions].push(Actions.edit(props, props.pages.list.entity, getIDs));
53
- if ((_o = (_m = props.pages.list.ui.action) === null || _m === void 0 ? void 0 : _m.menus.delete) !== null && _o !== void 0 ? _o : true)
54
- action.menus[name_actions].push(Actions.delete(getIDs));
51
+ if ((_c = props.pages) === null || _c === void 0 ? void 0 : _c.edit)
52
+ if (!action.menus[name_apply])
53
+ action.menus[name_apply] = [];
54
+ let getIDs = null;
55
+ if ((_d = props.pages) === null || _d === void 0 ? void 0 : _d.list) {
56
+ getIDs = () => [].filter(id => id);
55
57
  }
56
- if ((_p = props.pages) === null || _p === void 0 ? void 0 : _p.edit) {
58
+ if ((_e = props.pages) === null || _e === void 0 ? void 0 : _e.edit) {
59
+ let { id } = useParams();
60
+ getIDs = () => [id].filter(id => id);
57
61
  if (!action.title) {
58
- let name = NamingConvention.Pascal_Case.convert(props.pages.edit.entity.name, NamingConvention.Pascal_Case_Space);
59
62
  action.title = (props.pages.edit.isEdit ? "Edit" : "New") + " " + name;
60
63
  }
61
- if (!action.menus[name_apply])
62
- action.menus[name_apply] = [];
63
- let { id } = useParams();
64
- let getIDs = () => [id].filter(id => id);
65
- if ((_r = (_q = props.pages.edit.ui.action) === null || _q === void 0 ? void 0 : _q.menus.view) !== null && _r !== void 0 ? _r : true)
66
- action.menus[name_actions].push(Actions.view(props, props.pages.edit.entity, getIDs));
67
- if ((_t = (_s = props.pages.edit.ui.action) === null || _s === void 0 ? void 0 : _s.menus.viewHistory) !== null && _t !== void 0 ? _t : true)
68
- action.menus[name_actions].push(Actions.viewHistory(getIDs));
69
- if ((_v = (_u = props.pages.edit.ui.action) === null || _u === void 0 ? void 0 : _u.menus.copy) !== null && _v !== void 0 ? _v : true)
70
- action.menus[name_actions].push(Actions.copy(props, props.pages.edit.entity, getIDs));
71
- if ((_x = (_w = props.pages.edit.ui.action) === null || _w === void 0 ? void 0 : _w.menus.edit) !== null && _x !== void 0 ? _x : true)
72
- action.menus[name_actions].push(Actions.edit(props, props.pages.edit.entity, getIDs));
73
- if ((_z = (_y = props.pages.edit.ui.action) === null || _y === void 0 ? void 0 : _y.menus.delete) !== null && _z !== void 0 ? _z : true)
74
- action.menus[name_actions].push(Actions.delete(getIDs));
75
- if ((_1 = (_0 = props.pages.edit.ui.action) === null || _0 === void 0 ? void 0 : _0.menus.apply) !== null && _1 !== void 0 ? _1 : true)
64
+ if ((_g = (_f = props.pages.edit.ui.action) === null || _f === void 0 ? void 0 : _f.menus.apply) !== null && _g !== void 0 ? _g : true)
76
65
  action.menus[name_apply].push(Actions.apply(() => {
77
66
  var _a, _b;
78
67
  if ((_a = props.pages) === null || _a === void 0 ? void 0 : _a.edit)
79
- NSASectionEdit_onApply((_b = props.pages) === null || _b === void 0 ? void 0 : _b.edit, id);
68
+ NSASectionEdit_onApply((_b = props.pages) === null || _b === void 0 ? void 0 : _b.edit, props.pages.entity, id);
80
69
  }));
81
70
  }
82
- if ((_2 = props.pages) === null || _2 === void 0 ? void 0 : _2.view) {
83
- action.menus[name_actions].push(Actions.viewHistory(() => []));
84
- action.menus[name_actions].push(Actions.delete(() => []));
71
+ if ((_h = props.pages) === null || _h === void 0 ? void 0 : _h.view) {
72
+ getIDs = () => [].filter(id => id);
85
73
  }
74
+ if (getIDs)
75
+ if (props.pages) {
76
+ if ((_l = (_k = (_j = props.pages.ui) === null || _j === void 0 ? void 0 : _j.action) === null || _k === void 0 ? void 0 : _k.menus.view) !== null && _l !== void 0 ? _l : true)
77
+ action.menus[name_actions].push(Actions.view(props, props.pages.entity, getIDs));
78
+ if ((_p = (_o = (_m = props.pages.ui) === null || _m === void 0 ? void 0 : _m.action) === null || _o === void 0 ? void 0 : _o.menus.viewHistory) !== null && _p !== void 0 ? _p : true)
79
+ action.menus[name_actions].push(Actions.viewHistory(getIDs));
80
+ if ((_s = (_r = (_q = props.pages.ui) === null || _q === void 0 ? void 0 : _q.action) === null || _r === void 0 ? void 0 : _r.menus.copy) !== null && _s !== void 0 ? _s : true)
81
+ action.menus[name_actions].push(Actions.copy(props, props.pages.entity, getIDs));
82
+ if ((_v = (_u = (_t = props.pages.ui) === null || _t === void 0 ? void 0 : _t.action) === null || _u === void 0 ? void 0 : _u.menus.edit) !== null && _v !== void 0 ? _v : true)
83
+ action.menus[name_actions].push(Actions.edit(props, props.pages.entity, getIDs));
84
+ if ((_y = (_x = (_w = props.pages.ui) === null || _w === void 0 ? void 0 : _w.action) === null || _x === void 0 ? void 0 : _x.menus.delete) !== null && _y !== void 0 ? _y : true)
85
+ action.menus[name_actions].push(Actions.delete(getIDs, showDeleteModal));
86
+ }
86
87
  let content;
87
- if ((_3 = props.pages) === null || _3 === void 0 ? void 0 : _3.list)
88
- content = _jsx(NSASectionList, Object.assign({}, props.pages.list, { children: props.children }));
89
- else if ((_4 = props.pages) === null || _4 === void 0 ? void 0 : _4.edit)
90
- content = _jsx(NSASectionEdit, Object.assign({}, props.pages.edit, { children: props.children }));
91
- else if ((_5 = props.pages) === null || _5 === void 0 ? void 0 : _5.view)
88
+ if ((_z = props.pages) === null || _z === void 0 ? void 0 : _z.list)
89
+ content = _jsx(NSASectionList, Object.assign({}, props.pages.list, { entity: props.pages.entity, children: props.children }));
90
+ else if ((_0 = props.pages) === null || _0 === void 0 ? void 0 : _0.edit)
91
+ content = _jsx(NSASectionEdit, Object.assign({}, props.pages.edit, { entity: props.pages.entity, children: props.children }));
92
+ else if ((_1 = props.pages) === null || _1 === void 0 ? void 0 : _1.view)
92
93
  content = _jsx(NSASectionView, Object.assign({}, props.pages.view, { children: props.children }));
93
94
  else
94
95
  content = props.children;
95
96
  return (_jsx(NSLayout, Object.assign({}, props, { header: {
96
- title: (user_name + " " + ((_7 = (_6 = props.header) === null || _6 === void 0 ? void 0 : _6.title) !== null && _7 !== void 0 ? _7 : "")).trim(),
97
- icons: [...icons, ...((_9 = (_8 = props.header) === null || _8 === void 0 ? void 0 : _8.icons) !== null && _9 !== void 0 ? _9 : [])]
97
+ title: (user_name + " " + ((_3 = (_2 = props.header) === null || _2 === void 0 ? void 0 : _2.title) !== null && _3 !== void 0 ? _3 : "")).trim(),
98
+ icons: [...icons, ...((_5 = (_4 = props.header) === null || _4 === void 0 ? void 0 : _4.icons) !== null && _5 !== void 0 ? _5 : [])]
98
99
  }, action: {
99
- title: (_10 = action === null || action === void 0 ? void 0 : action.title) !== null && _10 !== void 0 ? _10 : "",
100
+ title: (_6 = action === null || action === void 0 ? void 0 : action.title) !== null && _6 !== void 0 ? _6 : "",
100
101
  description: action === null || action === void 0 ? void 0 : action.description,
101
102
  menus: action.menus
102
- }, children: _jsx("div", { className: "container-fluid", children: content }) })));
103
+ }, children: _jsxs("div", { className: "container-fluid", children: [_jsx(NSModal, { title: `Are you sure you want to delete ${name}?`, description: "", show: state.showDeleteModal, onClose: hideDeleteModal, children: _jsx(NSButtonRed, { title: "Yes", onClick: () => __awaiter(this, void 0, void 0, function* () {
104
+ try {
105
+ if (props.pages)
106
+ if (getIDs) {
107
+ let ids = getIDs();
108
+ if (ids.length == 0)
109
+ throw new Error("Nothing was found to delete.");
110
+ if (ids.length == 1) {
111
+ yield props.pages.entity.server.delete(ids[0]);
112
+ props.notifier.onSuccess(`${name} was deleted successfully.`);
113
+ }
114
+ else
115
+ throw new Error("Multiple deletion is not supported yet.");
116
+ }
117
+ }
118
+ catch (error) {
119
+ props.notifier.onError(error);
120
+ }
121
+ }) }) }), content] }) })));
103
122
  }
104
123
  //# sourceMappingURL=NSALayout.js.map
@@ -1 +1 @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AAC,yCAAyC,CAAC,CAAC;qCAC5D;6BAEF;4BAAC,OAAO,KAAU,EACnB;gCACC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;6BAC9B;wBACF,CAAC,CAAA,GAAI,GAAI,EACT,OAAO,IACH,IACI,CACX,CAAC;AACH,CAAC"}
@@ -5,18 +5,12 @@ import { IEntityInfo } from "../IEntityInfo";
5
5
  export interface NSASectionEditProps<EntityType extends {
6
6
  id: string;
7
7
  }, EntityTypeInput = EntityType> extends IBaseComponentProps, INSARouterProps {
8
- entity: IEntityInfo<EntityType, EntityTypeInput>;
9
8
  isEdit: boolean;
10
9
  ui: {
11
10
  getEntity: (entity: EntityType | null) => EntityTypeInput;
12
11
  setEntity: (entity: EntityType) => void;
13
12
  action?: {
14
13
  menus: {
15
- view?: boolean;
16
- viewHistory?: boolean;
17
- copy?: boolean;
18
- edit?: boolean;
19
- delete?: boolean;
20
14
  apply?: boolean;
21
15
  };
22
16
  };
@@ -24,9 +18,10 @@ export interface NSASectionEditProps<EntityType extends {
24
18
  }
25
19
  export declare function onApply<EntityType extends {
26
20
  id: string;
27
- }, EntityTypeInput = EntityType>(props: NSASectionEditProps<EntityType, EntityTypeInput>, id: string | undefined): void;
21
+ }, EntityTypeInput = EntityType>(props: NSASectionEditProps<EntityType, EntityTypeInput>, entity: IEntityInfo<EntityType, EntityTypeInput>, id: string | undefined): void;
28
22
  export declare function NSASectionEdit<EntityType extends {
29
23
  id: string;
30
24
  }, EntityTypeInput = EntityType>(props: NSASectionEditProps<EntityType, EntityTypeInput> & {
25
+ entity: IEntityInfo<EntityType, EntityTypeInput>;
31
26
  children: ReactNode;
32
27
  }): import("react/jsx-runtime").JSX.Element;
@@ -2,16 +2,18 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { NSSection, NSPanel, NSButtonBlue, NSLine, NSSpace, NSSpaceSizeType, NSTabPage } from 'namirasoft-site-react';
3
3
  import { useEffect } from "react";
4
4
  import { useParams } from "react-router-dom";
5
- export function onApply(props, id) {
5
+ import { NamingConvention } from "namirasoft-core";
6
+ export function onApply(props, entity, id) {
6
7
  try {
8
+ let name = NamingConvention.Pascal_Case.convert(entity.name, NamingConvention.Pascal_Case_Space);
7
9
  let onSuccess = (new_entity, message) => {
8
10
  props.notifier.onSuccess(message);
9
- if (props.entity.client.onSuccess)
10
- props.entity.client.onSuccess(new_entity);
11
+ if (entity.client.onSuccess)
12
+ entity.client.onSuccess(new_entity);
11
13
  else {
12
- let url = props.entity.client.getViewURL(new_entity.id);
14
+ let url = entity.client.getViewURL(new_entity.id);
13
15
  if (!url)
14
- url = props.entity.client.getListURL();
16
+ url = entity.client.getListURL();
15
17
  props.url.redirect(url, {});
16
18
  }
17
19
  };
@@ -19,15 +21,15 @@ export function onApply(props, id) {
19
21
  let cur_entity = props.ui.getEntity(old_entity);
20
22
  if (props.isEdit) {
21
23
  if (id)
22
- props.entity.server.update(id, cur_entity).then((new_entity) => {
23
- onSuccess(new_entity, props.entity.name + " has been updated successfully");
24
+ entity.server.update(id, cur_entity).then((new_entity) => {
25
+ onSuccess(new_entity, name + " has been updated successfully");
24
26
  }).catch(() => { });
25
27
  else
26
28
  throw new Error("ID was not provided.");
27
29
  }
28
30
  else {
29
- props.entity.server.create(cur_entity).then((new_entity) => {
30
- onSuccess(new_entity, props.entity.name + " has been created successfully");
31
+ entity.server.create(cur_entity).then((new_entity) => {
32
+ onSuccess(new_entity, name + " has been created successfully");
31
33
  }).catch(() => { });
32
34
  }
33
35
  }
@@ -59,6 +61,6 @@ export function NSASectionEdit(props) {
59
61
  { title: 'Category', getContent: content1 },
60
62
  { title: 'Field', getContent: content1 }
61
63
  ];
62
- return (_jsxs(NSSection, { id: props.id, classList: [`${(_a = props.classList) === null || _a === void 0 ? void 0 : _a.join(" ")}`], center_items: true, children: [_jsx(NSPanel, { grid: false, children: props.children }), _jsx(NSSpace, { size: NSSpaceSizeType.NORMAL }), _jsx(NSButtonBlue, { title: "Apply", onClick: () => { onApply(props, id); } }), _jsx(NSSpace, { size: NSSpaceSizeType.NORMAL }), props.isEdit && _jsx(NSLine, {}), props.isEdit && _jsx(NSSpace, { size: NSSpaceSizeType.NORMAL }), props.isEdit && _jsx(NSTabPage, { tabs: tabs })] }));
64
+ return (_jsxs(NSSection, { id: props.id, classList: [`${(_a = props.classList) === null || _a === void 0 ? void 0 : _a.join(" ")}`], center_items: true, children: [_jsx(NSPanel, { grid: false, children: props.children }), _jsx(NSSpace, { size: NSSpaceSizeType.NORMAL }), _jsx(NSButtonBlue, { title: "Apply", onClick: () => { onApply(props, props.entity, id); } }), _jsx(NSSpace, { size: NSSpaceSizeType.NORMAL }), props.isEdit && _jsx(NSLine, {}), props.isEdit && _jsx(NSSpace, { size: NSSpaceSizeType.NORMAL }), props.isEdit && _jsx(NSTabPage, { tabs: tabs })] }));
63
65
  }
64
66
  //# sourceMappingURL=NSASectionEdit.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NSASectionEdit.js","sourceRoot":"","sources":["../../src/layouts/NSASectionEdit.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEtH,OAAO,EAAa,SAAS,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAsB7C,MAAM,UAAU,OAAO,CAAkE,KAAuD,EAAE,EAAsB;IAEvK,IACA;QACC,IAAI,SAAS,GAAG,CAAC,UAAsB,EAAE,OAAe,EAAE,EAAE;YAE3D,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YAClC,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS;gBAChC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;iBAE3C;gB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KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE;QACtC,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE;QAC3C,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE;KACxC,CAAC;IAEF,OAAO,CACN,MAAC,SAAS,IACT,EAAE,EAAE,KAAK,CAAC,EAAE,EACZ,SAAS,EAAE,CAAC,GAAG,MAAA,KAAK,CAAC,SAAS,0CAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAC5C,YAAY,EAAE,IAAI,aAElB,KAAC,OAAO,IAAC,IAAI,EAAE,KAAK,YAClB,KAAK,CAAC,QAAQ,GACN,EACV,KAAC,OAAO,IAAC,IAAI,EAAE,eAAe,CAAC,MAAM,GAAY,EACjD,KAAC,YAAY,IAAC,KAAK,EAAC,OAAO,EAAC,OAAO,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAI,EACpF,KAAC,OAAO,IAAC,IAAI,EAAE,eAAe,CAAC,MAAM,GAAY,EAChD,KAAK,CAAC,MAAM,IAAI,KAAC,MAAM,KAAG,EAC1B,KAAK,CAAC,MAAM,IAAI,KAAC,OAAO,IAAC,IAAI,EAAE,eAAe,CAAC,MAAM,GAAY,EACjE,KAAK,CAAC,MAAM,IAAI,KAAC,SAAS,IAAC,IAAI,EAAE,IAAI,GAAI,IAC/B,CACZ,CAAC;AACH,CAAC"}
@@ -1,9 +1,6 @@
1
1
  import { ReactNode } from "react";
2
2
  import { IEntityInfo } from "../IEntityInfo";
3
- export interface NSASectionListProps<EntityType extends {
4
- id: string;
5
- }> {
6
- entity: IEntityInfo<EntityType>;
3
+ export interface NSASectionListProps {
7
4
  ui: {
8
5
  getColumns: () => {
9
6
  [key: string]: string;
@@ -30,6 +27,7 @@ export interface NSASectionListState {
30
27
  }
31
28
  export declare function NSASectionList<EntityType extends {
32
29
  id: string;
33
- }>(props: NSASectionListProps<EntityType> & {
30
+ }, EntityTypeInput>(props: NSASectionListProps & {
31
+ entity: IEntityInfo<EntityType, EntityTypeInput>;
34
32
  children: ReactNode;
35
33
  }): import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"NSASectionList.js","sourceRoot":"","sources":["../../src/layouts/NSASectionList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACxG,OAAO,EAAa,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AA+B/D,MAAM,UAAU,cAAc,CAAoC,KAAgE;IAEjI,MAAM,cAAc,GAAG,MAAM,CAAsB,IAAI,CAAC,CAAC;IAEzD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAsB,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;IAEzH,SAAS,CAAC,GAAG,EAAE;QAEd,MAAM,EAAE,CAAC;IAEV,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,UAAU,GAAG,GAA8B,EAAE;QAElD,uBACC,QAAQ,EAAE,EAAE,IACT,KAAK,CAAC,EAAE,CAAC,UAAU,EAAE,EACvB;IACH,CAAC,CAAC;IAEF,MAAM,MAAM,GAAG,GAAS,EAAE;QAEzB,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;;YAEnF,MAAA,cAAc,CAAC,OAAO,0CAAE,OAAO,CAAC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,IAAC,YAAY,EAAE,KAAK,aAC7B,KAAC,OAAO,IACP,GAAG,EAAE,cAAc,EACnB,OAAO,EAAE,UAAU,EAAE,EACrB,SAAS,EAAE,SAAS,EACpB,mBAAmB,EAAE,mBAAmB,EACxC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,EACzB,UAAU,EAAE,KAAK,CAAC,UAAU,EAC5B,MAAM,EAAE,MAAM,GACb,EACF,KAAC,OAAO,IAAC,IAAI,EAAE,eAAe,CAAC,MAAM,GAAY,EACjD,KAAC,MAAM,KAAU,EACjB,KAAC,OAAO,IAAC,IAAI,EAAE,eAAe,CAAC,MAAM,GAAY,EACjD,KAAC,SAAS,IAAC,IAAI,EAAE,IAAI,GAAI,IACd,CACZ,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "framework": "npm",
9
9
  "application": "package",
10
10
  "private": false,
11
- "version": "1.3.59",
11
+ "version": "1.3.61",
12
12
  "author": "Amir Abolhasani",
13
13
  "license": "MIT",
14
14
  "main": "./dist/main.js",
@@ -11,6 +11,7 @@ export interface IEntityInfo<EntityType extends { id: string }, EntityTypeInput
11
11
  }>;
12
12
  create: (entity: EntityTypeInput) => Promise<EntityType>;
13
13
  update: (id: string, entity: EntityTypeInput) => Promise<EntityType>;
14
+ delete: (id: string) => Promise<void>;
14
15
  };
15
16
  client: {
16
17
  getListURL: () => string;
@@ -68,16 +68,12 @@ export class Actions
68
68
  isActive() { return getIDs().length == 1; }
69
69
  };
70
70
  }
71
- static delete(getIDs: () => string[]): INSActionMenuProps
71
+ static delete(getIDs: () => string[], showDeleteModal: () => void): INSActionMenuProps
72
72
  {
73
73
  return {
74
74
  id: "5",
75
75
  menu_item: "Delete",
76
- handler: () =>
77
- {
78
- // if (props.delete)
79
- // props.delete();
80
- },
76
+ handler: showDeleteModal,
81
77
  isActive() { return getIDs().length != 0; }
82
78
  }
83
79
  }
@@ -1,14 +1,15 @@
1
- import { IBaseComponentProps, INSBarActionProps, INSBarHeroBannerProps, INSBarNotificationProps, INSBarTitleProps } from 'namirasoft-site-react';
1
+ import { IBaseComponentProps, INSBarActionProps, INSBarHeroBannerProps, INSBarNotificationProps, INSBarTitleProps, NSButtonRed, NSModal } from 'namirasoft-site-react';
2
2
  import { NSLayout } from 'namirasoft-site-react';
3
3
  import { NSASectionList, NSASectionListProps } from './NSASectionList';
4
4
  import { NSASectionEdit, NSASectionEditProps, onApply as NSASectionEdit_onApply } from './NSASectionEdit';
5
5
  import { NSASectionView, NSASectionViewProps } from './NSASectionView';
6
6
  import { IHeaderProps } from 'namirasoft-site-react';
7
- import { ReactNode } from 'react';
7
+ import { ReactNode, useState } from 'react';
8
8
  import { Actions } from './Actions';
9
9
  import { INSARouterProps } from '../INSARouterProps';
10
10
  import { useParams } from 'react-router-dom';
11
11
  import { NamingConvention } from 'namirasoft-core';
12
+ import { IEntityInfo } from '../IEntityInfo';
12
13
 
13
14
  export interface NSALayoutProps<EntityType extends { id: string }, EntityTypeInput = EntityType> extends IBaseComponentProps, INSARouterProps
14
15
  {
@@ -21,13 +22,31 @@ export interface NSALayoutProps<EntityType extends { id: string }, EntityTypeInp
21
22
  banner?: INSBarHeroBannerProps;
22
23
  title?: INSBarTitleProps;
23
24
  pages?: {
24
- list?: NSASectionListProps<EntityType>;
25
+ entity: IEntityInfo<EntityType, EntityTypeInput>;
26
+ ui?: {
27
+ action?: {
28
+ menus: {
29
+ view?: boolean,
30
+ viewHistory?: boolean,
31
+ copy?: boolean,
32
+ edit?: boolean,
33
+ delete?: boolean,
34
+ apply?: boolean,
35
+ }
36
+ }
37
+ }
38
+ list?: NSASectionListProps;
25
39
  edit?: NSASectionEditProps<EntityType, EntityTypeInput>;
26
40
  view?: NSASectionViewProps<EntityType>;
27
41
  }
28
42
  children: ReactNode;
29
43
  }
30
44
 
45
+ export interface NSALayoutState
46
+ {
47
+ showDeleteModal: boolean;
48
+ }
49
+
31
50
  export function NSALayout<EntityType extends { id: string }, EntityTypeInput = EntityType>(props: NSALayoutProps<EntityType, EntityTypeInput>)
32
51
  {
33
52
  const onLogout = async () =>
@@ -44,11 +63,18 @@ export function NSALayout<EntityType extends { id: string }, EntityTypeInput = E
44
63
  console.log("clicked")
45
64
  }
46
65
 
66
+ const [state, setState] = useState<NSALayoutState>({ showDeleteModal: false });
67
+ const hideDeleteModal = () => { setState(prevState => ({ ...prevState, showDeleteModal: false })); };
68
+ const showDeleteModal = () => { setState(prevState => ({ ...prevState, showDeleteModal: true })); };
69
+
47
70
  let icons = [
48
71
  { src: "https://static.namirasoft.com/image/concept/logout/white.svg", alt: "Logout", onClicked: onLogout, },
49
72
  { src: "https://static.namirasoft.com/image/concept/message/white.svg", alt: "Message", onClicked: onNotiffication, count: 1 },
50
73
  { src: "https://static.namirasoft.com/image/concept/message/white.svg", alt: "Access", onClicked: onNotiffication },
51
74
  ];
75
+ let name = "";
76
+ if (props.pages)
77
+ name = NamingConvention.Pascal_Case.convert(props.pages.entity.name, NamingConvention.Pascal_Case_Space);
52
78
 
53
79
  let user_name = props.account.token_manager.getUserData(user => [user.first_name, user.last_name].filter(n => n).join(" "), "");
54
80
 
@@ -56,70 +82,68 @@ export function NSALayout<EntityType extends { id: string }, EntityTypeInput = E
56
82
  if (!action)
57
83
  action = { title: "", description: "", menus: {} };
58
84
 
59
- let name_actions = "Actions";
60
85
  let name_apply = "Apply";
86
+ let name_actions = "Actions";
61
87
  if (props.pages?.list || props.pages?.edit)
62
88
  if (!action.menus[name_actions])
63
89
  action.menus[name_actions] = [];
90
+ if (props.pages?.edit)
91
+ if (!action.menus[name_apply])
92
+ action.menus[name_apply] = [];
93
+
94
+ let getIDs: (() => string[]) | null = null;
95
+
64
96
  if (props.pages?.list)
65
97
  {
66
98
  // todo
67
- let getIDs = () => [].filter(id => id) as string[];
68
- if (props.pages.list.ui.action?.menus.view ?? true)
69
- action.menus[name_actions].push(Actions.view(props, props.pages.list.entity, getIDs));
70
- if (props.pages.list.ui.action?.menus.viewHistory ?? true)
71
- action.menus[name_actions].push(Actions.viewHistory(getIDs));
72
- if (props.pages.list.ui.action?.menus.copy ?? true)
73
- action.menus[name_actions].push(Actions.copy(props, props.pages.list.entity, getIDs));
74
- if (props.pages.list.ui.action?.menus.edit ?? true)
75
- action.menus[name_actions].push(Actions.edit(props, props.pages.list.entity, getIDs));
76
- if (props.pages.list.ui.action?.menus.delete ?? true)
77
- action.menus[name_actions].push(Actions.delete(getIDs));
99
+ getIDs = () => [].filter(id => id) as string[];
78
100
  }
79
101
 
80
102
  if (props.pages?.edit)
81
103
  {
104
+ let { id } = useParams();
105
+ getIDs = () => [id].filter(id => id) as string[];
106
+
82
107
  if (!action.title)
83
108
  {
84
- let name = NamingConvention.Pascal_Case.convert(props.pages.edit.entity.name, NamingConvention.Pascal_Case_Space);
85
109
  action.title = (props.pages.edit.isEdit ? "Edit" : "New") + " " + name;
86
110
  }
87
- if (!action.menus[name_apply])
88
- action.menus[name_apply] = [];
89
111
 
90
- let { id } = useParams();
91
- let getIDs = () => [id].filter(id => id) as string[];
92
- if (props.pages.edit.ui.action?.menus.view ?? true)
93
- action.menus[name_actions].push(Actions.view(props, props.pages.edit.entity, getIDs));
94
- if (props.pages.edit.ui.action?.menus.viewHistory ?? true)
95
- action.menus[name_actions].push(Actions.viewHistory(getIDs));
96
- if (props.pages.edit.ui.action?.menus.copy ?? true)
97
- action.menus[name_actions].push(Actions.copy(props, props.pages.edit.entity, getIDs));
98
- if (props.pages.edit.ui.action?.menus.edit ?? true)
99
- action.menus[name_actions].push(Actions.edit(props, props.pages.edit.entity, getIDs));
100
- if (props.pages.edit.ui.action?.menus.delete ?? true)
101
- action.menus[name_actions].push(Actions.delete(getIDs));
112
+ // Menu
102
113
  if (props.pages.edit.ui.action?.menus.apply ?? true)
103
114
  action.menus[name_apply].push(Actions.apply(() =>
104
115
  {
105
116
  if (props.pages?.edit)
106
- NSASectionEdit_onApply(props.pages?.edit, id);
117
+ NSASectionEdit_onApply(props.pages?.edit, props.pages.entity, id);
107
118
  }));
108
119
  }
109
120
 
110
121
  if (props.pages?.view)
111
122
  {
112
- action.menus[name_actions].push(Actions.viewHistory(() => []));
113
- // action.menus[name_actions].push(Actions.copy(() => []));
114
- // action.menus[name_actions].push(Actions.edit(() => []));
115
- action.menus[name_actions].push(Actions.delete(() => []));
123
+ // todo
124
+ getIDs = () => [].filter(id => id) as string[];
116
125
  }
117
126
 
127
+ if (getIDs)
128
+ if (props.pages)
129
+ {
130
+ if (props.pages.ui?.action?.menus.view ?? true)
131
+ action.menus[name_actions].push(Actions.view(props, props.pages.entity, getIDs));
132
+ if (props.pages.ui?.action?.menus.viewHistory ?? true)
133
+ action.menus[name_actions].push(Actions.viewHistory(getIDs));
134
+ if (props.pages.ui?.action?.menus.copy ?? true)
135
+ action.menus[name_actions].push(Actions.copy(props, props.pages.entity, getIDs));
136
+ if (props.pages.ui?.action?.menus.edit ?? true)
137
+ action.menus[name_actions].push(Actions.edit(props, props.pages.entity, getIDs));
138
+ if (props.pages.ui?.action?.menus.delete ?? true)
139
+ action.menus[name_actions].push(Actions.delete(getIDs, showDeleteModal));
140
+ }
141
+
118
142
  let content;
119
143
  if (props.pages?.list)
120
- content = <NSASectionList<EntityType> {...props.pages.list}>{props.children}</NSASectionList>;
144
+ content = <NSASectionList<EntityType, EntityTypeInput> {...props.pages.list} entity={props.pages.entity}>{props.children}</NSASectionList>;
121
145
  else if (props.pages?.edit)
122
- content = <NSASectionEdit<EntityType, EntityTypeInput> {...props.pages.edit}>{props.children}</NSASectionEdit>;
146
+ content = <NSASectionEdit<EntityType, EntityTypeInput> {...props.pages.edit} entity={props.pages.entity}>{props.children}</NSASectionEdit>;
123
147
  else if (props.pages?.view)
124
148
  content = <NSASectionView<EntityType> {...props.pages.view}>{props.children}</NSASectionView>;
125
149
  else
@@ -139,6 +163,32 @@ export function NSALayout<EntityType extends { id: string }, EntityTypeInput = E
139
163
  }}
140
164
  >
141
165
  <div className="container-fluid">
166
+ <NSModal title={`Are you sure you want to delete ${name}?`} description={""} show={state.showDeleteModal}
167
+ onClose={hideDeleteModal} children={<NSButtonRed title="Yes" onClick={async () =>
168
+ {
169
+ try
170
+ {
171
+ if (props.pages)
172
+ if (getIDs)
173
+ {
174
+ let ids = getIDs();
175
+ if (ids.length == 0)
176
+ throw new Error("Nothing was found to delete.");
177
+ if (ids.length == 1)
178
+ {
179
+ await props.pages.entity.server.delete(ids[0]);
180
+ props.notifier.onSuccess(`${name} was deleted successfully.`);
181
+ }
182
+ else
183
+ // todo support multiple ids deletion
184
+ throw new Error("Multiple deletion is not supported yet.");
185
+ }
186
+
187
+ } catch (error: any)
188
+ {
189
+ props.notifier.onError(error);
190
+ }
191
+ }} />} />
142
192
  {content}
143
193
  </div>
144
194
  </NSLayout>
@@ -2,43 +2,40 @@ import { IBaseComponentProps } from "namirasoft-site-react";
2
2
  import { NSSection, NSPanel, NSButtonBlue, NSLine, NSSpace, NSSpaceSizeType, NSTabPage } from 'namirasoft-site-react';
3
3
  import { INSARouterProps } from "../INSARouterProps";
4
4
  import { ReactNode, useEffect } from "react";
5
- import { IEntityInfo } from "../IEntityInfo";
6
5
  import { useParams } from "react-router-dom";
6
+ import { IEntityInfo } from "../IEntityInfo";
7
+ import { NamingConvention } from "namirasoft-core";
7
8
 
8
9
  export interface NSASectionEditProps<EntityType extends { id: string }, EntityTypeInput = EntityType> extends IBaseComponentProps, INSARouterProps
9
10
  {
10
- entity: IEntityInfo<EntityType, EntityTypeInput>;
11
11
  isEdit: boolean;
12
12
  ui: {
13
13
  getEntity: (entity: EntityType | null) => EntityTypeInput;
14
14
  setEntity: (entity: EntityType) => void;
15
15
  action?: {
16
16
  menus: {
17
- view?: boolean,
18
- viewHistory?: boolean,
19
- copy?: boolean,
20
- edit?: boolean,
21
- delete?: boolean,
22
17
  apply?: boolean,
23
18
  }
24
19
  }
25
20
  }
26
21
  }
27
22
 
28
- export function onApply<EntityType extends { id: string }, EntityTypeInput = EntityType>(props: NSASectionEditProps<EntityType, EntityTypeInput>, id: string | undefined): void
23
+ export function onApply<EntityType extends { id: string }, EntityTypeInput = EntityType>(props: NSASectionEditProps<EntityType, EntityTypeInput>, entity: IEntityInfo<EntityType, EntityTypeInput>, id: string | undefined): void
29
24
  {
30
25
  try
31
26
  {
27
+ let name = NamingConvention.Pascal_Case.convert(entity.name, NamingConvention.Pascal_Case_Space);
28
+
32
29
  let onSuccess = (new_entity: EntityType, message: string) =>
33
30
  {
34
31
  props.notifier.onSuccess(message);
35
- if (props.entity.client.onSuccess)
36
- props.entity.client.onSuccess(new_entity);
32
+ if (entity.client.onSuccess)
33
+ entity.client.onSuccess(new_entity);
37
34
  else
38
35
  {
39
- let url = props.entity.client.getViewURL(new_entity.id);
36
+ let url = entity.client.getViewURL(new_entity.id);
40
37
  if (!url)
41
- url = props.entity.client.getListURL();
38
+ url = entity.client.getListURL();
42
39
  props.url.redirect(url, {});
43
40
  }
44
41
  };
@@ -47,18 +44,18 @@ export function onApply<EntityType extends { id: string }, EntityTypeInput = Ent
47
44
  if (props.isEdit)
48
45
  {
49
46
  if (id)
50
- props.entity.server.update(id, cur_entity).then((new_entity) =>
47
+ entity.server.update(id, cur_entity).then((new_entity) =>
51
48
  {
52
- onSuccess(new_entity, props.entity.name + " has been updated successfully");
49
+ onSuccess(new_entity, name + " has been updated successfully");
53
50
  }).catch(() => { });
54
51
  else
55
52
  throw new Error("ID was not provided.");
56
53
  }
57
54
  else
58
55
  {
59
- props.entity.server.create(cur_entity).then((new_entity) =>
56
+ entity.server.create(cur_entity).then((new_entity) =>
60
57
  {
61
- onSuccess(new_entity, props.entity.name + " has been created successfully");
58
+ onSuccess(new_entity, name + " has been created successfully");
62
59
  }).catch(() => { });
63
60
  }
64
61
  } catch (error: any)
@@ -67,7 +64,7 @@ export function onApply<EntityType extends { id: string }, EntityTypeInput = Ent
67
64
  }
68
65
  }
69
66
 
70
- export function NSASectionEdit<EntityType extends { id: string }, EntityTypeInput = EntityType>(props: NSASectionEditProps<EntityType, EntityTypeInput> & { children: ReactNode; })
67
+ export function NSASectionEdit<EntityType extends { id: string }, EntityTypeInput = EntityType>(props: NSASectionEditProps<EntityType, EntityTypeInput> & { entity: IEntityInfo<EntityType, EntityTypeInput>, children: ReactNode; })
71
68
  {
72
69
  let { id } = useParams();
73
70
 
@@ -107,7 +104,7 @@ export function NSASectionEdit<EntityType extends { id: string }, EntityTypeInpu
107
104
  {props.children}
108
105
  </NSPanel>
109
106
  <NSSpace size={NSSpaceSizeType.NORMAL}></NSSpace>
110
- <NSButtonBlue title="Apply" onClick={() => { onApply(props, id); }} />
107
+ <NSButtonBlue title="Apply" onClick={() => { onApply(props, props.entity, id); }} />
111
108
  <NSSpace size={NSSpaceSizeType.NORMAL}></NSSpace>
112
109
  {props.isEdit && <NSLine />}
113
110
  {props.isEdit && <NSSpace size={NSSpaceSizeType.NORMAL}></NSSpace>}
@@ -2,9 +2,8 @@ import { NSLine, NSSection, NSSpace, NSSpaceSizeType, NSTabPage, NSTable } from
2
2
  import { ReactNode, useEffect, useRef, useState } from "react";
3
3
  import { IEntityInfo } from "../IEntityInfo";
4
4
 
5
- export interface NSASectionListProps<EntityType extends { id: string }>
5
+ export interface NSASectionListProps
6
6
  {
7
- entity: IEntityInfo<EntityType>;
8
7
  ui: {
9
8
  getColumns: () => { [key: string]: string };
10
9
  action?: {
@@ -30,9 +29,9 @@ export interface NSASectionListState
30
29
  selected: string[];
31
30
  }
32
31
 
33
- export function NSASectionList<EntityType extends { id: string }>(props: NSASectionListProps<EntityType> & { children: ReactNode })
32
+ export function NSASectionList<EntityType extends { id: string }, EntityTypeInput>(props: NSASectionListProps & { entity: IEntityInfo<EntityType, EntityTypeInput>, children: ReactNode })
34
33
  {
35
- const NSTable_Device = useRef<NSTable<EntityType>>(null);
34
+ const NSTable_Rows = useRef<NSTable<EntityType>>(null);
36
35
 
37
36
  const [state, setState] = useState<NSASectionListState>({ page: { current: 1, size: 25 }, totalItems: 0, selected: [] });
38
37
 
@@ -54,7 +53,7 @@ export function NSASectionList<EntityType extends { id: string }>(props: NSASect
54
53
  {
55
54
  props.entity.server.list(null, state.page.current, state.page.size).then(response =>
56
55
  {
57
- NSTable_Device.current?.setRows(response.rows);
56
+ NSTable_Rows.current?.setRows(response.rows);
58
57
  setState(prevState => ({ ...prevState, totalItems: response.count ?? 0 }));
59
58
  }).catch(() => { });
60
59
  };
@@ -94,7 +93,7 @@ export function NSASectionList<EntityType extends { id: string }>(props: NSASect
94
93
  return (
95
94
  <NSSection center_items={false}>
96
95
  <NSTable<EntityType>
97
- ref={NSTable_Device}
96
+ ref={NSTable_Rows}
98
97
  columns={getColumns()}
99
98
  getRowKey={getRowKey}
100
99
  getColumnAttributes={getColumnAttributes}