dce-reactkit 3.9.4-beta-prompt.1 → 3.9.4-beta-logreviewer.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -186,7 +186,6 @@ var ModalButtonType$1 = ModalButtonType;
186
186
  var ModalType;
187
187
  (function (ModalType) {
188
188
  ModalType["Okay"] = "okay";
189
- ModalType["Cancel"] = "cancel";
190
189
  ModalType["OkayCancel"] = "okay-cancel";
191
190
  ModalType["YesNo"] = "yes-no";
192
191
  ModalType["YesNoCancel"] = "yes-no-cancel";
@@ -341,9 +340,6 @@ const modalTypeToModalButtonTypes = {
341
340
  [ModalType$1.Okay]: [
342
341
  ModalButtonType$1.Okay,
343
342
  ],
344
- [ModalType$1.Cancel]: [
345
- ModalButtonType$1.Cancel,
346
- ],
347
343
  [ModalType$1.OkayCancel]: [
348
344
  ModalButtonType$1.Okay,
349
345
  ModalButtonType$1.Cancel,
@@ -1084,73 +1080,6 @@ const confirm = (title, text, opts) => __awaiter(void 0, void 0, void 0, functio
1084
1080
  });
1085
1081
  });
1086
1082
  /*----------------------------------------*/
1087
- /* --------------- Prompt -------------- */
1088
- /*----------------------------------------*/
1089
- // Stored copies of setters
1090
- let setPromptInfo;
1091
- // Function to call when prompt is closed
1092
- let onPromptClosed;
1093
- /**
1094
- * Show a prompt modal asking the user for input
1095
- * @author Yuen Ler Chow
1096
- * @param title the title text to display at the top of the prompt
1097
- * @param text the text to display in the prompt
1098
- * @param [opts={}] additional options for the prompt dialog
1099
- * @param [opts.placeholder] the placeholder text for the input field
1100
- * @param [opts.defaultText] the default text for the input field
1101
- * @param [opts.confirmButtonText=Okay] the text of the confirm button
1102
- * @param [opts.confirmButtonVariant=Variant.Dark] the variant of the confirm button
1103
- * @param [opts.cancelButtonText=Cancel] the text of the cancel button
1104
- * @param [opts.cancelButtonVariant=Variant.Secondary] the variant of the cancel button
1105
- * @returns Promise that resolves with the input string or null if canceled
1106
- */
1107
- const prompt = (title, text, currentInputFieldText, opts) => __awaiter(void 0, void 0, void 0, function* () {
1108
- var _a;
1109
- // Wait for helper to exist
1110
- yield waitForHelper(() => {
1111
- return !!setPromptInfo;
1112
- });
1113
- // Fallback if prompt is not available
1114
- if (!setPromptInfo) {
1115
- const resultPassesValidation = false;
1116
- while (!resultPassesValidation) {
1117
- // eslint-disable-next-line no-alert
1118
- const result = window.prompt(`${title}\n\n${text}`, (_a = opts === null || opts === void 0 ? void 0 : opts.defaultText) !== null && _a !== void 0 ? _a : '');
1119
- if (result === null) {
1120
- return null;
1121
- }
1122
- // Validate min num chars
1123
- const minNumCharsValidationError = (((opts === null || opts === void 0 ? void 0 : opts.minNumChars) && result.length < opts.minNumChars)
1124
- ? `Please enter at least ${opts.minNumChars} characters.`
1125
- : undefined);
1126
- // Run custom validation
1127
- const customValidationError = ((opts === null || opts === void 0 ? void 0 : opts.findValidationError)
1128
- && opts.findValidationError(result));
1129
- // Show validation issue
1130
- if (minNumCharsValidationError || customValidationError) {
1131
- alert('Invalid Input', `${minNumCharsValidationError !== null && minNumCharsValidationError !== void 0 ? minNumCharsValidationError : ''} ${customValidationError !== null && customValidationError !== void 0 ? customValidationError : ''}`);
1132
- }
1133
- else {
1134
- return result;
1135
- }
1136
- }
1137
- }
1138
- // Return promise that resolves with result of prompt
1139
- return new Promise((resolve) => {
1140
- // Setup handler
1141
- onPromptClosed = (result) => {
1142
- resolve(result);
1143
- };
1144
- // Show the prompt
1145
- setPromptInfo({
1146
- title,
1147
- text,
1148
- currentInputFieldText,
1149
- opts: (opts !== null && opts !== void 0 ? opts : {}),
1150
- });
1151
- });
1152
- });
1153
- /*----------------------------------------*/
1154
1083
  /* ------------- Fatal Error ------------ */
1155
1084
  /*----------------------------------------*/
1156
1085
  // Stored copies of setters
@@ -1166,14 +1095,14 @@ const fatalErrorHandlers = [];
1166
1095
  * @param [errorTitle] title of the error box
1167
1096
  */
1168
1097
  const showFatalError = (error, errorTitle = 'An Error Occurred') => __awaiter(void 0, void 0, void 0, function* () {
1169
- var _b, _c;
1098
+ var _a, _b;
1170
1099
  // Determine message and code
1171
1100
  const message = (typeof error === 'string'
1172
1101
  ? error.trim()
1173
- : String((_b = error.message) !== null && _b !== void 0 ? _b : 'An unknown error occurred.'));
1102
+ : String((_a = error.message) !== null && _a !== void 0 ? _a : 'An unknown error occurred.'));
1174
1103
  const code = (typeof error === 'string'
1175
1104
  ? ReactKitErrorCode$1.NoCode
1176
- : String((_c = error.code) !== null && _c !== void 0 ? _c : ReactKitErrorCode$1.NoCode));
1105
+ : String((_b = error.code) !== null && _b !== void 0 ? _b : ReactKitErrorCode$1.NoCode));
1177
1106
  // Call all fatal error listeners
1178
1107
  try {
1179
1108
  fatalErrorHandlers.forEach((handler) => {
@@ -1300,9 +1229,6 @@ const AppWrapper = (props) => {
1300
1229
  // Confirm
1301
1230
  const [confirmInfo, setConfirmInfoInner,] = React.useState(undefined);
1302
1231
  setConfirmInfo = setConfirmInfoInner;
1303
- // Prompt
1304
- const [promptInfo, setPromptInfoInner] = React.useState(undefined);
1305
- setPromptInfo = setPromptInfoInner;
1306
1232
  // Session expired
1307
1233
  const [sessionHasExpired, setSessionHasExpiredInner,] = React.useState(false);
1308
1234
  setSessionHasExpired = setSessionHasExpiredInner;
@@ -1333,37 +1259,6 @@ const AppWrapper = (props) => {
1333
1259
  }
1334
1260
  }, onTopOfOtherModals: true, dontAllowBackdropExit: true }, confirmInfo.text));
1335
1261
  }
1336
- /* ------------- Prompt ------------ */
1337
- if (promptInfo) {
1338
- // Run min char validation
1339
- const minNumCharsValidationError = ((promptInfo.opts.minNumChars
1340
- && promptInfo.currentInputFieldText.length < promptInfo.opts.minNumChars)
1341
- ? `Please enter at least ${promptInfo.opts.minNumChars} characters.`
1342
- : undefined);
1343
- // Run custom validation
1344
- const customValidationError = (promptInfo.opts.findValidationError
1345
- && promptInfo.opts.findValidationError(promptInfo.currentInputFieldText));
1346
- modal = (React__default["default"].createElement(Modal, { key: `prompt-${promptInfo.title}-${promptInfo.text}`, title: promptInfo.title,
1347
- // Don't show ok button if there is a validation error
1348
- type: ((customValidationError || minNumCharsValidationError)
1349
- ? ModalType$1.Cancel
1350
- : ModalType$1.OkayCancel), okayLabel: promptInfo.opts.confirmButtonText, okayVariant: promptInfo.opts.confirmButtonVariant, cancelLabel: promptInfo.opts.cancelButtonText, cancelVariant: promptInfo.opts.cancelButtonVariant, onClose: (buttonType) => {
1351
- const result = (buttonType === ModalButtonType$1.Okay
1352
- ? promptInfo.currentInputFieldText
1353
- : null);
1354
- setPromptInfo(undefined);
1355
- if (onPromptClosed) {
1356
- onPromptClosed(result);
1357
- }
1358
- }, onTopOfOtherModals: true, dontAllowBackdropExit: true },
1359
- React__default["default"].createElement("div", { className: "d-flex flex-column align-items-center" },
1360
- React__default["default"].createElement("p", null, promptInfo.text),
1361
- React__default["default"].createElement("input", { type: "text", placeholder: promptInfo.opts.placeholder, value: promptInfo.currentInputFieldText, onChange: (e) => {
1362
- return setPromptInfo(Object.assign(Object.assign({}, promptInfo), { currentInputFieldText: e.target.value }));
1363
- } }),
1364
- minNumCharsValidationError && (React__default["default"].createElement("div", { className: "text-danger bg-danger bg-opacity-25 p-2 m-1 rounded" }, minNumCharsValidationError)),
1365
- customValidationError && (React__default["default"].createElement("div", { className: "text-danger bg-danger bg-opacity-25 p-2 m-1 rounded" }, customValidationError)))));
1366
- }
1367
1262
  /* ------ Custom Modal Portals ------ */
1368
1263
  // Custom modal portals
1369
1264
  const customModalPortals = [];
@@ -3896,10 +3791,21 @@ const LogReviewer = (props) => {
3896
3791
  // Destructure
3897
3792
  const { year, month } = toLoad[i];
3898
3793
  // Load
3899
- const logs = yield visitServerEndpoint({
3900
- path: `${LOG_REVIEW_ROUTE_PATH_PREFIX}/years/${year}/months/${month}`,
3901
- method: 'GET',
3902
- });
3794
+ let logs = [];
3795
+ let pageNumber = 1;
3796
+ let hasAnotherPage = true;
3797
+ while (hasAnotherPage) {
3798
+ const response = yield visitServerEndpoint({
3799
+ path: `${LOG_REVIEW_ROUTE_PATH_PREFIX}/years/${year}/months/${month}`,
3800
+ method: 'GET',
3801
+ params: {
3802
+ pageNumber,
3803
+ },
3804
+ });
3805
+ logs = logs.concat(response.items);
3806
+ hasAnotherPage = response.hasAnotherPage;
3807
+ pageNumber += 1;
3808
+ }
3903
3809
  // Add to map
3904
3810
  if (!logMap[year]) {
3905
3811
  logMap[year] = {};
@@ -14159,22 +14065,27 @@ const initServer = (opts) => {
14159
14065
  paramTypes: {
14160
14066
  year: ParamType$1.Int,
14161
14067
  month: ParamType$1.Int,
14068
+ pageNumber: ParamType$1.Int,
14162
14069
  },
14163
14070
  handler: ({ params }) => __awaiter(void 0, void 0, void 0, function* () {
14164
14071
  // Get user info
14165
- const { year, month, userId, isAdmin, } = params;
14072
+ const { year, month, pageNumber, userId, isAdmin, } = params;
14166
14073
  // Validate user
14167
14074
  const canReview = yield canReviewLogs(userId, isAdmin);
14168
14075
  if (!canReview) {
14169
14076
  throw new ErrorWithCode('You cannot access this resource because you do not have the appropriate permissions.', ReactKitErrorCode$1.NotAllowedToReviewLogs);
14170
14077
  }
14171
14078
  // Query for logs
14172
- const logs = yield _logCollection.find({
14173
- year,
14174
- month,
14079
+ const response = yield _logCollection.findPaged({
14080
+ query: {
14081
+ year,
14082
+ month,
14083
+ },
14084
+ perPage: 1000,
14085
+ pageNumber,
14175
14086
  });
14176
- // Return logs
14177
- return logs;
14087
+ // Return response
14088
+ return response;
14178
14089
  }),
14179
14090
  }));
14180
14091
  };
@@ -16426,7 +16337,6 @@ exports.padDecimalZeros = padDecimalZeros;
16426
16337
  exports.padZerosLeft = padZerosLeft;
16427
16338
  exports.parallelLimit = parallelLimit;
16428
16339
  exports.prefixWithAOrAn = prefixWithAOrAn;
16429
- exports.prompt = prompt;
16430
16340
  exports.roundToNumDecimals = roundToNumDecimals;
16431
16341
  exports.setClientEventMetadataPopulator = setClientEventMetadataPopulator;
16432
16342
  exports.showFatalError = showFatalError;