@datarailsshared/datarailsshared 1.4.165-rocket → 1.4.167

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.
Files changed (42) hide show
  1. package/bundles/datarailsshared-datarailsshared.umd.js +475 -23
  2. package/bundles/datarailsshared-datarailsshared.umd.js.map +1 -1
  3. package/datarailsshared-datarailsshared-1.4.167.tgz +0 -0
  4. package/datarailsshared-datarailsshared.d.ts +2 -0
  5. package/datarailsshared-datarailsshared.metadata.json +1 -1
  6. package/esm2015/datarailsshared-datarailsshared.js +3 -1
  7. package/esm2015/lib/date-tags/day-tag/day-tag.component.js +2 -2
  8. package/esm2015/lib/date-tags/month-tag/month-tag.component.js +2 -2
  9. package/esm2015/lib/date-tags/week-tag/week-tag.component.js +2 -2
  10. package/esm2015/lib/date-tags/year-tag/year-tag.component.js +5 -10
  11. package/esm2015/lib/dr-dialog/components/dialog-wrapper/dialog-wrapper.component.js +4 -1
  12. package/esm2015/lib/dr-dialog/services/dialog.service.js +4 -1
  13. package/esm2015/lib/dr-inputs/date-pickers/services/dr-date-picker.service.js +1 -1
  14. package/esm2015/lib/dr-inputs/dr-toggle-button/dr-toggle-button.component.js +6 -6
  15. package/esm2015/lib/dr-inputs/dr-toggle-button/toggle-button-mode.js +6 -0
  16. package/esm2015/lib/dr-scenario/components/dr-scenario-configuration/dr-scenario-configuration.component.js +93 -0
  17. package/esm2015/lib/dr-scenario/components/dr-scenario-tag-configuration/dr-scenario-tag-configuration.component.js +74 -0
  18. package/esm2015/lib/dr-scenario/consts/scenario-tags-config.js +73 -0
  19. package/esm2015/lib/dr-scenario/dr-scenario.module.js +28 -0
  20. package/esm2015/lib/dr-scenario/interfaces/scenario.js +8 -0
  21. package/esm2015/lib/dr-scenario/services/scenario.service.js +160 -0
  22. package/esm2015/lib/dr-tags/dr-tag.component.js +5 -4
  23. package/esm2015/public-api.js +5 -2
  24. package/fesm2015/datarailsshared-datarailsshared.js +441 -26
  25. package/fesm2015/datarailsshared-datarailsshared.js.map +1 -1
  26. package/lib/date-tags/date-tag.module.d.ts +1 -2
  27. package/lib/date-tags/year-tag/year-tag.component.d.ts +1 -3
  28. package/lib/dr-dialog/components/dialog-wrapper/dialog-wrapper.component.d.ts +1 -0
  29. package/lib/dr-dialog/services/dialog.service.d.ts +1 -0
  30. package/lib/dr-inputs/dr-toggle-button/dr-toggle-button.component.d.ts +2 -2
  31. package/lib/dr-inputs/dr-toggle-button/{toggle-button-theme.d.ts → toggle-button-mode.d.ts} +1 -1
  32. package/lib/dr-scenario/components/dr-scenario-configuration/dr-scenario-configuration.component.d.ts +27 -0
  33. package/lib/dr-scenario/components/dr-scenario-tag-configuration/dr-scenario-tag-configuration.component.d.ts +26 -0
  34. package/lib/dr-scenario/consts/scenario-tags-config.d.ts +24 -0
  35. package/lib/dr-scenario/dr-scenario.module.d.ts +2 -0
  36. package/lib/dr-scenario/interfaces/scenario.d.ts +43 -0
  37. package/lib/dr-scenario/services/scenario.service.d.ts +21 -0
  38. package/lib/dr-tags/dr-tag.component.d.ts +2 -2
  39. package/package.json +1 -1
  40. package/public-api.d.ts +4 -1
  41. package/datarailsshared-datarailsshared-1.4.165-rocket.tgz +0 -0
  42. package/esm2015/lib/dr-inputs/dr-toggle-button/toggle-button-theme.js +0 -6
@@ -1,9 +1,9 @@
1
1
  import * as i0 from '@angular/core';
2
- import { EventEmitter, Component, ViewEncapsulation, Input, Output, HostBinding, ChangeDetectorRef, ChangeDetectionStrategy, forwardRef, ElementRef, Inject, PLATFORM_ID, ContentChildren, Renderer2, ViewChild, ContentChild, Pipe, TemplateRef, HostListener, Directive, ComponentFactoryResolver, ViewContainerRef, Injector, Injectable, Host, Optional, NgModule } from '@angular/core';
2
+ import { EventEmitter, Component, ViewEncapsulation, Input, Output, HostBinding, ChangeDetectionStrategy, ChangeDetectorRef, forwardRef, ElementRef, Inject, PLATFORM_ID, ContentChildren, Renderer2, ViewChild, ContentChild, Pipe, TemplateRef, HostListener, Directive, ComponentFactoryResolver, ViewContainerRef, Injector, Injectable, Host, Optional, NgModule } from '@angular/core';
3
3
  import { DateAdapter, MAT_DATE_LOCALE, MAT_DATE_FORMATS } from '@angular/material/core';
4
4
  import { MomentDateAdapter, MAT_MOMENT_DATE_ADAPTER_OPTIONS } from '@angular/material-moment-adapter';
5
5
  import * as _ from 'lodash';
6
- import { find, map, merge, forEach, some, reduce, isObject, isNil, isNumber } from 'lodash';
6
+ import { find, map, merge, forEach, some, orderBy, filter as filter$1, reduce, cloneDeep, isObject, isNil, isNumber, includes } from 'lodash';
7
7
  import { NG_VALUE_ACCESSOR, FormGroupDirective, FormGroup, FormControl, NgModel, NgControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
8
8
  import { isPlatformBrowser, DOCUMENT, CommonModule } from '@angular/common';
9
9
  import { Subject, from, merge as merge$1, fromEvent, noop as noop$1, BehaviorSubject } from 'rxjs';
@@ -265,7 +265,7 @@ class MonthTagComponent extends AnyTagComponent {
265
265
  return this.date ? !this.dateFilter(moment$7.unix(this.date).utc()) : false;
266
266
  }
267
267
  initDate() {
268
- this.date = this.defaultValue || moment$7().unix();
268
+ this.date = this.defaultValue || moment$7().utc().unix();
269
269
  this.dateObj.date = this.date;
270
270
  }
271
271
  initName() {
@@ -444,7 +444,7 @@ class WeekTagComponent extends AnyTagComponent {
444
444
  }
445
445
  ngOnInit() {
446
446
  this.initName();
447
- const timestamp = this.defaultValue || moment$5().unix();
447
+ const timestamp = this.defaultValue || moment$5().utc().unix();
448
448
  this.date = timestamp;
449
449
  this.dateObj.date = timestamp;
450
450
  this.chosenTagHandler(timestamp);
@@ -514,21 +514,18 @@ const YEAR_FORMATS = {
514
514
  };
515
515
  const ɵ0$5 = YEAR_FORMATS;
516
516
  class YearTagComponent extends AnyTagComponent {
517
- constructor(cdr) {
517
+ constructor() {
518
518
  super();
519
- this.cdr = cdr;
520
519
  this.lockedDate = [];
521
520
  }
522
521
  get isLocked() {
523
522
  return this.date ? !this.dateFilter(moment$4.unix(this.date).utc()) : false;
524
523
  }
525
524
  initDate() {
526
- this.date = this.defaultValue || moment$4().unix();
525
+ this.date = this.defaultValue || moment$4().utc().unix();
527
526
  this.dateObj.date = this.date;
528
- this.cdr.markForCheck();
529
527
  }
530
528
  initName() {
531
- console.warn('bla bla bla');
532
529
  if (!this.name) {
533
530
  this.name = 'Year';
534
531
  }
@@ -569,9 +566,7 @@ YearTagComponent.decorators = [
569
566
  styles: [":host.locked>.tag-wrapper>dr-date-picker{opacity:.4}.tag__label{margin:0 0 4px;color:#0c142b;font-size:14px;font-weight:400;line-height:22px}\n"]
570
567
  },] }
571
568
  ];
572
- YearTagComponent.ctorParameters = () => [
573
- { type: ChangeDetectorRef }
574
- ];
569
+ YearTagComponent.ctorParameters = () => [];
575
570
  YearTagComponent.propDecorators = {
576
571
  isLocked: [{ type: HostBinding, args: ['class.locked',] }],
577
572
  lockedDate: [{ type: Input }]
@@ -620,12 +615,13 @@ class DrTagComponent {
620
615
  get connectedTags() {
621
616
  return this._connectedTags;
622
617
  }
623
- ngOnChanges() {
624
- this.calculateDynamicTag();
618
+ ngOnChanges(simpleChanges) {
619
+ if (simpleChanges.tagsConfig) {
620
+ this.calculateDynamicTag();
621
+ }
625
622
  }
626
623
  ngOnInit() {
627
624
  var _a, _b;
628
- this.calculateDynamicTag();
629
625
  this.dateTag = {
630
626
  type: this.tagConfig.type,
631
627
  sub_type: this.tagConfig.options.sub_type,
@@ -829,7 +825,7 @@ class DayTagComponent extends AnyTagComponent {
829
825
  return this.date ? !this.dateFilter(moment$3.unix(this.date).utc()) : false;
830
826
  }
831
827
  initDate() {
832
- this.date = this.defaultValue || moment$3().unix();
828
+ this.date = this.defaultValue || moment$3().utc().unix();
833
829
  this.dateObj.date = this.date;
834
830
  }
835
831
  initName() {
@@ -1945,11 +1941,11 @@ DrToggleComponent.propDecorators = {
1945
1941
  elementClass: [{ type: HostBinding, args: ['class',] }]
1946
1942
  };
1947
1943
 
1948
- var ToggleButtonTheme;
1949
- (function (ToggleButtonTheme) {
1950
- ToggleButtonTheme["DEFAULT"] = "default";
1951
- ToggleButtonTheme["DOTTED"] = "dotted";
1952
- })(ToggleButtonTheme || (ToggleButtonTheme = {}));
1944
+ var ToggleButtonMode;
1945
+ (function (ToggleButtonMode) {
1946
+ ToggleButtonMode["DEFAULT"] = "default";
1947
+ ToggleButtonMode["DOTTED"] = "dotted";
1948
+ })(ToggleButtonMode || (ToggleButtonMode = {}));
1953
1949
 
1954
1950
  class DrToggleButtonComponent {
1955
1951
  constructor(cdr) {
@@ -1958,7 +1954,7 @@ class DrToggleButtonComponent {
1958
1954
  this.bindLabel = null;
1959
1955
  this.bindValue = null;
1960
1956
  this.bindHidden = null;
1961
- this.theme = ToggleButtonTheme.DEFAULT;
1957
+ this.mode = ToggleButtonMode.DEFAULT;
1962
1958
  this.onChange = () => {
1963
1959
  };
1964
1960
  this.onTouched = () => {
@@ -1990,12 +1986,12 @@ class DrToggleButtonComponent {
1990
1986
  DrToggleButtonComponent.decorators = [
1991
1987
  { type: Component, args: [{
1992
1988
  selector: 'dr-toggle-button',
1993
- template: "<div class=\"toggle-container\"\n [class.disabled]=\"_disabled\"\n [attr.theme]=\"theme\">\n <ng-container *ngFor=\"let item of items\">\n <div *ngIf=\"!item?.[bindHidden]\"\n [class.selected]=\"item[bindValue] === selectedValue || item === selectedValue\"\n [class.disabled]=\"item.disabled\"\n class=\"toggle-container__item\">{{ item[bindLabel] || item.name || item }}</div>\n </ng-container>\n</div>\n",
1989
+ template: "<div class=\"toggle-container\"\n [class.disabled]=\"_disabled\"\n [attr.mode]=\"mode\">\n <ng-container *ngFor=\"let item of items\">\n <div *ngIf=\"!item?.[bindHidden]\"\n class=\"toggle-container__item\"\n [class.selected]=\"item[bindValue] === selectedValue || item === selectedValue\"\n [class.disabled]=\"item.disabled\"\n (click)=\"setValue(item)\">{{ item[bindLabel] || item.name || item }}</div>\n </ng-container>\n</div>\n",
1994
1990
  providers: [
1995
1991
  { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => DrToggleButtonComponent), multi: true }
1996
1992
  ],
1997
1993
  changeDetection: ChangeDetectionStrategy.OnPush,
1998
- styles: [".toggle-container{display:flex;flex-wrap:nowrap;box-sizing:border-box;border-radius:20px;height:28px}.toggle-container.disabled{pointer-events:none}.toggle-container__item{height:28px;display:flex;align-items:center;justify-content:center;padding:4px 16px;border-radius:20px;margin:-1px;cursor:pointer;font-weight:400;font-size:12px;line-height:20px;white-space:nowrap;color:#4e566c}.toggle-container__item.selected{background:#f2f2fb!important;border:1px solid #7f7fdd!important;color:#25258c!important}.toggle-container__item.disabled{pointer-events:none;cursor:default;background:#f0f1f4;color:#9ea1aa;border:1px solid #c3c4ce}.toggle-container[theme~=default]{background:#f6f7f8;border:1px solid #c3c4ce}.toggle-container[theme~=dotted] .toggle-container__item{border:1px solid #9ea1aa;border-radius:18px;margin-left:5px;color:#0c142b}.toggle-container[theme~=dotted] .toggle-container__item:hover{background:#f0f1f4}.toggle-container[theme~=dotted] .toggle-container__item:hover .toggle-container[theme~=dotted] .toggle-container__item.selected{background:unset}.toggle-container[theme~=dotted] .toggle-container__item:first-child{margin-left:0}\n"]
1994
+ styles: [".toggle-container{display:flex;flex-wrap:nowrap;box-sizing:border-box;border-radius:20px;height:28px}.toggle-container.disabled{pointer-events:none}.toggle-container__item{height:28px;display:flex;align-items:center;justify-content:center;padding:4px 16px;border-radius:20px;margin:-1px;cursor:pointer;font-weight:400;font-size:12px;line-height:20px;white-space:nowrap;color:#4e566c}.toggle-container__item.selected{background:#f2f2fb!important;border:1px solid #7f7fdd!important;color:#25258c!important}.toggle-container__item.disabled{pointer-events:none;cursor:default;background:#f0f1f4;color:#9ea1aa;border:1px solid #c3c4ce}.toggle-container[mode~=default]{background:#f6f7f8;border:1px solid #c3c4ce}.toggle-container[mode~=dotted] .toggle-container__item{padding:2px 8px;border:1px solid #9ea1aa;border-radius:18px;margin-left:4px;color:#0c142b}.toggle-container[mode~=dotted] .toggle-container__item:hover{background:#f0f1f4}.toggle-container[mode~=dotted] .toggle-container__item:hover .toggle-container[mode~=dotted] .toggle-container__item.selected{background:unset}.toggle-container[mode~=dotted] .toggle-container__item:first-child{margin-left:0}\n"]
1999
1995
  },] }
2000
1996
  ];
2001
1997
  DrToggleButtonComponent.ctorParameters = () => [
@@ -2006,7 +2002,7 @@ DrToggleButtonComponent.propDecorators = {
2006
2002
  bindLabel: [{ type: Input }],
2007
2003
  bindValue: [{ type: Input }],
2008
2004
  bindHidden: [{ type: Input }],
2009
- theme: [{ type: Input }],
2005
+ mode: [{ type: Input }],
2010
2006
  selectedValue: [{ type: Input }],
2011
2007
  disabled: [{ type: Input }]
2012
2008
  };
@@ -3316,6 +3312,9 @@ class DialogWrapperComponent {
3316
3312
  closeDialog(data) {
3317
3313
  this.dialogRef.close(data || false);
3318
3314
  }
3315
+ enableAcceptButton() {
3316
+ this.dialogData.acceptButton.isDisabled = false;
3317
+ }
3319
3318
  onDecline() {
3320
3319
  this.dialogRef.close(undefined);
3321
3320
  }
@@ -3500,6 +3499,9 @@ class DialogService {
3500
3499
  close(params) {
3501
3500
  this.wrapperComponent.close(params);
3502
3501
  }
3502
+ enableAcceptButton() {
3503
+ this.wrapperComponent.componentInstance.enableAcceptButton();
3504
+ }
3503
3505
  changeDialogThemeSize(theme) {
3504
3506
  this.wrapperComponent.componentInstance.class = theme;
3505
3507
  }
@@ -3600,6 +3602,14 @@ var TooltipPosition;
3600
3602
  TooltipPosition["LEFT_BOTTOM"] = "left-bottom";
3601
3603
  })(TooltipPosition || (TooltipPosition = {}));
3602
3604
 
3605
+ var Scenario;
3606
+ (function (Scenario) {
3607
+ Scenario["ACTUALS"] = "Actuals";
3608
+ Scenario["FORECAST"] = "Forecast";
3609
+ Scenario["BUDGET"] = "Budget";
3610
+ Scenario["NONE"] = "None";
3611
+ })(Scenario || (Scenario = {}));
3612
+
3603
3613
  class DrModelDebounceChangeDirective {
3604
3614
  constructor(ngModel) {
3605
3615
  this.ngModel = ngModel;
@@ -3662,6 +3672,232 @@ class ChatMessage {
3662
3672
  }
3663
3673
  }
3664
3674
 
3675
+ const allDateTags = {
3676
+ [TagsConfigSubType.YEAR]: {
3677
+ name: 'Date',
3678
+ toggle: false,
3679
+ },
3680
+ [TagsConfigSubType.QUARTER]: {
3681
+ name: 'Date',
3682
+ toggle: false,
3683
+ },
3684
+ [TagsConfigSubType.MONTH]: {
3685
+ name: 'Date',
3686
+ toggle: false,
3687
+ },
3688
+ [TagsConfigSubType.DAY]: {
3689
+ name: 'Date',
3690
+ toggle: false,
3691
+ },
3692
+ [TagsConfigSubType.WEEK]: {
3693
+ name: 'Date',
3694
+ toggle: false,
3695
+ }
3696
+ };
3697
+ function getScenarioTagDataConfig(isMultipleDimension) {
3698
+ return {
3699
+ [Scenario.ACTUALS]: Object.assign(Object.assign({}, allDateTags), { [TagsConfigSubType.MONTH]: {
3700
+ name: 'Date',
3701
+ toggle: true,
3702
+ }, [TagsConfigSubType.FILE_STATUS]: {
3703
+ toggle: false,
3704
+ } }),
3705
+ [Scenario.BUDGET]: {
3706
+ [TagsConfigSubType.BUDGET_CYCLE]: {
3707
+ toggle: true,
3708
+ acceptableDateTags: [TagsConfigSubType.YEAR],
3709
+ hidden: !isMultipleDimension,
3710
+ },
3711
+ [TagsConfigSubType.PLAN]: {
3712
+ toggle: false,
3713
+ turnOffDateTags: true,
3714
+ hidden: isMultipleDimension,
3715
+ },
3716
+ [TagsConfigSubType.YEAR]: {
3717
+ name: 'Date',
3718
+ toggle: true,
3719
+ },
3720
+ [TagsConfigSubType.QUARTER]: {
3721
+ name: 'Date',
3722
+ toggle: false,
3723
+ },
3724
+ [TagsConfigSubType.FILE_STATUS]: {
3725
+ toggle: false,
3726
+ },
3727
+ },
3728
+ [Scenario.FORECAST]: {
3729
+ [TagsConfigSubType.FORECAST_NEW]: {
3730
+ toggle: true,
3731
+ name: 'Date',
3732
+ },
3733
+ [TagsConfigSubType.FILE_STATUS]: {
3734
+ toggle: false,
3735
+ },
3736
+ },
3737
+ [Scenario.NONE]: Object.assign(Object.assign({}, allDateTags), { [TagsConfigSubType.MONTH]: {
3738
+ name: 'Date',
3739
+ toggle: true,
3740
+ }, [TagsConfigSubType.FILE_STATUS]: {
3741
+ toggle: true,
3742
+ } }),
3743
+ };
3744
+ }
3745
+
3746
+ class ScenarioService {
3747
+ constructor() {
3748
+ this.DEFAULT_FORECAST_DATE_TAG = 'Month';
3749
+ }
3750
+ get scenarios() {
3751
+ return orderBy(Object.values(Scenario), (scenario) => scenario === Scenario.NONE ? 1 : 0);
3752
+ }
3753
+ get areExistingTagsConfig() {
3754
+ return !!this.currentTagsConfig;
3755
+ }
3756
+ initScenarioTags(scenario, wholeTagsConfig, currentTagsConfig, isMultipleDimension) {
3757
+ if (!(wholeTagsConfig === null || wholeTagsConfig === void 0 ? void 0 : wholeTagsConfig.length) || !scenario)
3758
+ return;
3759
+ this.wholeTagsConfig = wholeTagsConfig;
3760
+ this.currentTagsConfig = currentTagsConfig;
3761
+ this.isMultipleDimension = isMultipleDimension;
3762
+ }
3763
+ getTagsConfigByScenarioTags(scenarioTags, tagsConfig) {
3764
+ const scenarioTagsConfig = filter$1(tagsConfig, (tagConfig) => some(scenarioTags, (scenarioTag) => scenarioTag.toggle && scenarioTag.selectedTagSubType === tagConfig.options.sub_type));
3765
+ return this.sortScenarioTags(scenarioTagsConfig);
3766
+ }
3767
+ getScenarioTagsByScenario(scenario) {
3768
+ const scenarioTagsConfig = this.getScenarioTagsConfig(scenario, this.wholeTagsConfig);
3769
+ const scenarioTagsUi = [];
3770
+ forEach(scenarioTagsConfig, (scenarioTag) => {
3771
+ const isDateTag = scenarioTag.type === TagTypes.DATE;
3772
+ const dateTag = isDateTag && find(scenarioTagsUi, { type: TagTypes.DATE });
3773
+ const tag = dateTag || this.prepareScenarioTag(scenarioTagsConfig, scenarioTag, scenario, isDateTag);
3774
+ if (isDateTag) {
3775
+ this.updateScenarioDateTag(tag, scenarioTag);
3776
+ }
3777
+ if (dateTag)
3778
+ return;
3779
+ scenarioTagsUi.push(tag);
3780
+ });
3781
+ if (this.areExistingTagsConfig) {
3782
+ this.initExistingTagsConfig(scenario, scenarioTagsUi);
3783
+ }
3784
+ const isTagNotSupportingDates = some(scenarioTagsUi, { turnOffDateTags: true, toggle: true });
3785
+ if (isTagNotSupportingDates) {
3786
+ this.turnOffDateTag(scenarioTagsUi);
3787
+ }
3788
+ const tagWithSpecificDateTags = find(scenarioTagsUi, (tag) => { var _a; return tag.toggle && !!((_a = tag.acceptableDateTags) === null || _a === void 0 ? void 0 : _a.length); });
3789
+ if (tagWithSpecificDateTags) {
3790
+ this.hideNotAvailableTags(tagWithSpecificDateTags, scenarioTagsUi);
3791
+ }
3792
+ return this.sortScenarioTags(scenarioTagsUi);
3793
+ }
3794
+ sortScenarioTags(scenarioTagsUi) {
3795
+ return orderBy(scenarioTagsUi, [
3796
+ (tag) => (tag.type === TagTypes.DATE ? 0 : 1),
3797
+ (tag) => (tag.name === 'File Status')
3798
+ ]);
3799
+ }
3800
+ initExistingTagsConfig(scenario, scenarioTagsUi) {
3801
+ forEach(this.currentTagsConfig, (tagConfig) => {
3802
+ var _a, _b;
3803
+ const tagSubType = (_a = tagConfig === null || tagConfig === void 0 ? void 0 : tagConfig.options) === null || _a === void 0 ? void 0 : _a.sub_type;
3804
+ const scenarioTagDataConfig = getScenarioTagDataConfig(this.isMultipleDimension);
3805
+ if (!((_b = scenarioTagDataConfig === null || scenarioTagDataConfig === void 0 ? void 0 : scenarioTagDataConfig[scenario]) === null || _b === void 0 ? void 0 : _b[tagSubType]))
3806
+ return;
3807
+ const scenarioTagUi = tagConfig.type === TagTypes.DATE
3808
+ ? find(scenarioTagsUi, { type: tagConfig.type })
3809
+ : find(scenarioTagsUi, { selectedTagSubType: tagSubType });
3810
+ scenarioTagUi.toggle = true;
3811
+ scenarioTagUi.selectedTagSubType = tagSubType;
3812
+ });
3813
+ }
3814
+ prepareScenarioTag(scenarioTagsConfig, scenarioTag, scenario, isDateTag) {
3815
+ const toggleStatus = isDateTag
3816
+ ? some(scenarioTagsConfig, (tag) => tag.type === TagTypes.DATE && tag.scenarioData.toggle)
3817
+ : scenarioTag.scenarioData.toggle;
3818
+ const selectedTagSubType = isDateTag
3819
+ ? this.getScenarioSelectedDateTag(scenario, scenarioTagsConfig)
3820
+ : scenarioTag.options.sub_type;
3821
+ const tag = {
3822
+ toggle: this.areExistingTagsConfig ? false : toggleStatus,
3823
+ name: scenarioTag.scenarioData.name || scenarioTag.name,
3824
+ description: scenarioTag.scenarioData.description || scenarioTag.description,
3825
+ type: scenarioTag.type,
3826
+ selectedTagSubType,
3827
+ };
3828
+ if (scenarioTag.scenarioData.turnOffDateTags) {
3829
+ tag.turnOffDateTags = scenarioTag.scenarioData.turnOffDateTags;
3830
+ }
3831
+ if (scenarioTag.scenarioData.acceptableDateTags) {
3832
+ tag.acceptableDateTags = scenarioTag.scenarioData.acceptableDateTags;
3833
+ }
3834
+ return tag;
3835
+ }
3836
+ updateScenarioDateTag(dateTag, scenarioTag) {
3837
+ if (!dateTag.subTags) {
3838
+ dateTag.subTags = [];
3839
+ }
3840
+ const tagSubType = scenarioTag.options.sub_type;
3841
+ dateTag.subTags.push({
3842
+ subType: tagSubType,
3843
+ name: tagSubType === TagsConfigSubType.FORECAST_NEW ? this.DEFAULT_FORECAST_DATE_TAG : scenarioTag.name,
3844
+ });
3845
+ }
3846
+ turnOffDateTag(scenarioTags) {
3847
+ const dateTag = find(scenarioTags, { type: TagTypes.DATE });
3848
+ if (!dateTag)
3849
+ return;
3850
+ dateTag.toggle = false;
3851
+ }
3852
+ hideNotAvailableTags(tagWithSpecificDateTags, scenarioTags) {
3853
+ var _a;
3854
+ const subTags = (_a = find(scenarioTags, { type: TagTypes.DATE })) === null || _a === void 0 ? void 0 : _a.subTags;
3855
+ if (!subTags.length)
3856
+ return;
3857
+ forEach(scenarioTags, (tag) => {
3858
+ var _a;
3859
+ if (!((_a = tag.acceptableDateTags) === null || _a === void 0 ? void 0 : _a.length))
3860
+ return;
3861
+ if (tag !== tagWithSpecificDateTags) {
3862
+ tag.toggle = false;
3863
+ }
3864
+ });
3865
+ forEach(subTags, (subTag) => {
3866
+ subTag.hidden = !tagWithSpecificDateTags.acceptableDateTags.includes(subTag.subType);
3867
+ });
3868
+ }
3869
+ getScenarioSelectedDateTag(scenario, dateTags) {
3870
+ var _a, _b;
3871
+ const monthSubType = (_b = (_a = find(dateTags, (tag) => tag.options.sub_type === TagsConfigSubType.MONTH)) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.sub_type;
3872
+ const scenarioSelectedDateTag = {
3873
+ [Scenario.ACTUALS]: () => monthSubType,
3874
+ [Scenario.BUDGET]: () => { var _a, _b; return (_b = (_a = find(dateTags, (tag) => tag.options.sub_type === TagsConfigSubType.YEAR)) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.sub_type; },
3875
+ [Scenario.FORECAST]: () => { var _a, _b; return (_b = (_a = find(dateTags, (tag) => tag.options.sub_type === TagsConfigSubType.FORECAST_NEW)) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.sub_type; },
3876
+ [Scenario.NONE]: () => monthSubType,
3877
+ };
3878
+ if (!scenarioSelectedDateTag[scenario])
3879
+ return;
3880
+ return scenarioSelectedDateTag[scenario]();
3881
+ }
3882
+ getScenarioTagsConfig(scenario, tagsConfig) {
3883
+ return reduce(tagsConfig, (acc, tagConfig) => {
3884
+ var _a, _b;
3885
+ const tagSubType = (_a = tagConfig === null || tagConfig === void 0 ? void 0 : tagConfig.options) === null || _a === void 0 ? void 0 : _a.sub_type;
3886
+ const scenarioTagDataConfig = getScenarioTagDataConfig(this.isMultipleDimension);
3887
+ const scenarioTagConfig = (_b = scenarioTagDataConfig === null || scenarioTagDataConfig === void 0 ? void 0 : scenarioTagDataConfig[scenario]) === null || _b === void 0 ? void 0 : _b[tagSubType];
3888
+ if (!scenarioTagConfig || scenarioTagConfig.hidden)
3889
+ return acc;
3890
+ const clonedTagConfig = cloneDeep(tagConfig);
3891
+ const scenarioTag = Object.assign(Object.assign({}, clonedTagConfig), { scenarioData: scenarioTagConfig });
3892
+ acc.push(scenarioTag);
3893
+ return acc;
3894
+ }, []);
3895
+ }
3896
+ }
3897
+ ScenarioService.decorators = [
3898
+ { type: Injectable }
3899
+ ];
3900
+
3665
3901
  class DrSharedUtils {
3666
3902
  /**
3667
3903
  * Get timeframe (day, year, month, quarter) based on passed format
@@ -5676,11 +5912,190 @@ DrChatModule.decorators = [
5676
5912
  },] }
5677
5913
  ];
5678
5914
 
5915
+ class DrScenarioConfigurationComponent {
5916
+ constructor(scenarioService) {
5917
+ this.scenarioService = scenarioService;
5918
+ this.toggleButtonMode = ToggleButtonMode;
5919
+ this._scenarioTags = [];
5920
+ this.wholeTagsConfig = [];
5921
+ this.selectedScenario = Scenario.ACTUALS;
5922
+ this.isMultipleDimension = false;
5923
+ this.scenarioDataChanged = new EventEmitter();
5924
+ }
5925
+ get scenarioTags() {
5926
+ return this._scenarioTags;
5927
+ }
5928
+ set scenarioTags(tags) {
5929
+ this._scenarioTags = tags;
5930
+ this.tagNotSupportingDates = find(tags, { turnOffDateTags: true });
5931
+ }
5932
+ get dateTag() {
5933
+ return find(this.scenarioTags, { type: TagTypes.DATE });
5934
+ }
5935
+ ngOnInit() {
5936
+ this.scenarios = this.scenarioService.scenarios;
5937
+ this.scenarioService.initScenarioTags(this.selectedScenario, this.wholeTagsConfig, this.currentTagsConfig, this.isMultipleDimension);
5938
+ this.scenarioTags = this.scenarioService.getScenarioTagsByScenario(this.selectedScenario);
5939
+ }
5940
+ onScenarioChange(scenario) {
5941
+ this.scenarioTags = this.scenarioService.getScenarioTagsByScenario(scenario);
5942
+ this.onScenarioDataChange();
5943
+ }
5944
+ onScenarioTagToggle(tag) {
5945
+ this.tagNotSupportingDatesHandler(tag);
5946
+ this.tagAcceptableDateHandler(tag);
5947
+ this.onScenarioDataChange();
5948
+ }
5949
+ onScenarioDataChange() {
5950
+ this.scenarioDataChanged.emit({
5951
+ scenario: this.selectedScenario,
5952
+ tagsConfig: this.scenarioService.getTagsConfigByScenarioTags(this.scenarioTags, this.wholeTagsConfig),
5953
+ });
5954
+ }
5955
+ tagNotSupportingDatesHandler(tag) {
5956
+ if (!this.tagNotSupportingDates || !tag.toggle)
5957
+ return;
5958
+ if (tag.type === TagTypes.DATE) {
5959
+ this.tagNotSupportingDates.toggle = false;
5960
+ }
5961
+ if (tag === this.tagNotSupportingDates) {
5962
+ const dateTag = this.dateTag;
5963
+ if (dateTag) {
5964
+ dateTag.toggle = false;
5965
+ }
5966
+ }
5967
+ }
5968
+ tagAcceptableDateHandler(tag) {
5969
+ var _a;
5970
+ if (!((_a = tag.acceptableDateTags) === null || _a === void 0 ? void 0 : _a.length))
5971
+ return;
5972
+ const dateTag = this.dateTag;
5973
+ if (!dateTag)
5974
+ return;
5975
+ dateTag.subTags = map(dateTag.subTags, (subTag) => {
5976
+ subTag.hidden = tag.toggle && !includes(tag.acceptableDateTags, subTag.subType);
5977
+ return subTag;
5978
+ });
5979
+ dateTag.selectedTagSubType = tag.acceptableDateTags[0];
5980
+ }
5981
+ }
5982
+ DrScenarioConfigurationComponent.decorators = [
5983
+ { type: Component, args: [{
5984
+ selector: 'dr-scenario-configuration',
5985
+ template: "<div class=\"scenario\">\n <div class=\"scenario__list\">\n <p class=\"scenario__title scenario__title-list\">Scenario</p>\n <dr-select [(ngModel)]=\"selectedScenario\"\n placeholder=\"select\"\n [items]=\"scenarios\"\n (ngModelChange)=\"onScenarioChange($event)\"></dr-select>\n </div>\n <div class=\"scenario__tags\">\n <p class=\"scenario__title--extra scenario__tags__title\">Tags</p>\n <div class=\"scenario__tag\" *ngFor=\"let tag of scenarioTags\">\n <div class=\"scenario__tag__header\">\n <p class=\"scenario__title\">{{ tag.name }}</p>\n <dr-toggle [(ngModel)]=\"tag.toggle\"\n (ngModelChange)=\"onScenarioTagToggle(tag)\"></dr-toggle>\n </div>\n <div class=\"scenario__tag__description\">\n <p class=\"scenario__text\">{{ tag.description }}</p>\n </div>\n <div *ngIf=\"tag.toggle\" class=\"scenario__tag__body\">\n <div *ngIf=\"tag.subTags?.length\" class=\"scenario__sub-tag\">\n <dr-toggle-button [(ngModel)]=\"tag.selectedTagSubType\"\n bindHidden=\"hidden\"\n bindLabel=\"name\"\n bindValue=\"subType\"\n [items]=\"tag.subTags\"\n [mode]=\"toggleButtonMode.DOTTED\"\n (ngModelChange)=\"onScenarioDataChange()\"></dr-toggle-button>\n </div>\n </div>\n </div>\n </div>\n</div>\n",
5986
+ changeDetection: ChangeDetectionStrategy.OnPush,
5987
+ providers: [ScenarioService],
5988
+ styles: [".scenario__text,.scenario__title,.scenario__title--extra{padding:0;margin:0;color:#0c142b;font-weight:400;font-size:14px;line-height:22px}.scenario__title{font-weight:600}.scenario__title--extra{font-weight:700}.scenario__tags{margin-top:24px}.scenario__tags__title{margin-bottom:16px}.scenario__title-list{margin-bottom:4px}.scenario__tag{margin-bottom:24px;padding-top:16px;border-top:1px solid #dfe0e3}.scenario__tag__description{margin-top:5px}.scenario__tag__header{display:flex;justify-content:space-between}.scenario__sub-tag{margin-top:8px}:host::ng-deep .toggle-container__item{padding:2px 8px!important}\n"]
5989
+ },] }
5990
+ ];
5991
+ DrScenarioConfigurationComponent.ctorParameters = () => [
5992
+ { type: ScenarioService }
5993
+ ];
5994
+ DrScenarioConfigurationComponent.propDecorators = {
5995
+ currentTagsConfig: [{ type: Input }],
5996
+ wholeTagsConfig: [{ type: Input }],
5997
+ selectedScenario: [{ type: Input }],
5998
+ isMultipleDimension: [{ type: Input }],
5999
+ scenarioDataChanged: [{ type: Output }]
6000
+ };
6001
+
6002
+ class DrScenarioTagConfigurationComponent {
6003
+ constructor() {
6004
+ this.connectedTags = {};
6005
+ this.dynamicTagValues = {};
6006
+ this.lockedDates = [];
6007
+ this.scenarioTagDataChanged = new EventEmitter();
6008
+ this.currentTagsMap = {};
6009
+ this._currentTags = [];
6010
+ this.dynamicTagsToSave = [];
6011
+ this.tagsToSave = [];
6012
+ }
6013
+ set currentTags(tags) {
6014
+ this._currentTags = tags;
6015
+ this.currentTagsMap = reduce(tags, (acc, curr) => {
6016
+ var _a;
6017
+ const tagId = (_a = find(this.tagsConfig, { name: curr.name })) === null || _a === void 0 ? void 0 : _a.id;
6018
+ if (isNaN(tagId))
6019
+ return acc;
6020
+ acc[tagId] = curr;
6021
+ return acc;
6022
+ }, {});
6023
+ }
6024
+ get currentTags() {
6025
+ return this._currentTags;
6026
+ }
6027
+ ngOnChanges(simpleChanges) {
6028
+ this.currentTags = this.currentTags;
6029
+ }
6030
+ onTagChange($event) {
6031
+ const savedTag = find(this.tagsToSave, { id: $event.id });
6032
+ if (savedTag) {
6033
+ merge(savedTag, $event);
6034
+ }
6035
+ else {
6036
+ this.tagsToSave.push($event);
6037
+ }
6038
+ this.onScenarioTagDataChanged();
6039
+ }
6040
+ onDynamicTagsChange($event) {
6041
+ this.dynamicTagsToSave = $event;
6042
+ this.onScenarioTagDataChanged();
6043
+ }
6044
+ onScenarioTagDataChanged() {
6045
+ const tags = [...this.dynamicTagsToSave, ...this.tagsToSave];
6046
+ this.scenarioTagDataChanged.emit({
6047
+ scenario: this.scenario,
6048
+ tagsConfig: this.tagsConfig,
6049
+ tags,
6050
+ });
6051
+ }
6052
+ }
6053
+ DrScenarioTagConfigurationComponent.decorators = [
6054
+ { type: Component, args: [{
6055
+ selector: 'dr-scenario-tag-configuration',
6056
+ template: "<div class=\"scenario-tag-configuration\"\n *ngFor=\"let tagConfig of tagsConfig\">\n <dr-tag [tagConfig]=\"tagConfig\"\n [selectedTag]=\"currentTagsMap[tagConfig.id]\"\n [lockedDate]=\"lockedDates\"\n [fiscalYearStartsFrom]=\"fiscalYearStartsFrom\"\n [fiscalYearBack]=\"fiscalYearBack\"\n [tagsConfig]=\"tagsConfig\"\n [dynamicTagValues]=\"dynamicTagValues\"\n [connectedTags]=\"connectedTags[tagConfig.id]\"\n [isDynamicTagAddEnabled]=\"isDynamicAddEnabled\"\n (tagChange)=\"onTagChange($event)\"\n (dynamicTagChange)=\"onDynamicTagsChange($event)\"></dr-tag>\n</div>\n",
6057
+ changeDetection: ChangeDetectionStrategy.OnPush,
6058
+ styles: [".scenario-tag-configuration{margin-bottom:24px}.scenario-tag-configuration:last-child{margin-bottom:0}\n"]
6059
+ },] }
6060
+ ];
6061
+ DrScenarioTagConfigurationComponent.propDecorators = {
6062
+ tagsConfig: [{ type: Input }],
6063
+ currentTags: [{ type: Input }],
6064
+ scenario: [{ type: Input }],
6065
+ connectedTags: [{ type: Input }],
6066
+ dynamicTagValues: [{ type: Input }],
6067
+ lockedDates: [{ type: Input }],
6068
+ fiscalYearStartsFrom: [{ type: Input }],
6069
+ fiscalYearBack: [{ type: Input }],
6070
+ isDynamicAddEnabled: [{ type: Input }],
6071
+ scenarioTagDataChanged: [{ type: Output }]
6072
+ };
6073
+
6074
+ const COMPONENTS = [
6075
+ DrScenarioConfigurationComponent,
6076
+ DrScenarioTagConfigurationComponent,
6077
+ ];
6078
+ class DrScenarioModule {
6079
+ }
6080
+ DrScenarioModule.decorators = [
6081
+ { type: NgModule, args: [{
6082
+ declarations: [...COMPONENTS],
6083
+ providers: [ScenarioService],
6084
+ imports: [
6085
+ CommonModule,
6086
+ DrInputsModule,
6087
+ FormsModule,
6088
+ DrTagModule
6089
+ ],
6090
+ exports: [...COMPONENTS],
6091
+ },] }
6092
+ ];
6093
+
5679
6094
  /* components */
5680
6095
 
5681
6096
  /**
5682
6097
  * Generated bundle index. Do not edit.
5683
6098
  */
5684
6099
 
5685
- export { AnyTagComponent, CHAT_MESSAGE_TYPE, CalendarView, ChatMessage, ChatRole, CheckboxComponent, CustomDateFormat, DIALOG_BUTTON_LABEL, DIALOG_FIELD_TYPE, DIALOG_SIZE, DateFromats, DatePickerPeriodPosition, DateTagComponent, DateTagModule, DateTags, DayTagComponent, DialogService, DrAccordionComponent, DrAccordionItemBodyComponent, DrAccordionItemComponent, DrAccordionItemHeaderComponent, DrAccordionModule, DrAvatarComponent, DrAvatarModule, DrAvatarPipe, DrButtonComponent, DrChatModule, DrDetailsListComponent, DrDetailsListModule, DrDialogModule, DrDropdownComponent, DrDropdownDirective, DrDropdownItemShowPipe, DrDropdownModule, DrDropdownPositionDirective, DrDropdownService, DrErrorComponent, DrErrorModule, DrInputComponent, DrInputsModule, DrLayoutBodyComponent, DrLayoutComponent, DrLayoutHeaderComponent, DrLayoutModule, DrModelDebounceChangeDirective, DrPopoverAlignmentDimension, DrPopoverComponent, DrPopoverDirective, DrPopoverModule, DrPopoverRef, DrPopoverService, DrSelectComponent, DrSharedUtils, DrSpinnerComponent, DrSpinnerDirective, DrSpinnerModule, DrStepperModule, DrTabComponent, DrTabsComponent, DrTabsModule, DrTagComponent, DrTagModule, DrToggleButtonComponent, DrToggleComponent, DrTooltipDirective, DrTooltipModule, ForecastTagComponent, IMAGE_TYPES, ListTagComponent, ListTagModule, MonthTagComponent, QuarterTagComponent, RadioButtonComponent, RadioGroupComponent, SpinnerSize, SpinnerType, TagTypes, TimeframeOption, ToggleButtonTheme, TooltipComponent, TooltipPosition, WeekTagComponent, YearTagComponent, components$2 as ɵa, POPUP_ANIMATION as ɵb, DrDatePickerComponent as ɵc, DrDatePickerService as ɵd, DrDatePickerWithTimeframeComponent as ɵe, DrDatePickerFormatDirective as ɵf, DrDatePickerCustomHeaderComponent as ɵg, DrShowTimeframePipe as ɵh, DrSelectAddItemComponent as ɵi, TooltipInfoComponent as ɵj, TooltipInfoSimpleComponent as ɵk, TooltipNoBodyComponent as ɵl, TooltipProcessDefaultComponent as ɵm, DrDynamicTagModule as ɵn, DrDynamicTagComponent as ɵo, StepperComponent as ɵp, DialogWrapperComponent as ɵq, DialogModalWrapperComponent as ɵr, DrChatComponent as ɵs, DrChatCustomMessageService as ɵt, DrChatMessageComponent as ɵu, DrChatFormComponent as ɵv, DrChatSuggestionsComponent as ɵw, DrChatMessageTextComponent as ɵx, DrChatMessageFileComponent as ɵy, DrChatCustomMessageDirective as ɵz };
6100
+ export { AnyTagComponent, CHAT_MESSAGE_TYPE, CalendarView, ChatMessage, ChatRole, CheckboxComponent, CustomDateFormat, DIALOG_BUTTON_LABEL, DIALOG_FIELD_TYPE, DIALOG_SIZE, DateFromats, DatePickerPeriodPosition, DateTagComponent, DateTagModule, DateTags, DayTagComponent, DialogService, DrAccordionComponent, DrAccordionItemBodyComponent, DrAccordionItemComponent, DrAccordionItemHeaderComponent, DrAccordionModule, DrAvatarComponent, DrAvatarModule, DrAvatarPipe, DrButtonComponent, DrChatModule, DrDetailsListComponent, DrDetailsListModule, DrDialogModule, DrDropdownComponent, DrDropdownDirective, DrDropdownItemShowPipe, DrDropdownModule, DrDropdownPositionDirective, DrDropdownService, DrErrorComponent, DrErrorModule, DrInputComponent, DrInputsModule, DrLayoutBodyComponent, DrLayoutComponent, DrLayoutHeaderComponent, DrLayoutModule, DrModelDebounceChangeDirective, DrPopoverAlignmentDimension, DrPopoverComponent, DrPopoverDirective, DrPopoverModule, DrPopoverRef, DrPopoverService, DrScenarioModule, DrSelectComponent, DrSharedUtils, DrSpinnerComponent, DrSpinnerDirective, DrSpinnerModule, DrStepperModule, DrTabComponent, DrTabsComponent, DrTabsModule, DrTagComponent, DrTagModule, DrToggleButtonComponent, DrToggleComponent, DrTooltipDirective, DrTooltipModule, ForecastTagComponent, IMAGE_TYPES, ListTagComponent, ListTagModule, MonthTagComponent, QuarterTagComponent, RadioButtonComponent, RadioGroupComponent, Scenario, ScenarioService, SpinnerSize, SpinnerType, TagTypes, TimeframeOption, ToggleButtonMode, TooltipComponent, TooltipPosition, WeekTagComponent, YearTagComponent, components$2 as ɵa, POPUP_ANIMATION as ɵb, DrScenarioConfigurationComponent as ɵba, DrScenarioTagConfigurationComponent as ɵbb, DrDatePickerComponent as ɵc, DrDatePickerService as ɵd, DrDatePickerWithTimeframeComponent as ɵe, DrDatePickerFormatDirective as ɵf, DrDatePickerCustomHeaderComponent as ɵg, DrShowTimeframePipe as ɵh, DrSelectAddItemComponent as ɵi, TooltipInfoComponent as ɵj, TooltipInfoSimpleComponent as ɵk, TooltipNoBodyComponent as ɵl, TooltipProcessDefaultComponent as ɵm, DrDynamicTagModule as ɵn, DrDynamicTagComponent as ɵo, StepperComponent as ɵp, DialogWrapperComponent as ɵq, DialogModalWrapperComponent as ɵr, DrChatComponent as ɵs, DrChatCustomMessageService as ɵt, DrChatMessageComponent as ɵu, DrChatFormComponent as ɵv, DrChatSuggestionsComponent as ɵw, DrChatMessageTextComponent as ɵx, DrChatMessageFileComponent as ɵy, DrChatCustomMessageDirective as ɵz };
5686
6101
  //# sourceMappingURL=datarailsshared-datarailsshared.js.map