@apia/api 4.0.29 → 4.0.31

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 CHANGED
@@ -425,7 +425,7 @@ declare class QueryController {
425
425
  tableController: TableController;
426
426
  conditions: TFilterTypesElementConditions[];
427
427
  constructor(ajaxUrl: string);
428
- protected actualRefreshMethod(): Promise<void>;
428
+ protected actualRefreshMethod(serverFirstRefresh?: boolean): Promise<void>;
429
429
  protected areRequiredFilters(): boolean;
430
430
  protected buildTableController(): TableController;
431
431
  clearFilters(): Promise<void>;
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ 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, formatMessage, getDateFormat, Mutex, uniqueId as uniqueId$1 } from '@apia/util';
5
+ import { debugDispatcher, parseXmlAsync, arrayOrArray, EventEmitter, 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';
@@ -174,6 +174,11 @@ function handleOnClose({
174
174
  console.error(e);
175
175
  }
176
176
  }
177
+ function parseMessages2(messages) {
178
+ for (const m of messages) {
179
+ notify({ message: m.text, title: m.title, trace: m.stack, type: m.type });
180
+ }
181
+ }
177
182
  function parseMessages(response) {
178
183
  if (!response)
179
184
  return;
@@ -230,6 +235,7 @@ const parseSuccessfulResponse = async (response, currentUrl, outerBehaveConfig =
230
235
  exceptions,
231
236
  sysExceptions,
232
237
  sysMessages,
238
+ messages,
233
239
  load,
234
240
  ...rest
235
241
  } = parsedObj;
@@ -237,6 +243,9 @@ const parseSuccessfulResponse = async (response, currentUrl, outerBehaveConfig =
237
243
  session.invalidate();
238
244
  return null;
239
245
  }
246
+ if (messages) {
247
+ parseMessages2(arrayOrArray(messages?.message));
248
+ }
240
249
  if (exceptions && behaveConfig.debug) {
241
250
  console.log(
242
251
  `%cparseSuccessfulResponse`,
@@ -3272,6 +3281,7 @@ const RangeFilterRenderer = observer(
3272
3281
  /* @__PURE__ */ jsx(Box, { className: "ApiaFilter__Range__Low", children: /* @__PURE__ */ jsx(
3273
3282
  Input$1,
3274
3283
  {
3284
+ disabled: state.readonly,
3275
3285
  onChange: ({ target: { value: currentValue } }) => {
3276
3286
  setLowValue(currentValue);
3277
3287
  emitLow(currentValue);
@@ -3291,6 +3301,7 @@ const RangeFilterRenderer = observer(
3291
3301
  /* @__PURE__ */ jsx(Box, { className: "ApiaFilter__Range__High", children: /* @__PURE__ */ jsx(
3292
3302
  Input$1,
3293
3303
  {
3304
+ disabled: state.readonly,
3294
3305
  onChange: ({ target: { value: currentValue } }) => {
3295
3306
  setHighValue(currentValue);
3296
3307
  emitHigh(currentValue);
@@ -3309,6 +3320,7 @@ const RangeFilterRenderer = observer(
3309
3320
  filter.isSize && /* @__PURE__ */ jsx(
3310
3321
  Select$1,
3311
3322
  {
3323
+ disabled: state.readonly,
3312
3324
  className: "ApiaFilter__Range__UnitSelector",
3313
3325
  onChange: (ev) => {
3314
3326
  const unit2 = ev.target.value;
@@ -3334,6 +3346,7 @@ const SelectFilterRenderer = observer(
3334
3346
  return /* @__PURE__ */ jsx(
3335
3347
  Select$1,
3336
3348
  {
3349
+ disabled: state.readonly,
3337
3350
  value: state.value,
3338
3351
  onChange: (ev) => {
3339
3352
  state.value = ev.target.value;
@@ -3350,6 +3363,7 @@ const InputFilterRenderer = observer(
3350
3363
  return /* @__PURE__ */ jsx(
3351
3364
  Input$1,
3352
3365
  {
3366
+ disabled: state.readonly,
3353
3367
  value: state.value,
3354
3368
  onChange: (ev) => {
3355
3369
  state.value = ev.target.value;
@@ -3386,6 +3400,7 @@ const DateFilterRenderer = observer(
3386
3400
  /* @__PURE__ */ jsx(
3387
3401
  DateInput,
3388
3402
  {
3403
+ disabled: state.readonly,
3389
3404
  value: state.value,
3390
3405
  onChange: (date) => {
3391
3406
  state.value = date;
@@ -3403,6 +3418,7 @@ const DateFilterRenderer = observer(
3403
3418
  /* @__PURE__ */ jsx(
3404
3419
  DateInput,
3405
3420
  {
3421
+ disabled: state.readonly,
3406
3422
  value: state.filterToValue,
3407
3423
  onChange: (date) => {
3408
3424
  const result = controlDatesOrder(state.value, date);
@@ -3702,7 +3718,7 @@ class QueryController {
3702
3718
  () => this.tableController.state.isLoading = this.mutex.isBusy
3703
3719
  );
3704
3720
  }
3705
- async actualRefreshMethod() {
3721
+ async actualRefreshMethod(serverFirstRefresh) {
3706
3722
  const newValues = this.getFiltersValuesMap();
3707
3723
  if (!this.areRequiredFilters()) {
3708
3724
  await this.mutex.acquire();
@@ -3718,7 +3734,11 @@ class QueryController {
3718
3734
  );
3719
3735
  this.parseRefreshResponse(refresh?.data);
3720
3736
  } finally {
3721
- this.tableController.state.finishedFirstLoad = true;
3737
+ if (serverFirstRefresh) {
3738
+ this.tableController.state.finishedFirstLoad = false;
3739
+ } else {
3740
+ this.tableController.state.finishedFirstLoad = true;
3741
+ }
3722
3742
  this.mutex.release();
3723
3743
  }
3724
3744
  }
@@ -3734,8 +3754,9 @@ class QueryController {
3734
3754
  async clearFilters() {
3735
3755
  this.tableController.state.filters.forEach((c) => {
3736
3756
  c.filterState.value = "";
3737
- c.filterState.valueTo = "";
3757
+ c.filterState.filterToValue = "";
3738
3758
  });
3759
+ this.actualRefreshMethod();
3739
3760
  }
3740
3761
  executeRefresh() {
3741
3762
  clearTimeout(this.timeout);
@@ -3845,6 +3866,7 @@ class QueryController {
3845
3866
  });
3846
3867
  }
3847
3868
  async initialLoad() {
3869
+ this.tableController.state.finishedFirstLoad = false;
3848
3870
  if (this.initializing && !this.hasInited) {
3849
3871
  throw new Error("Cannot initialize the query twice");
3850
3872
  }
@@ -3927,7 +3949,13 @@ class QueryController {
3927
3949
  hideToFilter: true,
3928
3950
  onChange: () => {
3929
3951
  },
3930
- options: [],
3952
+ options: f?.filterOption ? [
3953
+ { value: "", label: "" },
3954
+ ...arrayOrArray(f?.filterOption).map((c) => ({
3955
+ label: c.content,
3956
+ value: c.value
3957
+ }))
3958
+ ] : void 0,
3931
3959
  placeholder: f.title,
3932
3960
  readonly: f.readonly,
3933
3961
  required: f.required === "true",
@@ -4262,6 +4290,7 @@ class QueryModalController {
4262
4290
  },
4263
4291
  onCancel: () => {
4264
4292
  this.additionalFiltersController.closeModal();
4293
+ this.queryController.tableController.state.finishedFirstLoad = false;
4265
4294
  this.emitter.emit("cancel", null);
4266
4295
  },
4267
4296
  confirmProps: {
@@ -4315,6 +4344,9 @@ class QueryModalController {
4315
4344
  ...this.getModalDefinition(),
4316
4345
  ...properties
4317
4346
  });
4347
+ if (this.queryController.structure?.openFiltersAutomatically) {
4348
+ this.additionalFiltersController.openModal();
4349
+ }
4318
4350
  return this.onConfirmResolve();
4319
4351
  }
4320
4352
  getModalHandler() {
@@ -4452,6 +4484,7 @@ class MonDocQuery extends QueryController {
4452
4484
  getTableControllerDefaultProps() {
4453
4485
  return {
4454
4486
  ...super.getTableControllerDefaultProps(),
4487
+ showFilters: true,
4455
4488
  isMultiple: false,
4456
4489
  reserveColumnsForStates: 2,
4457
4490
  statesColumns: [
@@ -4665,7 +4698,7 @@ class MonDocQuery extends QueryController {
4665
4698
  filterToId: f?.filterToId,
4666
4699
  filterToValue: f?.filterToValue,
4667
4700
  isAdditional: f.type === "date",
4668
- value: f?.options?.[1].value ?? f.currentValue,
4701
+ value: f?.options?.find((c) => c.value === this.dynamicParams.docTypeSel)?.value ?? f.currentValue,
4669
4702
  column: f.column,
4670
4703
  title: f.title,
4671
4704
  tooltip: f.toolTip,