@datarailsshared/datarailsshared 1.4.163-rocket → 1.4.164-rocket

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 (35) hide show
  1. package/bundles/datarailsshared-datarailsshared.umd.js +492 -28
  2. package/bundles/datarailsshared-datarailsshared.umd.js.map +1 -1
  3. package/datarailsshared-datarailsshared-1.4.164-rocket.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 +3 -8
  8. package/esm2015/lib/date-tags/month-tag/month-tag.component.js +3 -8
  9. package/esm2015/lib/date-tags/year-tag/year-tag.component.js +3 -8
  10. package/esm2015/lib/dr-inputs/dr-toggle-button/dr-toggle-button.component.js +8 -3
  11. package/esm2015/lib/dr-inputs/dr-toggle-button/toggle-button-theme.js +6 -0
  12. package/esm2015/lib/dr-scenario/components/dr-scenario-configuration/dr-scenario-configuration.component.js +87 -0
  13. package/esm2015/lib/dr-scenario/components/dr-scenario-tag-configuration/dr-scenario-tag-configuration.component.js +74 -0
  14. package/esm2015/lib/dr-scenario/consts/scenario-tags-config.js +73 -0
  15. package/esm2015/lib/dr-scenario/dr-scenario.module.js +28 -0
  16. package/esm2015/lib/dr-scenario/interfaces/scenario.js +8 -0
  17. package/esm2015/lib/dr-scenario/services/scenario.service.js +160 -0
  18. package/esm2015/lib/dr-tags/dr-tag.component.js +17 -5
  19. package/esm2015/lib/models/serverTags.js +13 -1
  20. package/esm2015/public-api.js +6 -1
  21. package/fesm2015/datarailsshared-datarailsshared.js +455 -29
  22. package/fesm2015/datarailsshared-datarailsshared.js.map +1 -1
  23. package/lib/dr-inputs/dr-toggle-button/dr-toggle-button.component.d.ts +3 -0
  24. package/lib/dr-inputs/dr-toggle-button/toggle-button-theme.d.ts +4 -0
  25. package/lib/dr-scenario/components/dr-scenario-configuration/dr-scenario-configuration.component.d.ts +25 -0
  26. package/lib/dr-scenario/components/dr-scenario-tag-configuration/dr-scenario-tag-configuration.component.d.ts +26 -0
  27. package/lib/dr-scenario/consts/scenario-tags-config.d.ts +24 -0
  28. package/lib/dr-scenario/dr-scenario.module.d.ts +2 -0
  29. package/lib/dr-scenario/interfaces/scenario.d.ts +43 -0
  30. package/lib/dr-scenario/services/scenario.service.d.ts +21 -0
  31. package/lib/dr-tags/dr-tag.component.d.ts +7 -3
  32. package/lib/models/serverTags.d.ts +15 -1
  33. package/package.json +1 -1
  34. package/public-api.d.ts +5 -1
  35. package/datarailsshared-datarailsshared-1.4.163-rocket.tgz +0 -0
@@ -3,7 +3,7 @@ import { EventEmitter, Component, ViewEncapsulation, Input, Output, HostBinding,
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 { some, find, map, merge, forEach, 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,13 +265,8 @@ class MonthTagComponent extends AnyTagComponent {
265
265
  return this.date ? !this.dateFilter(moment$7.unix(this.date).utc()) : false;
266
266
  }
267
267
  initDate() {
268
- if (this.defaultValue) {
269
- this.date = this.defaultValue;
270
- this.dateObj.date = this.date;
271
- }
272
- else {
273
- this.dateObj.date = moment$7().unix();
274
- }
268
+ this.date = this.defaultValue || moment$7().unix();
269
+ this.dateObj.date = this.date;
275
270
  }
276
271
  initName() {
277
272
  if (!this.name) {
@@ -527,13 +522,8 @@ class YearTagComponent extends AnyTagComponent {
527
522
  return this.date ? !this.dateFilter(moment$4.unix(this.date).utc()) : false;
528
523
  }
529
524
  initDate() {
530
- if (this.defaultValue) {
531
- this.date = this.defaultValue;
532
- this.dateObj.date = this.date;
533
- }
534
- else {
535
- this.dateObj.date = moment$4().unix();
536
- }
525
+ this.date = this.defaultValue || moment$4().unix();
526
+ this.dateObj.date = this.date;
537
527
  }
538
528
  initName() {
539
529
  if (!this.name) {
@@ -589,29 +579,48 @@ var TagTypes;
589
579
  TagTypes["LIST"] = "LIST";
590
580
  TagTypes["DATE"] = "DATE";
591
581
  })(TagTypes || (TagTypes = {}));
582
+ var TagsConfigSubType;
583
+ (function (TagsConfigSubType) {
584
+ TagsConfigSubType["YEAR"] = "year";
585
+ TagsConfigSubType["PLAN"] = "plan";
586
+ TagsConfigSubType["BUDGET_CYCLE"] = "budget cycle";
587
+ TagsConfigSubType["MONTH"] = "month";
588
+ TagsConfigSubType["WEEK"] = "week";
589
+ TagsConfigSubType["DAY"] = "day";
590
+ TagsConfigSubType["FORECAST_NEW"] = "forecast_new";
591
+ TagsConfigSubType["QUARTER"] = "quarter";
592
+ TagsConfigSubType["FILE_STATUS"] = "file_status";
593
+ })(TagsConfigSubType || (TagsConfigSubType = {}));
592
594
 
593
595
  class DrTagComponent {
594
596
  constructor() {
595
597
  this.lockedDate = [];
596
598
  this.dynamicTagValues = {};
597
- this.connectedTags = [];
598
599
  this.tagChange = new EventEmitter(); // Not emit value for dynamic tag
599
600
  this.dynamicTagChange = new EventEmitter();
600
601
  this.dynamicTagAdd = new EventEmitter();
601
602
  this.currentTagConnectedToDynamic = false;
602
603
  this.tagTypes = TagTypes;
603
604
  this.connectedTagsValues = [];
605
+ this._connectedTags = [];
604
606
  this.selectedTag = {
605
607
  id: 0,
606
608
  value: undefined,
607
609
  name: ''
608
610
  };
609
611
  }
612
+ set connectedTags(tags) {
613
+ this._connectedTags = tags || [];
614
+ }
615
+ get connectedTags() {
616
+ return this._connectedTags;
617
+ }
618
+ ngOnChanges() {
619
+ this.calculateDynamicTag();
620
+ }
610
621
  ngOnInit() {
611
622
  var _a, _b;
612
- this.currentTagDynamic = this.tagConfig.options.is_custom;
613
- this.currentTagConnectedToDynamic = some(this.tagsConfig, (tagConfig) => tagConfig.options.is_custom
614
- && ['year'].includes(this.tagConfig.options.sub_type));
623
+ this.calculateDynamicTag();
615
624
  this.dateTag = {
616
625
  type: this.tagConfig.type,
617
626
  sub_type: this.tagConfig.options.sub_type,
@@ -725,6 +734,11 @@ class DrTagComponent {
725
734
  }
726
735
  });
727
736
  }
737
+ calculateDynamicTag() {
738
+ this.currentTagDynamic = this.tagConfig.options.is_custom;
739
+ this.currentTagConnectedToDynamic = some(this.tagsConfig, (tagConfig) => tagConfig.options.is_custom
740
+ && ['year'].includes(this.tagConfig.options.sub_type));
741
+ }
728
742
  }
729
743
  DrTagComponent.decorators = [
730
744
  { type: Component, args: [{
@@ -810,13 +824,8 @@ class DayTagComponent extends AnyTagComponent {
810
824
  return this.date ? !this.dateFilter(moment$3.unix(this.date).utc()) : false;
811
825
  }
812
826
  initDate() {
813
- if (this.defaultValue) {
814
- this.date = this.defaultValue;
815
- this.dateObj.date = this.date;
816
- }
817
- else {
818
- this.dateObj.date = moment$3().unix();
819
- }
827
+ this.date = this.defaultValue || moment$3().unix();
828
+ this.dateObj.date = this.date;
820
829
  }
821
830
  initName() {
822
831
  if (!this.name) {
@@ -1931,12 +1940,20 @@ DrToggleComponent.propDecorators = {
1931
1940
  elementClass: [{ type: HostBinding, args: ['class',] }]
1932
1941
  };
1933
1942
 
1943
+ var ToggleButtonTheme;
1944
+ (function (ToggleButtonTheme) {
1945
+ ToggleButtonTheme["DEFAULT"] = "default";
1946
+ ToggleButtonTheme["DOTTED"] = "dotted";
1947
+ })(ToggleButtonTheme || (ToggleButtonTheme = {}));
1948
+
1934
1949
  class DrToggleButtonComponent {
1935
1950
  constructor(cdr) {
1936
1951
  this.cdr = cdr;
1937
1952
  this._disabled = false;
1938
1953
  this.bindLabel = null;
1939
1954
  this.bindValue = null;
1955
+ this.bindHidden = null;
1956
+ this.theme = ToggleButtonTheme.DEFAULT;
1940
1957
  this.onChange = () => {
1941
1958
  };
1942
1959
  this.onTouched = () => {
@@ -1968,12 +1985,12 @@ class DrToggleButtonComponent {
1968
1985
  DrToggleButtonComponent.decorators = [
1969
1986
  { type: Component, args: [{
1970
1987
  selector: 'dr-toggle-button',
1971
- template: "<div class=\"toggle-container\" [class.disabled]=\"_disabled\">\n <div\n *ngFor=\"let item of items\"\n (click)=\"setValue(item)\"\n [class.selected]=\"item[bindValue] === selectedValue || item === selectedValue\"\n [class.disabled]=\"item.disabled\"\n class=\"toggle-container__item\"\n >\n {{ item[bindLabel] || item.name || item }}\n </div>\n</div>\n",
1988
+ 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",
1972
1989
  providers: [
1973
1990
  { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => DrToggleButtonComponent), multi: true }
1974
1991
  ],
1975
1992
  changeDetection: ChangeDetectionStrategy.OnPush,
1976
- styles: [".toggle-container{display:flex;flex-wrap:nowrap;background:#f6f7f8;border:1px solid #c3c4ce;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{font-weight:400;background:#f2f2fb;border:1px solid #7f7fdd;color:#25258c}.toggle-container__item.disabled{pointer-events:none;cursor:default;background:#f0f1f4;color:#9ea1aa;border:1px solid #c3c4ce}\n"]
1993
+ 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"]
1977
1994
  },] }
1978
1995
  ];
1979
1996
  DrToggleButtonComponent.ctorParameters = () => [
@@ -1983,6 +2000,8 @@ DrToggleButtonComponent.propDecorators = {
1983
2000
  items: [{ type: Input }],
1984
2001
  bindLabel: [{ type: Input }],
1985
2002
  bindValue: [{ type: Input }],
2003
+ bindHidden: [{ type: Input }],
2004
+ theme: [{ type: Input }],
1986
2005
  selectedValue: [{ type: Input }],
1987
2006
  disabled: [{ type: Input }]
1988
2007
  };
@@ -3576,6 +3595,14 @@ var TooltipPosition;
3576
3595
  TooltipPosition["LEFT_BOTTOM"] = "left-bottom";
3577
3596
  })(TooltipPosition || (TooltipPosition = {}));
3578
3597
 
3598
+ var Scenario;
3599
+ (function (Scenario) {
3600
+ Scenario["ACTUALS"] = "Actuals";
3601
+ Scenario["FORECAST"] = "Forecast";
3602
+ Scenario["BUDGET"] = "Budget";
3603
+ Scenario["NONE"] = "None";
3604
+ })(Scenario || (Scenario = {}));
3605
+
3579
3606
  class DrModelDebounceChangeDirective {
3580
3607
  constructor(ngModel) {
3581
3608
  this.ngModel = ngModel;
@@ -3638,6 +3665,232 @@ class ChatMessage {
3638
3665
  }
3639
3666
  }
3640
3667
 
3668
+ const allDateTags = {
3669
+ [TagsConfigSubType.YEAR]: {
3670
+ name: 'Date',
3671
+ toggle: false,
3672
+ },
3673
+ [TagsConfigSubType.QUARTER]: {
3674
+ name: 'Date',
3675
+ toggle: false,
3676
+ },
3677
+ [TagsConfigSubType.MONTH]: {
3678
+ name: 'Date',
3679
+ toggle: false,
3680
+ },
3681
+ [TagsConfigSubType.DAY]: {
3682
+ name: 'Date',
3683
+ toggle: false,
3684
+ },
3685
+ [TagsConfigSubType.WEEK]: {
3686
+ name: 'Date',
3687
+ toggle: false,
3688
+ }
3689
+ };
3690
+ function getScenarioTagDataConfig(isMultipleDimension) {
3691
+ return {
3692
+ [Scenario.ACTUALS]: Object.assign(Object.assign({}, allDateTags), { [TagsConfigSubType.MONTH]: {
3693
+ name: 'Date',
3694
+ toggle: true,
3695
+ }, [TagsConfigSubType.FILE_STATUS]: {
3696
+ toggle: false,
3697
+ } }),
3698
+ [Scenario.BUDGET]: {
3699
+ [TagsConfigSubType.BUDGET_CYCLE]: {
3700
+ toggle: true,
3701
+ acceptableDateTags: [TagsConfigSubType.YEAR],
3702
+ hidden: !isMultipleDimension,
3703
+ },
3704
+ [TagsConfigSubType.PLAN]: {
3705
+ toggle: false,
3706
+ turnOffDateTags: true,
3707
+ hidden: isMultipleDimension,
3708
+ },
3709
+ [TagsConfigSubType.YEAR]: {
3710
+ name: 'Date',
3711
+ toggle: true,
3712
+ },
3713
+ [TagsConfigSubType.QUARTER]: {
3714
+ name: 'Date',
3715
+ toggle: false,
3716
+ },
3717
+ [TagsConfigSubType.FILE_STATUS]: {
3718
+ toggle: false,
3719
+ },
3720
+ },
3721
+ [Scenario.FORECAST]: {
3722
+ [TagsConfigSubType.FORECAST_NEW]: {
3723
+ toggle: true,
3724
+ name: 'Date',
3725
+ },
3726
+ [TagsConfigSubType.FILE_STATUS]: {
3727
+ toggle: false,
3728
+ },
3729
+ },
3730
+ [Scenario.NONE]: Object.assign(Object.assign({}, allDateTags), { [TagsConfigSubType.MONTH]: {
3731
+ name: 'Date',
3732
+ toggle: true,
3733
+ }, [TagsConfigSubType.FILE_STATUS]: {
3734
+ toggle: true,
3735
+ } }),
3736
+ };
3737
+ }
3738
+
3739
+ class ScenarioService {
3740
+ constructor() {
3741
+ this.DEFAULT_FORECAST_DATE_TAG = 'Month';
3742
+ }
3743
+ get scenarios() {
3744
+ return orderBy(Object.values(Scenario), (scenario) => scenario === Scenario.NONE ? 1 : 0);
3745
+ }
3746
+ get areExistingTagsConfig() {
3747
+ return !!this.currentTagsConfig;
3748
+ }
3749
+ initScenarioTags(scenario, wholeTagsConfig, currentTagsConfig, isMultipleDimension = true) {
3750
+ if (!(wholeTagsConfig === null || wholeTagsConfig === void 0 ? void 0 : wholeTagsConfig.length) || !scenario)
3751
+ return;
3752
+ this.wholeTagsConfig = wholeTagsConfig;
3753
+ this.currentTagsConfig = currentTagsConfig;
3754
+ this.isMultipleDimension = isMultipleDimension;
3755
+ }
3756
+ getTagsConfigByScenarioTags(scenarioTags, tagsConfig) {
3757
+ const scenarioTagsConfig = filter$1(tagsConfig, (tagConfig) => some(scenarioTags, (scenarioTag) => scenarioTag.toggle && scenarioTag.selectedTagSubType === tagConfig.options.sub_type));
3758
+ return this.sortScenarioTags(scenarioTagsConfig);
3759
+ }
3760
+ getScenarioTagsByScenario(scenario) {
3761
+ const scenarioTagsConfig = this.getScenarioTagsConfig(scenario, this.wholeTagsConfig);
3762
+ const scenarioTagsUi = [];
3763
+ forEach(scenarioTagsConfig, (scenarioTag) => {
3764
+ const isDateTag = scenarioTag.type === TagTypes.DATE;
3765
+ const dateTag = isDateTag && find(scenarioTagsUi, { type: TagTypes.DATE });
3766
+ const tag = dateTag || this.prepareScenarioTag(scenarioTagsConfig, scenarioTag, scenario, isDateTag);
3767
+ if (isDateTag) {
3768
+ this.updateScenarioDateTag(tag, scenarioTag);
3769
+ }
3770
+ if (dateTag)
3771
+ return;
3772
+ scenarioTagsUi.push(tag);
3773
+ });
3774
+ if (this.areExistingTagsConfig) {
3775
+ this.initExistingTagsConfig(scenario, scenarioTagsUi);
3776
+ }
3777
+ const isTagNotSupportingDates = some(scenarioTagsUi, { turnOffDateTags: true, toggle: true });
3778
+ if (isTagNotSupportingDates) {
3779
+ this.turnOffDateTag(scenarioTagsUi);
3780
+ }
3781
+ const tagWithSpecificDateTags = find(scenarioTagsUi, (tag) => { var _a; return tag.toggle && !!((_a = tag.acceptableDateTags) === null || _a === void 0 ? void 0 : _a.length); });
3782
+ if (tagWithSpecificDateTags) {
3783
+ this.hideNotAvailableTags(tagWithSpecificDateTags, scenarioTagsUi);
3784
+ }
3785
+ return this.sortScenarioTags(scenarioTagsUi);
3786
+ }
3787
+ sortScenarioTags(scenarioTagsUi) {
3788
+ return orderBy(scenarioTagsUi, [
3789
+ (tag) => (tag.type === TagTypes.DATE ? 0 : 1),
3790
+ (tag) => (tag.name === 'File Status')
3791
+ ]);
3792
+ }
3793
+ initExistingTagsConfig(scenario, scenarioTagsUi) {
3794
+ forEach(this.currentTagsConfig, (tagConfig) => {
3795
+ var _a, _b;
3796
+ const tagSubType = (_a = tagConfig === null || tagConfig === void 0 ? void 0 : tagConfig.options) === null || _a === void 0 ? void 0 : _a.sub_type;
3797
+ const scenarioTagDataConfig = getScenarioTagDataConfig(this.isMultipleDimension);
3798
+ if (!((_b = scenarioTagDataConfig === null || scenarioTagDataConfig === void 0 ? void 0 : scenarioTagDataConfig[scenario]) === null || _b === void 0 ? void 0 : _b[tagSubType]))
3799
+ return;
3800
+ const scenarioTagUi = tagConfig.type === TagTypes.DATE
3801
+ ? find(scenarioTagsUi, { type: tagConfig.type })
3802
+ : find(scenarioTagsUi, { selectedTagSubType: tagSubType });
3803
+ scenarioTagUi.toggle = true;
3804
+ scenarioTagUi.selectedTagSubType = tagSubType;
3805
+ });
3806
+ }
3807
+ prepareScenarioTag(scenarioTagsConfig, scenarioTag, scenario, isDateTag) {
3808
+ const toggleStatus = isDateTag
3809
+ ? some(scenarioTagsConfig, (tag) => tag.type === TagTypes.DATE && tag.scenarioData.toggle)
3810
+ : scenarioTag.scenarioData.toggle;
3811
+ const selectedTagSubType = isDateTag
3812
+ ? this.getScenarioSelectedDateTag(scenario, scenarioTagsConfig)
3813
+ : scenarioTag.options.sub_type;
3814
+ const tag = {
3815
+ toggle: this.areExistingTagsConfig ? false : toggleStatus,
3816
+ name: scenarioTag.scenarioData.name || scenarioTag.name,
3817
+ description: scenarioTag.scenarioData.description || scenarioTag.description,
3818
+ type: scenarioTag.type,
3819
+ selectedTagSubType,
3820
+ };
3821
+ if (scenarioTag.scenarioData.turnOffDateTags) {
3822
+ tag.turnOffDateTags = scenarioTag.scenarioData.turnOffDateTags;
3823
+ }
3824
+ if (scenarioTag.scenarioData.acceptableDateTags) {
3825
+ tag.acceptableDateTags = scenarioTag.scenarioData.acceptableDateTags;
3826
+ }
3827
+ return tag;
3828
+ }
3829
+ updateScenarioDateTag(dateTag, scenarioTag) {
3830
+ if (!dateTag.subTags) {
3831
+ dateTag.subTags = [];
3832
+ }
3833
+ const tagSubType = scenarioTag.options.sub_type;
3834
+ dateTag.subTags.push({
3835
+ subType: tagSubType,
3836
+ name: tagSubType === TagsConfigSubType.FORECAST_NEW ? this.DEFAULT_FORECAST_DATE_TAG : scenarioTag.name,
3837
+ });
3838
+ }
3839
+ turnOffDateTag(scenarioTags) {
3840
+ const dateTag = find(scenarioTags, { type: TagTypes.DATE });
3841
+ if (!dateTag)
3842
+ return;
3843
+ dateTag.toggle = false;
3844
+ }
3845
+ hideNotAvailableTags(tagWithSpecificDateTags, scenarioTags) {
3846
+ var _a;
3847
+ const subTags = (_a = find(scenarioTags, { type: TagTypes.DATE })) === null || _a === void 0 ? void 0 : _a.subTags;
3848
+ if (!subTags.length)
3849
+ return;
3850
+ forEach(scenarioTags, (tag) => {
3851
+ var _a;
3852
+ if (!((_a = tag.acceptableDateTags) === null || _a === void 0 ? void 0 : _a.length))
3853
+ return;
3854
+ if (tag !== tagWithSpecificDateTags) {
3855
+ tag.toggle = false;
3856
+ }
3857
+ });
3858
+ forEach(subTags, (subTag) => {
3859
+ subTag.hidden = !tagWithSpecificDateTags.acceptableDateTags.includes(subTag.subType);
3860
+ });
3861
+ }
3862
+ getScenarioSelectedDateTag(scenario, dateTags) {
3863
+ var _a, _b;
3864
+ 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;
3865
+ const scenarioSelectedDateTag = {
3866
+ [Scenario.ACTUALS]: () => monthSubType,
3867
+ [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; },
3868
+ [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; },
3869
+ [Scenario.NONE]: () => monthSubType,
3870
+ };
3871
+ if (!scenarioSelectedDateTag[scenario])
3872
+ return;
3873
+ return scenarioSelectedDateTag[scenario]();
3874
+ }
3875
+ getScenarioTagsConfig(scenario, tagsConfig) {
3876
+ return reduce(tagsConfig, (acc, tagConfig) => {
3877
+ var _a, _b;
3878
+ const tagSubType = (_a = tagConfig === null || tagConfig === void 0 ? void 0 : tagConfig.options) === null || _a === void 0 ? void 0 : _a.sub_type;
3879
+ const scenarioTagDataConfig = getScenarioTagDataConfig(this.isMultipleDimension);
3880
+ const scenarioTagConfig = (_b = scenarioTagDataConfig === null || scenarioTagDataConfig === void 0 ? void 0 : scenarioTagDataConfig[scenario]) === null || _b === void 0 ? void 0 : _b[tagSubType];
3881
+ if (!scenarioTagConfig || scenarioTagConfig.hidden)
3882
+ return acc;
3883
+ const clonedTagConfig = cloneDeep(tagConfig);
3884
+ const scenarioTag = Object.assign(Object.assign({}, clonedTagConfig), { scenarioData: scenarioTagConfig });
3885
+ acc.push(scenarioTag);
3886
+ return acc;
3887
+ }, []);
3888
+ }
3889
+ }
3890
+ ScenarioService.decorators = [
3891
+ { type: Injectable }
3892
+ ];
3893
+
3641
3894
  class DrSharedUtils {
3642
3895
  /**
3643
3896
  * Get timeframe (day, year, month, quarter) based on passed format
@@ -5650,11 +5903,184 @@ DrChatModule.decorators = [
5650
5903
  },] }
5651
5904
  ];
5652
5905
 
5906
+ class DrScenarioConfigurationComponent {
5907
+ constructor(scenarioService) {
5908
+ this.scenarioService = scenarioService;
5909
+ this.toggleButtonTheme = ToggleButtonTheme;
5910
+ this._scenarioTags = [];
5911
+ this.wholeTagsConfig = [];
5912
+ this.selectedScenario = Scenario.ACTUALS;
5913
+ this.scenarioDataChanged = new EventEmitter();
5914
+ }
5915
+ get scenarioTags() {
5916
+ return this._scenarioTags;
5917
+ }
5918
+ set scenarioTags(tags) {
5919
+ this._scenarioTags = tags;
5920
+ this.tagNotSupportingDates = find(tags, { turnOffDateTags: true });
5921
+ }
5922
+ ngOnInit() {
5923
+ this.scenarios = this.scenarioService.scenarios;
5924
+ this.scenarioService.initScenarioTags(this.selectedScenario, this.wholeTagsConfig, this.currentTagsConfig);
5925
+ this.scenarioTags = this.scenarioService.getScenarioTagsByScenario(this.selectedScenario);
5926
+ }
5927
+ onScenarioChange(scenario) {
5928
+ this.scenarioTags = this.scenarioService.getScenarioTagsByScenario(scenario);
5929
+ this.onScenarioDataChange();
5930
+ }
5931
+ onScenarioTagToggle(tag) {
5932
+ this.tagNotSupportingDatesHandler(tag);
5933
+ this.tagAcceptableDateHandler(tag);
5934
+ this.onScenarioDataChange();
5935
+ }
5936
+ onScenarioDataChange() {
5937
+ this.scenarioDataChanged.emit({
5938
+ scenario: this.selectedScenario,
5939
+ tagsConfig: this.scenarioService.getTagsConfigByScenarioTags(this.scenarioTags, this.wholeTagsConfig),
5940
+ });
5941
+ }
5942
+ tagNotSupportingDatesHandler(tag) {
5943
+ if (!this.tagNotSupportingDates || !tag.toggle)
5944
+ return;
5945
+ if (tag.type === TagTypes.DATE) {
5946
+ this.tagNotSupportingDates.toggle = false;
5947
+ }
5948
+ if (tag === this.tagNotSupportingDates) {
5949
+ const dateTag = find(this.scenarioTags, { type: TagTypes.DATE });
5950
+ if (dateTag) {
5951
+ dateTag.toggle = false;
5952
+ }
5953
+ }
5954
+ }
5955
+ tagAcceptableDateHandler(tag) {
5956
+ var _a;
5957
+ if (!((_a = tag.acceptableDateTags) === null || _a === void 0 ? void 0 : _a.length))
5958
+ return;
5959
+ const dateTag = find(this.scenarioTags, { type: TagTypes.DATE });
5960
+ if (!dateTag)
5961
+ return;
5962
+ dateTag.subTags = map(dateTag.subTags, (subTag) => {
5963
+ subTag.hidden = tag.toggle && !includes(tag.acceptableDateTags, subTag.subType);
5964
+ return subTag;
5965
+ });
5966
+ dateTag.selectedTagSubType = tag.acceptableDateTags[0];
5967
+ }
5968
+ }
5969
+ DrScenarioConfigurationComponent.decorators = [
5970
+ { type: Component, args: [{
5971
+ selector: 'dr-scenario-configuration',
5972
+ 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 [theme]=\"toggleButtonTheme.DOTTED\"\n (ngModelChange)=\"onScenarioDataChange()\"></dr-toggle-button>\n </div>\n </div>\n </div>\n </div>\n</div>\n",
5973
+ changeDetection: ChangeDetectionStrategy.OnPush,
5974
+ 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"]
5975
+ },] }
5976
+ ];
5977
+ DrScenarioConfigurationComponent.ctorParameters = () => [
5978
+ { type: ScenarioService }
5979
+ ];
5980
+ DrScenarioConfigurationComponent.propDecorators = {
5981
+ currentTagsConfig: [{ type: Input }],
5982
+ wholeTagsConfig: [{ type: Input }],
5983
+ selectedScenario: [{ type: Input }],
5984
+ scenarioDataChanged: [{ type: Output }]
5985
+ };
5986
+
5987
+ class DrScenarioTagConfigurationComponent {
5988
+ constructor() {
5989
+ this.connectedTags = {};
5990
+ this.dynamicTagValues = {};
5991
+ this.lockedDates = [];
5992
+ this.scenarioTagDataChanged = new EventEmitter();
5993
+ this.currentTagsMap = {};
5994
+ this._currentTags = [];
5995
+ this.dynamicTagsToSave = [];
5996
+ this.tagsToSave = [];
5997
+ }
5998
+ set currentTags(tags) {
5999
+ this._currentTags = tags;
6000
+ this.currentTagsMap = reduce(tags, (acc, curr) => {
6001
+ var _a;
6002
+ const tagId = (_a = find(this.tagsConfig, { name: curr.name })) === null || _a === void 0 ? void 0 : _a.id;
6003
+ if (isNaN(tagId))
6004
+ return acc;
6005
+ acc[tagId] = curr;
6006
+ return acc;
6007
+ }, {});
6008
+ }
6009
+ get currentTags() {
6010
+ return this._currentTags;
6011
+ }
6012
+ ngOnChanges(simpleChanges) {
6013
+ this.currentTags = this.currentTags;
6014
+ }
6015
+ onTagChange($event) {
6016
+ const savedTag = find(this.tagsToSave, { id: $event.id });
6017
+ if (savedTag) {
6018
+ merge(savedTag, $event);
6019
+ }
6020
+ else {
6021
+ this.tagsToSave.push($event);
6022
+ }
6023
+ this.onScenarioTagDataChanged();
6024
+ }
6025
+ onDynamicTagsChange($event) {
6026
+ this.dynamicTagsToSave = $event;
6027
+ this.onScenarioTagDataChanged();
6028
+ }
6029
+ onScenarioTagDataChanged() {
6030
+ const tags = [...this.dynamicTagsToSave, ...this.tagsToSave];
6031
+ this.scenarioTagDataChanged.emit({
6032
+ scenario: this.scenario,
6033
+ tagsConfig: this.tagsConfig,
6034
+ tags,
6035
+ });
6036
+ }
6037
+ }
6038
+ DrScenarioTagConfigurationComponent.decorators = [
6039
+ { type: Component, args: [{
6040
+ selector: 'dr-scenario-tag-configuration',
6041
+ 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",
6042
+ changeDetection: ChangeDetectionStrategy.OnPush,
6043
+ styles: [".scenario-tag-configuration{margin-bottom:24px}.scenario-tag-configuration:last-child{margin-bottom:0}:host::ng-deep .tag__label,:host::ng-deep .dynamic-tag__label{font-weight:600!important}\n"]
6044
+ },] }
6045
+ ];
6046
+ DrScenarioTagConfigurationComponent.propDecorators = {
6047
+ tagsConfig: [{ type: Input }],
6048
+ currentTags: [{ type: Input }],
6049
+ scenario: [{ type: Input }],
6050
+ connectedTags: [{ type: Input }],
6051
+ dynamicTagValues: [{ type: Input }],
6052
+ lockedDates: [{ type: Input }],
6053
+ fiscalYearStartsFrom: [{ type: Input }],
6054
+ fiscalYearBack: [{ type: Input }],
6055
+ isDynamicAddEnabled: [{ type: Input }],
6056
+ scenarioTagDataChanged: [{ type: Output }]
6057
+ };
6058
+
6059
+ const COMPONENTS = [
6060
+ DrScenarioConfigurationComponent,
6061
+ DrScenarioTagConfigurationComponent,
6062
+ ];
6063
+ class DrScenarioModule {
6064
+ }
6065
+ DrScenarioModule.decorators = [
6066
+ { type: NgModule, args: [{
6067
+ declarations: [...COMPONENTS],
6068
+ providers: [ScenarioService],
6069
+ imports: [
6070
+ CommonModule,
6071
+ DrInputsModule,
6072
+ FormsModule,
6073
+ DrTagModule
6074
+ ],
6075
+ exports: [...COMPONENTS],
6076
+ },] }
6077
+ ];
6078
+
5653
6079
  /* components */
5654
6080
 
5655
6081
  /**
5656
6082
  * Generated bundle index. Do not edit.
5657
6083
  */
5658
6084
 
5659
- 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, 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 };
6085
+ 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, ToggleButtonTheme, 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 };
5660
6086
  //# sourceMappingURL=datarailsshared-datarailsshared.js.map