@gpa-gemstone/common-pages 0.0.151 → 0.0.153
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/lib/BulkUpload.d.ts +1 -11
- package/lib/ErrorBoundary.d.ts +2 -2
- package/lib/EventCharacteristicFilter.d.ts +1 -2
- package/lib/EventTypeFilter.d.ts +1 -2
- package/lib/Gemstone/ControllerFunctions.d.ts +22 -0
- package/lib/Gemstone/ControllerFunctions.js +266 -0
- package/lib/Gemstone/Gemstone.d.ts +18 -0
- package/lib/Gemstone/Gemstone.js +41 -0
- package/lib/Gemstone/GenericSlices/ReadOnlyGenericSlice.d.ts +51 -0
- package/lib/Gemstone/GenericSlices/ReadOnlyGenericSlice.js +230 -0
- package/lib/Gemstone/GenericSlices/ReadWriteGenericSlice.d.ts +19 -0
- package/lib/Gemstone/GenericSlices/ReadWriteGenericSlice.js +241 -0
- package/lib/Gemstone/GenericSlices/useInitializeData.d.ts +10 -0
- package/lib/Gemstone/GenericSlices/useInitializeData.js +65 -0
- package/lib/NavBarFilterButton.d.ts +1 -2
- package/lib/Note.d.ts +1 -1
- package/lib/Note.js +1 -1
- package/lib/RoleAcessErrorPage.d.ts +1 -1
- package/lib/SearchBar.d.ts +6 -6
- package/lib/SelectionPopup.d.ts +6 -6
- package/lib/StandardSelectPopup.d.ts +1 -1
- package/lib/TimeFilter/QuickSelects.d.ts +1 -2
- package/lib/TimeFilter/StartEndFilter/DateFilter.d.ts +1 -2
- package/lib/TimeFilter/StartEndFilter/DateTimeLocalFilter.d.ts +1 -2
- package/lib/TimeFilter/StartEndFilter/StartEndFilter.d.ts +1 -1
- package/lib/TimeFilter/StartEndFilter/TimeFilter.d.ts +1 -2
- package/lib/TimeFilter/TimeFilter.d.ts +9 -2
- package/lib/TimeFilter/TimeFilter.js +30 -15
- package/lib/TimeFilter/WindowFilter/WindowFilter.d.ts +1 -2
- package/lib/TimeFilter/WindowFilter/WindowForm.d.ts +1 -2
- package/lib/index.d.ts +8 -1
- package/lib/index.js +12 -1
- package/package.json +13 -8
@@ -0,0 +1,230 @@
|
|
1
|
+
"use strict";
|
2
|
+
// ******************************************************************************************************
|
3
|
+
// ReadOnlyGenericSlice.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
|
+
// 08/12/2024 - Preston Crawford
|
21
|
+
// Generated original version of source code.
|
22
|
+
// ******************************************************************************************************
|
23
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
24
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
25
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
26
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
27
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
28
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
29
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
30
|
+
});
|
31
|
+
};
|
32
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
33
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
34
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
35
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
36
|
+
function step(op) {
|
37
|
+
if (f) throw new TypeError("Generator is already executing.");
|
38
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
39
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
40
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
41
|
+
switch (op[0]) {
|
42
|
+
case 0: case 1: t = op; break;
|
43
|
+
case 4: _.label++; return { value: op[1], done: false };
|
44
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
45
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
46
|
+
default:
|
47
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
48
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
49
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
50
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
51
|
+
if (t[2]) _.ops.pop();
|
52
|
+
_.trys.pop(); continue;
|
53
|
+
}
|
54
|
+
op = body.call(thisArg, _);
|
55
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
56
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
57
|
+
}
|
58
|
+
};
|
59
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
60
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
61
|
+
if (ar || !(i in from)) {
|
62
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
63
|
+
ar[i] = from[i];
|
64
|
+
}
|
65
|
+
}
|
66
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
67
|
+
};
|
68
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
69
|
+
var toolkit_1 = require("@reduxjs/toolkit");
|
70
|
+
var ControllerFunctions_1 = require("../ControllerFunctions");
|
71
|
+
/**
|
72
|
+
* A generic class providing functionalities related to a slice of data.
|
73
|
+
*/
|
74
|
+
var ReadOnlyGenericSlice = /** @class */ (function () {
|
75
|
+
function ReadOnlyGenericSlice(name, defaultSortField, ascending, apiPathOrReadOnlyController) {
|
76
|
+
var _this = this;
|
77
|
+
this.Data = function (state) { return state[_this.Name].Data; };
|
78
|
+
this.Error = function (state) { return state[_this.Name].Error; };
|
79
|
+
this.FetchStatus = function (state) { return state[_this.Name].FetchStatus; };
|
80
|
+
this.SortField = function (state) { return state[_this.Name].SortField; };
|
81
|
+
this.Ascending = function (state) { return state[_this.Name].Ascending; };
|
82
|
+
this.ParentID = function (state) { return state[_this.Name].ParentID; };
|
83
|
+
this.Name = name;
|
84
|
+
this.fetchHandle = null;
|
85
|
+
if (typeof apiPathOrReadOnlyController === 'string')
|
86
|
+
this.controller = new ControllerFunctions_1.ReadOnlyControllerFunctions(apiPathOrReadOnlyController);
|
87
|
+
else
|
88
|
+
this.controller = apiPathOrReadOnlyController;
|
89
|
+
this.Fetch = (0, toolkit_1.createAsyncThunk)("".concat(this.Name, "/Fetch").concat(this.Name), function () {
|
90
|
+
var args_1 = [];
|
91
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
92
|
+
args_1[_i] = arguments[_i];
|
93
|
+
}
|
94
|
+
return __awaiter(_this, __spreadArray([], args_1, true), void 0, function (arg, _a) {
|
95
|
+
var stateMap, state, fetchHandle, sortField, ascending, filter, parentID, paginationHandle;
|
96
|
+
var _b, _c, _d, _e, _f;
|
97
|
+
if (arg === void 0) { arg = undefined; }
|
98
|
+
var signal = _a.signal, getState = _a.getState;
|
99
|
+
return __generator(this, function (_g) {
|
100
|
+
stateMap = getState();
|
101
|
+
state = stateMap[this.Name];
|
102
|
+
if (this.fetchHandle != null && this.fetchHandle.abort != null)
|
103
|
+
this.fetchHandle.abort('Prev');
|
104
|
+
sortField = (_b = arg === null || arg === void 0 ? void 0 : arg.sortField) !== null && _b !== void 0 ? _b : state.SortField;
|
105
|
+
ascending = (_c = arg === null || arg === void 0 ? void 0 : arg.ascending) !== null && _c !== void 0 ? _c : state.Ascending;
|
106
|
+
filter = (_d = arg === null || arg === void 0 ? void 0 : arg.filter) !== null && _d !== void 0 ? _d : state.Filter;
|
107
|
+
parentID = (_f = (_e = arg === null || arg === void 0 ? void 0 : arg.parentID) !== null && _e !== void 0 ? _e : state.ParentID) !== null && _f !== void 0 ? _f : undefined;
|
108
|
+
if ((arg === null || arg === void 0 ? void 0 : arg.filter) == null)
|
109
|
+
fetchHandle = this.controller.GetPage(0, sortField, ascending, parentID);
|
110
|
+
else
|
111
|
+
fetchHandle = this.controller.SearchPage(0, sortField, ascending, filter, parentID);
|
112
|
+
this.fetchHandle = fetchHandle;
|
113
|
+
paginationHandle = this.controller.GetPageInfo();
|
114
|
+
signal.addEventListener('abort', function () {
|
115
|
+
if (fetchHandle.abort !== undefined)
|
116
|
+
fetchHandle.abort();
|
117
|
+
if (paginationHandle.abort !== undefined)
|
118
|
+
paginationHandle.abort();
|
119
|
+
});
|
120
|
+
return [2 /*return*/, Promise.all([fetchHandle]).then(function (responses) { return ({ Data: responses[0] }); })];
|
121
|
+
});
|
122
|
+
});
|
123
|
+
});
|
124
|
+
this.SetStatusToChanged = (0, toolkit_1.createAsyncThunk)("".concat(this.Name, "/SetChanged").concat(this.Name), function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
125
|
+
return [2 /*return*/];
|
126
|
+
}); }); });
|
127
|
+
this.initializeSlice(defaultSortField, ascending);
|
128
|
+
}
|
129
|
+
ReadOnlyGenericSlice.prototype.initializeSlice = function (defaultSortField, ascending) {
|
130
|
+
var _this = this;
|
131
|
+
if (ascending === void 0) { ascending = true; }
|
132
|
+
var initialState = {
|
133
|
+
FetchStatus: 'uninitiated',
|
134
|
+
Error: null,
|
135
|
+
Data: [],
|
136
|
+
SortField: defaultSortField,
|
137
|
+
Ascending: ascending,
|
138
|
+
Filter: [],
|
139
|
+
ActiveID: [],
|
140
|
+
PageInfo: {
|
141
|
+
PageCount: 0,
|
142
|
+
TotalCount: 0,
|
143
|
+
PageSize: 0
|
144
|
+
},
|
145
|
+
ParentID: null
|
146
|
+
};
|
147
|
+
this.Slice = (0, toolkit_1.createSlice)({
|
148
|
+
name: this.Name,
|
149
|
+
initialState: initialState,
|
150
|
+
reducers: {},
|
151
|
+
extraReducers: function (builder) {
|
152
|
+
builder.addCase(_this.Fetch.pending, function (state, action) {
|
153
|
+
state.FetchStatus = 'loading';
|
154
|
+
state.ActiveID.push(action.meta.requestId);
|
155
|
+
});
|
156
|
+
builder.addCase(_this.Fetch.rejected, function (state, action) {
|
157
|
+
var _a;
|
158
|
+
state.ActiveID = state.ActiveID.filter(function (id) { return id !== action.meta.requestId; });
|
159
|
+
if (state.ActiveID.length > 0)
|
160
|
+
return;
|
161
|
+
state.FetchStatus = 'error';
|
162
|
+
state.Error = {
|
163
|
+
Message: (_a = action.error.message) !== null && _a !== void 0 ? _a : '',
|
164
|
+
Action: 'FETCH',
|
165
|
+
Time: new Date().toString()
|
166
|
+
};
|
167
|
+
});
|
168
|
+
builder.addCase(_this.Fetch.fulfilled, function (state, action) {
|
169
|
+
var _a, _b;
|
170
|
+
state.ActiveID = state.ActiveID.filter(function (id) { return id !== action.meta.requestId; });
|
171
|
+
state.FetchStatus = 'idle';
|
172
|
+
state.Error = null;
|
173
|
+
state.Data = action.payload.Data;
|
174
|
+
if (action.meta.arg == null)
|
175
|
+
return;
|
176
|
+
if (action.meta.arg.filter != null)
|
177
|
+
state.Filter = (_a = action.meta.arg) === null || _a === void 0 ? void 0 : _a.filter;
|
178
|
+
if (action.meta.arg.parentID != null)
|
179
|
+
state.ParentID = (_b = action.meta.arg) === null || _b === void 0 ? void 0 : _b.parentID;
|
180
|
+
if (state.SortField === action.meta.arg.sortField)
|
181
|
+
state.Ascending = !state.Ascending;
|
182
|
+
else if (action.meta.arg.sortField != null)
|
183
|
+
state.SortField = action.meta.arg.sortField;
|
184
|
+
});
|
185
|
+
builder.addCase(_this.SetStatusToChanged.pending, function (state) {
|
186
|
+
state.FetchStatus = 'changed';
|
187
|
+
});
|
188
|
+
}
|
189
|
+
});
|
190
|
+
this.Reducer = this.Slice.reducer;
|
191
|
+
};
|
192
|
+
ReadOnlyGenericSlice.prototype.addExtraReducers = function (builder) {
|
193
|
+
builder.addCase(this.Fetch.pending, function (state, action) {
|
194
|
+
state.FetchStatus = 'loading';
|
195
|
+
state.ActiveID.push(action.meta.requestId);
|
196
|
+
});
|
197
|
+
builder.addCase(this.Fetch.rejected, function (state, action) {
|
198
|
+
var _a;
|
199
|
+
state.ActiveID = state.ActiveID.filter(function (id) { return id !== action.meta.requestId; });
|
200
|
+
if (state.ActiveID.length > 0)
|
201
|
+
return;
|
202
|
+
state.FetchStatus = 'error';
|
203
|
+
state.Error = {
|
204
|
+
Message: (_a = action.error.message) !== null && _a !== void 0 ? _a : '',
|
205
|
+
Action: 'FETCH',
|
206
|
+
Time: new Date().toString()
|
207
|
+
};
|
208
|
+
});
|
209
|
+
builder.addCase(this.Fetch.fulfilled, function (state, action) {
|
210
|
+
var _a, _b;
|
211
|
+
state.ActiveID = state.ActiveID.filter(function (id) { return id !== action.meta.requestId; });
|
212
|
+
state.FetchStatus = 'idle';
|
213
|
+
state.Error = null;
|
214
|
+
state.Data = action.payload.Data;
|
215
|
+
if (action.meta.arg.filter != null)
|
216
|
+
state.Filter = (_a = action.meta.arg) === null || _a === void 0 ? void 0 : _a.filter;
|
217
|
+
if (action.meta.arg.parentID != null)
|
218
|
+
state.ParentID = (_b = action.meta.arg) === null || _b === void 0 ? void 0 : _b.parentID;
|
219
|
+
if (state.SortField === action.meta.arg.sortField)
|
220
|
+
state.Ascending = !state.Ascending;
|
221
|
+
else if (action.meta.arg.sortField != null)
|
222
|
+
state.SortField = action.meta.arg.sortField;
|
223
|
+
});
|
224
|
+
builder.addCase(this.SetStatusToChanged.pending, function (state) {
|
225
|
+
state.FetchStatus = 'changed';
|
226
|
+
});
|
227
|
+
};
|
228
|
+
return ReadOnlyGenericSlice;
|
229
|
+
}());
|
230
|
+
exports.default = ReadOnlyGenericSlice;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { AsyncThunk } from '@reduxjs/toolkit';
|
2
|
+
import { ReadOnlyControllerFunctions, ReadWriteControllerFunctions } from '../ControllerFunctions';
|
3
|
+
import ReadOnlyGenericSlice from './ReadOnlyGenericSlice';
|
4
|
+
import { Application } from '@gpa-gemstone/application-typings';
|
5
|
+
export default class ReadWriteGenericSlice<T> extends ReadOnlyGenericSlice<T> {
|
6
|
+
Add: AsyncThunk<T, T, {}>;
|
7
|
+
Update: AsyncThunk<T, T, {}>;
|
8
|
+
Delete: AsyncThunk<T, (string | number | T), {}>;
|
9
|
+
private updateHandle;
|
10
|
+
private addHandle;
|
11
|
+
private deleteHandle;
|
12
|
+
private readWriteController;
|
13
|
+
constructor(name: string, defaultSortField: keyof T, ascending: boolean, apiPath: string);
|
14
|
+
constructor(name: string, defaultSortField: keyof T, ascending: boolean, readWriteController: ReadWriteControllerFunctions<T>, readOnlyController?: ReadOnlyControllerFunctions<T>);
|
15
|
+
private initializeReadWriteSlice;
|
16
|
+
UpdateStatus: (state: any) => Application.Types.Status;
|
17
|
+
AddStatus: (state: any) => Application.Types.Status;
|
18
|
+
DeleteStatus: (state: any) => Application.Types.Status;
|
19
|
+
}
|
@@ -0,0 +1,241 @@
|
|
1
|
+
"use strict";
|
2
|
+
// ******************************************************************************************************
|
3
|
+
// ReadWriteGenericSlice.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
|
+
// 08/12/2024 - Preston Crawford
|
21
|
+
// Generated original version of source code.
|
22
|
+
// ******************************************************************************************************
|
23
|
+
var __extends = (this && this.__extends) || (function () {
|
24
|
+
var extendStatics = function (d, b) {
|
25
|
+
extendStatics = Object.setPrototypeOf ||
|
26
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
27
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
28
|
+
return extendStatics(d, b);
|
29
|
+
};
|
30
|
+
return function (d, b) {
|
31
|
+
if (typeof b !== "function" && b !== null)
|
32
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
33
|
+
extendStatics(d, b);
|
34
|
+
function __() { this.constructor = d; }
|
35
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
36
|
+
};
|
37
|
+
})();
|
38
|
+
var __assign = (this && this.__assign) || function () {
|
39
|
+
__assign = Object.assign || function(t) {
|
40
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
41
|
+
s = arguments[i];
|
42
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
43
|
+
t[p] = s[p];
|
44
|
+
}
|
45
|
+
return t;
|
46
|
+
};
|
47
|
+
return __assign.apply(this, arguments);
|
48
|
+
};
|
49
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
50
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
51
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
52
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
53
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
54
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
55
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
56
|
+
});
|
57
|
+
};
|
58
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
59
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
60
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
61
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
62
|
+
function step(op) {
|
63
|
+
if (f) throw new TypeError("Generator is already executing.");
|
64
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
65
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
66
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
67
|
+
switch (op[0]) {
|
68
|
+
case 0: case 1: t = op; break;
|
69
|
+
case 4: _.label++; return { value: op[1], done: false };
|
70
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
71
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
72
|
+
default:
|
73
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
74
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
75
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
76
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
77
|
+
if (t[2]) _.ops.pop();
|
78
|
+
_.trys.pop(); continue;
|
79
|
+
}
|
80
|
+
op = body.call(thisArg, _);
|
81
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
82
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
83
|
+
}
|
84
|
+
};
|
85
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
86
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
87
|
+
};
|
88
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
89
|
+
var toolkit_1 = require("@reduxjs/toolkit");
|
90
|
+
var ControllerFunctions_1 = require("../ControllerFunctions");
|
91
|
+
var ReadOnlyGenericSlice_1 = __importDefault(require("./ReadOnlyGenericSlice"));
|
92
|
+
var ReadWriteGenericSlice = /** @class */ (function (_super) {
|
93
|
+
__extends(ReadWriteGenericSlice, _super);
|
94
|
+
function ReadWriteGenericSlice(name, defaultSortField, ascending, apiPathOrReadWriteController, readOnlyController) {
|
95
|
+
var _this = _super.call(this, name, defaultSortField, ascending, typeof apiPathOrReadWriteController === 'string' ? new ControllerFunctions_1.ReadWriteControllerFunctions(apiPathOrReadWriteController) : (readOnlyController !== null && readOnlyController !== void 0 ? readOnlyController : apiPathOrReadWriteController)) || this;
|
96
|
+
_this.updateHandle = null;
|
97
|
+
_this.addHandle = null;
|
98
|
+
_this.deleteHandle = null;
|
99
|
+
_this.UpdateStatus = function (state) { return state[_this.Name].UpdateStatus; };
|
100
|
+
_this.AddStatus = function (state) { return state[_this.Name].AddStatus; };
|
101
|
+
_this.DeleteStatus = function (state) { return state[_this.Name].DeleteStatus; };
|
102
|
+
_this.readWriteController = typeof apiPathOrReadWriteController === 'string' ? new ControllerFunctions_1.ReadWriteControllerFunctions(apiPathOrReadWriteController) : apiPathOrReadWriteController;
|
103
|
+
_this.initializeReadWriteSlice();
|
104
|
+
return _this;
|
105
|
+
}
|
106
|
+
ReadWriteGenericSlice.prototype.initializeReadWriteSlice = function () {
|
107
|
+
var _this = this;
|
108
|
+
this.Add = (0, toolkit_1.createAsyncThunk)("".concat(this.Name, "/Add").concat(this.Name), function (record_1, _a) { return __awaiter(_this, [record_1, _a], void 0, function (record, _b) {
|
109
|
+
var _this = this;
|
110
|
+
var _c;
|
111
|
+
var signal = _b.signal;
|
112
|
+
return __generator(this, function (_d) {
|
113
|
+
switch (_d.label) {
|
114
|
+
case 0:
|
115
|
+
if (((_c = this.addHandle) === null || _c === void 0 ? void 0 : _c.abort) != null)
|
116
|
+
this.addHandle.abort('Prev');
|
117
|
+
this.addHandle = this.readWriteController.Add(record);
|
118
|
+
signal.addEventListener('abort', function () {
|
119
|
+
var _a;
|
120
|
+
(_a = _this.addHandle) === null || _a === void 0 ? void 0 : _a.abort();
|
121
|
+
});
|
122
|
+
return [4 /*yield*/, this.addHandle];
|
123
|
+
case 1: return [2 /*return*/, _d.sent()];
|
124
|
+
}
|
125
|
+
});
|
126
|
+
}); });
|
127
|
+
this.Update = (0, toolkit_1.createAsyncThunk)("".concat(this.Name, "/Update").concat(this.Name), function (record_1, _a) { return __awaiter(_this, [record_1, _a], void 0, function (record, _b) {
|
128
|
+
var _this = this;
|
129
|
+
var _c;
|
130
|
+
var signal = _b.signal;
|
131
|
+
return __generator(this, function (_d) {
|
132
|
+
switch (_d.label) {
|
133
|
+
case 0:
|
134
|
+
if (((_c = this.updateHandle) === null || _c === void 0 ? void 0 : _c.abort) != null)
|
135
|
+
this.updateHandle.abort('Prev');
|
136
|
+
this.updateHandle = this.readWriteController.Update(record);
|
137
|
+
signal.addEventListener('abort', function () {
|
138
|
+
var _a;
|
139
|
+
(_a = _this.updateHandle) === null || _a === void 0 ? void 0 : _a.abort();
|
140
|
+
});
|
141
|
+
return [4 /*yield*/, this.updateHandle];
|
142
|
+
case 1: return [2 /*return*/, _d.sent()];
|
143
|
+
}
|
144
|
+
});
|
145
|
+
}); });
|
146
|
+
this.Delete = (0, toolkit_1.createAsyncThunk)("".concat(this.Name, "/Delete").concat(this.Name), function (record_1, _a) { return __awaiter(_this, [record_1, _a], void 0, function (record, _b) {
|
147
|
+
var _this = this;
|
148
|
+
var _c;
|
149
|
+
var signal = _b.signal;
|
150
|
+
return __generator(this, function (_d) {
|
151
|
+
switch (_d.label) {
|
152
|
+
case 0:
|
153
|
+
if (((_c = this.deleteHandle) === null || _c === void 0 ? void 0 : _c.abort) != null)
|
154
|
+
this.deleteHandle.abort('Prev');
|
155
|
+
if (typeof record === 'string' || typeof record === 'number')
|
156
|
+
this.deleteHandle = this.readWriteController.DeleteByID(record);
|
157
|
+
else
|
158
|
+
this.deleteHandle = this.readWriteController.Delete(record);
|
159
|
+
signal.addEventListener('abort', function () {
|
160
|
+
var _a;
|
161
|
+
(_a = _this.deleteHandle) === null || _a === void 0 ? void 0 : _a.abort();
|
162
|
+
});
|
163
|
+
return [4 /*yield*/, this.deleteHandle];
|
164
|
+
case 1: return [2 /*return*/, _d.sent()];
|
165
|
+
}
|
166
|
+
});
|
167
|
+
}); });
|
168
|
+
// Create the slice with extended reducers
|
169
|
+
this.Slice = (0, toolkit_1.createSlice)({
|
170
|
+
name: this.Name,
|
171
|
+
initialState: __assign(__assign({}, this.Slice.getInitialState()), { AddStatus: 'uninitiated', UpdateStatus: 'uninitiated', DeleteStatus: 'uninitiated' }),
|
172
|
+
reducers: {},
|
173
|
+
extraReducers: function (builder) {
|
174
|
+
_this.addExtraReducers(builder);
|
175
|
+
builder.addCase(_this.Add.pending, function (state, action) {
|
176
|
+
state.AddStatus = 'loading';
|
177
|
+
state.ActiveID.push(action.meta.requestId);
|
178
|
+
});
|
179
|
+
builder.addCase(_this.Add.fulfilled, function (state, action) {
|
180
|
+
state.AddStatus = 'changed';
|
181
|
+
state.ActiveID = state.ActiveID.filter(function (id) { return id !== action.meta.requestId; });
|
182
|
+
});
|
183
|
+
builder.addCase(_this.Add.rejected, function (state, action) {
|
184
|
+
var _a;
|
185
|
+
state.ActiveID = state.ActiveID.filter(function (id) { return id !== action.meta.requestId; });
|
186
|
+
if (state.ActiveID.length > 0)
|
187
|
+
return;
|
188
|
+
state.AddStatus = 'error';
|
189
|
+
state.Error = {
|
190
|
+
Message: (_a = action.error.message) !== null && _a !== void 0 ? _a : '',
|
191
|
+
Action: 'ADD',
|
192
|
+
Time: new Date().toString()
|
193
|
+
};
|
194
|
+
});
|
195
|
+
builder.addCase(_this.Update.pending, function (state, action) {
|
196
|
+
state.UpdateStatus = 'loading';
|
197
|
+
state.ActiveID.push(action.meta.requestId);
|
198
|
+
});
|
199
|
+
builder.addCase(_this.Update.fulfilled, function (state, action) {
|
200
|
+
state.UpdateStatus = 'changed';
|
201
|
+
state.ActiveID = state.ActiveID.filter(function (id) { return id !== action.meta.requestId; });
|
202
|
+
});
|
203
|
+
builder.addCase(_this.Update.rejected, function (state, action) {
|
204
|
+
var _a;
|
205
|
+
state.ActiveID = state.ActiveID.filter(function (id) { return id !== action.meta.requestId; });
|
206
|
+
if (state.ActiveID.length > 0)
|
207
|
+
return;
|
208
|
+
state.UpdateStatus = 'error';
|
209
|
+
state.Error = {
|
210
|
+
Message: (_a = action.error.message) !== null && _a !== void 0 ? _a : '',
|
211
|
+
Action: 'UPDATE',
|
212
|
+
Time: new Date().toString()
|
213
|
+
};
|
214
|
+
});
|
215
|
+
builder.addCase(_this.Delete.pending, function (state, action) {
|
216
|
+
state.DeleteStatus = 'loading';
|
217
|
+
state.ActiveID.push(action.meta.requestId);
|
218
|
+
});
|
219
|
+
builder.addCase(_this.Delete.fulfilled, function (state, action) {
|
220
|
+
state.DeleteStatus = 'changed';
|
221
|
+
state.ActiveID = state.ActiveID.filter(function (id) { return id !== action.meta.requestId; });
|
222
|
+
});
|
223
|
+
builder.addCase(_this.Delete.rejected, function (state, action) {
|
224
|
+
var _a;
|
225
|
+
state.ActiveID = state.ActiveID.filter(function (id) { return id !== action.meta.requestId; });
|
226
|
+
if (state.ActiveID.length > 0)
|
227
|
+
return;
|
228
|
+
state.DeleteStatus = 'error';
|
229
|
+
state.Error = {
|
230
|
+
Message: (_a = action.error.message) !== null && _a !== void 0 ? _a : '',
|
231
|
+
Action: 'DELETE',
|
232
|
+
Time: new Date().toString()
|
233
|
+
};
|
234
|
+
});
|
235
|
+
}
|
236
|
+
});
|
237
|
+
this.Reducer = this.Slice.reducer;
|
238
|
+
};
|
239
|
+
return ReadWriteGenericSlice;
|
240
|
+
}(ReadOnlyGenericSlice_1.default));
|
241
|
+
exports.default = ReadWriteGenericSlice;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import ReadOnlyGenericSlice from './ReadOnlyGenericSlice';
|
2
|
+
/**
|
3
|
+
* Custom hook to initialize data fetching for a read-only generic slice.
|
4
|
+
* @param slice - The read-only generic slice instance.
|
5
|
+
* @param dispatch - The Redux dispatch function.
|
6
|
+
* @param useSelector - The Redux useSelector hook.
|
7
|
+
* @param parentID - The optional parent ID for the data fetch.
|
8
|
+
* @returns The current fetch status.
|
9
|
+
*/
|
10
|
+
export declare function useInitializeWithFetch<T>(slice: ReadOnlyGenericSlice<T>, dispatch: (action: any) => void, useSelector: any, parentID?: string | number): any;
|
@@ -0,0 +1,65 @@
|
|
1
|
+
"use strict";
|
2
|
+
// ******************************************************************************************************
|
3
|
+
// useInitializeHook.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
|
+
// 08/13/2024 - Preston Crawford
|
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.useInitializeWithFetch = useInitializeWithFetch;
|
48
|
+
var React = __importStar(require("react"));
|
49
|
+
/**
|
50
|
+
* Custom hook to initialize data fetching for a read-only generic slice.
|
51
|
+
* @param slice - The read-only generic slice instance.
|
52
|
+
* @param dispatch - The Redux dispatch function.
|
53
|
+
* @param useSelector - The Redux useSelector hook.
|
54
|
+
* @param parentID - The optional parent ID for the data fetch.
|
55
|
+
* @returns The current fetch status.
|
56
|
+
*/
|
57
|
+
function useInitializeWithFetch(slice, dispatch, useSelector, parentID) {
|
58
|
+
var status = useSelector(slice.FetchStatus);
|
59
|
+
var ParentID = useSelector(slice.ParentID);
|
60
|
+
React.useEffect(function () {
|
61
|
+
if (status === 'uninitiated' || status === 'changed' || ParentID != parentID)
|
62
|
+
dispatch(slice.Fetch({ parentID: parentID }));
|
63
|
+
}, [status, dispatch]);
|
64
|
+
return status;
|
65
|
+
}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import React from 'react';
|
2
1
|
import 'moment';
|
3
2
|
import { OpenXDA, SystemCenter } from '@gpa-gemstone/application-typings';
|
4
3
|
type S = SystemCenter.Types.DetailedMeter | SystemCenter.Types.DetailedAsset | SystemCenter.Types.DetailedLocation | OpenXDA.Types.AssetGroup;
|
@@ -11,5 +10,5 @@ interface IProps<S> {
|
|
11
10
|
selected: string;
|
12
11
|
};
|
13
12
|
}
|
14
|
-
declare function NavbarFilterButton(props: IProps<S>):
|
13
|
+
declare function NavbarFilterButton(props: IProps<S>): JSX.Element;
|
15
14
|
export default NavbarFilterButton;
|
package/lib/Note.d.ts
CHANGED
@@ -16,5 +16,5 @@ interface IProps {
|
|
16
16
|
DefaultApplication?: OpenXDA.Types.NoteApplication;
|
17
17
|
Filter?: (note: OpenXDA.Types.Note) => boolean;
|
18
18
|
}
|
19
|
-
declare function Note(props: React.PropsWithChildren<IProps>):
|
19
|
+
declare function Note(props: React.PropsWithChildren<IProps>): JSX.Element;
|
20
20
|
export default Note;
|
package/lib/Note.js
CHANGED
@@ -80,7 +80,7 @@ function Note(props) {
|
|
80
80
|
var _c = React.useState(CreateNewNote()), note = _c[0], setNote = _c[1];
|
81
81
|
var _d = React.useState([]), notes = _d[0], setNotes = _d[1];
|
82
82
|
React.useEffect(function () {
|
83
|
-
if (dataStatus === '
|
83
|
+
if (dataStatus === 'uninitiated' || dataStatus === 'changed' || parentID !== props.ReferenceTableID)
|
84
84
|
dispatch(props.NoteSlice.Fetch(props.ReferenceTableID));
|
85
85
|
}, [props.ReferenceTableID, dispatch, dataStatus]);
|
86
86
|
React.useEffect(function () {
|
package/lib/SearchBar.d.ts
CHANGED
@@ -21,16 +21,16 @@ interface IOptions {
|
|
21
21
|
/** This Implements a few standardized SearchBars */
|
22
22
|
export declare namespace DefaultSearch {
|
23
23
|
/** This Implements a standard Meter Search */
|
24
|
-
const Meter: React.
|
24
|
+
const Meter: (props: React.PropsWithChildren<IProps<SystemCenter.Types.DetailedMeter>>) => JSX.Element;
|
25
25
|
/** This Implements a standard Substation Search */
|
26
|
-
const Location: React.
|
26
|
+
const Location: (props: React.PropsWithChildren<IProps<SystemCenter.Types.DetailedLocation>>) => JSX.Element;
|
27
27
|
/** This Implements a standard Transmission Asset Search */
|
28
|
-
const Asset: React.
|
28
|
+
const Asset: (props: React.PropsWithChildren<IProps<SystemCenter.Types.DetailedAsset>>) => JSX.Element;
|
29
29
|
/** This Implements a standard AssetGroup Search */
|
30
|
-
const AssetGroup: React.
|
30
|
+
const AssetGroup: (props: React.PropsWithChildren<IProps<OpenXDA.Types.AssetGroup>>) => JSX.Element;
|
31
31
|
/** This Implements a standard User Search */
|
32
|
-
const User: React.
|
32
|
+
const User: (props: React.PropsWithChildren<IProps<Application.Types.iUserAccount>>) => JSX.Element;
|
33
33
|
/** This Implements a standard Customer Search */
|
34
|
-
const Customer: React.
|
34
|
+
const Customer: (props: React.PropsWithChildren<IProps<OpenXDA.Types.Customer>>) => JSX.Element;
|
35
35
|
}
|
36
36
|
export {};
|