@gpa-gemstone/common-pages 0.0.104 → 0.0.105

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. package/lib/ErrorBoundary.d.ts +17 -17
  2. package/lib/ErrorBoundary.js +91 -68
  3. package/lib/Note.d.ts +22 -22
  4. package/lib/Note.js +256 -230
  5. package/lib/SearchBar.d.ts +37 -37
  6. package/lib/SearchBar.js +203 -180
  7. package/lib/SelectionPopup.d.ts +42 -42
  8. package/lib/SelectionPopup.js +93 -90
  9. package/lib/Setting.d.ts +8 -8
  10. package/lib/Setting.js +151 -125
  11. package/lib/SliceInterfaces.d.ts +76 -76
  12. package/lib/SliceInterfaces.js +2 -2
  13. package/lib/StandardSelectPopup.d.ts +20 -20
  14. package/lib/StandardSelectPopup.js +135 -109
  15. package/lib/TimeFilter/QuickSelects.d.ts +7 -0
  16. package/lib/TimeFilter/QuickSelects.js +240 -0
  17. package/lib/TimeFilter.d.ts +26 -0
  18. package/lib/TimeFilter.js +270 -0
  19. package/lib/TimeWindowUtils.d.ts +33 -0
  20. package/lib/TimeWindowUtils.js +121 -0
  21. package/lib/ValueList/ByValueList.d.ts +10 -10
  22. package/lib/ValueList/ByValueList.js +141 -115
  23. package/lib/ValueList/Group.d.ts +11 -11
  24. package/lib/ValueList/Group.js +97 -71
  25. package/lib/ValueList/GroupForm.d.ts +9 -9
  26. package/lib/ValueList/GroupForm.js +74 -51
  27. package/lib/ValueList/GroupInfo.d.ts +8 -8
  28. package/lib/ValueList/GroupInfo.js +95 -69
  29. package/lib/ValueList/GroupItem.d.ts +9 -9
  30. package/lib/ValueList/GroupItem.js +142 -116
  31. package/lib/ValueList/ItemForm.d.ts +9 -9
  32. package/lib/ValueList/ItemForm.js +82 -59
  33. package/lib/index.d.ts +12 -11
  34. package/lib/index.js +50 -45
  35. package/lib/user/AdditionalField.d.ts +26 -26
  36. package/lib/user/AdditionalField.js +290 -264
  37. package/lib/user/ByUser.d.ts +12 -12
  38. package/lib/user/ByUser.js +174 -148
  39. package/lib/user/User.d.ts +14 -14
  40. package/lib/user/User.js +97 -71
  41. package/lib/user/UserForm.d.ts +12 -12
  42. package/lib/user/UserForm.js +166 -143
  43. package/lib/user/UserInfo.d.ts +7 -7
  44. package/lib/user/UserInfo.js +123 -97
  45. package/lib/user/UserPermissions.d.ts +8 -8
  46. package/lib/user/UserPermissions.js +106 -83
  47. package/package.json +9 -8
@@ -1,116 +1,142 @@
1
- "use strict";
2
- // ******************************************************************************************************
3
- // GroupItem.tsx - Gbtc
4
- //
5
- // Copyright © 2021, Grid Protection Alliance. All Rights Reserved.
6
- //
7
- // Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
8
- // the NOTICE file distributed with this work for additional information regarding copyright ownership.
9
- // The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
10
- // file except in compliance with the License. You may obtain a copy of the License at:
11
- //
12
- // http://opensource.org/licenses/MIT
13
- //
14
- // Unless agreed to in writing, the subject software distributed under the License is distributed on an
15
- // "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
16
- // License for the specific language governing permissions and limitations.
17
- //
18
- // Code Modification History:
19
- // ----------------------------------------------------------------------------------------------------
20
- // 07/04/2021 - C. Lackner
21
- // Generated original version of source code.
22
- // ******************************************************************************************************
23
- var __assign = (this && this.__assign) || function () {
24
- __assign = Object.assign || function(t) {
25
- for (var s, i = 1, n = arguments.length; i < n; i++) {
26
- s = arguments[i];
27
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
28
- t[p] = s[p];
29
- }
30
- return t;
31
- };
32
- return __assign.apply(this, arguments);
33
- };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- var React = require("react");
36
- var ItemForm_1 = require("./ItemForm");
37
- var react_interactive_1 = require("@gpa-gemstone/react-interactive");
38
- var react_table_1 = require("@gpa-gemstone/react-table");
39
- var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
40
- var react_redux_1 = require("react-redux");
41
- function GroupItemsWindow(props) {
42
- var dispatch = (0, react_redux_1.useDispatch)();
43
- var recordStatus = (0, react_redux_1.useSelector)(props.ValueListItemSlice.Status);
44
- var data = (0, react_redux_1.useSelector)(props.ValueListItemSlice.Data);
45
- var parentID = (0, react_redux_1.useSelector)((props.ValueListItemSlice.ParentID === undefined ? function (state) { return -1; } : props.ValueListItemSlice.ParentID));
46
- var _a = React.useState('Value'), sortField = _a[0], setSortField = _a[1];
47
- var _b = React.useState(false), ascending = _b[0], setAscending = _b[1];
48
- var emptyRecord = { ID: 0, GroupID: props.Record.ID, Value: '', AltValue: '', SortOrder: 0 };
49
- var _c = React.useState(emptyRecord), record = _c[0], setRecord = _c[1];
50
- var _d = React.useState(false), showNew = _d[0], setShowNew = _d[1];
51
- var _e = React.useState([]), newErrors = _e[0], setNewErrors = _e[1];
52
- var _f = React.useState(true), validValue = _f[0], setValidValue = _f[1];
53
- React.useEffect(function () {
54
- if (recordStatus === 'unintiated' || recordStatus === 'changed' || parentID !== props.Record.ID)
55
- dispatch(props.ValueListItemSlice.Fetch(props.Record.ID));
56
- }, [recordStatus, dispatch]);
57
- React.useEffect(function () {
58
- dispatch(props.ValueListItemSlice.Sort({ Ascending: ascending, SortField: sortField }));
59
- }, [sortField, ascending]);
60
- React.useEffect(function () {
61
- if (record.Value === null)
62
- setValidValue(true);
63
- if (data.findIndex(function (d) { return d.Value.toLowerCase() === record.Value.toLowerCase(); }) > -1)
64
- setValidValue(false);
65
- else
66
- setValidValue(true);
67
- }, [record, data]);
68
- return (React.createElement("div", { className: "card", style: { marginBottom: 10 } },
69
- React.createElement("div", { className: "card-header" },
70
- React.createElement("div", { className: "row" },
71
- React.createElement("div", { className: "col" },
72
- React.createElement("h4", null, "List Items:")))),
73
- React.createElement("div", { className: "card-body" },
74
- React.createElement("div", { className: "row" },
75
- React.createElement("div", { style: { width: '100%', height: window.innerHeight - 421, maxHeight: window.innerHeight - 421, padding: 0, overflowY: 'auto' } },
76
- React.createElement(react_table_1.SearchableTable, { cols: [
77
- { key: 'Value', field: 'Value', label: 'Value', headerStyle: { width: 'auto' }, rowStyle: { width: 'auto' } },
78
- { key: 'AltValue', field: 'AltValue', label: 'Alternate Value', headerStyle: { width: 'auto' }, rowStyle: { width: 'auto' } },
79
- { key: 'SortOrder', field: 'SortOrder', label: 'Sort Order', headerStyle: { width: 'auto' }, rowStyle: { width: 'auto' } },
80
- { key: 'remove', label: '', headerStyle: { width: '10%' }, rowStyle: { width: '10%' }, content: function (item) { return React.createElement("button", { className: "btn btn-sm", onClick: function (e) {
81
- e.preventDefault();
82
- dispatch(props.ValueListItemSlice.DBAction({ verb: 'DELETE', record: item }));
83
- } },
84
- React.createElement("span", null,
85
- React.createElement("i", { className: "fa fa-times" }))); }
86
- },
87
- { key: 'scroll', label: '', headerStyle: { width: 17, padding: 0 }, rowStyle: { width: 0, padding: 0 } },
88
- ], tableClass: "table table-hover", data: data, sortKey: sortField, onSort: function (d) {
89
- if (d.colKey === 'remove' || d.colKey === 'scroll' || d.colField === undefined)
90
- return;
91
- setSortField(d.colField);
92
- if (d.colField === sortField)
93
- setAscending(function (asc) { return !asc; });
94
- else
95
- setAscending(true);
96
- }, ascending: true, onClick: function () { }, theadStyle: { fontSize: 'smaller', display: 'table', tableLayout: 'fixed', width: '100%' }, tbodyStyle: { display: 'block', overflowY: 'scroll', maxHeight: window.innerHeight - 300, width: '100%' }, rowStyle: { fontSize: 'smaller', display: 'table', tableLayout: 'fixed', width: '100%' }, selected: function (item) { return false; }, matchSearch: function (item, search) { return item.Value.toLowerCase().indexOf(search.toLowerCase()) > -1; } })))),
97
- React.createElement("div", { className: "card-footer" },
98
- React.createElement("div", { className: "btn-group mr-2" },
99
- React.createElement("button", { className: "btn btn-primary pull-right", "data-toggle": "modal", "data-target": "#exampleModal", onClick: function () { setRecord(__assign(__assign({}, emptyRecord), { GroupID: props.Record.ID })); setShowNew(true); } }, "Add Item"))),
100
- React.createElement(react_interactive_1.Modal, { Title: 'Add new List Item', Show: showNew, Size: 'lg', ShowX: true, ShowCancel: false, DisableConfirm: newErrors.length > 0 || !validValue, ConfirmShowToolTip: newErrors.length > 0 || !validValue, ConfirmToolTipContent: React.createElement(React.Fragment, null,
101
- newErrors.map(function (t, i) { return React.createElement("p", { key: i },
102
- " ",
103
- gpa_symbols_1.CrossMark,
104
- " ",
105
- t); }),
106
- !validValue ? React.createElement("p", null,
107
- " ",
108
- gpa_symbols_1.CrossMark,
109
- " A Value has to be unique in a given Item List.") : null), CallBack: function (c) {
110
- setShowNew(false);
111
- if (c)
112
- dispatch(props.ValueListItemSlice.DBAction({ verb: 'POST', record: record }));
113
- } },
114
- React.createElement(ItemForm_1.default, { Record: record, Setter: setRecord, ErrorSetter: setNewErrors }))));
115
- }
116
- exports.default = GroupItemsWindow;
1
+ "use strict";
2
+ // ******************************************************************************************************
3
+ // GroupItem.tsx - Gbtc
4
+ //
5
+ // Copyright © 2021, Grid Protection Alliance. All Rights Reserved.
6
+ //
7
+ // Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
8
+ // the NOTICE file distributed with this work for additional information regarding copyright ownership.
9
+ // The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
10
+ // file except in compliance with the License. You may obtain a copy of the License at:
11
+ //
12
+ // http://opensource.org/licenses/MIT
13
+ //
14
+ // Unless agreed to in writing, the subject software distributed under the License is distributed on an
15
+ // "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
16
+ // License for the specific language governing permissions and limitations.
17
+ //
18
+ // Code Modification History:
19
+ // ----------------------------------------------------------------------------------------------------
20
+ // 07/04/2021 - C. Lackner
21
+ // Generated original version of source code.
22
+ // ******************************************************************************************************
23
+ var __assign = (this && this.__assign) || function () {
24
+ __assign = Object.assign || function(t) {
25
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
26
+ s = arguments[i];
27
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
28
+ t[p] = s[p];
29
+ }
30
+ return t;
31
+ };
32
+ return __assign.apply(this, arguments);
33
+ };
34
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
35
+ if (k2 === undefined) k2 = k;
36
+ var desc = Object.getOwnPropertyDescriptor(m, k);
37
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
38
+ desc = { enumerable: true, get: function() { return m[k]; } };
39
+ }
40
+ Object.defineProperty(o, k2, desc);
41
+ }) : (function(o, m, k, k2) {
42
+ if (k2 === undefined) k2 = k;
43
+ o[k2] = m[k];
44
+ }));
45
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
46
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
47
+ }) : function(o, v) {
48
+ o["default"] = v;
49
+ });
50
+ var __importStar = (this && this.__importStar) || function (mod) {
51
+ if (mod && mod.__esModule) return mod;
52
+ var result = {};
53
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
54
+ __setModuleDefault(result, mod);
55
+ return result;
56
+ };
57
+ var __importDefault = (this && this.__importDefault) || function (mod) {
58
+ return (mod && mod.__esModule) ? mod : { "default": mod };
59
+ };
60
+ Object.defineProperty(exports, "__esModule", { value: true });
61
+ exports.default = GroupItemsWindow;
62
+ var React = __importStar(require("react"));
63
+ var ItemForm_1 = __importDefault(require("./ItemForm"));
64
+ var react_interactive_1 = require("@gpa-gemstone/react-interactive");
65
+ var react_table_1 = require("@gpa-gemstone/react-table");
66
+ var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
67
+ var react_redux_1 = require("react-redux");
68
+ function GroupItemsWindow(props) {
69
+ var dispatch = (0, react_redux_1.useDispatch)();
70
+ var recordStatus = (0, react_redux_1.useSelector)(props.ValueListItemSlice.Status);
71
+ var data = (0, react_redux_1.useSelector)(props.ValueListItemSlice.Data);
72
+ var parentID = (0, react_redux_1.useSelector)((props.ValueListItemSlice.ParentID === undefined ? function (state) { return -1; } : props.ValueListItemSlice.ParentID));
73
+ var _a = React.useState('Value'), sortField = _a[0], setSortField = _a[1];
74
+ var _b = React.useState(false), ascending = _b[0], setAscending = _b[1];
75
+ var emptyRecord = { ID: 0, GroupID: props.Record.ID, Value: '', AltValue: '', SortOrder: 0 };
76
+ var _c = React.useState(emptyRecord), record = _c[0], setRecord = _c[1];
77
+ var _d = React.useState(false), showNew = _d[0], setShowNew = _d[1];
78
+ var _e = React.useState([]), newErrors = _e[0], setNewErrors = _e[1];
79
+ var _f = React.useState(true), validValue = _f[0], setValidValue = _f[1];
80
+ React.useEffect(function () {
81
+ if (recordStatus === 'unintiated' || recordStatus === 'changed' || parentID !== props.Record.ID)
82
+ dispatch(props.ValueListItemSlice.Fetch(props.Record.ID));
83
+ }, [recordStatus, dispatch]);
84
+ React.useEffect(function () {
85
+ dispatch(props.ValueListItemSlice.Sort({ Ascending: ascending, SortField: sortField }));
86
+ }, [sortField, ascending]);
87
+ React.useEffect(function () {
88
+ if (record.Value === null)
89
+ setValidValue(true);
90
+ if (data.findIndex(function (d) { return d.Value.toLowerCase() === record.Value.toLowerCase(); }) > -1)
91
+ setValidValue(false);
92
+ else
93
+ setValidValue(true);
94
+ }, [record, data]);
95
+ return (React.createElement("div", { className: "card", style: { marginBottom: 10 } },
96
+ React.createElement("div", { className: "card-header" },
97
+ React.createElement("div", { className: "row" },
98
+ React.createElement("div", { className: "col" },
99
+ React.createElement("h4", null, "List Items:")))),
100
+ React.createElement("div", { className: "card-body" },
101
+ React.createElement("div", { className: "row" },
102
+ React.createElement("div", { style: { width: '100%', height: window.innerHeight - 421, maxHeight: window.innerHeight - 421, padding: 0, overflowY: 'auto' } },
103
+ React.createElement(react_table_1.SearchableTable, { cols: [
104
+ { key: 'Value', field: 'Value', label: 'Value', headerStyle: { width: 'auto' }, rowStyle: { width: 'auto' } },
105
+ { key: 'AltValue', field: 'AltValue', label: 'Alternate Value', headerStyle: { width: 'auto' }, rowStyle: { width: 'auto' } },
106
+ { key: 'SortOrder', field: 'SortOrder', label: 'Sort Order', headerStyle: { width: 'auto' }, rowStyle: { width: 'auto' } },
107
+ { key: 'remove', label: '', headerStyle: { width: '10%' }, rowStyle: { width: '10%' }, content: function (item) { return React.createElement("button", { className: "btn btn-sm", onClick: function (e) {
108
+ e.preventDefault();
109
+ dispatch(props.ValueListItemSlice.DBAction({ verb: 'DELETE', record: item }));
110
+ } },
111
+ React.createElement("span", null,
112
+ React.createElement("i", { className: "fa fa-times" }))); }
113
+ },
114
+ { key: 'scroll', label: '', headerStyle: { width: 17, padding: 0 }, rowStyle: { width: 0, padding: 0 } },
115
+ ], tableClass: "table table-hover", data: data, sortKey: sortField, onSort: function (d) {
116
+ if (d.colKey === 'remove' || d.colKey === 'scroll' || d.colField === undefined)
117
+ return;
118
+ setSortField(d.colField);
119
+ if (d.colField === sortField)
120
+ setAscending(function (asc) { return !asc; });
121
+ else
122
+ setAscending(true);
123
+ }, ascending: true, onClick: function () { }, theadStyle: { fontSize: 'smaller', display: 'table', tableLayout: 'fixed', width: '100%' }, tbodyStyle: { display: 'block', overflowY: 'scroll', maxHeight: window.innerHeight - 300, width: '100%' }, rowStyle: { fontSize: 'smaller', display: 'table', tableLayout: 'fixed', width: '100%' }, selected: function (item) { return false; }, matchSearch: function (item, search) { return item.Value.toLowerCase().indexOf(search.toLowerCase()) > -1; } })))),
124
+ React.createElement("div", { className: "card-footer" },
125
+ React.createElement("div", { className: "btn-group mr-2" },
126
+ React.createElement("button", { className: "btn btn-primary pull-right", "data-toggle": "modal", "data-target": "#exampleModal", onClick: function () { setRecord(__assign(__assign({}, emptyRecord), { GroupID: props.Record.ID })); setShowNew(true); } }, "Add Item"))),
127
+ React.createElement(react_interactive_1.Modal, { Title: 'Add new List Item', Show: showNew, Size: 'lg', ShowX: true, ShowCancel: false, DisableConfirm: newErrors.length > 0 || !validValue, ConfirmShowToolTip: newErrors.length > 0 || !validValue, ConfirmToolTipContent: React.createElement(React.Fragment, null,
128
+ newErrors.map(function (t, i) { return React.createElement("p", { key: i },
129
+ " ",
130
+ gpa_symbols_1.CrossMark,
131
+ " ",
132
+ t); }),
133
+ !validValue ? React.createElement("p", null,
134
+ " ",
135
+ gpa_symbols_1.CrossMark,
136
+ " A Value has to be unique in a given Item List.") : null), CallBack: function (c) {
137
+ setShowNew(false);
138
+ if (c)
139
+ dispatch(props.ValueListItemSlice.DBAction({ verb: 'POST', record: record }));
140
+ } },
141
+ React.createElement(ItemForm_1.default, { Record: record, Setter: setRecord, ErrorSetter: setNewErrors }))));
142
+ }
@@ -1,9 +1,9 @@
1
- /// <reference types="react" />
2
- import { SystemCenter } from '@gpa-gemstone/application-typings';
3
- interface IProps {
4
- Record: SystemCenter.Types.ValueListItem;
5
- Setter: (record: SystemCenter.Types.ValueListItem) => void;
6
- ErrorSetter?: (errors: string[]) => void;
7
- }
8
- export default function ItemForm(props: IProps): JSX.Element;
9
- export {};
1
+ import * as React from 'react';
2
+ import { SystemCenter } from '@gpa-gemstone/application-typings';
3
+ interface IProps {
4
+ Record: SystemCenter.Types.ValueListItem;
5
+ Setter: (record: SystemCenter.Types.ValueListItem) => void;
6
+ ErrorSetter?: (errors: string[]) => void;
7
+ }
8
+ export default function ItemForm(props: IProps): React.JSX.Element;
9
+ export {};
@@ -1,59 +1,82 @@
1
- "use strict";
2
- // ******************************************************************************************************
3
- // ItemForm.tsx - Gbtc
4
- //
5
- // Copyright © 2020, Grid Protection Alliance. All Rights Reserved.
6
- //
7
- // Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
8
- // the NOTICE file distributed with this work for additional information regarding copyright ownership.
9
- // The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
10
- // file except in compliance with the License. You may obtain a copy of the License at:
11
- //
12
- // http://opensource.org/licenses/MIT
13
- //
14
- // Unless agreed to in writing, the subject software distributed under the License is distributed on an
15
- // "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
16
- // License for the specific language governing permissions and limitations.
17
- //
18
- // Code Modification History:
19
- // ----------------------------------------------------------------------------------------------------
20
- // 07/04/2021 - C. Lackner
21
- // Generated original version of source code.
22
- // ******************************************************************************************************
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- var React = require("react");
25
- var react_forms_1 = require("@gpa-gemstone/react-forms");
26
- var helper_functions_1 = require("@gpa-gemstone/helper-functions");
27
- function ItemForm(props) {
28
- var _a = React.useState([]), errors = _a[0], setErrors = _a[1];
29
- React.useEffect(function () {
30
- var e = [];
31
- if (props.Record.Value == null || props.Record.Value.length === 0)
32
- e.push('A Value is required.');
33
- if (props.Record.Value != null && props.Record.Value.length > 200)
34
- e.push('Value has to be less than 200 characters.');
35
- if (props.Record.AltValue != null && props.Record.AltValue.length > 200)
36
- e.push('Alt Value has to be less than 200 characters.');
37
- if (props.Record.SortOrder != null && !(0, helper_functions_1.IsInteger)(props.Record.SortOrder))
38
- e.push('Sort Order has to be an integer or be left blank.');
39
- setErrors(e);
40
- }, [props.Record]);
41
- React.useEffect(function () {
42
- if (props.ErrorSetter !== undefined)
43
- props.ErrorSetter(errors);
44
- }, [errors, props.ErrorSetter]);
45
- function Valid(field) {
46
- if (field === 'Value')
47
- return props.Record.Value != null && props.Record.Value.length > 0 && props.Record.Value.length <= 200;
48
- else if (field === 'AltValue')
49
- return props.Record.AltValue == null || props.Record.AltValue.length <= 200;
50
- else if (field === 'SortOrder')
51
- return props.Record.SortOrder == null || (0, helper_functions_1.IsInteger)(props.Record.SortOrder);
52
- return true;
53
- }
54
- return (React.createElement("form", null,
55
- React.createElement(react_forms_1.Input, { Record: props.Record, Field: 'Value', Feedback: 'Value must be set and be less than 200 characters.', Valid: Valid, Setter: props.Setter }),
56
- React.createElement(react_forms_1.Input, { Record: props.Record, Field: 'AltValue', Label: 'Alt. Value', Feedback: 'Alt. Value must be less than 200 characters.', Valid: Valid, Setter: props.Setter }),
57
- React.createElement(react_forms_1.Input, { Record: props.Record, Field: 'SortOrder', Label: 'Sort Order', Type: 'number', Valid: Valid, Setter: props.Setter })));
58
- }
59
- exports.default = ItemForm;
1
+ "use strict";
2
+ // ******************************************************************************************************
3
+ // ItemForm.tsx - Gbtc
4
+ //
5
+ // Copyright © 2020, Grid Protection Alliance. All Rights Reserved.
6
+ //
7
+ // Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
8
+ // the NOTICE file distributed with this work for additional information regarding copyright ownership.
9
+ // The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
10
+ // file except in compliance with the License. You may obtain a copy of the License at:
11
+ //
12
+ // http://opensource.org/licenses/MIT
13
+ //
14
+ // Unless agreed to in writing, the subject software distributed under the License is distributed on an
15
+ // "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
16
+ // License for the specific language governing permissions and limitations.
17
+ //
18
+ // Code Modification History:
19
+ // ----------------------------------------------------------------------------------------------------
20
+ // 07/04/2021 - C. Lackner
21
+ // Generated original version of source code.
22
+ // ******************************************************************************************************
23
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
24
+ if (k2 === undefined) k2 = k;
25
+ var desc = Object.getOwnPropertyDescriptor(m, k);
26
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
27
+ desc = { enumerable: true, get: function() { return m[k]; } };
28
+ }
29
+ Object.defineProperty(o, k2, desc);
30
+ }) : (function(o, m, k, k2) {
31
+ if (k2 === undefined) k2 = k;
32
+ o[k2] = m[k];
33
+ }));
34
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
35
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
36
+ }) : function(o, v) {
37
+ o["default"] = v;
38
+ });
39
+ var __importStar = (this && this.__importStar) || function (mod) {
40
+ if (mod && mod.__esModule) return mod;
41
+ var result = {};
42
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
43
+ __setModuleDefault(result, mod);
44
+ return result;
45
+ };
46
+ Object.defineProperty(exports, "__esModule", { value: true });
47
+ exports.default = ItemForm;
48
+ var React = __importStar(require("react"));
49
+ var react_forms_1 = require("@gpa-gemstone/react-forms");
50
+ var helper_functions_1 = require("@gpa-gemstone/helper-functions");
51
+ function ItemForm(props) {
52
+ var _a = React.useState([]), errors = _a[0], setErrors = _a[1];
53
+ React.useEffect(function () {
54
+ var e = [];
55
+ if (props.Record.Value == null || props.Record.Value.length === 0)
56
+ e.push('A Value is required.');
57
+ if (props.Record.Value != null && props.Record.Value.length > 200)
58
+ e.push('Value has to be less than 200 characters.');
59
+ if (props.Record.AltValue != null && props.Record.AltValue.length > 200)
60
+ e.push('Alt Value has to be less than 200 characters.');
61
+ if (props.Record.SortOrder != null && !(0, helper_functions_1.IsInteger)(props.Record.SortOrder))
62
+ e.push('Sort Order has to be an integer or be left blank.');
63
+ setErrors(e);
64
+ }, [props.Record]);
65
+ React.useEffect(function () {
66
+ if (props.ErrorSetter !== undefined)
67
+ props.ErrorSetter(errors);
68
+ }, [errors, props.ErrorSetter]);
69
+ function Valid(field) {
70
+ if (field === 'Value')
71
+ return props.Record.Value != null && props.Record.Value.length > 0 && props.Record.Value.length <= 200;
72
+ else if (field === 'AltValue')
73
+ return props.Record.AltValue == null || props.Record.AltValue.length <= 200;
74
+ else if (field === 'SortOrder')
75
+ return props.Record.SortOrder == null || (0, helper_functions_1.IsInteger)(props.Record.SortOrder);
76
+ return true;
77
+ }
78
+ return (React.createElement("form", null,
79
+ React.createElement(react_forms_1.Input, { Record: props.Record, Field: 'Value', Feedback: 'Value must be set and be less than 200 characters.', Valid: Valid, Setter: props.Setter }),
80
+ React.createElement(react_forms_1.Input, { Record: props.Record, Field: 'AltValue', Label: 'Alt. Value', Feedback: 'Alt. Value must be less than 200 characters.', Valid: Valid, Setter: props.Setter }),
81
+ React.createElement(react_forms_1.Input, { Record: props.Record, Field: 'SortOrder', Label: 'Sort Order', Type: 'number', Valid: Valid, Setter: props.Setter })));
82
+ }
package/lib/index.d.ts CHANGED
@@ -1,11 +1,12 @@
1
- import Setting from './Setting';
2
- import Note from './Note';
3
- import ByValueList from './ValueList/ByValueList';
4
- import ValueList from './ValueList/Group';
5
- import ByUser from './user/ByUser';
6
- import User from './user/User';
7
- import { DefaultSearch } from './SearchBar';
8
- import SelectPopup from './StandardSelectPopup';
9
- import { DefaultSelects } from './SelectionPopup';
10
- import ErrorBoundary from './ErrorBoundary';
11
- export { Setting, Note, ValueList, ByValueList, User, ByUser, DefaultSearch, SelectPopup, DefaultSelects, ErrorBoundary };
1
+ import Setting from './Setting';
2
+ import Note from './Note';
3
+ import ByValueList from './ValueList/ByValueList';
4
+ import ValueList from './ValueList/Group';
5
+ import ByUser from './user/ByUser';
6
+ import User from './user/User';
7
+ import { DefaultSearch } from './SearchBar';
8
+ import SelectPopup from './StandardSelectPopup';
9
+ import { DefaultSelects } from './SelectionPopup';
10
+ import ErrorBoundary from './ErrorBoundary';
11
+ import TimeFilter from './TimeFilter';
12
+ export { Setting, TimeFilter, Note, ValueList, ByValueList, User, ByUser, DefaultSearch, SelectPopup, DefaultSelects, ErrorBoundary };
package/lib/index.js CHANGED
@@ -1,45 +1,50 @@
1
- "use strict";
2
- // ******************************************************************************************************
3
- // index.tsx - Gbtc
4
- //
5
- // Copyright © 2020, Grid Protection Alliance. All Rights Reserved.
6
- //
7
- // Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
8
- // the NOTICE file distributed with this work for additional information regarding copyright ownership.
9
- // The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
10
- // file except in compliance with the License. You may obtain a copy of the License at:
11
- //
12
- // http://opensource.org/licenses/MIT
13
- //
14
- // Unless agreed to in writing, the subject software distributed under the License is distributed on an
15
- // "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
16
- // License for the specific language governing permissions and limitations.
17
- //
18
- // Code Modification History:
19
- // ----------------------------------------------------------------------------------------------------
20
- // 12/29/2020 - C. Lackner
21
- // Generated original version of source code.
22
- //
23
- // ******************************************************************************************************
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.ErrorBoundary = exports.DefaultSelects = exports.SelectPopup = exports.DefaultSearch = exports.ByUser = exports.User = exports.ByValueList = exports.ValueList = exports.Note = exports.Setting = void 0;
26
- var Setting_1 = require("./Setting");
27
- exports.Setting = Setting_1.default;
28
- var Note_1 = require("./Note");
29
- exports.Note = Note_1.default;
30
- var ByValueList_1 = require("./ValueList/ByValueList");
31
- exports.ByValueList = ByValueList_1.default;
32
- var Group_1 = require("./ValueList/Group");
33
- exports.ValueList = Group_1.default;
34
- var ByUser_1 = require("./user/ByUser");
35
- exports.ByUser = ByUser_1.default;
36
- var User_1 = require("./user/User");
37
- exports.User = User_1.default;
38
- var SearchBar_1 = require("./SearchBar");
39
- Object.defineProperty(exports, "DefaultSearch", { enumerable: true, get: function () { return SearchBar_1.DefaultSearch; } });
40
- var StandardSelectPopup_1 = require("./StandardSelectPopup");
41
- exports.SelectPopup = StandardSelectPopup_1.default;
42
- var SelectionPopup_1 = require("./SelectionPopup");
43
- Object.defineProperty(exports, "DefaultSelects", { enumerable: true, get: function () { return SelectionPopup_1.DefaultSelects; } });
44
- var ErrorBoundary_1 = require("./ErrorBoundary");
45
- exports.ErrorBoundary = ErrorBoundary_1.default;
1
+ "use strict";
2
+ // ******************************************************************************************************
3
+ // index.tsx - Gbtc
4
+ //
5
+ // Copyright © 2020, Grid Protection Alliance. All Rights Reserved.
6
+ //
7
+ // Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
8
+ // the NOTICE file distributed with this work for additional information regarding copyright ownership.
9
+ // The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
10
+ // file except in compliance with the License. You may obtain a copy of the License at:
11
+ //
12
+ // http://opensource.org/licenses/MIT
13
+ //
14
+ // Unless agreed to in writing, the subject software distributed under the License is distributed on an
15
+ // "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
16
+ // License for the specific language governing permissions and limitations.
17
+ //
18
+ // Code Modification History:
19
+ // ----------------------------------------------------------------------------------------------------
20
+ // 12/29/2020 - C. Lackner
21
+ // Generated original version of source code.
22
+ //
23
+ // ******************************************************************************************************
24
+ var __importDefault = (this && this.__importDefault) || function (mod) {
25
+ return (mod && mod.__esModule) ? mod : { "default": mod };
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.ErrorBoundary = exports.DefaultSelects = exports.SelectPopup = exports.DefaultSearch = exports.ByUser = exports.User = exports.ByValueList = exports.ValueList = exports.Note = exports.TimeFilter = exports.Setting = void 0;
29
+ var Setting_1 = __importDefault(require("./Setting"));
30
+ exports.Setting = Setting_1.default;
31
+ var Note_1 = __importDefault(require("./Note"));
32
+ exports.Note = Note_1.default;
33
+ var ByValueList_1 = __importDefault(require("./ValueList/ByValueList"));
34
+ exports.ByValueList = ByValueList_1.default;
35
+ var Group_1 = __importDefault(require("./ValueList/Group"));
36
+ exports.ValueList = Group_1.default;
37
+ var ByUser_1 = __importDefault(require("./user/ByUser"));
38
+ exports.ByUser = ByUser_1.default;
39
+ var User_1 = __importDefault(require("./user/User"));
40
+ exports.User = User_1.default;
41
+ var SearchBar_1 = require("./SearchBar");
42
+ Object.defineProperty(exports, "DefaultSearch", { enumerable: true, get: function () { return SearchBar_1.DefaultSearch; } });
43
+ var StandardSelectPopup_1 = __importDefault(require("./StandardSelectPopup"));
44
+ exports.SelectPopup = StandardSelectPopup_1.default;
45
+ var SelectionPopup_1 = require("./SelectionPopup");
46
+ Object.defineProperty(exports, "DefaultSelects", { enumerable: true, get: function () { return SelectionPopup_1.DefaultSelects; } });
47
+ var ErrorBoundary_1 = __importDefault(require("./ErrorBoundary"));
48
+ exports.ErrorBoundary = ErrorBoundary_1.default;
49
+ var TimeFilter_1 = __importDefault(require("./TimeFilter"));
50
+ exports.TimeFilter = TimeFilter_1.default;