@infomaximum/widget-sdk 4.0.0-beta2 → 4.0.0-beta20
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 +238 -62
- package/dist/index.esm.js +98 -36
- package/dist/index.js +100 -37
- package/package.json +9 -7
package/dist/index.d.ts
CHANGED
|
@@ -33,7 +33,9 @@ declare enum EControlType {
|
|
|
33
33
|
displayCondition = "displayCondition",
|
|
34
34
|
eventsColor = "eventsColor",
|
|
35
35
|
inputMarkdown = "inputMarkdown",
|
|
36
|
-
filter = "filter"
|
|
36
|
+
filter = "filter",
|
|
37
|
+
actionOnClick = "actionOnClick",
|
|
38
|
+
eventsPicker = "eventsPicker"
|
|
37
39
|
}
|
|
38
40
|
/** Конфигурация элемента управления настройкой */
|
|
39
41
|
interface IControlRecord<Settings extends object, Value, ControlType = EControlType> {
|
|
@@ -63,6 +65,12 @@ interface ICalculator<Input, Output> {
|
|
|
63
65
|
}
|
|
64
66
|
interface ICalculatorIndicatorInput {
|
|
65
67
|
alias: string;
|
|
68
|
+
/**
|
|
69
|
+
* Информация о типе данных:
|
|
70
|
+
* - Если тип не передан, не производится дополнительной обработки формулы.
|
|
71
|
+
* - Если передан тип "OTHER", формула дополнительно будет обернута в toString().
|
|
72
|
+
*/
|
|
73
|
+
dataType?: ESimpleDataType;
|
|
66
74
|
displayConditionFormula?: TNullable<string>;
|
|
67
75
|
}
|
|
68
76
|
interface ICalculatorIndicatorOutput {
|
|
@@ -71,6 +79,9 @@ interface ICalculatorIndicatorOutput {
|
|
|
71
79
|
interface ICalculatorDimensionInput extends ICalculatorIndicatorInput {
|
|
72
80
|
formula: string;
|
|
73
81
|
hideEmpty?: boolean;
|
|
82
|
+
/** Временно поддерживается обратная совместимость с форматом { alias: string; formula: string }[] */
|
|
83
|
+
/** Появилась необходимость в ленточном графике, т.к. разрез длительность используется, как мера */
|
|
84
|
+
additionalFormulas?: Map<string, string>;
|
|
74
85
|
}
|
|
75
86
|
interface ICalculatorDimensionOutput extends ICalculatorIndicatorOutput {
|
|
76
87
|
}
|
|
@@ -253,6 +264,7 @@ declare enum EDurationUnit {
|
|
|
253
264
|
declare const mapFormulaFilterToCalculatorInput: (filterValue: IFormulaFilterValue | string) => TNullable<ICalculatorFilter>;
|
|
254
265
|
declare const mapFormulaFiltersToInputs: (filters: (string | IFormulaFilterValue)[]) => ICalculatorFilter[];
|
|
255
266
|
|
|
267
|
+
type TSelectivePartial<T, Keys extends keyof T> = Omit<T, Keys> & Partial<Pick<T, Keys>>;
|
|
256
268
|
declare const formulaFilterMethods: {
|
|
257
269
|
readonly LAST_TIME: "LAST_TIME";
|
|
258
270
|
readonly EQUAL_TO: ECalculatorFilterMethods.EQUAL_TO;
|
|
@@ -282,6 +294,7 @@ declare enum EProcessFilterNames {
|
|
|
282
294
|
/** Длительность перехода */
|
|
283
295
|
durationOfTransition = "durationOfTransition"
|
|
284
296
|
}
|
|
297
|
+
/** @deprecated необходимо использовать @see {@link IFormulaFilterValue} */
|
|
285
298
|
interface IWidgetFormulaFilterValue extends ICalculatorFilter {
|
|
286
299
|
/**
|
|
287
300
|
* Название фильтра
|
|
@@ -298,16 +311,16 @@ interface IProcessFilterValue {
|
|
|
298
311
|
* События, доступные при выборе процесса.
|
|
299
312
|
* Если параметр не передан, используются все события процесса на основе запроса к вычислителю.
|
|
300
313
|
*/
|
|
301
|
-
|
|
314
|
+
eventsNamesByProcessNameMap?: Map<string, (string | null)[]>;
|
|
302
315
|
}
|
|
303
316
|
interface IProcessEventFilterValue extends IProcessFilterValue {
|
|
304
|
-
|
|
317
|
+
processName: string;
|
|
305
318
|
eventName: string;
|
|
306
319
|
}
|
|
307
320
|
interface IProcessTransitionFilterValue extends IProcessFilterValue {
|
|
308
|
-
|
|
321
|
+
startEventProcessName: string;
|
|
309
322
|
startEventName: string;
|
|
310
|
-
|
|
323
|
+
endEventProcessName: string;
|
|
311
324
|
endEventName: string;
|
|
312
325
|
}
|
|
313
326
|
interface IAddPresenceOfEventFilter {
|
|
@@ -322,15 +335,6 @@ interface IAddPresenceOfTransitionFilter {
|
|
|
322
335
|
interface IAddDurationOfTransitionFilter {
|
|
323
336
|
(name: EProcessFilterNames.durationOfTransition, value: IProcessTransitionFilterValue): void;
|
|
324
337
|
}
|
|
325
|
-
interface IWidgetFiltration {
|
|
326
|
-
/** Значения фильтров, подготовленные для передачи в вычислитель */
|
|
327
|
-
preparedFilterValues: ICalculatorFilter[];
|
|
328
|
-
/** Добавить фильтр по формуле */
|
|
329
|
-
addFormulaFilter(value: IWidgetFormulaFilterValue): void;
|
|
330
|
-
/** Удалить фильтр по формуле */
|
|
331
|
-
removeFormulaFilter(formula: string): void;
|
|
332
|
-
addProcessFilter(...args: Parameters<IAddPresenceOfEventFilter> | Parameters<IAddRepetitionOfEventFilter> | Parameters<IAddPresenceOfTransitionFilter> | Parameters<IAddDurationOfTransitionFilter>): void;
|
|
333
|
-
}
|
|
334
338
|
declare enum EFormulaFilterFieldKeys {
|
|
335
339
|
date = "date",
|
|
336
340
|
dateRange = "dateRange",
|
|
@@ -354,7 +358,7 @@ interface IFormulaFilterValue {
|
|
|
354
358
|
/** Метод фильтрации */
|
|
355
359
|
filteringMethod: valueof<typeof formulaFilterMethods>;
|
|
356
360
|
/** Выбранные в списке значения в виде моделей */
|
|
357
|
-
checkedValues: string[];
|
|
361
|
+
checkedValues: (string | null)[];
|
|
358
362
|
/** Значения полей формы редактора */
|
|
359
363
|
formValues: Partial<{
|
|
360
364
|
[EFormulaFilterFieldKeys.date]: string | null;
|
|
@@ -368,6 +372,40 @@ interface IFormulaFilterValue {
|
|
|
368
372
|
[EFormulaFilterFieldKeys.durationUnit]: EDurationUnit;
|
|
369
373
|
}>;
|
|
370
374
|
}
|
|
375
|
+
interface IStagesFilterItem {
|
|
376
|
+
/** Название этапа */
|
|
377
|
+
name: string;
|
|
378
|
+
/** Формула фильтра этапа */
|
|
379
|
+
formula: string;
|
|
380
|
+
isSelected: boolean;
|
|
381
|
+
}
|
|
382
|
+
interface IStagesFilterValue {
|
|
383
|
+
/** Ключ виджета */
|
|
384
|
+
widgetKey: string;
|
|
385
|
+
/** Заголовок фильтра */
|
|
386
|
+
name: TNullable<string>;
|
|
387
|
+
/** Этапы */
|
|
388
|
+
stages: IStagesFilterItem[];
|
|
389
|
+
}
|
|
390
|
+
type TWidgetFilterValue = IFormulaFilterValue | IStagesFilterValue | IProcessEventFilterValue | IProcessTransitionFilterValue;
|
|
391
|
+
interface IWidgetFilter {
|
|
392
|
+
filterValue: TWidgetFilterValue;
|
|
393
|
+
preparedFilterValue: ICalculatorFilter;
|
|
394
|
+
}
|
|
395
|
+
interface IWidgetFiltration {
|
|
396
|
+
/** Значения фильтров, подготовленные для передачи в вычислитель */
|
|
397
|
+
preparedFilterValues: ICalculatorFilter[];
|
|
398
|
+
filters: IWidgetFilter[];
|
|
399
|
+
/** Добавить фильтр по формуле */
|
|
400
|
+
addFormulaFilter(value: IWidgetFormulaFilterValue | TSelectivePartial<IFormulaFilterValue, "format" | "formValues">): void;
|
|
401
|
+
/** Удалить фильтр по формуле */
|
|
402
|
+
removeFormulaFilter(formula: string): void;
|
|
403
|
+
addProcessFilter(...args: Parameters<IAddPresenceOfEventFilter> | Parameters<IAddRepetitionOfEventFilter> | Parameters<IAddPresenceOfTransitionFilter> | Parameters<IAddDurationOfTransitionFilter>): void;
|
|
404
|
+
/** Добавить фильтр по этапам */
|
|
405
|
+
addStagesFilter(value: Omit<IStagesFilterValue, "widgetKey">): void;
|
|
406
|
+
/** Удалить фильтр по этапам */
|
|
407
|
+
removeStagesFilter(widgetKey: string): void;
|
|
408
|
+
}
|
|
371
409
|
|
|
372
410
|
declare enum EWidgetFilterMode {
|
|
373
411
|
DEFAULT = "DEFAULT",
|
|
@@ -383,25 +421,62 @@ type TWidgetFiltering = {
|
|
|
383
421
|
mode: EWidgetFilterMode;
|
|
384
422
|
};
|
|
385
423
|
declare enum EColorMode {
|
|
424
|
+
DISABLED = "DISABLED",
|
|
386
425
|
FORMULA = "FORMULA",
|
|
387
426
|
BASE = "BASE",
|
|
388
427
|
GRADIENT = "GRADIENT",
|
|
389
|
-
AUTO = "AUTO"
|
|
428
|
+
AUTO = "AUTO",
|
|
429
|
+
RULE = "RULE",
|
|
430
|
+
VALUES = "VALUES",
|
|
431
|
+
BY_DIMENSION = "BY_DIMENSION"
|
|
390
432
|
}
|
|
391
|
-
|
|
392
|
-
type TColor = {
|
|
393
|
-
mode: EColorMode.FORMULA;
|
|
394
|
-
formula: string;
|
|
395
|
-
} | {
|
|
433
|
+
type TColorBase = {
|
|
396
434
|
mode: EColorMode.BASE;
|
|
397
435
|
value?: string;
|
|
398
436
|
defaultColor?: string;
|
|
437
|
+
};
|
|
438
|
+
declare enum EColorScope {
|
|
439
|
+
WORKSPACE = "WORKSPACE",
|
|
440
|
+
DASHBOARD = "DASHBOARD"
|
|
441
|
+
}
|
|
442
|
+
type TColorRuleCommon = {
|
|
443
|
+
mode: EColorMode.RULE;
|
|
444
|
+
ruleName: string;
|
|
445
|
+
};
|
|
446
|
+
type TColorRule = ({
|
|
447
|
+
scope: EColorScope.DASHBOARD | null;
|
|
399
448
|
} | {
|
|
449
|
+
scope: EColorScope.WORKSPACE;
|
|
450
|
+
workspaceGroupId: number | null;
|
|
451
|
+
}) & TColorRuleCommon;
|
|
452
|
+
interface IColoredValue {
|
|
453
|
+
value: string;
|
|
454
|
+
color: TColorBase | TColorRule;
|
|
455
|
+
}
|
|
456
|
+
declare enum EMarkdownDisplayMode {
|
|
457
|
+
NONE = "NONE",
|
|
458
|
+
INDICATOR = "INDICATOR"
|
|
459
|
+
}
|
|
460
|
+
/** Настройка цвета */
|
|
461
|
+
type TColor = {
|
|
462
|
+
mode: EColorMode.FORMULA;
|
|
463
|
+
formula: string;
|
|
464
|
+
} | TColorBase | {
|
|
400
465
|
mode: EColorMode.GRADIENT;
|
|
401
466
|
startValue: string;
|
|
402
467
|
endValue: string;
|
|
403
468
|
} | {
|
|
404
469
|
mode: EColorMode.AUTO;
|
|
470
|
+
} | TColorRule | {
|
|
471
|
+
mode: EColorMode.VALUES;
|
|
472
|
+
dimensionFormula: string;
|
|
473
|
+
items: IColoredValue[];
|
|
474
|
+
} | {
|
|
475
|
+
mode: EColorMode.BY_DIMENSION;
|
|
476
|
+
dimensionName: string;
|
|
477
|
+
items: IColoredValue[];
|
|
478
|
+
} | {
|
|
479
|
+
mode: EColorMode.DISABLED;
|
|
405
480
|
};
|
|
406
481
|
declare enum EDisplayConditionMode {
|
|
407
482
|
DISABLED = "DISABLED",
|
|
@@ -416,7 +491,7 @@ type TDisplayCondition = {
|
|
|
416
491
|
formula: TNullable<string>;
|
|
417
492
|
} | {
|
|
418
493
|
mode: EDisplayConditionMode.VARIABLE;
|
|
419
|
-
|
|
494
|
+
variableName: TNullable<string>;
|
|
420
495
|
variableValue: TNullable<string>;
|
|
421
496
|
};
|
|
422
497
|
interface IRange {
|
|
@@ -435,6 +510,7 @@ type TSortDirection = ESortDirection.ascend | ESortDirection.descend;
|
|
|
435
510
|
interface ISortOrder {
|
|
436
511
|
formula: string;
|
|
437
512
|
direction: TSortDirection;
|
|
513
|
+
displayCondition?: TNullable<string>;
|
|
438
514
|
}
|
|
439
515
|
type TWidgetSortingValueRelatedWidgetMeasure = {
|
|
440
516
|
mode: ESortingValueModes.MEASURE_IN_WIDGET;
|
|
@@ -450,7 +526,7 @@ type TWidgetSortingValue = {
|
|
|
450
526
|
formula: string;
|
|
451
527
|
} | TWidgetSortingValueRelatedWidgetIndicator | {
|
|
452
528
|
mode: ESortingValueModes.IN_DASHBOARD | ESortingValueModes.IN_WORKSPACE;
|
|
453
|
-
|
|
529
|
+
name: string;
|
|
454
530
|
formula: string;
|
|
455
531
|
};
|
|
456
532
|
|
|
@@ -533,7 +609,6 @@ declare enum ESortingValueModes {
|
|
|
533
609
|
IN_WORKSPACE = "IN_WORKSPACE"
|
|
534
610
|
}
|
|
535
611
|
interface ICommonColumnIndicator {
|
|
536
|
-
guid: string;
|
|
537
612
|
name: string;
|
|
538
613
|
formula: string;
|
|
539
614
|
}
|
|
@@ -579,6 +654,10 @@ interface IWidgetDimension extends IWidgetColumnIndicator {
|
|
|
579
654
|
interface IWidgetMeasure extends IWidgetColumnIndicator {
|
|
580
655
|
type: EWidgetIndicatorType.MEASURE;
|
|
581
656
|
}
|
|
657
|
+
interface IMarkdownMeasure extends IWidgetMeasure {
|
|
658
|
+
format: EFormatTypes;
|
|
659
|
+
displayMode: EMarkdownDisplayMode;
|
|
660
|
+
}
|
|
582
661
|
/** Тип показателя */
|
|
583
662
|
declare enum EIndicatorType {
|
|
584
663
|
/** Показатели процесса */
|
|
@@ -651,8 +730,8 @@ interface IWidgetTableColumn {
|
|
|
651
730
|
dataType: ESimpleDataType;
|
|
652
731
|
}
|
|
653
732
|
interface IActionScript {
|
|
654
|
-
|
|
655
|
-
|
|
733
|
+
name: string | undefined;
|
|
734
|
+
fieldsNames: Set<string>;
|
|
656
735
|
}
|
|
657
736
|
interface IWidgetTable {
|
|
658
737
|
/** Имя таблицы */
|
|
@@ -660,12 +739,21 @@ interface IWidgetTable {
|
|
|
660
739
|
/** Колонки таблицы */
|
|
661
740
|
columns: Map<string, IWidgetTableColumn>;
|
|
662
741
|
}
|
|
742
|
+
/**
|
|
743
|
+
* simplified - упрощенный для работы фильтрации в образах открытых в дровере/модальном окне
|
|
744
|
+
*
|
|
745
|
+
* full - полный
|
|
746
|
+
*/
|
|
747
|
+
type TFiltrationMode = "simplified" | "full";
|
|
663
748
|
/**
|
|
664
749
|
* preview - упрощенный
|
|
665
750
|
*
|
|
666
751
|
* full - полный
|
|
667
752
|
*/
|
|
668
753
|
type TDisplayMode = "preview" | "full";
|
|
754
|
+
interface IDisplayRule {
|
|
755
|
+
color: TColor;
|
|
756
|
+
}
|
|
669
757
|
interface IWidgetsContext {
|
|
670
758
|
/** используемый язык в системе */
|
|
671
759
|
language: ELanguages;
|
|
@@ -675,8 +763,8 @@ interface IWidgetsContext {
|
|
|
675
763
|
/** Переменные отчета */
|
|
676
764
|
variables: Map<string, TWidgetVariable>;
|
|
677
765
|
/** Метод установки значения переменной отчета */
|
|
678
|
-
setVariableValue(
|
|
679
|
-
|
|
766
|
+
setVariableValue(name: string, value: TNullable<string> | string[]): void;
|
|
767
|
+
statesNames: Set<string>;
|
|
680
768
|
reportName: string;
|
|
681
769
|
/**
|
|
682
770
|
* режим дашборда
|
|
@@ -688,6 +776,10 @@ interface IWidgetsContext {
|
|
|
688
776
|
userLogin: string;
|
|
689
777
|
scripts: Map<string, IActionScript>;
|
|
690
778
|
tables: Set<string>;
|
|
779
|
+
filtrationMode: TFiltrationMode;
|
|
780
|
+
reportDisplayRules: Map<string, IDisplayRule>;
|
|
781
|
+
workspaceDisplayRules: Map<number, Map<string, IDisplayRule>>;
|
|
782
|
+
viewKeyByName: Map<string, string>;
|
|
691
783
|
}
|
|
692
784
|
|
|
693
785
|
declare enum EWidgetActionInputMode {
|
|
@@ -698,13 +790,70 @@ declare enum EWidgetActionInputMode {
|
|
|
698
790
|
FORMULA = "FORMULA",
|
|
699
791
|
MANUALLY = "MANUALLY"
|
|
700
792
|
}
|
|
793
|
+
interface IActionCommon {
|
|
794
|
+
id: number;
|
|
795
|
+
name: string;
|
|
796
|
+
}
|
|
797
|
+
declare enum EActionTypes {
|
|
798
|
+
URL = "URL",
|
|
799
|
+
UPDATE_VARIABLE = "UPDATE_VARIABLE",
|
|
800
|
+
RUN_SCRIPT = "RUN_SCRIPT",
|
|
801
|
+
OPEN_VIEW = "OPEN_VIEW"
|
|
802
|
+
}
|
|
803
|
+
interface IActionGoToUrl extends IActionCommon {
|
|
804
|
+
type: EActionTypes.URL;
|
|
805
|
+
url: string;
|
|
806
|
+
targetBlank: boolean;
|
|
807
|
+
}
|
|
808
|
+
interface IActionScriptField {
|
|
809
|
+
name: string;
|
|
810
|
+
id: number;
|
|
811
|
+
value: TWidgetActionInputValue;
|
|
812
|
+
}
|
|
813
|
+
interface IActionRunScript extends IActionCommon {
|
|
814
|
+
description: string;
|
|
815
|
+
type: EActionTypes.RUN_SCRIPT;
|
|
816
|
+
filters: (IFormulaFilterValue | string)[];
|
|
817
|
+
inputs: IActionScriptField[];
|
|
818
|
+
scriptName: string;
|
|
819
|
+
shouldRefreshWidgetsAfterExecution: boolean;
|
|
820
|
+
}
|
|
821
|
+
interface IActionUpdateVariable extends IActionCommon {
|
|
822
|
+
type: EActionTypes.UPDATE_VARIABLE;
|
|
823
|
+
variables: Array<string>;
|
|
824
|
+
}
|
|
825
|
+
declare enum EViewType {
|
|
826
|
+
CREATED_VIEW = "CREATED_VIEW",
|
|
827
|
+
GENERATED_BY_SCRIPT = "GENERATED_BY_SCRIPT"
|
|
828
|
+
}
|
|
829
|
+
declare enum EOpenViewMode {
|
|
830
|
+
NEW_WINDOW = "NEW_WINDOW",
|
|
831
|
+
PLACEHOLDER = "PLACEHOLDER",
|
|
832
|
+
MODAL = "MODAL",
|
|
833
|
+
DRAWER = "DRAWER"
|
|
834
|
+
}
|
|
835
|
+
declare enum EDrawerPlacement {
|
|
836
|
+
LEFT = "LEFT",
|
|
837
|
+
RIGHT = "RIGHT"
|
|
838
|
+
}
|
|
839
|
+
interface IActionOpenView extends IActionCommon {
|
|
840
|
+
type: EActionTypes.OPEN_VIEW;
|
|
841
|
+
viewName: string;
|
|
842
|
+
viewKey: string;
|
|
843
|
+
openMode: EOpenViewMode;
|
|
844
|
+
viewType: EViewType;
|
|
845
|
+
drawerPlacement: EDrawerPlacement;
|
|
846
|
+
placeholderName: string;
|
|
847
|
+
isOpenInCurrentWindow?: boolean;
|
|
848
|
+
}
|
|
849
|
+
type TActionsOnClick = IActionGoToUrl | IActionRunScript | IActionUpdateVariable | IActionOpenView;
|
|
701
850
|
type TWidgetActionInputValue = {
|
|
702
851
|
mode: EWidgetActionInputMode.FROM_COLUMN;
|
|
703
852
|
tableName: string;
|
|
704
853
|
columnName: string;
|
|
705
854
|
} | {
|
|
706
855
|
mode: EWidgetActionInputMode.FROM_VARIABLE;
|
|
707
|
-
|
|
856
|
+
name: string;
|
|
708
857
|
} | {
|
|
709
858
|
mode: EWidgetActionInputMode.FORMULA;
|
|
710
859
|
formula: string;
|
|
@@ -721,33 +870,25 @@ type TWidgetActionInputValue = {
|
|
|
721
870
|
defaultValue: string;
|
|
722
871
|
};
|
|
723
872
|
interface IWidgetActionInput {
|
|
724
|
-
guid: string;
|
|
725
|
-
value: TWidgetActionInputValue;
|
|
726
|
-
}
|
|
727
|
-
interface IWidgetAction {
|
|
728
|
-
id: number;
|
|
729
873
|
name: string;
|
|
730
|
-
|
|
731
|
-
filters: (IFormulaFilterValue | string)[];
|
|
732
|
-
scriptGuid?: string;
|
|
733
|
-
/** Поле name необходимо, чтобы показать название скрипта, который был удален */
|
|
734
|
-
scriptName?: string;
|
|
735
|
-
inputs: IWidgetActionInput[];
|
|
736
|
-
shouldRefreshWidgetsAfterExecution: boolean;
|
|
874
|
+
value: TWidgetActionInputValue;
|
|
737
875
|
}
|
|
738
|
-
declare const isActionValid: (action:
|
|
876
|
+
declare const isActionValid: (action: TActionsOnClick, { scripts, tables, variables }: IWidgetsContext) => boolean;
|
|
739
877
|
|
|
740
878
|
interface IBaseWidgetSettings {
|
|
741
879
|
apiVersion: string;
|
|
742
880
|
type: string;
|
|
743
881
|
header?: string;
|
|
744
882
|
headerSize?: number;
|
|
745
|
-
|
|
883
|
+
stateName?: string | null;
|
|
884
|
+
showMarkdown?: boolean;
|
|
885
|
+
markdownMeasures?: IMarkdownMeasure[];
|
|
886
|
+
markdownText?: string;
|
|
746
887
|
filters?: (IFormulaFilterValue | string)[];
|
|
747
888
|
filterMode?: EWidgetFilterMode;
|
|
748
889
|
ignoreFilters?: boolean;
|
|
749
890
|
sorting?: IWidgetSortingIndicator[];
|
|
750
|
-
actions?:
|
|
891
|
+
actions?: TActionsOnClick[];
|
|
751
892
|
displayCondition?: TDisplayCondition;
|
|
752
893
|
displayConditionComment?: string;
|
|
753
894
|
}
|
|
@@ -785,14 +926,31 @@ interface ICustomAddButtonProps {
|
|
|
785
926
|
fetchOptions?: () => Promise<ISelectOption[]>;
|
|
786
927
|
onSelect: (value: string, update: <T extends object>(f: (prevItems: T[]) => T[]) => void) => void;
|
|
787
928
|
}
|
|
929
|
+
interface IWidgetIndicatorMenuConfig {
|
|
930
|
+
hideTablesColumnsOptions?: boolean;
|
|
931
|
+
hideCommonOptions?: boolean;
|
|
932
|
+
hideQuantityOption?: boolean;
|
|
933
|
+
}
|
|
934
|
+
interface IMeasureMenuConfig extends IWidgetIndicatorMenuConfig {
|
|
935
|
+
}
|
|
936
|
+
interface ISortingMenuConfig extends IWidgetIndicatorMenuConfig {
|
|
937
|
+
}
|
|
788
938
|
/** Кнопка добавления группы в набор */
|
|
789
939
|
type TAddButton = {
|
|
790
940
|
title: string;
|
|
791
|
-
indicatorType: Exclude<EWidgetIndicatorType, EWidgetIndicatorType.CUSTOM>;
|
|
941
|
+
indicatorType: Exclude<EWidgetIndicatorType, EWidgetIndicatorType.CUSTOM | EWidgetIndicatorType.MEASURE | EWidgetIndicatorType.SORTING>;
|
|
792
942
|
} | {
|
|
793
943
|
title: string;
|
|
794
944
|
indicatorType: EWidgetIndicatorType.CUSTOM;
|
|
795
945
|
props: ICustomAddButtonProps;
|
|
946
|
+
} | {
|
|
947
|
+
title: string;
|
|
948
|
+
indicatorType: EWidgetIndicatorType.MEASURE;
|
|
949
|
+
menuConfig?: IMeasureMenuConfig;
|
|
950
|
+
} | {
|
|
951
|
+
title: string;
|
|
952
|
+
indicatorType: EWidgetIndicatorType.SORTING;
|
|
953
|
+
menuConfig?: ISortingMenuConfig;
|
|
796
954
|
};
|
|
797
955
|
interface IAutoIdentifiedArrayItem {
|
|
798
956
|
/**
|
|
@@ -826,6 +984,10 @@ interface IGroupSetDescription<Settings extends object, GroupSettings extends ob
|
|
|
826
984
|
}
|
|
827
985
|
/** Конфигурация левой панели */
|
|
828
986
|
interface IPanelDescription<Settings extends object, GroupSettings extends IGroupSettings = IGroupSettings> {
|
|
987
|
+
/** Добавить заголовок для виджета */
|
|
988
|
+
useHeader?: boolean;
|
|
989
|
+
/** Добавить описание для виджета */
|
|
990
|
+
useMarkdown?: boolean;
|
|
829
991
|
/** Конфигурация настроек данных виджета */
|
|
830
992
|
dataRecords?: TWidgetLevelRecord<Settings>[];
|
|
831
993
|
/** Конфигурация настроек отображения виджета */
|
|
@@ -984,7 +1146,7 @@ interface IEdge extends IGraphElement {
|
|
|
984
1146
|
endName: string | null;
|
|
985
1147
|
}
|
|
986
1148
|
interface IProcessGraphCalculatorInput {
|
|
987
|
-
|
|
1149
|
+
processName: string;
|
|
988
1150
|
vertexLimit: number | null;
|
|
989
1151
|
edgeLimit: number;
|
|
990
1152
|
vertexMeasures: ICalculatorMeasureInput[];
|
|
@@ -1056,11 +1218,18 @@ interface ITwoLimitsCalculator extends ICalculator<ITwoLimitsCalculatorInput, IT
|
|
|
1056
1218
|
}
|
|
1057
1219
|
|
|
1058
1220
|
interface ITypeCalculatorInput {
|
|
1059
|
-
|
|
1221
|
+
dimensions: {
|
|
1222
|
+
alias: string;
|
|
1223
|
+
formula: string;
|
|
1224
|
+
}[];
|
|
1225
|
+
measures: {
|
|
1226
|
+
alias: string;
|
|
1227
|
+
formula: string;
|
|
1228
|
+
}[];
|
|
1060
1229
|
variablesValues: ICalculatorVariablesValues;
|
|
1061
1230
|
}
|
|
1062
1231
|
interface ITypeCalculatorOutput {
|
|
1063
|
-
|
|
1232
|
+
types: Map<string, ESimpleDataType>;
|
|
1064
1233
|
}
|
|
1065
1234
|
interface ITypeCalculator extends ICalculator<ITypeCalculatorInput, ITypeCalculatorOutput> {
|
|
1066
1235
|
}
|
|
@@ -1077,7 +1246,7 @@ declare const replaceDisplayCondition: <I extends IWidgetColumnIndicator>(dimens
|
|
|
1077
1246
|
declare function mapMeasuresToInputs<T extends IWidgetMeasure>(measures: T[], variables: Map<string, TWidgetVariable>, addFormulas?: (measure: T) => Map<string, string>): ICalculatorMeasureInput[];
|
|
1078
1247
|
|
|
1079
1248
|
/** Конвертировать разрезы виджета во входы для вычислителя */
|
|
1080
|
-
declare function mapDimensionsToInputs(dimensions:
|
|
1249
|
+
declare function mapDimensionsToInputs<T extends IWidgetDimension>(dimensions: T[], variables: Map<string, TWidgetVariable>, addFormulas?: (dimension: T) => Map<string, string>): ICalculatorDimensionInput[];
|
|
1081
1250
|
|
|
1082
1251
|
/** Конвертировать процессные показатели виджета во входы для вычислителя */
|
|
1083
1252
|
declare function mapTransitionMeasuresToInputs<T extends IProcessIndicator>(indicators: T[], process: IWidgetProcess, variables: Map<string, TWidgetVariable>, addFormulas?: (indicator: T) => Map<string, string>): ICalculatorMeasureInput[];
|
|
@@ -1092,7 +1261,7 @@ declare function mapEventMeasuresToInputs<T extends IProcessIndicator>(indicator
|
|
|
1092
1261
|
* @param measuresInOriginalOrder меры виджета (конкретная мера будет браться по индексу)
|
|
1093
1262
|
* @returns
|
|
1094
1263
|
*/
|
|
1095
|
-
declare function mapSortingToInputs(sortingIndicators
|
|
1264
|
+
declare function mapSortingToInputs(sortingIndicators: IWidgetSortingIndicator[] | undefined, dimensionsInOriginalOrder: IWidgetDimension[] | undefined, measuresInOriginalOrder: IWidgetMeasure[] | undefined, variables: Map<string, TWidgetVariable>): ISortOrder[];
|
|
1096
1265
|
|
|
1097
1266
|
/**
|
|
1098
1267
|
* Выбрать активный разрез иерархии на основе активных фильтров.
|
|
@@ -1116,6 +1285,8 @@ declare function bindContentWithIndicator<Output extends ICalculatorIndicatorOut
|
|
|
1116
1285
|
*/
|
|
1117
1286
|
declare function bindContentsWithIndicators<Output extends ICalculatorIndicatorOutput, Indicator extends IWidgetIndicator>(outputs: Map<string, Output>, indicators: Indicator[]): TBoundedContentWithIndicator<Output, Indicator>[];
|
|
1118
1287
|
|
|
1288
|
+
declare const escapeSpecialCharacters: (formula: string) => string;
|
|
1289
|
+
|
|
1119
1290
|
interface ICalculatorFactory {
|
|
1120
1291
|
general: () => IGeneralCalculator;
|
|
1121
1292
|
pie: () => IPieCalculator;
|
|
@@ -1136,6 +1307,18 @@ interface IDefinition<WidgetSettings extends IBaseWidgetSettings, GroupSettings
|
|
|
1136
1307
|
getMeasures?(settings: WidgetSettings): IWidgetMeasure[];
|
|
1137
1308
|
}
|
|
1138
1309
|
|
|
1310
|
+
type TLaunchActionParams = {
|
|
1311
|
+
action: TActionsOnClick;
|
|
1312
|
+
onSuccess: () => void;
|
|
1313
|
+
filters: ICalculatorFilter[];
|
|
1314
|
+
needConfirmation?: boolean;
|
|
1315
|
+
};
|
|
1316
|
+
type TWidgetContainer = {
|
|
1317
|
+
/** Имеет ли контейнер виджета ограниченную максимальную высоту */
|
|
1318
|
+
isMaxHeightLimited: boolean;
|
|
1319
|
+
/** Установить минимальную высоту рабочей области виджета */
|
|
1320
|
+
setContentMinHeight(value: number): void;
|
|
1321
|
+
};
|
|
1139
1322
|
interface IWidgetProps<WidgetSettings extends IBaseWidgetSettings = IBaseWidgetSettings> {
|
|
1140
1323
|
/** guid виджета */
|
|
1141
1324
|
guid: string;
|
|
@@ -1158,17 +1341,10 @@ interface IWidgetProps<WidgetSettings extends IBaseWidgetSettings = IBaseWidgetS
|
|
|
1158
1341
|
placeholder: IWidgetPlaceholderController;
|
|
1159
1342
|
/** Контекст виджетов */
|
|
1160
1343
|
widgetsContext: IWidgetsContext;
|
|
1161
|
-
/** Вызывает модальное окно для запуска действия */
|
|
1162
|
-
launchAction(params: {
|
|
1163
|
-
action: IWidgetAction;
|
|
1164
|
-
onSuccess: () => void;
|
|
1165
|
-
filters: ICalculatorFilter[];
|
|
1166
|
-
}): void;
|
|
1167
1344
|
/** Данные о контейнере виджета */
|
|
1168
|
-
widgetContainer:
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
};
|
|
1345
|
+
widgetContainer: TWidgetContainer;
|
|
1346
|
+
/** Запуск действия */
|
|
1347
|
+
launchAction(params: TLaunchActionParams): void;
|
|
1172
1348
|
}
|
|
1173
1349
|
interface ICustomWidgetProps<WidgetSettings extends IBaseWidgetSettings = IBaseWidgetSettings> extends IWidgetProps<WidgetSettings> {
|
|
1174
1350
|
/** @deprecated - нужно использовать из widgetsContext */
|
|
@@ -1324,7 +1500,7 @@ declare const replaceFiltersBySelection: (filters: ICalculatorFilter[], selectio
|
|
|
1324
1500
|
* @param {P} [props] - Дополнительные параметры локализации.
|
|
1325
1501
|
* @returns {string} - Локализованный текст для указанного языка.
|
|
1326
1502
|
*/
|
|
1327
|
-
declare const getLocalizedText: <L extends TLocalizationDescription, P extends ILocalizationProps = TExtractLocalizationParams<L>>(language: ELanguages, locObj: L, props?: P
|
|
1503
|
+
declare const getLocalizedText: <L extends TLocalizationDescription, P extends ILocalizationProps = TExtractLocalizationParams<L>>(language: ELanguages, locObj: L, props?: P) => string;
|
|
1328
1504
|
|
|
1329
1505
|
type TDefineWidgetOptions = {
|
|
1330
1506
|
manifest?: Record<string, unknown>;
|
|
@@ -1340,4 +1516,4 @@ declare global {
|
|
|
1340
1516
|
}
|
|
1341
1517
|
}
|
|
1342
1518
|
|
|
1343
|
-
export { ECalculatorFilterMethods, EColorMode, EControlType, EDbType, EDimensionTemplateNames, EDisplayConditionMode, EDurationUnit, EEventMeasureTemplateNames, EFormatTypes, EFormattingPresets, EFormulaFilterFieldKeys, EIndicatorType, ELastTimeUnit, EMeasureTemplateNames, EProcessFilterNames, ESimpleDataType, ESortDirection, ESortingValueModes, ETransitionMeasureTemplateNames, EWidgetActionInputMode, EWidgetFilterMode, EWidgetIndicatorType, EWidgetIndicatorValueModes, type IActionScript, type IAddDurationOfTransitionFilter, type IAddPresenceOfEventFilter, type IAddPresenceOfTransitionFilter, type IAddRepetitionOfEventFilter, type IBaseDimensionsAndMeasuresCalculator, type IBaseDimensionsAndMeasuresCalculatorInput, type IBaseDimensionsAndMeasuresCalculatorOutput, type IBaseWidgetSettings, type ICalculator, type ICalculatorDimensionInput, type ICalculatorDimensionOutput, type ICalculatorFactory, type ICalculatorFilter, type ICalculatorIndicatorInput, type ICalculatorIndicatorOutput, type ICalculatorMeasureInput, type ICalculatorMeasureOutput, type ICalculatorVariable, type ICalculatorVariablesValues, type ICommonColumnIndicator, type IControlRecord, type ICustomAddButtonProps, type ICustomWidgetProps, type IDefinition, type IDimensionSelection, type IDimensionSelectionByFormula, type IDisplayPredicate, type IDivePanelDescription, type IDividerRecord, type IEdge, type IExportColumnOrder, type IFillSettings, type IFormulaFilterValue, type IGeneralCalculator, type IGeneralCalculatorExportInput, type IGeneralCalculatorInput, type IGeneralCalculatorOutput, type IGraphElement, type IGroupSetDescription, type IGroupSetRecord, type IGroupSettings, type IHistogramBin, type IHistogramCalculator, type IHistogramCalculatorInput, type IHistogramCalculatorOutput, type ILens, type IPanelDescription, type IPanelDescriptionCreator, type IPieCalculator, type IPieCalculatorInput, type IPieCalculatorOutput, type IProcessEventFilterValue, type IProcessEventIndicator, type IProcessGraphCalculator, type IProcessGraphCalculatorInput, type IProcessGraphCalculatorOutput, type IProcessIndicator, type IProcessTransitionFilterValue, type IProcessTransitionIndicator, type IRange, type ISelectOption, type ISortOrder, type ITwoLimitsCalculator, type ITwoLimitsCalculatorExportInput, type ITwoLimitsCalculatorInput, type ITwoLimitsCalculatorOutput, type ITypeCalculator, type ITypeCalculatorInput, type ITypeCalculatorOutput, type IVertex, type IWidget, type
|
|
1519
|
+
export { EActionTypes, ECalculatorFilterMethods, EColorMode, EColorScope, EControlType, EDbType, EDimensionTemplateNames, EDisplayConditionMode, EDrawerPlacement, EDurationUnit, EEventMeasureTemplateNames, EFormatTypes, EFormattingPresets, EFormulaFilterFieldKeys, EIndicatorType, ELastTimeUnit, EMarkdownDisplayMode, EMeasureTemplateNames, EOpenViewMode, EProcessFilterNames, ESimpleDataType, ESortDirection, ESortingValueModes, ETransitionMeasureTemplateNames, EViewType, EWidgetActionInputMode, EWidgetFilterMode, EWidgetIndicatorType, EWidgetIndicatorValueModes, type IActionCommon, type IActionGoToUrl, type IActionOpenView, type IActionRunScript, type IActionScript, type IActionScriptField, type IActionUpdateVariable, type IAddDurationOfTransitionFilter, type IAddPresenceOfEventFilter, type IAddPresenceOfTransitionFilter, type IAddRepetitionOfEventFilter, type IBaseDimensionsAndMeasuresCalculator, type IBaseDimensionsAndMeasuresCalculatorInput, type IBaseDimensionsAndMeasuresCalculatorOutput, type IBaseWidgetSettings, type ICalculator, type ICalculatorDimensionInput, type ICalculatorDimensionOutput, type ICalculatorFactory, type ICalculatorFilter, type ICalculatorIndicatorInput, type ICalculatorIndicatorOutput, type ICalculatorMeasureInput, type ICalculatorMeasureOutput, type ICalculatorVariable, type ICalculatorVariablesValues, type IColoredValue, type ICommonColumnIndicator, type IControlRecord, type ICustomAddButtonProps, type ICustomWidgetProps, type IDefinition, type IDimensionSelection, type IDimensionSelectionByFormula, type IDisplayPredicate, type IDisplayRule, type IDivePanelDescription, type IDividerRecord, type IEdge, type IExportColumnOrder, type IFillSettings, type IFormulaFilterValue, type IGeneralCalculator, type IGeneralCalculatorExportInput, type IGeneralCalculatorInput, type IGeneralCalculatorOutput, type IGraphElement, type IGroupSetDescription, type IGroupSetRecord, type IGroupSettings, type IHistogramBin, type IHistogramCalculator, type IHistogramCalculatorInput, type IHistogramCalculatorOutput, type ILens, type IMarkdownMeasure, type IMeasureMenuConfig, type IPanelDescription, type IPanelDescriptionCreator, type IPieCalculator, type IPieCalculatorInput, type IPieCalculatorOutput, type IProcessEventFilterValue, type IProcessEventIndicator, type IProcessGraphCalculator, type IProcessGraphCalculatorInput, type IProcessGraphCalculatorOutput, type IProcessIndicator, type IProcessTransitionFilterValue, type IProcessTransitionIndicator, type IRange, type ISelectOption, type ISortOrder, type ISortingMenuConfig, type IStagesFilterValue, type ITwoLimitsCalculator, type ITwoLimitsCalculatorExportInput, type ITwoLimitsCalculatorInput, type ITwoLimitsCalculatorOutput, type ITypeCalculator, type ITypeCalculatorInput, type ITypeCalculatorOutput, type IVertex, type IWidget, type IWidgetActionInput, type IWidgetColumnIndicator, type IWidgetDimension, type IWidgetDimensionHierarchy, type IWidgetEntity, type IWidgetFilter, type IWidgetFiltration, type IWidgetFormatting, type IWidgetFormulaFilterValue, type IWidgetIndicator, type IWidgetIndicatorMenuConfig, type IWidgetMeasure, type IWidgetPlaceholderController, type IWidgetProcess, type IWidgetProps, type IWidgetSortingIndicator, type IWidgetTable, type IWidgetTableColumn, type IWidgetsContext, type TActionsOnClick, type TBoundedContentWithIndicator, type TColor, type TColorRule, type TColumnIndicatorValue, type TDefineWidgetOptions, type TDisplayCondition, type TDisplayMode, type TEmptyRecord, type TFiltrationMode, type TGroupLevelRecord, type TLaunchActionParams, type TProcessIndicatorValue, type TRecordAccessor, type TSelectivePartial, type TSortDirection, type TUpdateSelection, type TValuePath, type TWidgetActionInputValue, type TWidgetContainer, type TWidgetFilterValue, type TWidgetFiltering, type TWidgetLevelRecord, type TWidgetSortingValue, type TWidgetSortingValueRelatedWidgetDimension, type TWidgetSortingValueRelatedWidgetIndicator, type TWidgetSortingValueRelatedWidgetMeasure, type TWidgetVariable, bindContentWithIndicator, bindContentsWithIndicators, checkDisplayCondition, dimensionTemplateFormulas, escapeSpecialCharacters, eventMeasureTemplateFormulas, fillTemplateString, formulaFilterMethods, generateColumnFormula, getDimensionFormula, getDisplayConditionFormula, getEventMeasureFormula, getLocalizedText, getMeasureFormula, getTransitionMeasureFormula, isActionValid, isHierarchy, mapDimensionsToInputs, mapEventMeasuresToInputs, mapFormulaFilterToCalculatorInput, mapFormulaFiltersToInputs, mapMeasuresToInputs, mapSortingToInputs, mapTransitionMeasuresToInputs, mapVariablesToInputs, measureTemplateFormulas, prepareValuesForSql, replaceDisplayCondition, replaceFiltersBySelection, replaceHierarchiesWithDimensions, selectDimensionFromHierarchy, transitionMeasureTemplateFormulas, updateDefaultModeSelection, updateMultiModeSelection, updateSingleModeSelection };
|
package/dist/index.esm.js
CHANGED
|
@@ -71,24 +71,51 @@ var EWidgetActionInputMode;
|
|
|
71
71
|
EWidgetActionInputMode["FORMULA"] = "FORMULA";
|
|
72
72
|
EWidgetActionInputMode["MANUALLY"] = "MANUALLY";
|
|
73
73
|
})(EWidgetActionInputMode || (EWidgetActionInputMode = {}));
|
|
74
|
+
var EActionTypes;
|
|
75
|
+
(function (EActionTypes) {
|
|
76
|
+
EActionTypes["URL"] = "URL";
|
|
77
|
+
EActionTypes["UPDATE_VARIABLE"] = "UPDATE_VARIABLE";
|
|
78
|
+
EActionTypes["RUN_SCRIPT"] = "RUN_SCRIPT";
|
|
79
|
+
EActionTypes["OPEN_VIEW"] = "OPEN_VIEW";
|
|
80
|
+
})(EActionTypes || (EActionTypes = {}));
|
|
81
|
+
var EViewType;
|
|
82
|
+
(function (EViewType) {
|
|
83
|
+
EViewType["CREATED_VIEW"] = "CREATED_VIEW";
|
|
84
|
+
EViewType["GENERATED_BY_SCRIPT"] = "GENERATED_BY_SCRIPT";
|
|
85
|
+
})(EViewType || (EViewType = {}));
|
|
86
|
+
var EOpenViewMode;
|
|
87
|
+
(function (EOpenViewMode) {
|
|
88
|
+
EOpenViewMode["NEW_WINDOW"] = "NEW_WINDOW";
|
|
89
|
+
EOpenViewMode["PLACEHOLDER"] = "PLACEHOLDER";
|
|
90
|
+
EOpenViewMode["MODAL"] = "MODAL";
|
|
91
|
+
EOpenViewMode["DRAWER"] = "DRAWER";
|
|
92
|
+
})(EOpenViewMode || (EOpenViewMode = {}));
|
|
93
|
+
var EDrawerPlacement;
|
|
94
|
+
(function (EDrawerPlacement) {
|
|
95
|
+
EDrawerPlacement["LEFT"] = "LEFT";
|
|
96
|
+
EDrawerPlacement["RIGHT"] = "RIGHT";
|
|
97
|
+
})(EDrawerPlacement || (EDrawerPlacement = {}));
|
|
74
98
|
var isActionValid = function (action, _a) {
|
|
75
99
|
var _b;
|
|
76
|
-
var scripts = _a.scripts, tables = _a.tables;
|
|
77
|
-
|
|
100
|
+
var scripts = _a.scripts, tables = _a.tables, variables = _a.variables;
|
|
101
|
+
if (action.type !== EActionTypes.RUN_SCRIPT) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
var currentScript = scripts.get((_b = action.scriptName) !== null && _b !== void 0 ? _b : "");
|
|
78
105
|
if (!currentScript) {
|
|
79
106
|
return false;
|
|
80
107
|
}
|
|
81
|
-
var actionInputsMap = new Map(action.inputs.map(function (input) { return [input.
|
|
82
|
-
if (actionInputsMap.size < currentScript.
|
|
108
|
+
var actionInputsMap = new Map(action.inputs.map(function (input) { return [input.name, input]; }));
|
|
109
|
+
if (actionInputsMap.size < currentScript.fieldsNames.size) {
|
|
83
110
|
return false;
|
|
84
111
|
}
|
|
85
|
-
return __spreadArray([], __read(currentScript.
|
|
86
|
-
var actionInput = actionInputsMap.get(
|
|
112
|
+
return __spreadArray([], __read(currentScript.fieldsNames), false).every(function (name) {
|
|
113
|
+
var actionInput = actionInputsMap.get(name !== null && name !== void 0 ? name : "");
|
|
87
114
|
if (!actionInput) {
|
|
88
115
|
return false;
|
|
89
116
|
}
|
|
90
117
|
var value = actionInput.value;
|
|
91
|
-
if (value.mode === EWidgetActionInputMode.FROM_VARIABLE && !value.
|
|
118
|
+
if (value.mode === EWidgetActionInputMode.FROM_VARIABLE && !variables.has(value.name)) {
|
|
92
119
|
return false;
|
|
93
120
|
}
|
|
94
121
|
if (value.mode === EWidgetActionInputMode.FORMULA && !value.formula) {
|
|
@@ -97,8 +124,7 @@ var isActionValid = function (action, _a) {
|
|
|
97
124
|
if (value.mode === EWidgetActionInputMode.DYNAMIC_LIST && !value.formula) {
|
|
98
125
|
return false;
|
|
99
126
|
}
|
|
100
|
-
if (value.mode === EWidgetActionInputMode.FROM_COLUMN &&
|
|
101
|
-
!tables.has(value.tableName)) {
|
|
127
|
+
if (value.mode === EWidgetActionInputMode.FROM_COLUMN && !tables.has(value.tableName)) {
|
|
102
128
|
return false;
|
|
103
129
|
}
|
|
104
130
|
return true;
|
|
@@ -123,9 +149,7 @@ var prepareValuesForSql = function (dataType, values) {
|
|
|
123
149
|
dataType === ESimpleDataType.BOOLEAN
|
|
124
150
|
? values
|
|
125
151
|
: values.map(function (value) {
|
|
126
|
-
return value === null
|
|
127
|
-
? null
|
|
128
|
-
: "'".concat(escapeSingularQuotes(escapeReverseSlash(value)), "'");
|
|
152
|
+
return value === null ? null : "'".concat(escapeSingularQuotes(escapeReverseSlash(value)), "'");
|
|
129
153
|
});
|
|
130
154
|
};
|
|
131
155
|
var escapeReverseSlash = function (formula) {
|
|
@@ -136,7 +160,9 @@ var escapeSingularQuotes = function (formula) {
|
|
|
136
160
|
};
|
|
137
161
|
|
|
138
162
|
var compact = function (items) { return ((items === null || items === void 0 ? void 0 : items.filter(Boolean)) || []); };
|
|
139
|
-
var compactMap = function (items, f) {
|
|
163
|
+
var compactMap = function (items, f) {
|
|
164
|
+
return compact(items === null || items === void 0 ? void 0 : items.map(f));
|
|
165
|
+
};
|
|
140
166
|
var isNil = function (value) {
|
|
141
167
|
return value === null || value === undefined;
|
|
142
168
|
};
|
|
@@ -476,11 +502,25 @@ var EWidgetFilterMode;
|
|
|
476
502
|
})(EWidgetFilterMode || (EWidgetFilterMode = {}));
|
|
477
503
|
var EColorMode;
|
|
478
504
|
(function (EColorMode) {
|
|
505
|
+
EColorMode["DISABLED"] = "DISABLED";
|
|
479
506
|
EColorMode["FORMULA"] = "FORMULA";
|
|
480
507
|
EColorMode["BASE"] = "BASE";
|
|
481
508
|
EColorMode["GRADIENT"] = "GRADIENT";
|
|
482
509
|
EColorMode["AUTO"] = "AUTO";
|
|
510
|
+
EColorMode["RULE"] = "RULE";
|
|
511
|
+
EColorMode["VALUES"] = "VALUES";
|
|
512
|
+
EColorMode["BY_DIMENSION"] = "BY_DIMENSION";
|
|
483
513
|
})(EColorMode || (EColorMode = {}));
|
|
514
|
+
var EColorScope;
|
|
515
|
+
(function (EColorScope) {
|
|
516
|
+
EColorScope["WORKSPACE"] = "WORKSPACE";
|
|
517
|
+
EColorScope["DASHBOARD"] = "DASHBOARD";
|
|
518
|
+
})(EColorScope || (EColorScope = {}));
|
|
519
|
+
var EMarkdownDisplayMode;
|
|
520
|
+
(function (EMarkdownDisplayMode) {
|
|
521
|
+
EMarkdownDisplayMode["NONE"] = "NONE";
|
|
522
|
+
EMarkdownDisplayMode["INDICATOR"] = "INDICATOR";
|
|
523
|
+
})(EMarkdownDisplayMode || (EMarkdownDisplayMode = {}));
|
|
484
524
|
var EDisplayConditionMode;
|
|
485
525
|
(function (EDisplayConditionMode) {
|
|
486
526
|
EDisplayConditionMode["DISABLED"] = "DISABLED";
|
|
@@ -491,8 +531,8 @@ var EDisplayConditionMode;
|
|
|
491
531
|
function checkDisplayCondition(displayCondition, variables) {
|
|
492
532
|
var _a;
|
|
493
533
|
if ((displayCondition === null || displayCondition === void 0 ? void 0 : displayCondition.mode) === EDisplayConditionMode.VARIABLE) {
|
|
494
|
-
var
|
|
495
|
-
var currentVariableValue =
|
|
534
|
+
var variableName = displayCondition.variableName, variableValue = displayCondition.variableValue;
|
|
535
|
+
var currentVariableValue = variableName && ((_a = variables.get(variableName)) === null || _a === void 0 ? void 0 : _a.value);
|
|
496
536
|
var isCurrentVariableMatch = Array.isArray(currentVariableValue)
|
|
497
537
|
? !!variableValue && (currentVariableValue === null || currentVariableValue === void 0 ? void 0 : currentVariableValue.includes(variableValue))
|
|
498
538
|
: currentVariableValue === variableValue;
|
|
@@ -508,13 +548,20 @@ function getDisplayConditionFormula(displayCondition) {
|
|
|
508
548
|
}
|
|
509
549
|
}
|
|
510
550
|
var replaceDisplayCondition = function (dimension, displayCondition) {
|
|
511
|
-
return isNil(displayCondition)
|
|
512
|
-
|
|
513
|
-
|
|
551
|
+
return isNil(displayCondition) ? dimension : __assign(__assign({}, dimension), { displayCondition: displayCondition });
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
var escapeSpecialCharacters = function (formula) {
|
|
555
|
+
return formula
|
|
556
|
+
.replaceAll("\\", "\\\\")
|
|
557
|
+
.replaceAll('"', '\\"')
|
|
558
|
+
.replaceAll("`", "\\`");
|
|
514
559
|
};
|
|
515
560
|
|
|
516
561
|
function generateColumnFormula(tableName, columnName) {
|
|
517
|
-
|
|
562
|
+
var preparedTableName = escapeSpecialCharacters(tableName);
|
|
563
|
+
var preparedColumnName = escapeSpecialCharacters(columnName);
|
|
564
|
+
return "\"".concat(preparedTableName, "\".\"").concat(preparedColumnName, "\"");
|
|
518
565
|
}
|
|
519
566
|
function fillTemplateString(templateString, params) {
|
|
520
567
|
return templateString.replace(/\{(.*?)\}/g, function (_, key) { var _a; return (_a = params[key]) !== null && _a !== void 0 ? _a : ""; });
|
|
@@ -738,18 +785,18 @@ function mapMeasureToInput(measure, variables, addFormulas) {
|
|
|
738
785
|
return {
|
|
739
786
|
alias: String(measure.id),
|
|
740
787
|
mainFormula: mainFormula,
|
|
788
|
+
dataType: measure.dataType,
|
|
741
789
|
displayConditionFormula: getDisplayConditionFormula(measure.displayCondition),
|
|
742
790
|
additionalFormulas: addFormulas(measure),
|
|
743
791
|
};
|
|
744
792
|
}
|
|
745
793
|
/** Конвертировать меры виджета во входы для вычислителя */
|
|
746
794
|
function mapMeasuresToInputs(measures, variables, addFormulas) {
|
|
747
|
-
return compactMap(measures, function (measure) {
|
|
748
|
-
return mapMeasureToInput(measure, variables, addFormulas);
|
|
749
|
-
});
|
|
795
|
+
return compactMap(measures, function (measure) { return mapMeasureToInput(measure, variables, addFormulas); });
|
|
750
796
|
}
|
|
751
797
|
|
|
752
|
-
function mapDimensionToInput(dimension, variables) {
|
|
798
|
+
function mapDimensionToInput(dimension, variables, addFormulas) {
|
|
799
|
+
if (addFormulas === void 0) { addFormulas = function () { return new Map(); }; }
|
|
753
800
|
var formula = getDimensionFormula(dimension);
|
|
754
801
|
if (!formula) {
|
|
755
802
|
return null;
|
|
@@ -760,14 +807,16 @@ function mapDimensionToInput(dimension, variables) {
|
|
|
760
807
|
return {
|
|
761
808
|
alias: String(dimension.id),
|
|
762
809
|
formula: formula,
|
|
810
|
+
dataType: dimension.dataType,
|
|
763
811
|
hideEmpty: dimension.hideEmptyValues,
|
|
764
812
|
displayConditionFormula: getDisplayConditionFormula(dimension.displayCondition),
|
|
813
|
+
additionalFormulas: addFormulas(dimension),
|
|
765
814
|
};
|
|
766
815
|
}
|
|
767
816
|
/** Конвертировать разрезы виджета во входы для вычислителя */
|
|
768
|
-
function mapDimensionsToInputs(dimensions, variables) {
|
|
817
|
+
function mapDimensionsToInputs(dimensions, variables, addFormulas) {
|
|
769
818
|
return compactMap(dimensions, function (dimension) {
|
|
770
|
-
return mapDimensionToInput(dimension, variables);
|
|
819
|
+
return mapDimensionToInput(dimension, variables, addFormulas);
|
|
771
820
|
});
|
|
772
821
|
}
|
|
773
822
|
|
|
@@ -783,6 +832,7 @@ function mapTransitionMeasureToInput(indicator, process, variables, addFormulas)
|
|
|
783
832
|
return {
|
|
784
833
|
alias: String(indicator.id),
|
|
785
834
|
mainFormula: mainFormula,
|
|
835
|
+
dataType: indicator.dataType,
|
|
786
836
|
displayConditionFormula: getDisplayConditionFormula(indicator.displayCondition),
|
|
787
837
|
additionalFormulas: addFormulas(indicator),
|
|
788
838
|
};
|
|
@@ -806,6 +856,7 @@ function mapEventMeasureToInput(indicator, process, variables, addFormulas) {
|
|
|
806
856
|
return {
|
|
807
857
|
alias: String(indicator.id),
|
|
808
858
|
mainFormula: mainFormula,
|
|
859
|
+
dataType: indicator.dataType,
|
|
809
860
|
displayConditionFormula: getDisplayConditionFormula(indicator.displayCondition),
|
|
810
861
|
additionalFormulas: addFormulas(indicator),
|
|
811
862
|
};
|
|
@@ -824,11 +875,12 @@ function mapEventMeasuresToInputs(indicators, process, variables, addFormulas) {
|
|
|
824
875
|
* @param measuresInOriginalOrder меры виджета (конкретная мера будет браться по индексу)
|
|
825
876
|
* @returns
|
|
826
877
|
*/
|
|
827
|
-
function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measuresInOriginalOrder) {
|
|
878
|
+
function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measuresInOriginalOrder, variables) {
|
|
828
879
|
if (sortingIndicators === void 0) { sortingIndicators = []; }
|
|
829
880
|
if (dimensionsInOriginalOrder === void 0) { dimensionsInOriginalOrder = []; }
|
|
830
881
|
if (measuresInOriginalOrder === void 0) { measuresInOriginalOrder = []; }
|
|
831
882
|
return compactMap(sortingIndicators, function (_a) {
|
|
883
|
+
var _b;
|
|
832
884
|
var value = _a.value, direction = _a.direction;
|
|
833
885
|
if (value.mode === ESortingValueModes.FORMULA ||
|
|
834
886
|
value.mode === ESortingValueModes.QUANTITY ||
|
|
@@ -839,7 +891,20 @@ function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measur
|
|
|
839
891
|
if (value.mode === ESortingValueModes.DIMENSION_IN_WIDGET ||
|
|
840
892
|
value.mode === ESortingValueModes.HIERARCHY) {
|
|
841
893
|
var dimension = dimensionsInOriginalOrder[value.index];
|
|
842
|
-
|
|
894
|
+
if (!dimension) {
|
|
895
|
+
return;
|
|
896
|
+
}
|
|
897
|
+
var formula = getDimensionFormula(dimension);
|
|
898
|
+
if (!formula || !checkDisplayCondition(dimension.displayCondition, variables)) {
|
|
899
|
+
return;
|
|
900
|
+
}
|
|
901
|
+
return {
|
|
902
|
+
formula: getDimensionFormula(dimension),
|
|
903
|
+
direction: direction,
|
|
904
|
+
displayCondition: ((_b = dimension.displayCondition) === null || _b === void 0 ? void 0 : _b.mode) === EDisplayConditionMode.FORMULA
|
|
905
|
+
? dimension.displayCondition.formula
|
|
906
|
+
: undefined,
|
|
907
|
+
};
|
|
843
908
|
}
|
|
844
909
|
if (value.mode === ESortingValueModes.MEASURE_IN_WIDGET) {
|
|
845
910
|
var measure = measuresInOriginalOrder[value.index];
|
|
@@ -867,9 +932,7 @@ function selectDimensionFromHierarchy(_a, filters) {
|
|
|
867
932
|
if (!matchedFilter) {
|
|
868
933
|
return "continue";
|
|
869
934
|
}
|
|
870
|
-
var selectionIndex = matchedFilter.values.length > 1
|
|
871
|
-
? i
|
|
872
|
-
: Math.min(i + 1, dimensions.length - 1);
|
|
935
|
+
var selectionIndex = matchedFilter.values.length > 1 ? i : Math.min(i + 1, dimensions.length - 1);
|
|
873
936
|
return { value: dimensions[selectionIndex] };
|
|
874
937
|
};
|
|
875
938
|
for (var i = dimensions.length - 1; i >= 0; i--) {
|
|
@@ -884,8 +947,7 @@ var replaceHierarchiesWithDimensions = function (dimensions, filters) {
|
|
|
884
947
|
return compactMap(dimensions, function (indicator) {
|
|
885
948
|
if (isHierarchy(indicator)) {
|
|
886
949
|
var selectedDimension = selectDimensionFromHierarchy(indicator, filters);
|
|
887
|
-
return (selectedDimension &&
|
|
888
|
-
replaceDisplayCondition(selectedDimension, indicator.displayCondition));
|
|
950
|
+
return (selectedDimension && replaceDisplayCondition(selectedDimension, indicator.displayCondition));
|
|
889
951
|
}
|
|
890
952
|
return indicator;
|
|
891
953
|
});
|
|
@@ -902,9 +964,7 @@ function bindContentWithIndicator(outputs, indicator) {
|
|
|
902
964
|
* Массив объектов, каждый из которых содержит показатель и его контент
|
|
903
965
|
*/
|
|
904
966
|
function bindContentsWithIndicators(outputs, indicators) {
|
|
905
|
-
return compactMap(indicators, function (indicator) {
|
|
906
|
-
return bindContentWithIndicator(outputs, indicator);
|
|
907
|
-
});
|
|
967
|
+
return compactMap(indicators, function (indicator) { return bindContentWithIndicator(outputs, indicator); });
|
|
908
968
|
}
|
|
909
969
|
|
|
910
970
|
var EControlType;
|
|
@@ -926,6 +986,8 @@ var EControlType;
|
|
|
926
986
|
EControlType["eventsColor"] = "eventsColor";
|
|
927
987
|
EControlType["inputMarkdown"] = "inputMarkdown";
|
|
928
988
|
EControlType["filter"] = "filter";
|
|
989
|
+
EControlType["actionOnClick"] = "actionOnClick";
|
|
990
|
+
EControlType["eventsPicker"] = "eventsPicker";
|
|
929
991
|
})(EControlType || (EControlType = {}));
|
|
930
992
|
|
|
931
993
|
var ESortDirection;
|
|
@@ -1030,4 +1092,4 @@ var getLocalizedText = function (language, locObj, props) {
|
|
|
1030
1092
|
return localization.getLocalized(locObj, props);
|
|
1031
1093
|
};
|
|
1032
1094
|
|
|
1033
|
-
export { ECalculatorFilterMethods, EColorMode, EControlType, EDbType, EDimensionTemplateNames, EDisplayConditionMode, EDurationUnit, EEventMeasureTemplateNames, EFormatTypes, EFormattingPresets, EFormulaFilterFieldKeys, EIndicatorType, ELastTimeUnit, EMeasureTemplateNames, EProcessFilterNames, ESimpleDataType, ESortDirection, ESortingValueModes, ETransitionMeasureTemplateNames, EWidgetActionInputMode, EWidgetFilterMode, EWidgetIndicatorType, EWidgetIndicatorValueModes, bindContentWithIndicator, bindContentsWithIndicators, checkDisplayCondition, dimensionTemplateFormulas, eventMeasureTemplateFormulas, fillTemplateString, formulaFilterMethods, generateColumnFormula, getDimensionFormula, getDisplayConditionFormula, getEventMeasureFormula, getLocalizedText, getMeasureFormula, getTransitionMeasureFormula, isActionValid, isHierarchy, mapDimensionsToInputs, mapEventMeasuresToInputs, mapFormulaFilterToCalculatorInput, mapFormulaFiltersToInputs, mapMeasuresToInputs, mapSortingToInputs, mapTransitionMeasuresToInputs, mapVariablesToInputs, measureTemplateFormulas, prepareValuesForSql, replaceDisplayCondition, replaceFiltersBySelection, replaceHierarchiesWithDimensions, selectDimensionFromHierarchy, transitionMeasureTemplateFormulas, updateDefaultModeSelection, updateMultiModeSelection, updateSingleModeSelection };
|
|
1095
|
+
export { EActionTypes, ECalculatorFilterMethods, EColorMode, EColorScope, EControlType, EDbType, EDimensionTemplateNames, EDisplayConditionMode, EDrawerPlacement, EDurationUnit, EEventMeasureTemplateNames, EFormatTypes, EFormattingPresets, EFormulaFilterFieldKeys, EIndicatorType, ELastTimeUnit, EMarkdownDisplayMode, EMeasureTemplateNames, EOpenViewMode, EProcessFilterNames, ESimpleDataType, ESortDirection, ESortingValueModes, ETransitionMeasureTemplateNames, EViewType, EWidgetActionInputMode, EWidgetFilterMode, EWidgetIndicatorType, EWidgetIndicatorValueModes, bindContentWithIndicator, bindContentsWithIndicators, checkDisplayCondition, dimensionTemplateFormulas, escapeSpecialCharacters, eventMeasureTemplateFormulas, fillTemplateString, formulaFilterMethods, generateColumnFormula, getDimensionFormula, getDisplayConditionFormula, getEventMeasureFormula, getLocalizedText, getMeasureFormula, getTransitionMeasureFormula, isActionValid, isHierarchy, mapDimensionsToInputs, mapEventMeasuresToInputs, mapFormulaFilterToCalculatorInput, mapFormulaFiltersToInputs, mapMeasuresToInputs, mapSortingToInputs, mapTransitionMeasuresToInputs, mapVariablesToInputs, measureTemplateFormulas, prepareValuesForSql, replaceDisplayCondition, replaceFiltersBySelection, replaceHierarchiesWithDimensions, selectDimensionFromHierarchy, transitionMeasureTemplateFormulas, updateDefaultModeSelection, updateMultiModeSelection, updateSingleModeSelection };
|
package/dist/index.js
CHANGED
|
@@ -72,24 +72,51 @@ exports.EWidgetActionInputMode = void 0;
|
|
|
72
72
|
EWidgetActionInputMode["FORMULA"] = "FORMULA";
|
|
73
73
|
EWidgetActionInputMode["MANUALLY"] = "MANUALLY";
|
|
74
74
|
})(exports.EWidgetActionInputMode || (exports.EWidgetActionInputMode = {}));
|
|
75
|
+
exports.EActionTypes = void 0;
|
|
76
|
+
(function (EActionTypes) {
|
|
77
|
+
EActionTypes["URL"] = "URL";
|
|
78
|
+
EActionTypes["UPDATE_VARIABLE"] = "UPDATE_VARIABLE";
|
|
79
|
+
EActionTypes["RUN_SCRIPT"] = "RUN_SCRIPT";
|
|
80
|
+
EActionTypes["OPEN_VIEW"] = "OPEN_VIEW";
|
|
81
|
+
})(exports.EActionTypes || (exports.EActionTypes = {}));
|
|
82
|
+
exports.EViewType = void 0;
|
|
83
|
+
(function (EViewType) {
|
|
84
|
+
EViewType["CREATED_VIEW"] = "CREATED_VIEW";
|
|
85
|
+
EViewType["GENERATED_BY_SCRIPT"] = "GENERATED_BY_SCRIPT";
|
|
86
|
+
})(exports.EViewType || (exports.EViewType = {}));
|
|
87
|
+
exports.EOpenViewMode = void 0;
|
|
88
|
+
(function (EOpenViewMode) {
|
|
89
|
+
EOpenViewMode["NEW_WINDOW"] = "NEW_WINDOW";
|
|
90
|
+
EOpenViewMode["PLACEHOLDER"] = "PLACEHOLDER";
|
|
91
|
+
EOpenViewMode["MODAL"] = "MODAL";
|
|
92
|
+
EOpenViewMode["DRAWER"] = "DRAWER";
|
|
93
|
+
})(exports.EOpenViewMode || (exports.EOpenViewMode = {}));
|
|
94
|
+
exports.EDrawerPlacement = void 0;
|
|
95
|
+
(function (EDrawerPlacement) {
|
|
96
|
+
EDrawerPlacement["LEFT"] = "LEFT";
|
|
97
|
+
EDrawerPlacement["RIGHT"] = "RIGHT";
|
|
98
|
+
})(exports.EDrawerPlacement || (exports.EDrawerPlacement = {}));
|
|
75
99
|
var isActionValid = function (action, _a) {
|
|
76
100
|
var _b;
|
|
77
|
-
var scripts = _a.scripts, tables = _a.tables;
|
|
78
|
-
|
|
101
|
+
var scripts = _a.scripts, tables = _a.tables, variables = _a.variables;
|
|
102
|
+
if (action.type !== exports.EActionTypes.RUN_SCRIPT) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
var currentScript = scripts.get((_b = action.scriptName) !== null && _b !== void 0 ? _b : "");
|
|
79
106
|
if (!currentScript) {
|
|
80
107
|
return false;
|
|
81
108
|
}
|
|
82
|
-
var actionInputsMap = new Map(action.inputs.map(function (input) { return [input.
|
|
83
|
-
if (actionInputsMap.size < currentScript.
|
|
109
|
+
var actionInputsMap = new Map(action.inputs.map(function (input) { return [input.name, input]; }));
|
|
110
|
+
if (actionInputsMap.size < currentScript.fieldsNames.size) {
|
|
84
111
|
return false;
|
|
85
112
|
}
|
|
86
|
-
return __spreadArray([], __read(currentScript.
|
|
87
|
-
var actionInput = actionInputsMap.get(
|
|
113
|
+
return __spreadArray([], __read(currentScript.fieldsNames), false).every(function (name) {
|
|
114
|
+
var actionInput = actionInputsMap.get(name !== null && name !== void 0 ? name : "");
|
|
88
115
|
if (!actionInput) {
|
|
89
116
|
return false;
|
|
90
117
|
}
|
|
91
118
|
var value = actionInput.value;
|
|
92
|
-
if (value.mode === exports.EWidgetActionInputMode.FROM_VARIABLE && !value.
|
|
119
|
+
if (value.mode === exports.EWidgetActionInputMode.FROM_VARIABLE && !variables.has(value.name)) {
|
|
93
120
|
return false;
|
|
94
121
|
}
|
|
95
122
|
if (value.mode === exports.EWidgetActionInputMode.FORMULA && !value.formula) {
|
|
@@ -98,8 +125,7 @@ var isActionValid = function (action, _a) {
|
|
|
98
125
|
if (value.mode === exports.EWidgetActionInputMode.DYNAMIC_LIST && !value.formula) {
|
|
99
126
|
return false;
|
|
100
127
|
}
|
|
101
|
-
if (value.mode === exports.EWidgetActionInputMode.FROM_COLUMN &&
|
|
102
|
-
!tables.has(value.tableName)) {
|
|
128
|
+
if (value.mode === exports.EWidgetActionInputMode.FROM_COLUMN && !tables.has(value.tableName)) {
|
|
103
129
|
return false;
|
|
104
130
|
}
|
|
105
131
|
return true;
|
|
@@ -124,9 +150,7 @@ var prepareValuesForSql = function (dataType, values) {
|
|
|
124
150
|
dataType === exports.ESimpleDataType.BOOLEAN
|
|
125
151
|
? values
|
|
126
152
|
: values.map(function (value) {
|
|
127
|
-
return value === null
|
|
128
|
-
? null
|
|
129
|
-
: "'".concat(escapeSingularQuotes(escapeReverseSlash(value)), "'");
|
|
153
|
+
return value === null ? null : "'".concat(escapeSingularQuotes(escapeReverseSlash(value)), "'");
|
|
130
154
|
});
|
|
131
155
|
};
|
|
132
156
|
var escapeReverseSlash = function (formula) {
|
|
@@ -137,7 +161,9 @@ var escapeSingularQuotes = function (formula) {
|
|
|
137
161
|
};
|
|
138
162
|
|
|
139
163
|
var compact = function (items) { return ((items === null || items === void 0 ? void 0 : items.filter(Boolean)) || []); };
|
|
140
|
-
var compactMap = function (items, f) {
|
|
164
|
+
var compactMap = function (items, f) {
|
|
165
|
+
return compact(items === null || items === void 0 ? void 0 : items.map(f));
|
|
166
|
+
};
|
|
141
167
|
var isNil = function (value) {
|
|
142
168
|
return value === null || value === undefined;
|
|
143
169
|
};
|
|
@@ -477,11 +503,25 @@ exports.EWidgetFilterMode = void 0;
|
|
|
477
503
|
})(exports.EWidgetFilterMode || (exports.EWidgetFilterMode = {}));
|
|
478
504
|
exports.EColorMode = void 0;
|
|
479
505
|
(function (EColorMode) {
|
|
506
|
+
EColorMode["DISABLED"] = "DISABLED";
|
|
480
507
|
EColorMode["FORMULA"] = "FORMULA";
|
|
481
508
|
EColorMode["BASE"] = "BASE";
|
|
482
509
|
EColorMode["GRADIENT"] = "GRADIENT";
|
|
483
510
|
EColorMode["AUTO"] = "AUTO";
|
|
511
|
+
EColorMode["RULE"] = "RULE";
|
|
512
|
+
EColorMode["VALUES"] = "VALUES";
|
|
513
|
+
EColorMode["BY_DIMENSION"] = "BY_DIMENSION";
|
|
484
514
|
})(exports.EColorMode || (exports.EColorMode = {}));
|
|
515
|
+
exports.EColorScope = void 0;
|
|
516
|
+
(function (EColorScope) {
|
|
517
|
+
EColorScope["WORKSPACE"] = "WORKSPACE";
|
|
518
|
+
EColorScope["DASHBOARD"] = "DASHBOARD";
|
|
519
|
+
})(exports.EColorScope || (exports.EColorScope = {}));
|
|
520
|
+
exports.EMarkdownDisplayMode = void 0;
|
|
521
|
+
(function (EMarkdownDisplayMode) {
|
|
522
|
+
EMarkdownDisplayMode["NONE"] = "NONE";
|
|
523
|
+
EMarkdownDisplayMode["INDICATOR"] = "INDICATOR";
|
|
524
|
+
})(exports.EMarkdownDisplayMode || (exports.EMarkdownDisplayMode = {}));
|
|
485
525
|
exports.EDisplayConditionMode = void 0;
|
|
486
526
|
(function (EDisplayConditionMode) {
|
|
487
527
|
EDisplayConditionMode["DISABLED"] = "DISABLED";
|
|
@@ -492,8 +532,8 @@ exports.EDisplayConditionMode = void 0;
|
|
|
492
532
|
function checkDisplayCondition(displayCondition, variables) {
|
|
493
533
|
var _a;
|
|
494
534
|
if ((displayCondition === null || displayCondition === void 0 ? void 0 : displayCondition.mode) === exports.EDisplayConditionMode.VARIABLE) {
|
|
495
|
-
var
|
|
496
|
-
var currentVariableValue =
|
|
535
|
+
var variableName = displayCondition.variableName, variableValue = displayCondition.variableValue;
|
|
536
|
+
var currentVariableValue = variableName && ((_a = variables.get(variableName)) === null || _a === void 0 ? void 0 : _a.value);
|
|
497
537
|
var isCurrentVariableMatch = Array.isArray(currentVariableValue)
|
|
498
538
|
? !!variableValue && (currentVariableValue === null || currentVariableValue === void 0 ? void 0 : currentVariableValue.includes(variableValue))
|
|
499
539
|
: currentVariableValue === variableValue;
|
|
@@ -509,13 +549,20 @@ function getDisplayConditionFormula(displayCondition) {
|
|
|
509
549
|
}
|
|
510
550
|
}
|
|
511
551
|
var replaceDisplayCondition = function (dimension, displayCondition) {
|
|
512
|
-
return isNil(displayCondition)
|
|
513
|
-
|
|
514
|
-
|
|
552
|
+
return isNil(displayCondition) ? dimension : __assign(__assign({}, dimension), { displayCondition: displayCondition });
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
var escapeSpecialCharacters = function (formula) {
|
|
556
|
+
return formula
|
|
557
|
+
.replaceAll("\\", "\\\\")
|
|
558
|
+
.replaceAll('"', '\\"')
|
|
559
|
+
.replaceAll("`", "\\`");
|
|
515
560
|
};
|
|
516
561
|
|
|
517
562
|
function generateColumnFormula(tableName, columnName) {
|
|
518
|
-
|
|
563
|
+
var preparedTableName = escapeSpecialCharacters(tableName);
|
|
564
|
+
var preparedColumnName = escapeSpecialCharacters(columnName);
|
|
565
|
+
return "\"".concat(preparedTableName, "\".\"").concat(preparedColumnName, "\"");
|
|
519
566
|
}
|
|
520
567
|
function fillTemplateString(templateString, params) {
|
|
521
568
|
return templateString.replace(/\{(.*?)\}/g, function (_, key) { var _a; return (_a = params[key]) !== null && _a !== void 0 ? _a : ""; });
|
|
@@ -739,18 +786,18 @@ function mapMeasureToInput(measure, variables, addFormulas) {
|
|
|
739
786
|
return {
|
|
740
787
|
alias: String(measure.id),
|
|
741
788
|
mainFormula: mainFormula,
|
|
789
|
+
dataType: measure.dataType,
|
|
742
790
|
displayConditionFormula: getDisplayConditionFormula(measure.displayCondition),
|
|
743
791
|
additionalFormulas: addFormulas(measure),
|
|
744
792
|
};
|
|
745
793
|
}
|
|
746
794
|
/** Конвертировать меры виджета во входы для вычислителя */
|
|
747
795
|
function mapMeasuresToInputs(measures, variables, addFormulas) {
|
|
748
|
-
return compactMap(measures, function (measure) {
|
|
749
|
-
return mapMeasureToInput(measure, variables, addFormulas);
|
|
750
|
-
});
|
|
796
|
+
return compactMap(measures, function (measure) { return mapMeasureToInput(measure, variables, addFormulas); });
|
|
751
797
|
}
|
|
752
798
|
|
|
753
|
-
function mapDimensionToInput(dimension, variables) {
|
|
799
|
+
function mapDimensionToInput(dimension, variables, addFormulas) {
|
|
800
|
+
if (addFormulas === void 0) { addFormulas = function () { return new Map(); }; }
|
|
754
801
|
var formula = getDimensionFormula(dimension);
|
|
755
802
|
if (!formula) {
|
|
756
803
|
return null;
|
|
@@ -761,14 +808,16 @@ function mapDimensionToInput(dimension, variables) {
|
|
|
761
808
|
return {
|
|
762
809
|
alias: String(dimension.id),
|
|
763
810
|
formula: formula,
|
|
811
|
+
dataType: dimension.dataType,
|
|
764
812
|
hideEmpty: dimension.hideEmptyValues,
|
|
765
813
|
displayConditionFormula: getDisplayConditionFormula(dimension.displayCondition),
|
|
814
|
+
additionalFormulas: addFormulas(dimension),
|
|
766
815
|
};
|
|
767
816
|
}
|
|
768
817
|
/** Конвертировать разрезы виджета во входы для вычислителя */
|
|
769
|
-
function mapDimensionsToInputs(dimensions, variables) {
|
|
818
|
+
function mapDimensionsToInputs(dimensions, variables, addFormulas) {
|
|
770
819
|
return compactMap(dimensions, function (dimension) {
|
|
771
|
-
return mapDimensionToInput(dimension, variables);
|
|
820
|
+
return mapDimensionToInput(dimension, variables, addFormulas);
|
|
772
821
|
});
|
|
773
822
|
}
|
|
774
823
|
|
|
@@ -784,6 +833,7 @@ function mapTransitionMeasureToInput(indicator, process, variables, addFormulas)
|
|
|
784
833
|
return {
|
|
785
834
|
alias: String(indicator.id),
|
|
786
835
|
mainFormula: mainFormula,
|
|
836
|
+
dataType: indicator.dataType,
|
|
787
837
|
displayConditionFormula: getDisplayConditionFormula(indicator.displayCondition),
|
|
788
838
|
additionalFormulas: addFormulas(indicator),
|
|
789
839
|
};
|
|
@@ -807,6 +857,7 @@ function mapEventMeasureToInput(indicator, process, variables, addFormulas) {
|
|
|
807
857
|
return {
|
|
808
858
|
alias: String(indicator.id),
|
|
809
859
|
mainFormula: mainFormula,
|
|
860
|
+
dataType: indicator.dataType,
|
|
810
861
|
displayConditionFormula: getDisplayConditionFormula(indicator.displayCondition),
|
|
811
862
|
additionalFormulas: addFormulas(indicator),
|
|
812
863
|
};
|
|
@@ -825,11 +876,12 @@ function mapEventMeasuresToInputs(indicators, process, variables, addFormulas) {
|
|
|
825
876
|
* @param measuresInOriginalOrder меры виджета (конкретная мера будет браться по индексу)
|
|
826
877
|
* @returns
|
|
827
878
|
*/
|
|
828
|
-
function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measuresInOriginalOrder) {
|
|
879
|
+
function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measuresInOriginalOrder, variables) {
|
|
829
880
|
if (sortingIndicators === void 0) { sortingIndicators = []; }
|
|
830
881
|
if (dimensionsInOriginalOrder === void 0) { dimensionsInOriginalOrder = []; }
|
|
831
882
|
if (measuresInOriginalOrder === void 0) { measuresInOriginalOrder = []; }
|
|
832
883
|
return compactMap(sortingIndicators, function (_a) {
|
|
884
|
+
var _b;
|
|
833
885
|
var value = _a.value, direction = _a.direction;
|
|
834
886
|
if (value.mode === exports.ESortingValueModes.FORMULA ||
|
|
835
887
|
value.mode === exports.ESortingValueModes.QUANTITY ||
|
|
@@ -840,7 +892,20 @@ function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measur
|
|
|
840
892
|
if (value.mode === exports.ESortingValueModes.DIMENSION_IN_WIDGET ||
|
|
841
893
|
value.mode === exports.ESortingValueModes.HIERARCHY) {
|
|
842
894
|
var dimension = dimensionsInOriginalOrder[value.index];
|
|
843
|
-
|
|
895
|
+
if (!dimension) {
|
|
896
|
+
return;
|
|
897
|
+
}
|
|
898
|
+
var formula = getDimensionFormula(dimension);
|
|
899
|
+
if (!formula || !checkDisplayCondition(dimension.displayCondition, variables)) {
|
|
900
|
+
return;
|
|
901
|
+
}
|
|
902
|
+
return {
|
|
903
|
+
formula: getDimensionFormula(dimension),
|
|
904
|
+
direction: direction,
|
|
905
|
+
displayCondition: ((_b = dimension.displayCondition) === null || _b === void 0 ? void 0 : _b.mode) === exports.EDisplayConditionMode.FORMULA
|
|
906
|
+
? dimension.displayCondition.formula
|
|
907
|
+
: undefined,
|
|
908
|
+
};
|
|
844
909
|
}
|
|
845
910
|
if (value.mode === exports.ESortingValueModes.MEASURE_IN_WIDGET) {
|
|
846
911
|
var measure = measuresInOriginalOrder[value.index];
|
|
@@ -868,9 +933,7 @@ function selectDimensionFromHierarchy(_a, filters) {
|
|
|
868
933
|
if (!matchedFilter) {
|
|
869
934
|
return "continue";
|
|
870
935
|
}
|
|
871
|
-
var selectionIndex = matchedFilter.values.length > 1
|
|
872
|
-
? i
|
|
873
|
-
: Math.min(i + 1, dimensions.length - 1);
|
|
936
|
+
var selectionIndex = matchedFilter.values.length > 1 ? i : Math.min(i + 1, dimensions.length - 1);
|
|
874
937
|
return { value: dimensions[selectionIndex] };
|
|
875
938
|
};
|
|
876
939
|
for (var i = dimensions.length - 1; i >= 0; i--) {
|
|
@@ -885,8 +948,7 @@ var replaceHierarchiesWithDimensions = function (dimensions, filters) {
|
|
|
885
948
|
return compactMap(dimensions, function (indicator) {
|
|
886
949
|
if (isHierarchy(indicator)) {
|
|
887
950
|
var selectedDimension = selectDimensionFromHierarchy(indicator, filters);
|
|
888
|
-
return (selectedDimension &&
|
|
889
|
-
replaceDisplayCondition(selectedDimension, indicator.displayCondition));
|
|
951
|
+
return (selectedDimension && replaceDisplayCondition(selectedDimension, indicator.displayCondition));
|
|
890
952
|
}
|
|
891
953
|
return indicator;
|
|
892
954
|
});
|
|
@@ -903,9 +965,7 @@ function bindContentWithIndicator(outputs, indicator) {
|
|
|
903
965
|
* Массив объектов, каждый из которых содержит показатель и его контент
|
|
904
966
|
*/
|
|
905
967
|
function bindContentsWithIndicators(outputs, indicators) {
|
|
906
|
-
return compactMap(indicators, function (indicator) {
|
|
907
|
-
return bindContentWithIndicator(outputs, indicator);
|
|
908
|
-
});
|
|
968
|
+
return compactMap(indicators, function (indicator) { return bindContentWithIndicator(outputs, indicator); });
|
|
909
969
|
}
|
|
910
970
|
|
|
911
971
|
exports.EControlType = void 0;
|
|
@@ -927,6 +987,8 @@ exports.EControlType = void 0;
|
|
|
927
987
|
EControlType["eventsColor"] = "eventsColor";
|
|
928
988
|
EControlType["inputMarkdown"] = "inputMarkdown";
|
|
929
989
|
EControlType["filter"] = "filter";
|
|
990
|
+
EControlType["actionOnClick"] = "actionOnClick";
|
|
991
|
+
EControlType["eventsPicker"] = "eventsPicker";
|
|
930
992
|
})(exports.EControlType || (exports.EControlType = {}));
|
|
931
993
|
|
|
932
994
|
exports.ESortDirection = void 0;
|
|
@@ -1031,11 +1093,11 @@ var getLocalizedText = function (language, locObj, props) {
|
|
|
1031
1093
|
return localization.getLocalized(locObj, props);
|
|
1032
1094
|
};
|
|
1033
1095
|
|
|
1034
|
-
Object.defineProperty(exports,
|
|
1096
|
+
Object.defineProperty(exports, "ELanguages", {
|
|
1035
1097
|
enumerable: true,
|
|
1036
1098
|
get: function () { return localization$1.ELanguages; }
|
|
1037
1099
|
});
|
|
1038
|
-
Object.defineProperty(exports,
|
|
1100
|
+
Object.defineProperty(exports, "EFilteringMethodValues", {
|
|
1039
1101
|
enumerable: true,
|
|
1040
1102
|
get: function () { return baseFilter.EFilteringMethodValues; }
|
|
1041
1103
|
});
|
|
@@ -1043,6 +1105,7 @@ exports.bindContentWithIndicator = bindContentWithIndicator;
|
|
|
1043
1105
|
exports.bindContentsWithIndicators = bindContentsWithIndicators;
|
|
1044
1106
|
exports.checkDisplayCondition = checkDisplayCondition;
|
|
1045
1107
|
exports.dimensionTemplateFormulas = dimensionTemplateFormulas;
|
|
1108
|
+
exports.escapeSpecialCharacters = escapeSpecialCharacters;
|
|
1046
1109
|
exports.eventMeasureTemplateFormulas = eventMeasureTemplateFormulas;
|
|
1047
1110
|
exports.fillTemplateString = fillTemplateString;
|
|
1048
1111
|
exports.formulaFilterMethods = formulaFilterMethods;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infomaximum/widget-sdk",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-beta20",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.esm.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -12,24 +12,26 @@
|
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "rollup -c",
|
|
14
14
|
"lint": "tsc --noEmit",
|
|
15
|
-
"release": "tsc --noEmit && standard-version && rollup -c"
|
|
15
|
+
"release": "tsc --noEmit && standard-version && rollup -c",
|
|
16
|
+
"format": "prettier --find-config-path --write 'src/**/*'"
|
|
16
17
|
},
|
|
17
18
|
"dependencies": {
|
|
19
|
+
"@infomaximum/base-filter": "^1.1.0",
|
|
18
20
|
"@infomaximum/global-types": "^1.2.0",
|
|
19
|
-
"@infomaximum/localization": "^1.0.4"
|
|
20
|
-
"@infomaximum/base-filter": "^1.1.0"
|
|
21
|
+
"@infomaximum/localization": "^1.0.4"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
24
|
+
"@infomaximum/config": "^2.6.0",
|
|
23
25
|
"@rollup/plugin-commonjs": "25.0.7",
|
|
24
26
|
"@rollup/plugin-node-resolve": "15.2.3",
|
|
25
27
|
"@rollup/plugin-typescript": "11.1.5",
|
|
26
|
-
"prettier": "3.
|
|
27
|
-
"rollup": "4.
|
|
28
|
+
"prettier": "3.2.5",
|
|
29
|
+
"rollup": "4.14.3",
|
|
28
30
|
"rollup-plugin-delete": "2.0.0",
|
|
29
31
|
"rollup-plugin-dts": "6.1.0",
|
|
30
32
|
"standard-version": "9.5.0",
|
|
31
33
|
"tslib": "^2.4.1",
|
|
32
|
-
"typescript": "5.
|
|
34
|
+
"typescript": "5.4.5"
|
|
33
35
|
},
|
|
34
36
|
"repository": {
|
|
35
37
|
"type": "git",
|