@datarailsshared/datarailsshared 1.4.519 → 1.4.537

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.
@@ -416,13 +416,97 @@
416
416
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
417
417
  }
418
418
 
419
+ exports.DateFromats = void 0;
420
+ (function (DateFromats) {
421
+ DateFromats["MAT_DEFAULT_DATE_FORMAT"] = "MM/DD/yyyy";
422
+ DateFromats["DATE_INPUT_FORMAT"] = "YYYY/MM/DD";
423
+ DateFromats["YEAR_FORMAT"] = "yyyy";
424
+ DateFromats["MONTH_YEAR_FORMAT"] = "MM/yyyy";
425
+ DateFromats["QUARTER_FORMAT"] = "Q/yyyy";
426
+ DateFromats["WEEK_FORMAT"] = "w/yyyy";
427
+ })(exports.DateFromats || (exports.DateFromats = {}));
428
+ var CustomDateFormat = /** @class */ (function () {
429
+ function CustomDateFormat() {
430
+ this._parse = {
431
+ dateInput: exports.DateFromats.DATE_INPUT_FORMAT,
432
+ };
433
+ this._display = {
434
+ dateInput: exports.DateFromats.DATE_INPUT_FORMAT,
435
+ monthYearLabel: 'MMM YYYY',
436
+ dateA11yLabel: 'LL',
437
+ monthYearA11yLabel: 'MMM YYYY',
438
+ quarterYearLabel: 'Q/YYYY',
439
+ yearLabel: 'YYYY'
440
+ };
441
+ }
442
+ Object.defineProperty(CustomDateFormat.prototype, "parse", {
443
+ get: function () {
444
+ return this._parse;
445
+ },
446
+ set: function (parse) {
447
+ this._parse = Object.assign({}, this._parse, parse);
448
+ },
449
+ enumerable: false,
450
+ configurable: true
451
+ });
452
+ Object.defineProperty(CustomDateFormat.prototype, "display", {
453
+ get: function () {
454
+ return this._display;
455
+ },
456
+ set: function (display) {
457
+ this._display = Object.assign({}, this._display, display);
458
+ },
459
+ enumerable: false,
460
+ configurable: true
461
+ });
462
+ CustomDateFormat.prototype.updateDateFormat = function (parse, display) {
463
+ this.parse = parse;
464
+ if (!display) {
465
+ display = parse;
466
+ }
467
+ this.display = display;
468
+ };
469
+ return CustomDateFormat;
470
+ }());
471
+ exports.DatePickerPeriodPosition = void 0;
472
+ (function (DatePickerPeriodPosition) {
473
+ DatePickerPeriodPosition[DatePickerPeriodPosition["END_OF_PERIOD"] = 0] = "END_OF_PERIOD";
474
+ DatePickerPeriodPosition[DatePickerPeriodPosition["MIDDLE_OF_PERIOD"] = 1] = "MIDDLE_OF_PERIOD";
475
+ DatePickerPeriodPosition[DatePickerPeriodPosition["START_OF_PERIOD"] = 2] = "START_OF_PERIOD";
476
+ DatePickerPeriodPosition[DatePickerPeriodPosition["DEFAULT"] = 3] = "DEFAULT";
477
+ })(exports.DatePickerPeriodPosition || (exports.DatePickerPeriodPosition = {}));
478
+ exports.TimeframeOption = void 0;
479
+ (function (TimeframeOption) {
480
+ TimeframeOption["DAY"] = "day";
481
+ TimeframeOption["MONTH"] = "month";
482
+ TimeframeOption["QUARTER"] = "quarter";
483
+ TimeframeOption["WEEK"] = "week";
484
+ TimeframeOption["YEAR"] = "year";
485
+ })(exports.TimeframeOption || (exports.TimeframeOption = {}));
486
+ exports.CalendarView = void 0;
487
+ (function (CalendarView) {
488
+ CalendarView["FOR_DAYS"] = "month";
489
+ CalendarView["FOR_MONTHS"] = "year";
490
+ CalendarView["FOR_QUARTERS"] = "none";
491
+ CalendarView["FOR_YEARS"] = "multi-year";
492
+ })(exports.CalendarView || (exports.CalendarView = {}));
493
+ exports.DateTags = void 0;
494
+ (function (DateTags) {
495
+ DateTags["TODAY"] = "today";
496
+ DateTags["YESTERDAY"] = "yesterday";
497
+ DateTags["THIS_MONTH"] = "this_month";
498
+ DateTags["PREV_MONTH"] = "prev_month";
499
+ })(exports.DateTags || (exports.DateTags = {}));
500
+
419
501
  /* BEFORE MERGE INTO MASTER YOU MUST CONSULT WITH ARTEM LAZIUK !!!*/
420
502
  // @ts-ignore
421
503
  var moment$9 = require('moment');
504
+ var FORECAST_DEFAULT_DATE_FORMAT = 'MM/DD/yyyy';
422
505
  var ForecastTagComponent = /** @class */ (function (_super) {
423
506
  __extends(ForecastTagComponent, _super);
424
507
  function ForecastTagComponent() {
425
508
  var _this = _super.call(this) || this;
509
+ _this.datePickerPeriodPosition = exports.DatePickerPeriodPosition;
426
510
  _this.lockedDate = [];
427
511
  _this.tagAdditionalSettings = {};
428
512
  _this.forecastValue = undefined;
@@ -442,6 +526,7 @@
442
526
  { value: 11, label: '11+1', disabled: false }
443
527
  ];
444
528
  _this.initDateValue = null;
529
+ _this.firstDayMonthOfYear = '01';
445
530
  return _this;
446
531
  }
447
532
  ForecastTagComponent.prototype.ngOnChanges = function (changes) {
@@ -453,22 +538,18 @@
453
538
  var dateVal = this.defaultValue ? moment$9.unix(this.defaultValue) : moment$9();
454
539
  var fiscal_year_starts_from = this.fiscalYearStartsFrom || 1;
455
540
  this.forecastValue = this.getFiscalMonthFromDate(dateVal, fiscal_year_starts_from) - 1;
456
- this.updateYear(dateVal.year(), this.forecastValue);
541
+ this.forecastYear = moment$9
542
+ .utc(this.firstDayMonthOfYear + "/" + this.firstDayMonthOfYear + "/" + this.getFiscalYearFromDate(dateVal, fiscal_year_starts_from, this.fiscalYearBack), FORECAST_DEFAULT_DATE_FORMAT)
543
+ .set('hours', 12)
544
+ .unix();
457
545
  this.updateLockedDate();
458
546
  if (!this.initDateValue) {
459
547
  this.initDateValue = _.cloneDeep(this.dateObj.date);
460
548
  }
461
549
  };
462
- ForecastTagComponent.prototype.updateYear = function (fiscalYear, month) {
463
- var DATE_TIME = '12:00:00';
464
- var MONTH_DIFF = 1;
465
- this.dateObj.date = fiscalYear
466
- ? moment$9.utc((month + MONTH_DIFF || '01') + "/01/" + fiscalYear + " " + DATE_TIME, 'MM/DD/YYYY hh:mm:ss').unix()
467
- : moment$9.utc().unix();
468
- };
469
550
  ForecastTagComponent.prototype.updateLockedDate = function () {
470
551
  var _this = this;
471
- var year = moment$9.unix(this.dateObj.date).year();
552
+ var year = moment$9.unix(this.forecastYear).year();
472
553
  this.forecastTags = this.forecastTags.map(function (forecastTag) {
473
554
  forecastTag.disabled = _this.lockedDate.some(function (timestamp) {
474
555
  var locked = moment$9.unix(timestamp);
@@ -520,12 +601,11 @@
520
601
  if (this.isDateEventHappened)
521
602
  return;
522
603
  var month = this.forecastValue;
523
- var year = moment$9.unix(this.dateObj.date).year();
604
+ var year = moment$9.unix(this.forecastYear);
524
605
  var fiscal_year_starts_from = this.fiscalYearStartsFrom || 1;
525
606
  var fiscal_year_back = this.fiscalYearBack || false;
526
- var chosenDate = moment$9.unix(this.dateObj.date).unix();
527
607
  if (!Number.isNaN(month) && !Number.isNaN(year)) {
528
- var date = new Date(year, month, 1, 12, 0, 0, 0);
608
+ var date = new Date(year.year(), month, 1, 12, 0, 0, 0);
529
609
  if (fiscal_year_starts_from !== 1) {
530
610
  if (!fiscal_year_back) {
531
611
  date.setMonth(date.getMonth() - 13 + fiscal_year_starts_from);
@@ -534,19 +614,16 @@
534
614
  date.setMonth(date.getMonth() - 1 + fiscal_year_starts_from);
535
615
  }
536
616
  }
537
- this.updateYear(year, date.getMonth());
617
+ this.dateObj.date = moment$9(date).unix();
538
618
  this.isDateEventHappened = true;
539
619
  setTimeout(function () {
540
620
  _this.isDateEventHappened = false;
541
621
  });
542
622
  }
543
- var calculatedDate = moment$9.unix(this.dateObj.date).year(this.getFiscalYearFromDate(moment$9.unix(this.dateObj.date), fiscal_year_starts_from, fiscal_year_back));
544
623
  var resultTag = {
545
624
  name: this.name,
546
625
  value: this.dateObj.date,
547
- calculatedValue: calculatedDate.unix(),
548
- chosenValue: chosenDate,
549
- label: ((_a = _.find(this.forecastTags, { value: this.forecastValue })) === null || _a === void 0 ? void 0 : _a.label) + " (" + year + ")",
626
+ label: ((_a = _.find(this.forecastTags, { value: this.forecastValue })) === null || _a === void 0 ? void 0 : _a.label) + " (" + year.year() + ")",
550
627
  locked: !this.dateFilter(moment$9.unix(this.dateObj.date)),
551
628
  };
552
629
  this.dateChange.emit(resultTag);
@@ -564,7 +641,7 @@
564
641
  }(AnyTagComponent));
565
642
  ForecastTagComponent.decorators = [
566
643
  { type: i0.Component, args: [{
567
- template: "<ng-container *ngIf=\"!tagAdditionalSettings?.showSplitInputs; else splitInputsTpl\">\n <div class=\"forecast-tag__container\">\n <div class=\"forecast-tag__forecast\">\n <p class=\"tag__label\">Forecast</p>\n <dr-select\n placeholder=\"Select\"\n [(ngModel)]=\"forecastValue\"\n bindLabel=\"label\"\n bindValue=\"value\"\n [disabled]=\"disabled\"\n [items]=\"forecastTags\"\n (ngModelChange)=\"changeTagInputHandler()\"></dr-select>\n </div>\n <div class=\"forecast-tag__year\">\n <p class=\"tag__label\">Year</p>\n <dr-date-picker\n format=\"year\"\n [(ngModel)]=\"dateObj.date\"\n [datepickerFilter]=\"dateFilter.bind(this)\"\n [disabled]=\"disabled\"\n (ngModelChange)=\"changeYearInputHandler()\"></dr-date-picker>\n </div>\n </div>\n</ng-container>\n\n<ng-template #splitInputsTpl>\n <div class=\"forecast-tag__split-container\">\n <p class=\"tag__label\">Period</p>\n <div class=\"forecast-tag__split-dropdowns\">\n <dr-date-picker\n format=\"year\"\n [(ngModel)]=\"dateObj.date\"\n [datepickerFilter]=\"dateFilter.bind(this)\"\n [disabled]=\"disabled\"\n class=\"no-right-border-radius no-right-border\"\n (ngModelChange)=\"changeYearInputHandler()\"></dr-date-picker>\n <dr-select\n placeholder=\"Select\"\n [(ngModel)]=\"forecastValue\"\n bindLabel=\"label\"\n bindValue=\"value\"\n [disabled]=\"disabled\"\n [items]=\"forecastTags\"\n no-left-border-radius\n (ngModelChange)=\"changeTagInputHandler()\"></dr-select>\n </div>\n </div>\n</ng-template>\n",
644
+ template: "<ng-container *ngIf=\"!tagAdditionalSettings?.showSplitInputs; else splitInputsTpl\">\n <div class=\"forecast-tag__container\">\n <div class=\"forecast-tag__forecast\">\n <p class=\"tag__label\">Forecast</p>\n <dr-select\n placeholder=\"Select\"\n [(ngModel)]=\"forecastValue\"\n bindLabel=\"label\"\n bindValue=\"value\"\n [disabled]=\"disabled\"\n [items]=\"forecastTags\"\n (ngModelChange)=\"changeTagInputHandler()\"></dr-select>\n </div>\n <div class=\"forecast-tag__year\">\n <p class=\"tag__label\">Year</p>\n <dr-date-picker\n format=\"year\"\n [(ngModel)]=\"forecastYear\"\n [datepickerFilter]=\"dateFilter.bind(this)\"\n [periodPosition]=\"datePickerPeriodPosition.MIDDLE_OF_PERIOD\"\n [disabled]=\"disabled\"\n (ngModelChange)=\"changeYearInputHandler()\"></dr-date-picker>\n </div>\n </div>\n</ng-container>\n\n<ng-template #splitInputsTpl>\n <div class=\"forecast-tag__split-container\">\n <p class=\"tag__label\">Period</p>\n <div class=\"forecast-tag__split-dropdowns\">\n <dr-date-picker\n format=\"year\"\n [(ngModel)]=\"forecastYear\"\n [datepickerFilter]=\"dateFilter.bind(this)\"\n [disabled]=\"disabled\"\n class=\"no-right-border-radius no-right-border\"\n (ngModelChange)=\"changeYearInputHandler()\"></dr-date-picker>\n <dr-select\n placeholder=\"Select\"\n [(ngModel)]=\"forecastValue\"\n bindLabel=\"label\"\n bindValue=\"value\"\n [disabled]=\"disabled\"\n [items]=\"forecastTags\"\n no-left-border-radius\n (ngModelChange)=\"changeTagInputHandler()\"></dr-select>\n </div>\n </div>\n</ng-template>\n",
568
645
  selector: 'forecast-tag',
569
646
  providers: [
570
647
  {
@@ -1137,8 +1214,6 @@
1137
1214
  id: this.tagConfig.id,
1138
1215
  name: event.name,
1139
1216
  value: event.value,
1140
- calculatedValue: event.calculatedValue,
1141
- chosenValue: event.chosenValue,
1142
1217
  label: event.label,
1143
1218
  locked: event.locked
1144
1219
  };
@@ -2143,88 +2218,6 @@
2143
2218
  },] }
2144
2219
  ];
2145
2220
 
2146
- exports.DateFromats = void 0;
2147
- (function (DateFromats) {
2148
- DateFromats["MAT_DEFAULT_DATE_FORMAT"] = "MM/DD/yyyy";
2149
- DateFromats["DATE_INPUT_FORMAT"] = "YYYY/MM/DD";
2150
- DateFromats["YEAR_FORMAT"] = "yyyy";
2151
- DateFromats["MONTH_YEAR_FORMAT"] = "MM/yyyy";
2152
- DateFromats["QUARTER_FORMAT"] = "Q/yyyy";
2153
- DateFromats["WEEK_FORMAT"] = "w/yyyy";
2154
- })(exports.DateFromats || (exports.DateFromats = {}));
2155
- var CustomDateFormat = /** @class */ (function () {
2156
- function CustomDateFormat() {
2157
- this._parse = {
2158
- dateInput: exports.DateFromats.DATE_INPUT_FORMAT,
2159
- };
2160
- this._display = {
2161
- dateInput: exports.DateFromats.DATE_INPUT_FORMAT,
2162
- monthYearLabel: 'MMM YYYY',
2163
- dateA11yLabel: 'LL',
2164
- monthYearA11yLabel: 'MMM YYYY',
2165
- quarterYearLabel: 'Q/YYYY',
2166
- yearLabel: 'YYYY'
2167
- };
2168
- }
2169
- Object.defineProperty(CustomDateFormat.prototype, "parse", {
2170
- get: function () {
2171
- return this._parse;
2172
- },
2173
- set: function (parse) {
2174
- this._parse = Object.assign({}, this._parse, parse);
2175
- },
2176
- enumerable: false,
2177
- configurable: true
2178
- });
2179
- Object.defineProperty(CustomDateFormat.prototype, "display", {
2180
- get: function () {
2181
- return this._display;
2182
- },
2183
- set: function (display) {
2184
- this._display = Object.assign({}, this._display, display);
2185
- },
2186
- enumerable: false,
2187
- configurable: true
2188
- });
2189
- CustomDateFormat.prototype.updateDateFormat = function (parse, display) {
2190
- this.parse = parse;
2191
- if (!display) {
2192
- display = parse;
2193
- }
2194
- this.display = display;
2195
- };
2196
- return CustomDateFormat;
2197
- }());
2198
- exports.DatePickerPeriodPosition = void 0;
2199
- (function (DatePickerPeriodPosition) {
2200
- DatePickerPeriodPosition[DatePickerPeriodPosition["END_OF_PERIOD"] = 0] = "END_OF_PERIOD";
2201
- DatePickerPeriodPosition[DatePickerPeriodPosition["MIDDLE_OF_PERIOD"] = 1] = "MIDDLE_OF_PERIOD";
2202
- DatePickerPeriodPosition[DatePickerPeriodPosition["START_OF_PERIOD"] = 2] = "START_OF_PERIOD";
2203
- DatePickerPeriodPosition[DatePickerPeriodPosition["DEFAULT"] = 3] = "DEFAULT";
2204
- })(exports.DatePickerPeriodPosition || (exports.DatePickerPeriodPosition = {}));
2205
- exports.TimeframeOption = void 0;
2206
- (function (TimeframeOption) {
2207
- TimeframeOption["DAY"] = "day";
2208
- TimeframeOption["MONTH"] = "month";
2209
- TimeframeOption["QUARTER"] = "quarter";
2210
- TimeframeOption["WEEK"] = "week";
2211
- TimeframeOption["YEAR"] = "year";
2212
- })(exports.TimeframeOption || (exports.TimeframeOption = {}));
2213
- exports.CalendarView = void 0;
2214
- (function (CalendarView) {
2215
- CalendarView["FOR_DAYS"] = "month";
2216
- CalendarView["FOR_MONTHS"] = "year";
2217
- CalendarView["FOR_QUARTERS"] = "none";
2218
- CalendarView["FOR_YEARS"] = "multi-year";
2219
- })(exports.CalendarView || (exports.CalendarView = {}));
2220
- exports.DateTags = void 0;
2221
- (function (DateTags) {
2222
- DateTags["TODAY"] = "today";
2223
- DateTags["YESTERDAY"] = "yesterday";
2224
- DateTags["THIS_MONTH"] = "this_month";
2225
- DateTags["PREV_MONTH"] = "prev_month";
2226
- })(exports.DateTags || (exports.DateTags = {}));
2227
-
2228
2221
  var POPUP_POSITIONS = {
2229
2222
  top: {
2230
2223
  originX: 'center',