@apia/api 4.0.26 → 4.0.28
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 +17 -5
- package/dist/index.js +215 -46
- package/dist/index.js.map +1 -1
- package/package.json +10 -9
package/dist/index.d.ts
CHANGED
|
@@ -279,6 +279,8 @@ type TFilter = {
|
|
|
279
279
|
errorMessage?: string;
|
|
280
280
|
id: string;
|
|
281
281
|
filterToId?: string;
|
|
282
|
+
filterToValue?: string;
|
|
283
|
+
hideToFilter?: true;
|
|
282
284
|
isAdditional?: boolean;
|
|
283
285
|
isHidden?: boolean;
|
|
284
286
|
onChange?: (queryController: QueryController) => unknown;
|
|
@@ -291,6 +293,7 @@ type TFilter = {
|
|
|
291
293
|
title?: string;
|
|
292
294
|
tooltip?: string;
|
|
293
295
|
isRange?: boolean;
|
|
296
|
+
group?: string;
|
|
294
297
|
type?: 'date' | 'D' | 'S' | 'number' | 'N' | 'apiaNumber' | 'triple' | 'dateHour';
|
|
295
298
|
value: any;
|
|
296
299
|
valueTo?: any;
|
|
@@ -400,12 +403,23 @@ type QueryControllerStructure = {
|
|
|
400
403
|
title: string;
|
|
401
404
|
columns: TResponsiveTableColumn[];
|
|
402
405
|
filters: TFilter[];
|
|
406
|
+
queryData?: {
|
|
407
|
+
noExecFirstTime?: boolean;
|
|
408
|
+
autoFilter?: boolean;
|
|
409
|
+
showAllAttributes?: boolean;
|
|
410
|
+
showColumn?: string;
|
|
411
|
+
name?: string;
|
|
412
|
+
hideCount?: boolean;
|
|
413
|
+
description?: string;
|
|
414
|
+
storeColumn?: string;
|
|
415
|
+
title?: string;
|
|
416
|
+
};
|
|
403
417
|
};
|
|
404
418
|
type StoredQueryControllerStructure = Omit<QueryControllerStructure, 'columns' | 'filters'>;
|
|
405
419
|
declare class QueryController {
|
|
406
420
|
ajaxUrl: string;
|
|
407
|
-
|
|
408
|
-
|
|
421
|
+
protected hasInited: boolean;
|
|
422
|
+
protected initializing: boolean;
|
|
409
423
|
protected mutex: Mutex;
|
|
410
424
|
structure: StoredQueryControllerStructure | null;
|
|
411
425
|
tableController: TableController;
|
|
@@ -461,13 +475,12 @@ type QueryModalControllerEvents = Pick<TableControllerEvents, 'onSelectRows'> &
|
|
|
461
475
|
cancel: null;
|
|
462
476
|
};
|
|
463
477
|
declare class QueryModalController {
|
|
464
|
-
protected title?: string | undefined;
|
|
465
478
|
protected emitter: EventEmitter<QueryModalControllerEvents>;
|
|
466
479
|
protected queryController: QueryController;
|
|
467
480
|
private modalHandler;
|
|
468
481
|
protected currentSelection: TResponsiveTableRowsSelectionEvent | null;
|
|
469
482
|
private additionalFiltersController;
|
|
470
|
-
constructor(queryController: QueryController
|
|
483
|
+
constructor(queryController: QueryController);
|
|
471
484
|
protected getModalDefinition(): TOpenModal;
|
|
472
485
|
getQueryController(): QueryController;
|
|
473
486
|
protected on<K extends keyof QueryModalControllerEvents>(ev: K, cb: (e: QueryModalControllerEvents[K]) => unknown): UnSubscriber;
|
|
@@ -490,7 +503,6 @@ declare class GenericListQuery extends QueryController {
|
|
|
490
503
|
protected getRefreshParameters(): Record<string, unknown>;
|
|
491
504
|
protected parseRefreshResponse(response?: TApiaFunction | null): void;
|
|
492
505
|
protected parseLoadStructureResponse(response: any): QueryControllerStructure;
|
|
493
|
-
initialLoad(): Promise<void>;
|
|
494
506
|
}
|
|
495
507
|
|
|
496
508
|
declare const makeApiaPoolsModals2: () => QueryModalController;
|
package/dist/index.js
CHANGED
|
@@ -2,18 +2,19 @@ import { jsx, jsxs, Fragment } from '@apia/theme/jsx-runtime';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
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, useIntermediateValue, Mutex, uniqueId as uniqueId$1 } 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
8
|
import { Accordion, AccordionItem, useModal, LabelBox, SimpleButton, ApiaUtil, Modal, ProgressBar, DateInput } from '@apia/components';
|
|
9
|
-
import axios from 'axios';
|
|
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, defaultLabels, makeController2, responsiveTableActions, TableContextReproducer } from '@apia/table';
|
|
14
|
+
import { ResponsiveTableContext, ResponsiveTable, Pagination, Sort, Responsive, Additional, responsiveTableStore, useResponsiveTableContext, getResponsiveTableContext, TableLoadingContext, defaultLabels, makeController2, responsiveTableActions, TableContextReproducer, Grouped } from '@apia/table';
|
|
15
15
|
import { makeObservable, observable, reaction, toJS, action, computed } from 'mobx';
|
|
16
16
|
import { observer } from 'mobx-react-lite';
|
|
17
|
+
import dayjs from 'dayjs';
|
|
17
18
|
import { Icon, FileIcon } from '@apia/icons';
|
|
18
19
|
|
|
19
20
|
const ApiaApiId = createContext("apiaApi");
|
|
@@ -78,6 +79,10 @@ function getColor(color, colors = defaultConfig.colors ?? {
|
|
|
78
79
|
return colors[color];
|
|
79
80
|
}
|
|
80
81
|
const handleWrongResponse = (error) => {
|
|
82
|
+
if (error instanceof AxiosError && (error.status === 403 || error.response?.status === 403)) {
|
|
83
|
+
session.invalidate();
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
81
86
|
let errorMessage;
|
|
82
87
|
if (typeof error !== "string") {
|
|
83
88
|
if (error.message)
|
|
@@ -378,7 +383,7 @@ async function post(par1, par2) {
|
|
|
378
383
|
);
|
|
379
384
|
}
|
|
380
385
|
const response = await axios.post(parsedUrl, behaveConfig.postData, behaveConfig.axiosConfig).catch((e) => {
|
|
381
|
-
handleWrongResponse(new Error(e));
|
|
386
|
+
handleWrongResponse(e instanceof AxiosError ? e : new Error(e));
|
|
382
387
|
});
|
|
383
388
|
if (response) {
|
|
384
389
|
const result = handleResponse(response, actualUrl, behaveConfig);
|
|
@@ -405,7 +410,7 @@ async function get(par1, par2) {
|
|
|
405
410
|
}
|
|
406
411
|
);
|
|
407
412
|
const response = await axios.get(parsedUrl, behaveConfig.axiosConfig).catch((e) => {
|
|
408
|
-
handleWrongResponse(new Error(e));
|
|
413
|
+
handleWrongResponse(e instanceof AxiosError ? e : new Error(e));
|
|
409
414
|
});
|
|
410
415
|
if (response) {
|
|
411
416
|
const result = await handleResponse(
|
|
@@ -3362,26 +3367,63 @@ const InputFilterRenderer = observer(
|
|
|
3362
3367
|
}
|
|
3363
3368
|
);
|
|
3364
3369
|
|
|
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
|
+
}
|
|
3365
3379
|
const DateFilterRenderer = observer(
|
|
3366
3380
|
({ filter, state }) => {
|
|
3367
|
-
const { onFilterBlur,
|
|
3368
|
-
return /* @__PURE__ */
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
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);
|
|
3378
3396
|
}
|
|
3379
|
-
},
|
|
3380
|
-
onBlur: () => {
|
|
3381
|
-
onFilterBlur?.(filter);
|
|
3382
3397
|
}
|
|
3383
|
-
|
|
3384
|
-
|
|
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
|
+
] });
|
|
3385
3427
|
}
|
|
3386
3428
|
);
|
|
3387
3429
|
|
|
@@ -3407,7 +3449,7 @@ class Filter {
|
|
|
3407
3449
|
if (arrayOrArray(this.filterState.options).length > 0) {
|
|
3408
3450
|
return this.getSelectRenderer({ filter });
|
|
3409
3451
|
}
|
|
3410
|
-
if (this.filterState.type === "D") {
|
|
3452
|
+
if (this.filterState.type === "D" || this.filterState.type === "date") {
|
|
3411
3453
|
return this.getDateRenderer({ filter });
|
|
3412
3454
|
}
|
|
3413
3455
|
return this.getInputRenderer({ filter });
|
|
@@ -3754,10 +3796,10 @@ class QueryController {
|
|
|
3754
3796
|
}
|
|
3755
3797
|
getFiltersValuesMap() {
|
|
3756
3798
|
return [...this.tableController.state.filters.values()].reduce((result, filterWrapper) => {
|
|
3757
|
-
const { id, value, filterToId,
|
|
3799
|
+
const { id, value, filterToId, filterToValue } = filterWrapper.filterState;
|
|
3758
3800
|
result[id] = filterWrapper.filterState.multiplier ? value * filterWrapper.filterState.multiplier : value;
|
|
3759
|
-
if (filterToId !== void 0 &&
|
|
3760
|
-
result[filterToId] = filterWrapper.filterState.multiplier ?
|
|
3801
|
+
if (filterToId !== void 0 && filterToValue != void 0) {
|
|
3802
|
+
result[filterToId] = filterWrapper.filterState.multiplier ? Number(filterToValue) * filterWrapper.filterState.multiplier : filterToValue;
|
|
3761
3803
|
}
|
|
3762
3804
|
return result;
|
|
3763
3805
|
}, {});
|
|
@@ -3816,6 +3858,8 @@ class QueryController {
|
|
|
3816
3858
|
this.hasInited = true;
|
|
3817
3859
|
this.initializing = false;
|
|
3818
3860
|
this.loadFilterTypes();
|
|
3861
|
+
if (!this.structure.queryData?.noExecFirstTime)
|
|
3862
|
+
this.refresh();
|
|
3819
3863
|
}
|
|
3820
3864
|
}
|
|
3821
3865
|
async loadFilterTypes() {
|
|
@@ -3859,7 +3903,7 @@ class QueryController {
|
|
|
3859
3903
|
id: c.name,
|
|
3860
3904
|
showAsAdditional: c.asMoreInformation,
|
|
3861
3905
|
title: c.toolTip,
|
|
3862
|
-
width: c.width
|
|
3906
|
+
width: c.width === "" || c.width === void 0 ? "300px" : c.width
|
|
3863
3907
|
};
|
|
3864
3908
|
return column;
|
|
3865
3909
|
}),
|
|
@@ -3868,16 +3912,18 @@ class QueryController {
|
|
|
3868
3912
|
const filter = {
|
|
3869
3913
|
id: f.id ?? `filter${String(i + 1)}`,
|
|
3870
3914
|
// Id generado en APIA
|
|
3871
|
-
filterToId: f?.filterToId,
|
|
3915
|
+
filterToId: f?.filterToId ?? f.type == "D" ? `filter${String(i + 1)}i` : void 0,
|
|
3916
|
+
// Id generado en APIA
|
|
3872
3917
|
value: f.currentValue,
|
|
3873
|
-
|
|
3874
|
-
|
|
3918
|
+
avoidLabel: f.type === "D" || f.type === "date" ? true : false,
|
|
3919
|
+
filterToValue: f?.filterToValue,
|
|
3875
3920
|
column: f.column,
|
|
3876
3921
|
isAdditional: f.asAdditional,
|
|
3877
3922
|
isHidden: f.hideFilterOption,
|
|
3878
3923
|
title: f.title,
|
|
3879
3924
|
tooltip: f.toolTip,
|
|
3880
3925
|
type: f.type,
|
|
3926
|
+
hideToFilter: true,
|
|
3881
3927
|
onChange: () => {
|
|
3882
3928
|
},
|
|
3883
3929
|
options: [],
|
|
@@ -3895,7 +3941,8 @@ class QueryController {
|
|
|
3895
3941
|
title: typedResponse.queryData?.title,
|
|
3896
3942
|
openFiltersAutomatically: typedResponse.filters.openFiltersAutomatically,
|
|
3897
3943
|
runFiltersAutomatically: typedResponse.filters.runFiltersAutomatically,
|
|
3898
|
-
hideFilterTypes: typedResponse.filters.hideFilterTypes
|
|
3944
|
+
hideFilterTypes: typedResponse.filters.hideFilterTypes,
|
|
3945
|
+
queryData: typedResponse?.queryData
|
|
3899
3946
|
};
|
|
3900
3947
|
}
|
|
3901
3948
|
parseRefreshResponse(response) {
|
|
@@ -4038,6 +4085,9 @@ const AdditionalFiltersComponent = ({
|
|
|
4038
4085
|
const hasSortable = !![
|
|
4039
4086
|
...queryController.tableController.state.columns.values()
|
|
4040
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;
|
|
4041
4091
|
return /* @__PURE__ */ jsx(
|
|
4042
4092
|
TableContextReproducer,
|
|
4043
4093
|
{
|
|
@@ -4063,6 +4113,23 @@ const AdditionalFiltersComponent = ({
|
|
|
4063
4113
|
children: /* @__PURE__ */ jsx(Additional, {})
|
|
4064
4114
|
}
|
|
4065
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
|
+
),
|
|
4066
4133
|
hasSortable && /* @__PURE__ */ jsx(
|
|
4067
4134
|
AccordionItem,
|
|
4068
4135
|
{
|
|
@@ -4156,8 +4223,7 @@ var __publicField$1 = (obj, key, value) => {
|
|
|
4156
4223
|
return value;
|
|
4157
4224
|
};
|
|
4158
4225
|
class QueryModalController {
|
|
4159
|
-
constructor(queryController
|
|
4160
|
-
this.title = title;
|
|
4226
|
+
constructor(queryController) {
|
|
4161
4227
|
__publicField$1(this, "emitter", new EventEmitter());
|
|
4162
4228
|
__publicField$1(this, "queryController");
|
|
4163
4229
|
__publicField$1(this, "modalHandler", null);
|
|
@@ -4189,7 +4255,7 @@ class QueryModalController {
|
|
|
4189
4255
|
/* @__PURE__ */ jsx(tableController.Table, {}),
|
|
4190
4256
|
/* @__PURE__ */ jsx(tableController.Pagination, {})
|
|
4191
4257
|
] }),
|
|
4192
|
-
title:
|
|
4258
|
+
title: structure?.title,
|
|
4193
4259
|
onConfirm: () => {
|
|
4194
4260
|
this.onConfirm();
|
|
4195
4261
|
},
|
|
@@ -4202,6 +4268,16 @@ class QueryModalController {
|
|
|
4202
4268
|
cancelButtonText: getLabel("btnCan").text
|
|
4203
4269
|
},
|
|
4204
4270
|
NavBar: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4271
|
+
/* @__PURE__ */ jsx(
|
|
4272
|
+
SimpleButton,
|
|
4273
|
+
{
|
|
4274
|
+
variant: "primary-sm",
|
|
4275
|
+
onClick: () => {
|
|
4276
|
+
this.queryController.refresh();
|
|
4277
|
+
},
|
|
4278
|
+
children: getLabel("btnSearch").text
|
|
4279
|
+
}
|
|
4280
|
+
),
|
|
4205
4281
|
/* @__PURE__ */ jsx(
|
|
4206
4282
|
SimpleButton,
|
|
4207
4283
|
{
|
|
@@ -4233,11 +4309,11 @@ class QueryModalController {
|
|
|
4233
4309
|
return this.emitter.on(ev, cb);
|
|
4234
4310
|
}
|
|
4235
4311
|
async openModal(properties) {
|
|
4312
|
+
await this.queryController.initialLoad();
|
|
4236
4313
|
this.modalHandler = ApiaUtil.instance.modals.open({
|
|
4237
4314
|
...this.getModalDefinition(),
|
|
4238
4315
|
...properties
|
|
4239
4316
|
});
|
|
4240
|
-
await this.queryController.initialLoad();
|
|
4241
4317
|
return this.onConfirmResolve();
|
|
4242
4318
|
}
|
|
4243
4319
|
getModalHandler() {
|
|
@@ -4308,12 +4384,6 @@ class GenericListQuery extends QueryController {
|
|
|
4308
4384
|
}
|
|
4309
4385
|
});
|
|
4310
4386
|
}
|
|
4311
|
-
async initialLoad() {
|
|
4312
|
-
this.tableController.updateState({
|
|
4313
|
-
props: this.getTableControllerDefaultProps()
|
|
4314
|
-
});
|
|
4315
|
-
await this.refresh();
|
|
4316
|
-
}
|
|
4317
4387
|
}
|
|
4318
4388
|
|
|
4319
4389
|
class UsersQuery extends GenericListQuery {
|
|
@@ -4331,6 +4401,11 @@ class UsersQuery extends GenericListQuery {
|
|
|
4331
4401
|
forCurrentEnv: false
|
|
4332
4402
|
};
|
|
4333
4403
|
}
|
|
4404
|
+
parseLoadStructureResponse(response) {
|
|
4405
|
+
const structure = { ...super.parseLoadStructureResponse(response) };
|
|
4406
|
+
structure.hideFilterTypes = true;
|
|
4407
|
+
return structure;
|
|
4408
|
+
}
|
|
4334
4409
|
}
|
|
4335
4410
|
const makeApiaUsersModal2 = () => new QueryModalController(new UsersQuery());
|
|
4336
4411
|
|
|
@@ -4353,6 +4428,11 @@ class PoolsQuery extends GenericListQuery {
|
|
|
4353
4428
|
fetchAllInHierarchy: false
|
|
4354
4429
|
};
|
|
4355
4430
|
}
|
|
4431
|
+
parseLoadStructureResponse(response) {
|
|
4432
|
+
const structure = { ...super.parseLoadStructureResponse(response) };
|
|
4433
|
+
structure.hideFilterTypes = true;
|
|
4434
|
+
return structure;
|
|
4435
|
+
}
|
|
4356
4436
|
}
|
|
4357
4437
|
const makeApiaPoolsModals2 = () => new QueryModalController(new PoolsQuery());
|
|
4358
4438
|
|
|
@@ -4385,6 +4465,44 @@ class MonDocQuery extends QueryController {
|
|
|
4385
4465
|
]
|
|
4386
4466
|
};
|
|
4387
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
|
+
}
|
|
4388
4506
|
async loadFilterTypes() {
|
|
4389
4507
|
}
|
|
4390
4508
|
processFilterChangeEvent(ev) {
|
|
@@ -4414,10 +4532,49 @@ class MonDocQuery extends QueryController {
|
|
|
4414
4532
|
isAjax: true
|
|
4415
4533
|
};
|
|
4416
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
|
+
}
|
|
4417
4571
|
getEventsHandlers() {
|
|
4418
4572
|
return {
|
|
4419
4573
|
...super.getEventsHandlers(),
|
|
4420
|
-
onFilterChange: () => {
|
|
4574
|
+
onFilterChange: (e) => {
|
|
4575
|
+
if (e.id === "txtDocTypeId") {
|
|
4576
|
+
this.loadMetadataFilters();
|
|
4577
|
+
}
|
|
4421
4578
|
this.refresh(false);
|
|
4422
4579
|
}
|
|
4423
4580
|
};
|
|
@@ -4505,13 +4662,15 @@ class MonDocQuery extends QueryController {
|
|
|
4505
4662
|
const filter = {
|
|
4506
4663
|
id: f.id,
|
|
4507
4664
|
filterToId: f?.filterToId,
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4665
|
+
filterToValue: f?.filterToValue,
|
|
4666
|
+
isAdditional: f.type === "date",
|
|
4667
|
+
value: f?.options?.[1].value ?? f.currentValue,
|
|
4511
4668
|
column: f.column,
|
|
4512
4669
|
title: f.title,
|
|
4513
4670
|
tooltip: f.toolTip,
|
|
4514
|
-
|
|
4671
|
+
hideToFilter: true,
|
|
4672
|
+
avoidLabel: f.type === "date",
|
|
4673
|
+
type: f.type,
|
|
4515
4674
|
onChange: () => {
|
|
4516
4675
|
},
|
|
4517
4676
|
options: f.options?.map((option) => ({
|
|
@@ -4530,10 +4689,20 @@ class MonDocQuery extends QueryController {
|
|
|
4530
4689
|
isDynamic: false,
|
|
4531
4690
|
openFiltersAutomatically: false,
|
|
4532
4691
|
runFiltersAutomatically: true,
|
|
4533
|
-
title: ""
|
|
4692
|
+
title: "",
|
|
4693
|
+
queryData: { noExecFirstTime: true }
|
|
4534
4694
|
};
|
|
4535
4695
|
return returnObject;
|
|
4536
4696
|
}
|
|
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
|
+
})
|
|
4704
|
+
);
|
|
4705
|
+
}
|
|
4537
4706
|
}
|
|
4538
4707
|
class ApiaMonDocModal2 extends QueryModalController {
|
|
4539
4708
|
constructor() {
|