@apia/api 4.0.25 → 4.0.27
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/index.d.ts +93 -84
- package/dist/index.js +785 -522
- package/dist/index.js.map +1 -1
- package/package.json +10 -9
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from '@apia/theme/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import React__default, { createContext, useState, useCallback, useEffect, useId,
|
|
3
|
+
import React__default, { createContext, useState, useCallback, useEffect, useId, useRef, useMemo } from 'react';
|
|
4
4
|
import { Box, Label, spacing, getVariant, Input as Input$1, Select as Select$1 } from '@apia/theme';
|
|
5
|
-
import { debugDispatcher, parseXmlAsync, EventEmitter, arrayOrArray, useMount, encrypt, noNaN, getIndex, getLabel, StatefulEmitter, focus, focusSelector, useLatest } from '@apia/util';
|
|
5
|
+
import { debugDispatcher, parseXmlAsync, EventEmitter, arrayOrArray, useMount, encrypt, noNaN, getIndex, getLabel, StatefulEmitter, focus, focusSelector, useLatest, useIntermediateValue, formatMessage, getDateFormat, Mutex, uniqueId as uniqueId$1 } from '@apia/util';
|
|
6
6
|
import { notify, getNotificationMessageObj, dispatchNotifications } from '@apia/notifications';
|
|
7
7
|
import { classToValidate, Checkbox, FileInput, classToValidationFunction, Input, Radio, Select, Textarea, useFormContext, validationsStore, hasSucceedFormValidation, Form } from '@apia/validations';
|
|
8
|
-
import { Accordion, AccordionItem, useModal, LabelBox, SimpleButton, ApiaUtil, Modal, ProgressBar } from '@apia/components';
|
|
9
|
-
import axios from 'axios';
|
|
8
|
+
import { Accordion, AccordionItem, useModal, LabelBox, SimpleButton, ApiaUtil, Modal, ProgressBar, DateInput } from '@apia/components';
|
|
9
|
+
import axios, { AxiosError } from 'axios';
|
|
10
10
|
import merge from 'lodash-es/merge';
|
|
11
11
|
import QueryString from 'qs';
|
|
12
12
|
import { session } from '@apia/session';
|
|
13
13
|
import uniqueId from 'lodash-es/uniqueId';
|
|
14
|
-
import { ResponsiveTableContext, ResponsiveTable, Pagination, Sort, Responsive, Additional, responsiveTableStore, useResponsiveTableContext, getResponsiveTableContext, TableLoadingContext, makeController2, responsiveTableActions, TableContextReproducer } from '@apia/table';
|
|
15
|
-
import { makeObservable, observable, reaction, toJS, action } from 'mobx';
|
|
14
|
+
import { ResponsiveTableContext, ResponsiveTable, Pagination, Sort, Responsive, Additional, responsiveTableStore, useResponsiveTableContext, getResponsiveTableContext, TableLoadingContext, defaultLabels, makeController2, responsiveTableActions, TableContextReproducer, Grouped } from '@apia/table';
|
|
15
|
+
import { makeObservable, observable, reaction, toJS, action, computed } from 'mobx';
|
|
16
16
|
import { observer } from 'mobx-react-lite';
|
|
17
|
-
import
|
|
18
|
-
import { Icon } from '@apia/icons';
|
|
17
|
+
import dayjs from 'dayjs';
|
|
18
|
+
import { Icon, FileIcon } from '@apia/icons';
|
|
19
19
|
|
|
20
20
|
const ApiaApiId = createContext("apiaApi");
|
|
21
21
|
const ApiaApiContext = ({
|
|
@@ -79,6 +79,10 @@ function getColor(color, colors = defaultConfig.colors ?? {
|
|
|
79
79
|
return colors[color];
|
|
80
80
|
}
|
|
81
81
|
const handleWrongResponse = (error) => {
|
|
82
|
+
if (error instanceof AxiosError && (error.status === 403 || error.response?.status === 403)) {
|
|
83
|
+
session.invalidate();
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
82
86
|
let errorMessage;
|
|
83
87
|
if (typeof error !== "string") {
|
|
84
88
|
if (error.message)
|
|
@@ -379,7 +383,7 @@ async function post(par1, par2) {
|
|
|
379
383
|
);
|
|
380
384
|
}
|
|
381
385
|
const response = await axios.post(parsedUrl, behaveConfig.postData, behaveConfig.axiosConfig).catch((e) => {
|
|
382
|
-
handleWrongResponse(new Error(e));
|
|
386
|
+
handleWrongResponse(e instanceof AxiosError ? e : new Error(e));
|
|
383
387
|
});
|
|
384
388
|
if (response) {
|
|
385
389
|
const result = handleResponse(response, actualUrl, behaveConfig);
|
|
@@ -406,7 +410,7 @@ async function get(par1, par2) {
|
|
|
406
410
|
}
|
|
407
411
|
);
|
|
408
412
|
const response = await axios.get(parsedUrl, behaveConfig.axiosConfig).catch((e) => {
|
|
409
|
-
handleWrongResponse(new Error(e));
|
|
413
|
+
handleWrongResponse(e instanceof AxiosError ? e : new Error(e));
|
|
410
414
|
});
|
|
411
415
|
if (response) {
|
|
412
416
|
const result = await handleResponse(
|
|
@@ -3226,60 +3230,113 @@ const ApiaApiHandler = React.memo(ApiaApiHandlerNonMemoized);
|
|
|
3226
3230
|
const units = ["B", "KB", "MB", "GB"];
|
|
3227
3231
|
const RangeFilterRenderer = observer(
|
|
3228
3232
|
({ filter, state }) => {
|
|
3229
|
-
const
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3233
|
+
const multiplier = useRef(1);
|
|
3234
|
+
const lastEmittedHigh = useRef(null);
|
|
3235
|
+
const lastEmittedLow = useRef(null);
|
|
3236
|
+
const lastEmittedMultiplier = useRef(1);
|
|
3237
|
+
if (lastEmittedLow.current !== state.value) {
|
|
3238
|
+
lastEmittedLow.current = state.value;
|
|
3239
|
+
lastEmittedHigh.current = state.valueTo || "";
|
|
3240
|
+
}
|
|
3241
|
+
const emitLow = (currentValue) => {
|
|
3242
|
+
const numberValue = currentValue ?? "";
|
|
3243
|
+
if (lastEmittedLow.current === numberValue && lastEmittedMultiplier.current === multiplier.current) {
|
|
3244
|
+
return;
|
|
3245
|
+
}
|
|
3246
|
+
lastEmittedLow.current = numberValue;
|
|
3247
|
+
lastEmittedMultiplier.current = multiplier.current;
|
|
3248
|
+
const emitValue = numberValue;
|
|
3249
|
+
state.value = emitValue;
|
|
3250
|
+
state.multiplier = multiplier.current;
|
|
3251
|
+
};
|
|
3252
|
+
const emitHigh = (currentValue) => {
|
|
3253
|
+
const numberValue = currentValue ?? "";
|
|
3254
|
+
if (lastEmittedHigh.current === numberValue && lastEmittedMultiplier.current === multiplier.current) {
|
|
3255
|
+
return;
|
|
3256
|
+
}
|
|
3257
|
+
lastEmittedHigh.current = numberValue;
|
|
3258
|
+
lastEmittedMultiplier.current = multiplier.current;
|
|
3259
|
+
const emitValue = numberValue;
|
|
3260
|
+
state.valueTo = emitValue;
|
|
3261
|
+
state.multiplier = multiplier.current;
|
|
3262
|
+
};
|
|
3263
|
+
const [lowValue, setLowValue] = useIntermediateValue(state.value);
|
|
3264
|
+
const [highValue, setHighValue] = useIntermediateValue(state.valueTo);
|
|
3265
|
+
const [unit, setUnit] = useIntermediateValue(state.multiplier);
|
|
3266
|
+
return /* @__PURE__ */ jsxs(
|
|
3267
|
+
Box,
|
|
3268
|
+
{
|
|
3269
|
+
className: `ApiaFilter__Range`,
|
|
3270
|
+
...getVariant("layout.common.components.filters.rangeFilter"),
|
|
3271
|
+
children: [
|
|
3272
|
+
/* @__PURE__ */ jsx(Box, { className: "ApiaFilter__Range__Low", children: /* @__PURE__ */ jsx(
|
|
3273
|
+
Input$1,
|
|
3274
|
+
{
|
|
3275
|
+
onChange: ({ target: { value: currentValue } }) => {
|
|
3276
|
+
setLowValue(currentValue);
|
|
3277
|
+
emitLow(currentValue);
|
|
3278
|
+
},
|
|
3279
|
+
onBlur: ({ target: { value: currentValue } }) => {
|
|
3280
|
+
emitLow(currentValue);
|
|
3281
|
+
},
|
|
3282
|
+
onKeyDown: ({ code, target }) => {
|
|
3283
|
+
if (code === "Enter") {
|
|
3284
|
+
emitLow(target.value);
|
|
3285
|
+
}
|
|
3286
|
+
},
|
|
3287
|
+
value: lowValue
|
|
3243
3288
|
}
|
|
3244
|
-
},
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3289
|
+
) }),
|
|
3290
|
+
" - ",
|
|
3291
|
+
/* @__PURE__ */ jsx(Box, { className: "ApiaFilter__Range__High", children: /* @__PURE__ */ jsx(
|
|
3292
|
+
Input$1,
|
|
3293
|
+
{
|
|
3294
|
+
onChange: ({ target: { value: currentValue } }) => {
|
|
3295
|
+
setHighValue(currentValue);
|
|
3296
|
+
emitHigh(currentValue);
|
|
3297
|
+
},
|
|
3298
|
+
onBlur: ({ target: { value: currentValue } }) => {
|
|
3299
|
+
emitHigh(currentValue);
|
|
3300
|
+
},
|
|
3301
|
+
onKeyDown: ({ code, target }) => {
|
|
3302
|
+
if (code === "Enter") {
|
|
3303
|
+
emitHigh(target.value);
|
|
3304
|
+
}
|
|
3305
|
+
},
|
|
3306
|
+
value: highValue
|
|
3307
|
+
}
|
|
3308
|
+
) }),
|
|
3309
|
+
filter.isSize && /* @__PURE__ */ jsx(
|
|
3310
|
+
Select$1,
|
|
3311
|
+
{
|
|
3312
|
+
className: "ApiaFilter__Range__UnitSelector",
|
|
3313
|
+
onChange: (ev) => {
|
|
3314
|
+
const unit2 = ev.target.value;
|
|
3315
|
+
const index = units.indexOf(unit2);
|
|
3316
|
+
if (index !== -1) {
|
|
3317
|
+
multiplier.current = 2 ** (index * 10);
|
|
3318
|
+
setUnit(multiplier.current);
|
|
3319
|
+
emitLow(lastEmittedLow.current ?? "");
|
|
3320
|
+
}
|
|
3321
|
+
},
|
|
3322
|
+
value: units[Math.log2(unit || 1) / 10],
|
|
3323
|
+
children: units.map((c) => /* @__PURE__ */ jsx("option", { value: c, children: c }, c))
|
|
3324
|
+
}
|
|
3325
|
+
)
|
|
3326
|
+
]
|
|
3327
|
+
}
|
|
3328
|
+
);
|
|
3270
3329
|
}
|
|
3271
3330
|
);
|
|
3272
3331
|
|
|
3273
3332
|
const SelectFilterRenderer = observer(
|
|
3274
3333
|
({ filter, state }) => {
|
|
3275
|
-
const { onFilterChange } = useResponsiveTableContext();
|
|
3276
3334
|
return /* @__PURE__ */ jsx(
|
|
3277
3335
|
Select$1,
|
|
3278
3336
|
{
|
|
3279
3337
|
value: state.value,
|
|
3280
3338
|
onChange: (ev) => {
|
|
3281
3339
|
state.value = ev.target.value;
|
|
3282
|
-
onFilterChange?.(filter);
|
|
3283
3340
|
},
|
|
3284
3341
|
children: arrayOrArray(filter.options).map((c) => /* @__PURE__ */ jsx("option", { value: c.value, children: c.label }, c.value))
|
|
3285
3342
|
}
|
|
@@ -3310,20 +3367,80 @@ const InputFilterRenderer = observer(
|
|
|
3310
3367
|
}
|
|
3311
3368
|
);
|
|
3312
3369
|
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3370
|
+
const dateFormat = getDateFormat();
|
|
3371
|
+
function controlDatesOrder(first, last) {
|
|
3372
|
+
if (!first || !last)
|
|
3373
|
+
return true;
|
|
3374
|
+
if (dayjs(last, dateFormat).isBefore(dayjs(first, dateFormat))) {
|
|
3375
|
+
return false;
|
|
3376
|
+
}
|
|
3377
|
+
return true;
|
|
3378
|
+
}
|
|
3379
|
+
const DateFilterRenderer = observer(
|
|
3380
|
+
({ filter, state }) => {
|
|
3381
|
+
const { onFilterBlur, onFilterChange } = useResponsiveTableContext();
|
|
3382
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3383
|
+
/* @__PURE__ */ jsx(Box, { as: "span", children: state?.filterToId ? formatMessage(window.LBL_DATE_FILTER_FROM_TXT, {
|
|
3384
|
+
TOK1: filter.title ?? ""
|
|
3385
|
+
}) : state.title }),
|
|
3386
|
+
/* @__PURE__ */ jsx(
|
|
3387
|
+
DateInput,
|
|
3388
|
+
{
|
|
3389
|
+
value: state.value,
|
|
3390
|
+
onChange: (date) => {
|
|
3391
|
+
state.value = date;
|
|
3392
|
+
onFilterChange?.(filter);
|
|
3393
|
+
},
|
|
3394
|
+
onBlur: () => {
|
|
3395
|
+
onFilterBlur?.(filter);
|
|
3396
|
+
}
|
|
3397
|
+
}
|
|
3398
|
+
),
|
|
3399
|
+
(state?.isAdditional || state.group) && state?.filterToId && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3400
|
+
/* @__PURE__ */ jsx(Box, { as: "span", children: formatMessage(window.LBL_DATE_FILTER_TO_TXT, {
|
|
3401
|
+
TOK1: state.title ?? ""
|
|
3402
|
+
}) }),
|
|
3403
|
+
/* @__PURE__ */ jsx(
|
|
3404
|
+
DateInput,
|
|
3405
|
+
{
|
|
3406
|
+
value: state.filterToValue,
|
|
3407
|
+
onChange: (date) => {
|
|
3408
|
+
const result = controlDatesOrder(state.value, date);
|
|
3409
|
+
if (result) {
|
|
3410
|
+
state.filterToValue = date;
|
|
3411
|
+
onFilterChange?.(filter);
|
|
3412
|
+
} else {
|
|
3413
|
+
state.filterToValue = void 0;
|
|
3414
|
+
ApiaUtil.instance.notifications.notify({
|
|
3415
|
+
message: window.MSG_FEC_FIN_MAY_FEC_INI,
|
|
3416
|
+
type: "warning"
|
|
3417
|
+
});
|
|
3418
|
+
}
|
|
3419
|
+
},
|
|
3420
|
+
onBlur: () => {
|
|
3421
|
+
onFilterBlur?.(filter);
|
|
3422
|
+
}
|
|
3423
|
+
}
|
|
3424
|
+
)
|
|
3425
|
+
] })
|
|
3426
|
+
] });
|
|
3427
|
+
}
|
|
3428
|
+
);
|
|
3429
|
+
|
|
3430
|
+
var __defProp$5 = Object.defineProperty;
|
|
3431
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3432
|
+
var __publicField$5 = (obj, key, value) => {
|
|
3433
|
+
__defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
3317
3434
|
return value;
|
|
3318
3435
|
};
|
|
3319
3436
|
class Filter {
|
|
3320
3437
|
constructor(properties) {
|
|
3321
|
-
__publicField$
|
|
3322
|
-
__publicField$
|
|
3438
|
+
__publicField$5(this, "tableName");
|
|
3439
|
+
__publicField$5(this, "filterState", {
|
|
3323
3440
|
runAutomatically: false,
|
|
3324
3441
|
value: ""
|
|
3325
3442
|
});
|
|
3326
|
-
__publicField$
|
|
3443
|
+
__publicField$5(this, "Component", observer(({ filter }) => {
|
|
3327
3444
|
const { name } = useResponsiveTableContext();
|
|
3328
3445
|
this.tableName = name;
|
|
3329
3446
|
if (this.filterState.isRange) {
|
|
@@ -3332,6 +3449,9 @@ class Filter {
|
|
|
3332
3449
|
if (arrayOrArray(this.filterState.options).length > 0) {
|
|
3333
3450
|
return this.getSelectRenderer({ filter });
|
|
3334
3451
|
}
|
|
3452
|
+
if (this.filterState.type === "D" || this.filterState.type === "date") {
|
|
3453
|
+
return this.getDateRenderer({ filter });
|
|
3454
|
+
}
|
|
3335
3455
|
return this.getInputRenderer({ filter });
|
|
3336
3456
|
}));
|
|
3337
3457
|
Object.assign(this.filterState, properties);
|
|
@@ -3347,6 +3467,28 @@ class Filter {
|
|
|
3347
3467
|
}
|
|
3348
3468
|
}
|
|
3349
3469
|
);
|
|
3470
|
+
reaction(
|
|
3471
|
+
() => this.filterState.valueTo,
|
|
3472
|
+
() => {
|
|
3473
|
+
if (this.tableName) {
|
|
3474
|
+
getResponsiveTableContext(this.tableName).onFilterChange?.({
|
|
3475
|
+
id: properties.id,
|
|
3476
|
+
column: properties.column
|
|
3477
|
+
});
|
|
3478
|
+
}
|
|
3479
|
+
}
|
|
3480
|
+
);
|
|
3481
|
+
reaction(
|
|
3482
|
+
() => this.filterState.multiplier,
|
|
3483
|
+
() => {
|
|
3484
|
+
if (this.tableName) {
|
|
3485
|
+
getResponsiveTableContext(this.tableName).onFilterChange?.({
|
|
3486
|
+
id: properties.id,
|
|
3487
|
+
column: properties.column
|
|
3488
|
+
});
|
|
3489
|
+
}
|
|
3490
|
+
}
|
|
3491
|
+
);
|
|
3350
3492
|
}
|
|
3351
3493
|
focus() {
|
|
3352
3494
|
}
|
|
@@ -3359,82 +3501,8 @@ class Filter {
|
|
|
3359
3501
|
getRangeRenderer({ filter }) {
|
|
3360
3502
|
return /* @__PURE__ */ jsx(RangeFilterRenderer, { filter, state: this.filterState });
|
|
3361
3503
|
}
|
|
3362
|
-
}
|
|
3363
|
-
|
|
3364
|
-
const FilterTypesComponent = observer(
|
|
3365
|
-
({ filterTypes }) => {
|
|
3366
|
-
return /* @__PURE__ */ jsx(Fragment, { children: filterTypes.conditions.map((f, idx) => {
|
|
3367
|
-
const options = arrayOrArray(f.options.option);
|
|
3368
|
-
return /* @__PURE__ */ jsxs(Label, { children: [
|
|
3369
|
-
/* @__PURE__ */ jsxs(Box, { as: "span", children: [
|
|
3370
|
-
f.text,
|
|
3371
|
-
":"
|
|
3372
|
-
] }),
|
|
3373
|
-
/* @__PURE__ */ jsx(
|
|
3374
|
-
Select$1,
|
|
3375
|
-
{
|
|
3376
|
-
title: f.title,
|
|
3377
|
-
onChange: (ev) => {
|
|
3378
|
-
const selectedValue = ev.target.value;
|
|
3379
|
-
filterTypes.conditions[idx].value = selectedValue;
|
|
3380
|
-
filterTypes.setFilterOptions();
|
|
3381
|
-
},
|
|
3382
|
-
disabled: f.readonly || f.disabled,
|
|
3383
|
-
value: f.value,
|
|
3384
|
-
children: options.map((option) => {
|
|
3385
|
-
return /* @__PURE__ */ jsx("option", { value: option.value, children: option.content }, option.value);
|
|
3386
|
-
})
|
|
3387
|
-
}
|
|
3388
|
-
)
|
|
3389
|
-
] }, f.name);
|
|
3390
|
-
}) });
|
|
3391
|
-
}
|
|
3392
|
-
);
|
|
3393
|
-
|
|
3394
|
-
var __defProp$5 = Object.defineProperty;
|
|
3395
|
-
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3396
|
-
var __publicField$5 = (obj, key, value) => {
|
|
3397
|
-
__defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
3398
|
-
return value;
|
|
3399
|
-
};
|
|
3400
|
-
class FilterTypes {
|
|
3401
|
-
constructor() {
|
|
3402
|
-
__publicField$5(this, "conditions", []);
|
|
3403
|
-
__publicField$5(this, "Component", () => /* @__PURE__ */ jsx(FilterTypesComponent, { filterTypes: this }));
|
|
3404
|
-
makeObservable(this, {
|
|
3405
|
-
conditions: observable
|
|
3406
|
-
});
|
|
3407
|
-
}
|
|
3408
|
-
async getFilterTypes() {
|
|
3409
|
-
const result = await ApiaApi.post(
|
|
3410
|
-
makeApiaUrl({
|
|
3411
|
-
ajaxUrl: "apia.query.ModalAction.run?",
|
|
3412
|
-
action: "filterOptions"
|
|
3413
|
-
})
|
|
3414
|
-
);
|
|
3415
|
-
if (!result?.data?.form?.elements?.element)
|
|
3416
|
-
return;
|
|
3417
|
-
this.conditions = arrayOrArray(result.data.form.elements.element);
|
|
3418
|
-
}
|
|
3419
|
-
async initialLoad() {
|
|
3420
|
-
await this.getFilterTypes();
|
|
3421
|
-
}
|
|
3422
|
-
async setFilterOptions() {
|
|
3423
|
-
const result = await ApiaApi.post(
|
|
3424
|
-
makeApiaUrl({
|
|
3425
|
-
ajaxUrl: "apia.query.ModalAction.run?",
|
|
3426
|
-
action: "setFilterOptions"
|
|
3427
|
-
}),
|
|
3428
|
-
{
|
|
3429
|
-
postData: this.conditions.reduce((acc, c) => {
|
|
3430
|
-
acc[c.id] = c.value;
|
|
3431
|
-
return acc;
|
|
3432
|
-
}, {}),
|
|
3433
|
-
postDataTreatement: "stringify"
|
|
3434
|
-
}
|
|
3435
|
-
);
|
|
3436
|
-
if (!result)
|
|
3437
|
-
return;
|
|
3504
|
+
getDateRenderer({ filter }) {
|
|
3505
|
+
return /* @__PURE__ */ jsx(DateFilterRenderer, { filter, state: this.filterState });
|
|
3438
3506
|
}
|
|
3439
3507
|
}
|
|
3440
3508
|
|
|
@@ -3449,13 +3517,12 @@ class TableController {
|
|
|
3449
3517
|
constructor(initialState) {
|
|
3450
3518
|
__publicField$4(this, "emitter", new EventEmitter());
|
|
3451
3519
|
__publicField$4(this, "tableName", `TableController${controllerCount++}`);
|
|
3452
|
-
__publicField$4(this, "tableSelectionController");
|
|
3453
3520
|
__publicField$4(this, "controllerComponent", () => null);
|
|
3454
|
-
__publicField$4(this, "filterTypes", new FilterTypes());
|
|
3455
3521
|
__publicField$4(this, "state", {
|
|
3456
|
-
|
|
3522
|
+
finishedFirstLoad: false,
|
|
3457
3523
|
columns: /* @__PURE__ */ new Map(),
|
|
3458
3524
|
filters: /* @__PURE__ */ new Map(),
|
|
3525
|
+
isLoading: false,
|
|
3459
3526
|
pagination: { currentPage: 0, totalPages: 0, totalRecords: 0 },
|
|
3460
3527
|
props: {},
|
|
3461
3528
|
rows: []
|
|
@@ -3464,44 +3531,57 @@ class TableController {
|
|
|
3464
3531
|
return /* @__PURE__ */ jsx(
|
|
3465
3532
|
TableLoadingContext.Provider,
|
|
3466
3533
|
{
|
|
3467
|
-
value: { current: this.state.
|
|
3534
|
+
value: { current: this.state.finishedFirstLoad },
|
|
3468
3535
|
children: /* @__PURE__ */ jsx(this.TableContext, { children })
|
|
3469
3536
|
}
|
|
3470
3537
|
);
|
|
3471
3538
|
}));
|
|
3472
|
-
__publicField$4(this, "TableContext",
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
this.emitter,
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3539
|
+
__publicField$4(this, "TableContext", observer(
|
|
3540
|
+
({ children }) => {
|
|
3541
|
+
const state = this.state;
|
|
3542
|
+
const props = toJS(state.props);
|
|
3543
|
+
const columns = useMemo(
|
|
3544
|
+
() => [...toJS(state.columns).values()],
|
|
3545
|
+
[state.columns]
|
|
3546
|
+
);
|
|
3547
|
+
return /* @__PURE__ */ jsx(
|
|
3548
|
+
ResponsiveTableContext,
|
|
3549
|
+
{
|
|
3550
|
+
...props,
|
|
3551
|
+
columns,
|
|
3552
|
+
rows: useMemo(() => [], []),
|
|
3553
|
+
filters: useMemo(() => this.parseFilters(), [this.state.filters]),
|
|
3554
|
+
FiltersRenderer: useCallback(
|
|
3555
|
+
(filterId) => this.state.filters.get(filterId).Component,
|
|
3556
|
+
[]
|
|
3557
|
+
),
|
|
3558
|
+
customLabels: {
|
|
3559
|
+
noRegisters: this.state.finishedFirstLoad ? defaultLabels.noRegisters : ""
|
|
3560
|
+
},
|
|
3561
|
+
name: this.tableName,
|
|
3562
|
+
SelectionHandler: this.controllerComponent,
|
|
3563
|
+
onSortChange: this.emitter.emit.bind(this.emitter, "onSortChange"),
|
|
3564
|
+
onChangeSelection: this.emitter.emit.bind(
|
|
3565
|
+
this.emitter,
|
|
3566
|
+
"onChangeSelection"
|
|
3567
|
+
),
|
|
3568
|
+
onFilterBlur: this.emitter.emit.bind(this.emitter, "onFilterBlur"),
|
|
3569
|
+
onFilterChange: this.emitter.emit.bind(
|
|
3570
|
+
this.emitter,
|
|
3571
|
+
"onFilterChange"
|
|
3572
|
+
),
|
|
3573
|
+
onFilterPressEnter: this.emitter.emit.bind(
|
|
3574
|
+
this.emitter,
|
|
3575
|
+
"onFilterPressEnter"
|
|
3576
|
+
),
|
|
3577
|
+
onRowClick: this.emitter.emit.bind(this.emitter, "onRowClick"),
|
|
3578
|
+
onSelectRows: this.emitter.emit.bind(this.emitter, "onSelectRows"),
|
|
3579
|
+
isLoading: this.state.isLoading,
|
|
3580
|
+
children
|
|
3581
|
+
}
|
|
3582
|
+
);
|
|
3583
|
+
}
|
|
3584
|
+
));
|
|
3505
3585
|
__publicField$4(this, "Pagination", observer(() => {
|
|
3506
3586
|
return /* @__PURE__ */ jsx(
|
|
3507
3587
|
Pagination,
|
|
@@ -3510,7 +3590,9 @@ class TableController {
|
|
|
3510
3590
|
pageCount: this.state.pagination.totalPages,
|
|
3511
3591
|
recordsCount: this.state.pagination.totalRecords,
|
|
3512
3592
|
onPageChange: this.emitter.emit.bind(this.emitter, "onPage"),
|
|
3513
|
-
onRefresh: this.emitter.emit.bind(this.emitter, "onRefresh", null)
|
|
3593
|
+
onRefresh: this.emitter.emit.bind(this.emitter, "onRefresh", null),
|
|
3594
|
+
isLoading: this.state.isLoading,
|
|
3595
|
+
hideMaximizeButton: true
|
|
3514
3596
|
}
|
|
3515
3597
|
);
|
|
3516
3598
|
}));
|
|
@@ -3519,8 +3601,7 @@ class TableController {
|
|
|
3519
3601
|
state: observable,
|
|
3520
3602
|
updateState: action
|
|
3521
3603
|
});
|
|
3522
|
-
const [
|
|
3523
|
-
this.tableSelectionController = controller;
|
|
3604
|
+
const [, controllerComponent] = makeController2(this.tableName);
|
|
3524
3605
|
this.controllerComponent = controllerComponent;
|
|
3525
3606
|
if (initialState) {
|
|
3526
3607
|
Object.assign(this.state, initialState);
|
|
@@ -3565,12 +3646,14 @@ class TableController {
|
|
|
3565
3646
|
parseFilters() {
|
|
3566
3647
|
return [...toJS(this.state.filters).values()].map((c) => {
|
|
3567
3648
|
return {
|
|
3649
|
+
...c.filterState,
|
|
3568
3650
|
id: c.filterState.id,
|
|
3569
|
-
column: c.filterState.column,
|
|
3651
|
+
column: c.filterState.isAdditional ? "" : c.filterState.column,
|
|
3570
3652
|
asAdditional: c.filterState.isAdditional || this.state.columns.get(c.filterState.column || "")?.hidden,
|
|
3571
3653
|
options: c.filterState.options,
|
|
3572
3654
|
detectOnChange: c.filterState.runAutomatically,
|
|
3573
|
-
runAutomatically: c.filterState.runAutomatically
|
|
3655
|
+
runAutomatically: c.filterState.runAutomatically,
|
|
3656
|
+
title: c.filterState.title
|
|
3574
3657
|
};
|
|
3575
3658
|
});
|
|
3576
3659
|
}
|
|
@@ -3605,23 +3688,62 @@ class QueryController {
|
|
|
3605
3688
|
this.ajaxUrl = ajaxUrl;
|
|
3606
3689
|
__publicField$3(this, "hasInited", false);
|
|
3607
3690
|
__publicField$3(this, "initializing", false);
|
|
3691
|
+
__publicField$3(this, "mutex", new Mutex());
|
|
3608
3692
|
__publicField$3(this, "structure", null);
|
|
3609
3693
|
__publicField$3(this, "tableController");
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
*/
|
|
3613
|
-
__publicField$3(this, "executeRefresh", throttle(
|
|
3614
|
-
async () => {
|
|
3615
|
-
await this.actualRefreshMethod();
|
|
3616
|
-
},
|
|
3617
|
-
300,
|
|
3618
|
-
{ leading: false, trailing: true }
|
|
3619
|
-
));
|
|
3694
|
+
__publicField$3(this, "conditions", []);
|
|
3695
|
+
__publicField$3(this, "timeout", -1);
|
|
3620
3696
|
this.tableController = this.buildTableController();
|
|
3621
3697
|
this.initEvents();
|
|
3698
|
+
makeObservable(this, { conditions: observable, isLoading: computed });
|
|
3699
|
+
reaction(
|
|
3700
|
+
() => this.mutex.isBusy,
|
|
3701
|
+
() => this.tableController.state.isLoading = this.mutex.isBusy
|
|
3702
|
+
);
|
|
3703
|
+
}
|
|
3704
|
+
async actualRefreshMethod() {
|
|
3705
|
+
const newValues = this.getFiltersValuesMap();
|
|
3706
|
+
if (!this.areRequiredFilters()) {
|
|
3707
|
+
await this.mutex.acquire();
|
|
3708
|
+
try {
|
|
3709
|
+
this.tableController.state.finishedFirstLoad = false;
|
|
3710
|
+
const refresh = await ApiaApi.post(
|
|
3711
|
+
makeApiaUrl(this.getRefreshParameters()),
|
|
3712
|
+
{
|
|
3713
|
+
postData: newValues,
|
|
3714
|
+
postDataTreatement: "stringify",
|
|
3715
|
+
stringifyOptions: { arrayFormat: "repeat" }
|
|
3716
|
+
}
|
|
3717
|
+
);
|
|
3718
|
+
this.parseRefreshResponse(refresh?.data);
|
|
3719
|
+
} finally {
|
|
3720
|
+
this.tableController.state.finishedFirstLoad = true;
|
|
3721
|
+
this.mutex.release();
|
|
3722
|
+
}
|
|
3723
|
+
}
|
|
3724
|
+
}
|
|
3725
|
+
areRequiredFilters() {
|
|
3726
|
+
return !![...this.tableController.state.filters.values()].find(
|
|
3727
|
+
(c) => c.filterState.required && !c.filterState.value && !c.filterState.isHidden
|
|
3728
|
+
);
|
|
3729
|
+
}
|
|
3730
|
+
buildTableController() {
|
|
3731
|
+
return new TableController();
|
|
3732
|
+
}
|
|
3733
|
+
async clearFilters() {
|
|
3734
|
+
this.tableController.state.filters.forEach((c) => {
|
|
3735
|
+
c.filterState.value = "";
|
|
3736
|
+
c.filterState.valueTo = "";
|
|
3737
|
+
});
|
|
3738
|
+
}
|
|
3739
|
+
executeRefresh() {
|
|
3740
|
+
clearTimeout(this.timeout);
|
|
3741
|
+
this.timeout = setTimeout(() => {
|
|
3742
|
+
this.actualRefreshMethod();
|
|
3743
|
+
}, 300);
|
|
3622
3744
|
}
|
|
3623
3745
|
getTableControllerDefaultProps() {
|
|
3624
|
-
return {};
|
|
3746
|
+
return { statesColumns: [] };
|
|
3625
3747
|
}
|
|
3626
3748
|
getEventsHandlers() {
|
|
3627
3749
|
return {
|
|
@@ -3643,21 +3765,20 @@ class QueryController {
|
|
|
3643
3765
|
onSelectRows: (_ev) => {
|
|
3644
3766
|
},
|
|
3645
3767
|
onSortChange: (ev) => {
|
|
3646
|
-
|
|
3768
|
+
const isDesc = ["Up", "Desc", "D"].includes(ev.sortValue ?? "A");
|
|
3769
|
+
const col = this.tableController.state?.columns.get(ev.column.name);
|
|
3770
|
+
if (col) {
|
|
3771
|
+
col.currentSorting = isDesc ? "D" : "A";
|
|
3772
|
+
this.tableController.state.columns = new Map(
|
|
3773
|
+
this.tableController.state.columns
|
|
3774
|
+
);
|
|
3775
|
+
}
|
|
3776
|
+
this.sort(String(ev.columnIndex), isDesc ? "Des" : "Asc");
|
|
3647
3777
|
},
|
|
3648
3778
|
onPage: this.page.bind(this),
|
|
3649
3779
|
onRefresh: () => this.refresh(true)
|
|
3650
3780
|
};
|
|
3651
3781
|
}
|
|
3652
|
-
buildTableController() {
|
|
3653
|
-
return new TableController();
|
|
3654
|
-
}
|
|
3655
|
-
initEvents() {
|
|
3656
|
-
const handlers = this.getEventsHandlers();
|
|
3657
|
-
Object.entries(handlers).forEach(([eventName, handler]) => {
|
|
3658
|
-
this.tableController.on(eventName, handler.bind(this));
|
|
3659
|
-
});
|
|
3660
|
-
}
|
|
3661
3782
|
getLoadStructureParameters() {
|
|
3662
3783
|
return {
|
|
3663
3784
|
ajaxUrl: this.ajaxUrl,
|
|
@@ -3675,14 +3796,17 @@ class QueryController {
|
|
|
3675
3796
|
}
|
|
3676
3797
|
getFiltersValuesMap() {
|
|
3677
3798
|
return [...this.tableController.state.filters.values()].reduce((result, filterWrapper) => {
|
|
3678
|
-
const { id, value, filterToId,
|
|
3679
|
-
result[id] = value;
|
|
3680
|
-
if (filterToId !== void 0 &&
|
|
3681
|
-
result[filterToId] =
|
|
3799
|
+
const { id, value, filterToId, filterToValue } = filterWrapper.filterState;
|
|
3800
|
+
result[id] = filterWrapper.filterState.multiplier ? value * filterWrapper.filterState.multiplier : value;
|
|
3801
|
+
if (filterToId !== void 0 && filterToValue != void 0) {
|
|
3802
|
+
result[filterToId] = filterWrapper.filterState.multiplier ? Number(filterToValue) * filterWrapper.filterState.multiplier : filterToValue;
|
|
3682
3803
|
}
|
|
3683
3804
|
return result;
|
|
3684
3805
|
}, {});
|
|
3685
3806
|
}
|
|
3807
|
+
get isLoading() {
|
|
3808
|
+
return this.mutex.isBusy;
|
|
3809
|
+
}
|
|
3686
3810
|
getPageParameters() {
|
|
3687
3811
|
return {
|
|
3688
3812
|
ajaxUrl: this.ajaxUrl,
|
|
@@ -3704,6 +3828,64 @@ class QueryController {
|
|
|
3704
3828
|
orderJustThisColumn: true
|
|
3705
3829
|
};
|
|
3706
3830
|
}
|
|
3831
|
+
async getStructure() {
|
|
3832
|
+
const result = await ApiaApi.post(
|
|
3833
|
+
makeApiaUrl(this.getLoadStructureParameters())
|
|
3834
|
+
);
|
|
3835
|
+
if (!result?.data) {
|
|
3836
|
+
throw new Error("Cannot load Input query structure");
|
|
3837
|
+
}
|
|
3838
|
+
return this.parseLoadStructureResponse(result.data);
|
|
3839
|
+
}
|
|
3840
|
+
initEvents() {
|
|
3841
|
+
const handlers = this.getEventsHandlers();
|
|
3842
|
+
Object.entries(handlers).forEach(([eventName, handler]) => {
|
|
3843
|
+
this.tableController.on(eventName, handler.bind(this));
|
|
3844
|
+
});
|
|
3845
|
+
}
|
|
3846
|
+
async initialLoad() {
|
|
3847
|
+
if (this.initializing && !this.hasInited) {
|
|
3848
|
+
throw new Error("Cannot initialize the query twice");
|
|
3849
|
+
}
|
|
3850
|
+
this.initializing = true;
|
|
3851
|
+
if (!this.hasInited) {
|
|
3852
|
+
const structure = await this.getStructure();
|
|
3853
|
+
this.structure = structure;
|
|
3854
|
+
this.parseStructure(structure);
|
|
3855
|
+
this.tableController.updateState({
|
|
3856
|
+
props: this.getTableControllerDefaultProps()
|
|
3857
|
+
});
|
|
3858
|
+
this.hasInited = true;
|
|
3859
|
+
this.initializing = false;
|
|
3860
|
+
this.loadFilterTypes();
|
|
3861
|
+
if (!this.structure.queryData?.noExecFirstTime)
|
|
3862
|
+
this.refresh();
|
|
3863
|
+
}
|
|
3864
|
+
}
|
|
3865
|
+
async loadFilterTypes() {
|
|
3866
|
+
if (!this.structure?.hideFilterTypes) {
|
|
3867
|
+
const result = await ApiaApi.post(
|
|
3868
|
+
makeApiaUrl({
|
|
3869
|
+
ajaxUrl: "apia.query.ModalAction.run?",
|
|
3870
|
+
action: "filterOptions"
|
|
3871
|
+
})
|
|
3872
|
+
);
|
|
3873
|
+
if (result?.data?.form?.elements?.element) {
|
|
3874
|
+
this.conditions = arrayOrArray(result.data.form.elements.element);
|
|
3875
|
+
}
|
|
3876
|
+
}
|
|
3877
|
+
}
|
|
3878
|
+
async page(num) {
|
|
3879
|
+
await this.mutex.acquire();
|
|
3880
|
+
try {
|
|
3881
|
+
const page = await ApiaApi.post(
|
|
3882
|
+
makeApiaUrl({ ...this.getPageParameters(), pageNumber: num })
|
|
3883
|
+
);
|
|
3884
|
+
this.parseRefreshResponse(page?.data);
|
|
3885
|
+
} finally {
|
|
3886
|
+
this.mutex.release();
|
|
3887
|
+
}
|
|
3888
|
+
}
|
|
3707
3889
|
parseLoadStructureResponse(response) {
|
|
3708
3890
|
const typedResponse = response;
|
|
3709
3891
|
const retrievedColumns = arrayOrArray(typedResponse.columns.column);
|
|
@@ -3713,33 +3895,35 @@ class QueryController {
|
|
|
3713
3895
|
label: c.title,
|
|
3714
3896
|
name: c.name,
|
|
3715
3897
|
additionalData: c,
|
|
3716
|
-
allowSorting: c.enableOrder
|
|
3898
|
+
allowSorting: c.enableOrder !== false,
|
|
3717
3899
|
ariaLabel: c.title,
|
|
3718
3900
|
currentSorting: c.order,
|
|
3719
|
-
hidden: c.hide === "1",
|
|
3720
|
-
hideFromAccordion: c.hide ===
|
|
3901
|
+
hidden: c.hide === true || c.hide == "1",
|
|
3902
|
+
hideFromAccordion: c.hide === true,
|
|
3721
3903
|
id: c.name,
|
|
3722
3904
|
showAsAdditional: c.asMoreInformation,
|
|
3723
3905
|
title: c.toolTip,
|
|
3724
|
-
width: c.width
|
|
3906
|
+
width: c.width === "" || c.width === void 0 ? "300px" : c.width
|
|
3725
3907
|
};
|
|
3726
3908
|
return column;
|
|
3727
3909
|
}),
|
|
3728
|
-
description: typedResponse.queryData
|
|
3910
|
+
description: typedResponse.queryData?.description,
|
|
3729
3911
|
filters: arrayOrArray(typedResponse.filters.filter).filter((f) => !!f.column).map((f, i) => {
|
|
3730
3912
|
const filter = {
|
|
3731
|
-
id: `filter${String(i + 1)}`,
|
|
3913
|
+
id: f.id ?? `filter${String(i + 1)}`,
|
|
3914
|
+
// Id generado en APIA
|
|
3915
|
+
filterToId: f?.filterToId ?? f.type == "D" ? `filter${String(i + 1)}i` : void 0,
|
|
3732
3916
|
// Id generado en APIA
|
|
3733
3917
|
value: f.currentValue,
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
avoidLabel: false,
|
|
3918
|
+
avoidLabel: f.type === "D" || f.type === "date" ? true : false,
|
|
3919
|
+
filterToValue: f?.filterToValue,
|
|
3737
3920
|
column: f.column,
|
|
3738
3921
|
isAdditional: f.asAdditional,
|
|
3739
3922
|
isHidden: f.hideFilterOption,
|
|
3740
3923
|
title: f.title,
|
|
3741
3924
|
tooltip: f.toolTip,
|
|
3742
3925
|
type: f.type,
|
|
3926
|
+
hideToFilter: true,
|
|
3743
3927
|
onChange: () => {
|
|
3744
3928
|
},
|
|
3745
3929
|
options: [],
|
|
@@ -3754,10 +3938,11 @@ class QueryController {
|
|
|
3754
3938
|
(c) => c.asMoreInformation
|
|
3755
3939
|
),
|
|
3756
3940
|
isDynamic: false,
|
|
3757
|
-
title: typedResponse.queryData
|
|
3941
|
+
title: typedResponse.queryData?.title,
|
|
3758
3942
|
openFiltersAutomatically: typedResponse.filters.openFiltersAutomatically,
|
|
3759
3943
|
runFiltersAutomatically: typedResponse.filters.runFiltersAutomatically,
|
|
3760
|
-
hideFilterTypes: typedResponse.filters.hideFilterTypes
|
|
3944
|
+
hideFilterTypes: typedResponse.filters.hideFilterTypes,
|
|
3945
|
+
queryData: typedResponse?.queryData
|
|
3761
3946
|
};
|
|
3762
3947
|
}
|
|
3763
3948
|
parseRefreshResponse(response) {
|
|
@@ -3780,20 +3965,11 @@ class QueryController {
|
|
|
3780
3965
|
}))
|
|
3781
3966
|
].filter(Boolean),
|
|
3782
3967
|
className: r.classToAdd,
|
|
3783
|
-
id: r.id
|
|
3968
|
+
id: r.id ?? uniqueId$1("row")
|
|
3784
3969
|
};
|
|
3785
3970
|
})
|
|
3786
3971
|
]);
|
|
3787
3972
|
}
|
|
3788
|
-
async getStructure() {
|
|
3789
|
-
const result = await ApiaApi.post(
|
|
3790
|
-
makeApiaUrl(this.getLoadStructureParameters())
|
|
3791
|
-
);
|
|
3792
|
-
if (!result?.data) {
|
|
3793
|
-
throw new Error("Cannot load Input query structure");
|
|
3794
|
-
}
|
|
3795
|
-
return this.parseLoadStructureResponse(result.data);
|
|
3796
|
-
}
|
|
3797
3973
|
parseStructure(structure) {
|
|
3798
3974
|
const columns = new Map(
|
|
3799
3975
|
arrayOrArray(structure.columns).map((c) => [c.name, c])
|
|
@@ -3803,139 +3979,176 @@ class QueryController {
|
|
|
3803
3979
|
return [f.id, new Filter(f)];
|
|
3804
3980
|
})
|
|
3805
3981
|
);
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
}
|
|
3811
|
-
updatePageState(pageInfo) {
|
|
3812
|
-
const currentPage = Number(pageInfo?.currentPage ?? 0);
|
|
3813
|
-
const totalPages = Number(pageInfo?.pageCount ?? 0);
|
|
3814
|
-
const totalRecords = Number(pageInfo?.totalRecords ?? 0);
|
|
3815
|
-
this.tableController.updateState({
|
|
3816
|
-
pagination: { currentPage, totalPages, totalRecords }
|
|
3817
|
-
});
|
|
3818
|
-
}
|
|
3819
|
-
updateRows(rows) {
|
|
3820
|
-
this.tableController.state.rows = rows;
|
|
3821
|
-
}
|
|
3822
|
-
async clearFilters() {
|
|
3823
|
-
const result = await ApiaApi.post(
|
|
3824
|
-
makeApiaUrl({ ...this.getClearFiltersParameters() })
|
|
3825
|
-
);
|
|
3826
|
-
if (!result?.data)
|
|
3827
|
-
return;
|
|
3828
|
-
const structure = this.parseLoadStructureResponse(result.data);
|
|
3829
|
-
this.parseStructure(structure);
|
|
3830
|
-
this.refresh();
|
|
3831
|
-
}
|
|
3832
|
-
async initialLoad() {
|
|
3833
|
-
if (this.initializing && !this.hasInited) {
|
|
3834
|
-
throw new Error("Cannot initialize the query twice");
|
|
3982
|
+
if (columns.size) {
|
|
3983
|
+
this.tableController.updateState({
|
|
3984
|
+
columns
|
|
3985
|
+
});
|
|
3835
3986
|
}
|
|
3836
|
-
|
|
3837
|
-
if (!this.hasInited) {
|
|
3838
|
-
this.structure = await this.getStructure();
|
|
3839
|
-
this.parseStructure(this.structure);
|
|
3987
|
+
if (filters.size) {
|
|
3840
3988
|
this.tableController.updateState({
|
|
3841
|
-
|
|
3989
|
+
filters
|
|
3842
3990
|
});
|
|
3843
|
-
this.hasInited = true;
|
|
3844
|
-
this.initializing = false;
|
|
3845
3991
|
}
|
|
3846
3992
|
}
|
|
3847
|
-
async
|
|
3848
|
-
|
|
3849
|
-
makeApiaUrl({ ...this.getPageParameters(), pageNumber: num })
|
|
3850
|
-
);
|
|
3851
|
-
this.parseRefreshResponse(page?.data);
|
|
3993
|
+
async refresh(now = true) {
|
|
3994
|
+
return now ? this.actualRefreshMethod() : this.executeRefresh();
|
|
3852
3995
|
}
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
(
|
|
3996
|
+
async setFilterOptions() {
|
|
3997
|
+
await ApiaApi.post(
|
|
3998
|
+
makeApiaUrl({
|
|
3999
|
+
ajaxUrl: this.ajaxUrl,
|
|
4000
|
+
action: "setFilterOptions"
|
|
4001
|
+
}),
|
|
4002
|
+
{
|
|
4003
|
+
postData: this.conditions.reduce((acc, c) => {
|
|
4004
|
+
acc[c.id] = c.value;
|
|
4005
|
+
return acc;
|
|
4006
|
+
}, {}),
|
|
4007
|
+
postDataTreatement: "stringify"
|
|
4008
|
+
}
|
|
3856
4009
|
);
|
|
3857
4010
|
}
|
|
3858
|
-
async
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
{
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
}
|
|
4011
|
+
async sort(column, orderType) {
|
|
4012
|
+
await this.mutex.acquire();
|
|
4013
|
+
try {
|
|
4014
|
+
const result = await ApiaApi.post(
|
|
4015
|
+
makeApiaUrl({
|
|
4016
|
+
...this.getSortParameters(),
|
|
4017
|
+
orderBy: column,
|
|
4018
|
+
orderType
|
|
4019
|
+
})
|
|
3867
4020
|
);
|
|
3868
|
-
|
|
4021
|
+
if (result?.data) {
|
|
4022
|
+
const structure = this.parseLoadStructureResponse(result.data);
|
|
4023
|
+
this.parseStructure(structure);
|
|
4024
|
+
this.parseRefreshResponse(result.data);
|
|
4025
|
+
}
|
|
4026
|
+
} finally {
|
|
4027
|
+
this.mutex.release();
|
|
3869
4028
|
}
|
|
3870
4029
|
}
|
|
3871
|
-
|
|
3872
|
-
|
|
4030
|
+
updatePageState(pageInfo) {
|
|
4031
|
+
const currentPage = Number(pageInfo?.currentPage ?? 0);
|
|
4032
|
+
const totalPages = Number(pageInfo?.pageCount ?? 0);
|
|
4033
|
+
const totalRecords = Number(pageInfo?.totalRecords ?? 0);
|
|
4034
|
+
this.tableController.updateState({
|
|
4035
|
+
pagination: { currentPage, totalPages, totalRecords }
|
|
4036
|
+
});
|
|
3873
4037
|
}
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
makeApiaUrl({ ...this.getSortParameters(), orderBy: column })
|
|
3877
|
-
);
|
|
3878
|
-
if (result?.data) {
|
|
3879
|
-
const structure = this.parseLoadStructureResponse(result.data);
|
|
3880
|
-
this.parseStructure(structure);
|
|
3881
|
-
}
|
|
3882
|
-
this.refresh();
|
|
4038
|
+
updateRows(rows) {
|
|
4039
|
+
this.tableController.state.rows = rows;
|
|
3883
4040
|
}
|
|
3884
4041
|
}
|
|
3885
4042
|
|
|
4043
|
+
const FilterTypesComponent = observer(
|
|
4044
|
+
({ queryController }) => {
|
|
4045
|
+
return /* @__PURE__ */ jsx(Fragment, { children: queryController.conditions.map((f, idx) => {
|
|
4046
|
+
const options = arrayOrArray(f.options.option);
|
|
4047
|
+
return /* @__PURE__ */ jsxs(Label, { children: [
|
|
4048
|
+
/* @__PURE__ */ jsxs(Box, { as: "span", children: [
|
|
4049
|
+
f.text,
|
|
4050
|
+
":"
|
|
4051
|
+
] }),
|
|
4052
|
+
/* @__PURE__ */ jsx(
|
|
4053
|
+
Select$1,
|
|
4054
|
+
{
|
|
4055
|
+
title: f.title,
|
|
4056
|
+
onChange: (ev) => {
|
|
4057
|
+
const selectedValue = ev.target.value;
|
|
4058
|
+
queryController.conditions[idx].value = selectedValue;
|
|
4059
|
+
queryController.setFilterOptions();
|
|
4060
|
+
},
|
|
4061
|
+
disabled: f.readonly || f.disabled,
|
|
4062
|
+
value: f.value,
|
|
4063
|
+
children: options.map((option) => {
|
|
4064
|
+
return /* @__PURE__ */ jsx("option", { value: option.value, children: option.content }, option.value);
|
|
4065
|
+
})
|
|
4066
|
+
}
|
|
4067
|
+
)
|
|
4068
|
+
] }, f.name);
|
|
4069
|
+
}) });
|
|
4070
|
+
}
|
|
4071
|
+
);
|
|
4072
|
+
|
|
3886
4073
|
const AdditionalFiltersComponent = ({
|
|
3887
|
-
|
|
4074
|
+
queryController
|
|
3888
4075
|
}) => {
|
|
3889
4076
|
const filterTitle = getLabel("sbtFilters").text;
|
|
3890
4077
|
const sortTitle = getLabel("titOrderBy").text;
|
|
3891
4078
|
const filterTypes = getLabel("btnFilterType").text;
|
|
3892
|
-
const hasAdditional = !![
|
|
3893
|
-
(
|
|
3894
|
-
);
|
|
3895
|
-
const hasFilters = !![
|
|
3896
|
-
|
|
3897
|
-
);
|
|
3898
|
-
const hasSortable = !![
|
|
3899
|
-
(
|
|
4079
|
+
const hasAdditional = !![
|
|
4080
|
+
...queryController.tableController.state.filters.values()
|
|
4081
|
+
].find((f) => f.filterState.isAdditional || !f.filterState.column);
|
|
4082
|
+
const hasFilters = !![
|
|
4083
|
+
...queryController.tableController.state.filters.values()
|
|
4084
|
+
].find((f) => !f.filterState.isAdditional && f.filterState.column);
|
|
4085
|
+
const hasSortable = !![
|
|
4086
|
+
...queryController.tableController.state.columns.values()
|
|
4087
|
+
].find((c) => c.allowSorting !== false);
|
|
4088
|
+
const hasGroupFilter = [
|
|
4089
|
+
...queryController.tableController.state.filters.values()
|
|
4090
|
+
].find((f) => f.filterState.group && f.filterState.group !== "")?.filterState;
|
|
4091
|
+
return /* @__PURE__ */ jsx(
|
|
4092
|
+
TableContextReproducer,
|
|
4093
|
+
{
|
|
4094
|
+
tableName: queryController.tableController.getTableName(),
|
|
4095
|
+
children: /* @__PURE__ */ jsxs(Accordion, { className: "additionalFiltersContent", singleExpand: true, children: [
|
|
4096
|
+
hasFilters && /* @__PURE__ */ jsx(
|
|
4097
|
+
AccordionItem,
|
|
4098
|
+
{
|
|
4099
|
+
id: "Responsive",
|
|
4100
|
+
defaultExpanded: true,
|
|
4101
|
+
buttonProps: { ariaLabel: filterTitle, label: filterTitle },
|
|
4102
|
+
children: /* @__PURE__ */ jsx(Responsive, {})
|
|
4103
|
+
}
|
|
4104
|
+
),
|
|
4105
|
+
hasAdditional && /* @__PURE__ */ jsx(
|
|
4106
|
+
AccordionItem,
|
|
4107
|
+
{
|
|
4108
|
+
id: "Additional",
|
|
4109
|
+
buttonProps: {
|
|
4110
|
+
ariaLabel: window.ADDITIONAL_FILTERS_LABEL,
|
|
4111
|
+
label: window.ADDITIONAL_FILTERS_LABEL
|
|
4112
|
+
},
|
|
4113
|
+
children: /* @__PURE__ */ jsx(Additional, {})
|
|
4114
|
+
}
|
|
4115
|
+
),
|
|
4116
|
+
hasGroupFilter && /* @__PURE__ */ jsx(
|
|
4117
|
+
AccordionItem,
|
|
4118
|
+
{
|
|
4119
|
+
id: "Group",
|
|
4120
|
+
buttonProps: {
|
|
4121
|
+
ariaLabel: getLabel("titMetadata").text,
|
|
4122
|
+
label: getLabel("titMetadata").text
|
|
4123
|
+
},
|
|
4124
|
+
children: /* @__PURE__ */ jsx(
|
|
4125
|
+
Grouped,
|
|
4126
|
+
{
|
|
4127
|
+
tableName: queryController.tableController.getTableName(),
|
|
4128
|
+
group: hasGroupFilter?.group ?? ""
|
|
4129
|
+
}
|
|
4130
|
+
)
|
|
4131
|
+
}
|
|
4132
|
+
),
|
|
4133
|
+
hasSortable && /* @__PURE__ */ jsx(
|
|
4134
|
+
AccordionItem,
|
|
4135
|
+
{
|
|
4136
|
+
id: "Sort",
|
|
4137
|
+
buttonProps: { ariaLabel: sortTitle, label: sortTitle },
|
|
4138
|
+
children: /* @__PURE__ */ jsx(Sort, {})
|
|
4139
|
+
}
|
|
4140
|
+
),
|
|
4141
|
+
hasFilters && !queryController.structure?.hideFilterTypes && /* @__PURE__ */ jsx(
|
|
4142
|
+
AccordionItem,
|
|
4143
|
+
{
|
|
4144
|
+
id: "FilterTypes",
|
|
4145
|
+
buttonProps: { ariaLabel: filterTypes, label: filterTypes },
|
|
4146
|
+
children: /* @__PURE__ */ jsx(FilterTypesComponent, { queryController })
|
|
4147
|
+
}
|
|
4148
|
+
)
|
|
4149
|
+
] })
|
|
4150
|
+
}
|
|
3900
4151
|
);
|
|
3901
|
-
return /* @__PURE__ */ jsx(TableContextReproducer, { tableName: tableController.getTableName(), children: /* @__PURE__ */ jsxs(Accordion, { className: "additionalFiltersContent", singleExpand: true, children: [
|
|
3902
|
-
hasFilters && /* @__PURE__ */ jsx(
|
|
3903
|
-
AccordionItem,
|
|
3904
|
-
{
|
|
3905
|
-
id: "Responsive",
|
|
3906
|
-
defaultExpanded: true,
|
|
3907
|
-
buttonProps: { ariaLabel: filterTitle, label: filterTitle },
|
|
3908
|
-
children: /* @__PURE__ */ jsx(Responsive, {})
|
|
3909
|
-
}
|
|
3910
|
-
),
|
|
3911
|
-
hasAdditional && /* @__PURE__ */ jsx(
|
|
3912
|
-
AccordionItem,
|
|
3913
|
-
{
|
|
3914
|
-
id: "Additional",
|
|
3915
|
-
buttonProps: {
|
|
3916
|
-
ariaLabel: "todo: additional",
|
|
3917
|
-
label: "todo:additional"
|
|
3918
|
-
},
|
|
3919
|
-
children: /* @__PURE__ */ jsx(Additional, {})
|
|
3920
|
-
}
|
|
3921
|
-
),
|
|
3922
|
-
hasSortable && /* @__PURE__ */ jsx(
|
|
3923
|
-
AccordionItem,
|
|
3924
|
-
{
|
|
3925
|
-
id: "Sort",
|
|
3926
|
-
buttonProps: { ariaLabel: sortTitle, label: sortTitle },
|
|
3927
|
-
children: /* @__PURE__ */ jsx(Sort, {})
|
|
3928
|
-
}
|
|
3929
|
-
),
|
|
3930
|
-
hasFilters && /* @__PURE__ */ jsx(
|
|
3931
|
-
AccordionItem,
|
|
3932
|
-
{
|
|
3933
|
-
id: "FilterTypes",
|
|
3934
|
-
buttonProps: { ariaLabel: filterTypes, label: filterTypes },
|
|
3935
|
-
children: /* @__PURE__ */ jsx(tableController.filterTypes.Component, {})
|
|
3936
|
-
}
|
|
3937
|
-
)
|
|
3938
|
-
] }) });
|
|
3939
4152
|
};
|
|
3940
4153
|
|
|
3941
4154
|
var __defProp$2 = Object.defineProperty;
|
|
@@ -3944,6 +4157,34 @@ var __publicField$2 = (obj, key, value) => {
|
|
|
3944
4157
|
__defNormalProp$2(obj, key + "" , value);
|
|
3945
4158
|
return value;
|
|
3946
4159
|
};
|
|
4160
|
+
const ButtonsBar = observer(
|
|
4161
|
+
({ queryController }) => {
|
|
4162
|
+
return /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "row", gap: "10px" }, children: [
|
|
4163
|
+
/* @__PURE__ */ jsx(
|
|
4164
|
+
SimpleButton,
|
|
4165
|
+
{
|
|
4166
|
+
variant: "primary-sm",
|
|
4167
|
+
onClick: () => {
|
|
4168
|
+
queryController.refresh();
|
|
4169
|
+
},
|
|
4170
|
+
disabled: queryController.isLoading,
|
|
4171
|
+
children: getLabel("btnSearch").text
|
|
4172
|
+
}
|
|
4173
|
+
),
|
|
4174
|
+
/* @__PURE__ */ jsx(
|
|
4175
|
+
SimpleButton,
|
|
4176
|
+
{
|
|
4177
|
+
variant: "outline-sm",
|
|
4178
|
+
onClick: () => {
|
|
4179
|
+
queryController.clearFilters();
|
|
4180
|
+
},
|
|
4181
|
+
disabled: queryController.isLoading,
|
|
4182
|
+
children: getLabel("btnClearFilter").text
|
|
4183
|
+
}
|
|
4184
|
+
)
|
|
4185
|
+
] });
|
|
4186
|
+
}
|
|
4187
|
+
);
|
|
3947
4188
|
class AdditionalFiltersModal {
|
|
3948
4189
|
constructor(queryController) {
|
|
3949
4190
|
this.queryController = queryController;
|
|
@@ -3951,39 +4192,13 @@ class AdditionalFiltersModal {
|
|
|
3951
4192
|
}
|
|
3952
4193
|
getModalDefinition() {
|
|
3953
4194
|
return {
|
|
3954
|
-
children: /* @__PURE__ */ jsx(
|
|
3955
|
-
AdditionalFiltersComponent,
|
|
3956
|
-
{
|
|
3957
|
-
tableController: this.queryController.tableController
|
|
3958
|
-
}
|
|
3959
|
-
),
|
|
4195
|
+
children: /* @__PURE__ */ jsx(AdditionalFiltersComponent, { queryController: this.queryController }),
|
|
3960
4196
|
onConfirm: () => {
|
|
3961
4197
|
},
|
|
3962
4198
|
confirmProps: {
|
|
3963
4199
|
hideConfirmButton: true,
|
|
3964
4200
|
hideCancelButton: true,
|
|
3965
|
-
additionalButtonsOnRight: /* @__PURE__ */
|
|
3966
|
-
/* @__PURE__ */ jsx(
|
|
3967
|
-
SimpleButton,
|
|
3968
|
-
{
|
|
3969
|
-
variant: "primary-sm",
|
|
3970
|
-
onClick: () => {
|
|
3971
|
-
this.queryController.refresh();
|
|
3972
|
-
},
|
|
3973
|
-
children: getLabel("btnSearch").text
|
|
3974
|
-
}
|
|
3975
|
-
),
|
|
3976
|
-
/* @__PURE__ */ jsx(
|
|
3977
|
-
SimpleButton,
|
|
3978
|
-
{
|
|
3979
|
-
variant: "outline-sm",
|
|
3980
|
-
onClick: () => {
|
|
3981
|
-
this.queryController.clearFilters();
|
|
3982
|
-
},
|
|
3983
|
-
children: getLabel("btnClearFilter").text
|
|
3984
|
-
}
|
|
3985
|
-
)
|
|
3986
|
-
] })
|
|
4201
|
+
additionalButtonsOnRight: /* @__PURE__ */ jsx(ButtonsBar, { queryController: this.queryController })
|
|
3987
4202
|
},
|
|
3988
4203
|
draggable: true,
|
|
3989
4204
|
variant: "layout.common.modals.apiaFinder.additionalFiltersModal",
|
|
@@ -3991,7 +4206,6 @@ class AdditionalFiltersModal {
|
|
|
3991
4206
|
};
|
|
3992
4207
|
}
|
|
3993
4208
|
async openModal(properties) {
|
|
3994
|
-
this.queryController.tableController.filterTypes.initialLoad();
|
|
3995
4209
|
this.modalHandler = ApiaUtil.instance.modals.open({
|
|
3996
4210
|
...this.getModalDefinition(),
|
|
3997
4211
|
...properties
|
|
@@ -4095,11 +4309,11 @@ class QueryModalController {
|
|
|
4095
4309
|
return this.emitter.on(ev, cb);
|
|
4096
4310
|
}
|
|
4097
4311
|
async openModal(properties) {
|
|
4312
|
+
await this.queryController.initialLoad();
|
|
4098
4313
|
this.modalHandler = ApiaUtil.instance.modals.open({
|
|
4099
4314
|
...this.getModalDefinition(),
|
|
4100
4315
|
...properties
|
|
4101
4316
|
});
|
|
4102
|
-
await this.queryController.initialLoad();
|
|
4103
4317
|
return this.onConfirmResolve();
|
|
4104
4318
|
}
|
|
4105
4319
|
getModalHandler() {
|
|
@@ -4132,6 +4346,9 @@ class GenericListQuery extends QueryController {
|
|
|
4132
4346
|
super(ajaxUrl);
|
|
4133
4347
|
this.ajaxUrl = ajaxUrl;
|
|
4134
4348
|
}
|
|
4349
|
+
getClearFiltersParameters() {
|
|
4350
|
+
return { ...super.getClearFiltersParameters(), action: "filter" };
|
|
4351
|
+
}
|
|
4135
4352
|
getTableControllerDefaultProps() {
|
|
4136
4353
|
return {
|
|
4137
4354
|
...super.getTableControllerDefaultProps(),
|
|
@@ -4142,122 +4359,82 @@ class GenericListQuery extends QueryController {
|
|
|
4142
4359
|
return { ...super.getLoadStructureParameters(), action: "filter" };
|
|
4143
4360
|
}
|
|
4144
4361
|
getRefreshParameters() {
|
|
4145
|
-
return { ...super.getRefreshParameters() };
|
|
4146
|
-
}
|
|
4147
|
-
getSortParameters() {
|
|
4148
|
-
return {
|
|
4149
|
-
...super.getSortParameters()
|
|
4150
|
-
};
|
|
4151
|
-
}
|
|
4152
|
-
getFilterParameters() {
|
|
4153
4362
|
return {
|
|
4154
|
-
|
|
4363
|
+
...super.getRefreshParameters(),
|
|
4155
4364
|
action: "filter",
|
|
4156
|
-
react: true,
|
|
4157
4365
|
isAjax: true
|
|
4158
4366
|
};
|
|
4159
4367
|
}
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
}
|
|
4163
|
-
async filter() {
|
|
4164
|
-
const filterResult = await ApiaApi.post(
|
|
4165
|
-
makeApiaUrl(this.getFilterParameters()),
|
|
4166
|
-
{
|
|
4167
|
-
postData: {
|
|
4168
|
-
...super.getFiltersValuesMap(),
|
|
4169
|
-
externalUser: false,
|
|
4170
|
-
selectOnlyOne: false,
|
|
4171
|
-
globalAndEnv: true,
|
|
4172
|
-
hierarchy: false,
|
|
4173
|
-
forOrgUnit: false,
|
|
4174
|
-
forCurrentEnv: false
|
|
4175
|
-
},
|
|
4176
|
-
postDataTreatement: "stringify",
|
|
4177
|
-
stringifyOptions: { arrayFormat: "repeat" }
|
|
4178
|
-
}
|
|
4179
|
-
);
|
|
4180
|
-
if (!filterResult?.data)
|
|
4368
|
+
parseRefreshResponse(response) {
|
|
4369
|
+
if (!response)
|
|
4181
4370
|
return;
|
|
4182
|
-
const structure = this.parseLoadStructureResponse(
|
|
4371
|
+
const structure = this.parseLoadStructureResponse(response);
|
|
4183
4372
|
this.parseStructure(structure);
|
|
4184
4373
|
setTimeout(() => {
|
|
4185
|
-
|
|
4186
|
-
},
|
|
4374
|
+
super.parseRefreshResponse(response);
|
|
4375
|
+
}, 0);
|
|
4187
4376
|
}
|
|
4188
4377
|
parseLoadStructureResponse(response) {
|
|
4189
4378
|
const typedResponse = response;
|
|
4190
|
-
|
|
4191
|
-
typedResponse.function
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
const returnObject = {
|
|
4197
|
-
columns: retrievedColumns.map((c) => {
|
|
4198
|
-
const column = {
|
|
4199
|
-
label: c.label,
|
|
4200
|
-
name: c.name
|
|
4201
|
-
};
|
|
4202
|
-
return column;
|
|
4203
|
-
}),
|
|
4204
|
-
filters: arrayOrArray(retrievedFilters).map((f, i) => {
|
|
4205
|
-
const filter = {
|
|
4206
|
-
id: `filter${String(i + 1)}`,
|
|
4207
|
-
value: f.value,
|
|
4208
|
-
avoidLabel: false,
|
|
4209
|
-
isHidden: f.isHidden,
|
|
4210
|
-
column: f.column,
|
|
4211
|
-
title: f.title,
|
|
4212
|
-
tooltip: f.tooltip,
|
|
4213
|
-
type: f.type,
|
|
4214
|
-
onChange: () => {
|
|
4215
|
-
},
|
|
4216
|
-
options: [],
|
|
4217
|
-
placeholder: f.title,
|
|
4218
|
-
readonly: f.readonly,
|
|
4219
|
-
required: f.required
|
|
4220
|
-
};
|
|
4221
|
-
return filter;
|
|
4222
|
-
}),
|
|
4223
|
-
description: "",
|
|
4224
|
-
hasAdditionalInformation: false,
|
|
4225
|
-
hideFilterTypes: false,
|
|
4226
|
-
isDynamic: false,
|
|
4227
|
-
openFiltersAutomatically: false,
|
|
4228
|
-
runFiltersAutomatically: false,
|
|
4229
|
-
title: ""
|
|
4230
|
-
};
|
|
4231
|
-
return returnObject;
|
|
4232
|
-
}
|
|
4233
|
-
async initialLoad() {
|
|
4234
|
-
this.tableController.updateState({
|
|
4235
|
-
props: this.getTableControllerDefaultProps()
|
|
4379
|
+
return super.parseLoadStructureResponse({
|
|
4380
|
+
columns: { ...typedResponse.function.messages.result.columns },
|
|
4381
|
+
filters: {
|
|
4382
|
+
...typedResponse.function.messages.result.filters,
|
|
4383
|
+
runFiltersAutomatically: true
|
|
4384
|
+
}
|
|
4236
4385
|
});
|
|
4237
|
-
await this.refresh();
|
|
4238
4386
|
}
|
|
4239
|
-
|
|
4240
|
-
|
|
4387
|
+
}
|
|
4388
|
+
|
|
4389
|
+
class UsersQuery extends GenericListQuery {
|
|
4390
|
+
constructor() {
|
|
4391
|
+
super("apia.modals.UsersAction.run");
|
|
4241
4392
|
}
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4393
|
+
getFiltersValuesMap() {
|
|
4394
|
+
return {
|
|
4395
|
+
...super.getFiltersValuesMap(),
|
|
4396
|
+
externalUser: false,
|
|
4397
|
+
selectOnlyOne: false,
|
|
4398
|
+
globalAndEnv: true,
|
|
4399
|
+
hierarchy: false,
|
|
4400
|
+
forOrgUnit: false,
|
|
4401
|
+
forCurrentEnv: false
|
|
4402
|
+
};
|
|
4403
|
+
}
|
|
4404
|
+
parseLoadStructureResponse(response) {
|
|
4405
|
+
const structure = { ...super.parseLoadStructureResponse(response) };
|
|
4406
|
+
structure.hideFilterTypes = true;
|
|
4407
|
+
return structure;
|
|
4251
4408
|
}
|
|
4252
4409
|
}
|
|
4410
|
+
const makeApiaUsersModal2 = () => new QueryModalController(new UsersQuery());
|
|
4253
4411
|
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
);
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
)
|
|
4412
|
+
class PoolsQuery extends GenericListQuery {
|
|
4413
|
+
constructor() {
|
|
4414
|
+
super("apia.modals.PoolsAction.run");
|
|
4415
|
+
}
|
|
4416
|
+
getFiltersValuesMap() {
|
|
4417
|
+
return {
|
|
4418
|
+
...super.getFiltersValuesMap(),
|
|
4419
|
+
showAutogenerated: false,
|
|
4420
|
+
showNotAutogenerated: false,
|
|
4421
|
+
showCurrentEnv: true,
|
|
4422
|
+
showGlobal: true,
|
|
4423
|
+
selectOnlyOne: false,
|
|
4424
|
+
forHierarchy: false,
|
|
4425
|
+
showOnlyPoolsInHierarchy: false,
|
|
4426
|
+
showOnlyPoolsOutsideHierarchy: false,
|
|
4427
|
+
refreshParameters: false,
|
|
4428
|
+
fetchAllInHierarchy: false
|
|
4429
|
+
};
|
|
4430
|
+
}
|
|
4431
|
+
parseLoadStructureResponse(response) {
|
|
4432
|
+
const structure = { ...super.parseLoadStructureResponse(response) };
|
|
4433
|
+
structure.hideFilterTypes = true;
|
|
4434
|
+
return structure;
|
|
4435
|
+
}
|
|
4436
|
+
}
|
|
4437
|
+
const makeApiaPoolsModals2 = () => new QueryModalController(new PoolsQuery());
|
|
4261
4438
|
|
|
4262
4439
|
var __defProp = Object.defineProperty;
|
|
4263
4440
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -4288,9 +4465,49 @@ class MonDocQuery extends QueryController {
|
|
|
4288
4465
|
]
|
|
4289
4466
|
};
|
|
4290
4467
|
}
|
|
4468
|
+
async initialLoad() {
|
|
4469
|
+
await super.initialLoad();
|
|
4470
|
+
await this.loadMetadataFilters();
|
|
4471
|
+
await this.setFilters();
|
|
4472
|
+
}
|
|
4473
|
+
async loadMetadataFilters() {
|
|
4474
|
+
const res = await ApiaApi.post(
|
|
4475
|
+
makeApiaUrl({
|
|
4476
|
+
ajaxUrl: this.ajaxUrl,
|
|
4477
|
+
action: "loadMetadata",
|
|
4478
|
+
docTypeId: !this.hasInited ? this.dynamicParams.docTypeSel : this.tableController.state.filters.get("txtDocTypeId")?.filterState.value
|
|
4479
|
+
})
|
|
4480
|
+
);
|
|
4481
|
+
if (res?.data?.docMetadata?.metadata) {
|
|
4482
|
+
const parsedFilters = res.data.docMetadata.metadata.map((c) => {
|
|
4483
|
+
const filter = {
|
|
4484
|
+
...c,
|
|
4485
|
+
group: "metadata",
|
|
4486
|
+
hideToFilter: true,
|
|
4487
|
+
filterToId: `${String(c.id)}i`,
|
|
4488
|
+
filterToValue: c.value2,
|
|
4489
|
+
avoidLabel: c.type === "D"
|
|
4490
|
+
};
|
|
4491
|
+
return filter;
|
|
4492
|
+
});
|
|
4493
|
+
const metadataFilters = new Map(
|
|
4494
|
+
arrayOrArray(parsedFilters).map((f) => {
|
|
4495
|
+
return [f.id, new Filter(f)];
|
|
4496
|
+
})
|
|
4497
|
+
);
|
|
4498
|
+
this.tableController.updateState({
|
|
4499
|
+
filters: new Map([
|
|
4500
|
+
...this.tableController.state.filters.entries(),
|
|
4501
|
+
...metadataFilters.entries()
|
|
4502
|
+
])
|
|
4503
|
+
});
|
|
4504
|
+
}
|
|
4505
|
+
}
|
|
4506
|
+
async loadFilterTypes() {
|
|
4507
|
+
}
|
|
4291
4508
|
processFilterChangeEvent(ev) {
|
|
4292
4509
|
this.tableController.state.filters.get(ev.id);
|
|
4293
|
-
this.
|
|
4510
|
+
this.refresh();
|
|
4294
4511
|
}
|
|
4295
4512
|
getLoadStructureParameters() {
|
|
4296
4513
|
return {
|
|
@@ -4302,59 +4519,106 @@ class MonDocQuery extends QueryController {
|
|
|
4302
4519
|
...this.dynamicParams
|
|
4303
4520
|
};
|
|
4304
4521
|
}
|
|
4305
|
-
getRefreshParameters() {
|
|
4306
|
-
return { ...super.getRefreshParameters() };
|
|
4307
|
-
}
|
|
4308
|
-
getSortParameters() {
|
|
4309
|
-
return {
|
|
4310
|
-
...super.getSortParameters()
|
|
4311
|
-
};
|
|
4312
|
-
}
|
|
4313
4522
|
setDynamicParams(params) {
|
|
4314
4523
|
this.dynamicParams = params;
|
|
4315
4524
|
}
|
|
4316
|
-
|
|
4525
|
+
getClearFiltersParameters() {
|
|
4526
|
+
return { ...super.getClearFiltersParameters(), action: "filter" };
|
|
4527
|
+
}
|
|
4528
|
+
getRefreshParameters() {
|
|
4317
4529
|
return {
|
|
4318
|
-
|
|
4530
|
+
...super.getRefreshParameters(),
|
|
4319
4531
|
action: "filter",
|
|
4320
|
-
react: true,
|
|
4321
4532
|
isAjax: true
|
|
4322
4533
|
};
|
|
4323
4534
|
}
|
|
4535
|
+
getFiltersValuesMap() {
|
|
4536
|
+
const metadataValues = [];
|
|
4537
|
+
const filtersValues = [
|
|
4538
|
+
...this.tableController.state.filters.values()
|
|
4539
|
+
].reduce((result, filterWrapper) => {
|
|
4540
|
+
const { id, value, type, group, multiplier, filterToId, filterToValue } = filterWrapper.filterState;
|
|
4541
|
+
if (group?.match(/metadata(\d+)/)) {
|
|
4542
|
+
if (value !== "") {
|
|
4543
|
+
const prefix = `${id}${window.PRIMARY_SEPARATOR}`;
|
|
4544
|
+
if (type) {
|
|
4545
|
+
const t = type === "apiaNumber" ? "N" : type;
|
|
4546
|
+
metadataValues.push(
|
|
4547
|
+
`${prefix}${t}${window.PRIMARY_SEPARATOR}${value}`
|
|
4548
|
+
);
|
|
4549
|
+
if (filterToValue) {
|
|
4550
|
+
metadataValues.push(
|
|
4551
|
+
`${prefix}${t}${window.PRIMARY_SEPARATOR}${filterToValue}`
|
|
4552
|
+
);
|
|
4553
|
+
}
|
|
4554
|
+
} else {
|
|
4555
|
+
metadataValues.push(`${prefix}${value}`);
|
|
4556
|
+
}
|
|
4557
|
+
}
|
|
4558
|
+
return result;
|
|
4559
|
+
}
|
|
4560
|
+
result[id] = multiplier ? value * multiplier : value;
|
|
4561
|
+
if (filterToId !== void 0 && filterToValue != void 0) {
|
|
4562
|
+
result[filterToId] = multiplier ? Number(filterToValue) * multiplier : filterToValue;
|
|
4563
|
+
}
|
|
4564
|
+
return result;
|
|
4565
|
+
}, {});
|
|
4566
|
+
return {
|
|
4567
|
+
...filtersValues,
|
|
4568
|
+
strDocMetadata: metadataValues.join(";")
|
|
4569
|
+
};
|
|
4570
|
+
}
|
|
4324
4571
|
getEventsHandlers() {
|
|
4325
4572
|
return {
|
|
4326
4573
|
...super.getEventsHandlers(),
|
|
4327
|
-
onFilterChange: () => {
|
|
4328
|
-
|
|
4574
|
+
onFilterChange: (e) => {
|
|
4575
|
+
if (e.id === "txtDocTypeId") {
|
|
4576
|
+
this.loadMetadataFilters();
|
|
4577
|
+
}
|
|
4578
|
+
this.refresh(false);
|
|
4329
4579
|
}
|
|
4330
4580
|
};
|
|
4331
4581
|
}
|
|
4332
|
-
async filter() {
|
|
4333
|
-
const filterResult = await ApiaApi.post(
|
|
4334
|
-
makeApiaUrl(this.getFilterParameters()),
|
|
4335
|
-
{
|
|
4336
|
-
postData: {
|
|
4337
|
-
...super.getFiltersValuesMap()
|
|
4338
|
-
},
|
|
4339
|
-
postDataTreatement: "stringify",
|
|
4340
|
-
stringifyOptions: { arrayFormat: "repeat" }
|
|
4341
|
-
}
|
|
4342
|
-
);
|
|
4343
|
-
if (!filterResult?.data)
|
|
4344
|
-
return;
|
|
4345
|
-
setTimeout(() => {
|
|
4346
|
-
this.parseRefreshResponse(filterResult.data);
|
|
4347
|
-
}, 200);
|
|
4348
|
-
}
|
|
4349
4582
|
parseRefreshResponse(response) {
|
|
4350
|
-
const rows = response?.function?.messages?.result?.table?.row;
|
|
4583
|
+
const rows = arrayOrArray(response?.function?.messages?.result?.table?.row);
|
|
4351
4584
|
const pageState = response?.function.messages.result.pageInfo;
|
|
4352
4585
|
this.updatePageState(pageState);
|
|
4353
4586
|
this.updateRows([
|
|
4354
|
-
...
|
|
4355
|
-
(r)
|
|
4587
|
+
...rows.map((r) => {
|
|
4588
|
+
const cells = arrayOrArray(r.cell);
|
|
4589
|
+
const fileName = typeof cells[1] === "string" ? cells[1] : typeof cells[1] === "object" && cells[1] ? cells[1].content : "";
|
|
4590
|
+
return {
|
|
4356
4591
|
rowProps: r,
|
|
4592
|
+
isLocked: r.docLock,
|
|
4593
|
+
states: [
|
|
4594
|
+
{
|
|
4595
|
+
Icon: () => /* @__PURE__ */ jsx(
|
|
4596
|
+
Icon,
|
|
4597
|
+
{
|
|
4598
|
+
title: getLabel("lblLockedDocument").text,
|
|
4599
|
+
icon: "Locked",
|
|
4600
|
+
sx: { display: r.docLock ? "block" : "none" }
|
|
4601
|
+
}
|
|
4602
|
+
),
|
|
4603
|
+
tooltip: ""
|
|
4604
|
+
},
|
|
4605
|
+
{
|
|
4606
|
+
Icon: () => /* @__PURE__ */ jsx(
|
|
4607
|
+
Icon,
|
|
4608
|
+
{
|
|
4609
|
+
title: getLabel("lblReadOnly").text,
|
|
4610
|
+
icon: "Readonly",
|
|
4611
|
+
size: 22,
|
|
4612
|
+
sx: { display: r.uneditableTR ? "block" : "none" }
|
|
4613
|
+
}
|
|
4614
|
+
),
|
|
4615
|
+
tooltip: ""
|
|
4616
|
+
}
|
|
4617
|
+
],
|
|
4357
4618
|
cells: [
|
|
4619
|
+
{
|
|
4620
|
+
children: /* @__PURE__ */ jsx(FileIcon, { docName: fileName })
|
|
4621
|
+
},
|
|
4358
4622
|
...arrayOrArray(r.cell).map((c) => {
|
|
4359
4623
|
if (typeof c === "string") {
|
|
4360
4624
|
return { children: c };
|
|
@@ -4370,9 +4634,10 @@ class MonDocQuery extends QueryController {
|
|
|
4370
4634
|
return { children: c };
|
|
4371
4635
|
})
|
|
4372
4636
|
],
|
|
4373
|
-
id: r?.id
|
|
4374
|
-
|
|
4375
|
-
|
|
4637
|
+
id: r?.id,
|
|
4638
|
+
className: `${r.boldType ? "bold" : ""} ${r["expired-doc"] ? "expired" : ""} `
|
|
4639
|
+
};
|
|
4640
|
+
})
|
|
4376
4641
|
]);
|
|
4377
4642
|
}
|
|
4378
4643
|
parseLoadStructureResponse(response) {
|
|
@@ -4381,17 +4646,15 @@ class MonDocQuery extends QueryController {
|
|
|
4381
4646
|
const retrievedFilters = arrayOrArray(typedResponse.filters);
|
|
4382
4647
|
const returnObject = {
|
|
4383
4648
|
columns: retrievedColumns.map((c) => {
|
|
4384
|
-
if (c.name === "docFile")
|
|
4385
|
-
return null;
|
|
4386
4649
|
const column = {
|
|
4387
4650
|
label: c.label,
|
|
4388
4651
|
name: c.name,
|
|
4389
4652
|
allowSorting: c.allowSorting,
|
|
4390
4653
|
dataSortBy: c.dataSortBy,
|
|
4391
|
-
minWidth: "25%",
|
|
4392
4654
|
sort: c.sort,
|
|
4393
4655
|
toolTip: c.toolTip,
|
|
4394
|
-
|
|
4656
|
+
minWidth: c.name === "docFile" ? "50px" : "25%",
|
|
4657
|
+
width: c.name === "docFile" ? "50px" : "25%"
|
|
4395
4658
|
};
|
|
4396
4659
|
return column;
|
|
4397
4660
|
}).filter((c) => c !== null),
|
|
@@ -4399,13 +4662,15 @@ class MonDocQuery extends QueryController {
|
|
|
4399
4662
|
const filter = {
|
|
4400
4663
|
id: f.id,
|
|
4401
4664
|
filterToId: f?.filterToId,
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4665
|
+
filterToValue: f?.filterToValue,
|
|
4666
|
+
isAdditional: f.type === "date",
|
|
4667
|
+
value: f?.options?.[1].value ?? f.currentValue,
|
|
4405
4668
|
column: f.column,
|
|
4406
4669
|
title: f.title,
|
|
4407
4670
|
tooltip: f.toolTip,
|
|
4408
|
-
|
|
4671
|
+
hideToFilter: true,
|
|
4672
|
+
avoidLabel: f.type === "date",
|
|
4673
|
+
type: f.type,
|
|
4409
4674
|
onChange: () => {
|
|
4410
4675
|
},
|
|
4411
4676
|
options: f.options?.map((option) => ({
|
|
@@ -4415,8 +4680,6 @@ class MonDocQuery extends QueryController {
|
|
|
4415
4680
|
placeholder: f.title,
|
|
4416
4681
|
isRange: f.isRange,
|
|
4417
4682
|
isSize: f.isSize
|
|
4418
|
-
// readonly: f.readonly,
|
|
4419
|
-
// required: f.required,
|
|
4420
4683
|
};
|
|
4421
4684
|
return filter;
|
|
4422
4685
|
}),
|
|
@@ -4426,21 +4689,22 @@ class MonDocQuery extends QueryController {
|
|
|
4426
4689
|
isDynamic: false,
|
|
4427
4690
|
openFiltersAutomatically: false,
|
|
4428
4691
|
runFiltersAutomatically: true,
|
|
4429
|
-
title: ""
|
|
4692
|
+
title: "",
|
|
4693
|
+
queryData: { noExecFirstTime: true }
|
|
4430
4694
|
};
|
|
4431
4695
|
return returnObject;
|
|
4432
4696
|
}
|
|
4433
|
-
async
|
|
4434
|
-
|
|
4435
|
-
makeApiaUrl({
|
|
4697
|
+
async setFilters() {
|
|
4698
|
+
await ApiaApi.post(
|
|
4699
|
+
makeApiaUrl({
|
|
4700
|
+
ajaxUrl: this.ajaxUrl,
|
|
4701
|
+
action: "setFilters",
|
|
4702
|
+
txtDocTypeId: this.tableController.state.filters.get("txtDocTypeId")?.filterState.value
|
|
4703
|
+
})
|
|
4436
4704
|
);
|
|
4437
|
-
if (result?.data) {
|
|
4438
|
-
this.parseRefreshResponse(result.data);
|
|
4439
|
-
}
|
|
4440
|
-
return super.refresh();
|
|
4441
4705
|
}
|
|
4442
4706
|
}
|
|
4443
|
-
class
|
|
4707
|
+
class ApiaMonDocModal2 extends QueryModalController {
|
|
4444
4708
|
constructor() {
|
|
4445
4709
|
super(new MonDocQuery("/apia.execution.CustMonDocumentAction.run"));
|
|
4446
4710
|
}
|
|
@@ -4451,7 +4715,6 @@ class ApiaMonDocModal extends QueryModalController {
|
|
|
4451
4715
|
return super.openModal(properties);
|
|
4452
4716
|
}
|
|
4453
4717
|
}
|
|
4454
|
-
const ApiaMonDocModal2 = new ApiaMonDocModal();
|
|
4455
4718
|
|
|
4456
|
-
export { ApiaApi, ApiaApiHandler, ApiaMonDocModal2,
|
|
4719
|
+
export { ApiaApi, ApiaApiHandler, ApiaMonDocModal2, GenericListQuery, QueryController, QueryModalController, getFunction, getModal, isHtmlResponse, isXmlResponse, makeApiaPoolsModals2, makeApiaUrl, makeApiaUsersModal2, parseSuccessfulResponse };
|
|
4457
4720
|
//# sourceMappingURL=index.js.map
|