mmhglobal-dynamicform 2.41.4 → 2.42.0

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.
@@ -2376,37 +2376,27 @@ class ZComponentService {
2376
2376
  }
2377
2377
  return obsList;
2378
2378
  }
2379
- localizeDateTimeByIgnoringTimeZone(value, data) {
2380
- if (this.timePickerDateType.includes(data.Type)) {
2381
- const userTimeZoneOffSet = this.convertOffsetMinToHour((new Date(value).getTimezoneOffset()));
2382
- const datetimeWithoutTimeZone = this.removeTimeZoneAndConvertToISOString(value);
2383
- //return new Date(`${datetimeWithoutTimeZone.split('.000Z')[0]}${userTimeZoneOffSet}`);
2384
- return new Date(`${datetimeWithoutTimeZone.split('Z')[0]}${userTimeZoneOffSet}`);
2385
- }
2386
- else if (data.Type === 'zshortdate') {
2387
- const dateOnly = value.includes('T') ? value.split('T')[0] : value; // Extract date portion
2388
- const date = new Date(dateOnly); // Create a date object from the extracted date
2389
- date.setUTCDate(1); // Set day to the first of the month
2390
- // Convert to UTC, accounting for the timezone offset
2391
- const timezoneOffset = date.getTimezoneOffset(); // Get timezone offset in minutes
2392
- date.setMinutes(date.getMinutes() + timezoneOffset); // Adjust for timezone offset
2393
- // Return the final date object
2394
- return date;
2395
- }
2396
- else {
2397
- const dateOnly = value.includes('T') ? value.split('T')[0] : value;
2398
- return new Date(dateOnly + " " + new Date(dateOnly).toLocaleTimeString());
2399
- }
2400
- }
2401
- removeTimeZoneAndConvertToISOString(value) {
2402
- const result = value.split('+')[0];
2403
- return new Date(result.endsWith('Z') ? result : `${result}Z`).toISOString();
2404
- }
2405
- convertOffsetMinToHour(num) {
2406
- num = -num;
2407
- const prefix = num.toString().startsWith('-') ? '-' : '+';
2408
- const result = `${(Math.abs(num) / 60).toString().padStart(2, '0')}:00`;
2409
- return `${prefix}${result}`;
2379
+ localizeDateTimeByIgnoringTimeZone(value, field) {
2380
+ // Support both string and Date inputs
2381
+ const originalDate = value instanceof Date ? new Date(value.getTime()) : new Date(value);
2382
+ // Case 1: time / datetime fields → keep wall-clock time stable
2383
+ if (this.timePickerDateType.includes(field.Type)) {
2384
+ const adjusted = new Date(originalDate);
2385
+ const offsetMinutes = originalDate.getTimezoneOffset();
2386
+ adjusted.setMinutes(originalDate.getMinutes() - offsetMinutes);
2387
+ return adjusted;
2388
+ }
2389
+ // Case 2: month-only (zshortdate) → year+month, day fixed to 1
2390
+ if (field.Type === 'zshortdate') {
2391
+ return new Date(originalDate.getFullYear(), originalDate.getMonth(), 1, // day
2392
+ 0, 0, 0, 0);
2393
+ }
2394
+ // Case 3: normal date-only → keep calendar date stable, ignore time
2395
+ const dateOnly = new Date(originalDate.getFullYear(), originalDate.getMonth(), originalDate.getDate(), 0, 0, 0, 0);
2396
+ const normalizedDate = new Date(dateOnly);
2397
+ const localOffsetMinutes = dateOnly.getTimezoneOffset();
2398
+ normalizedDate.setMinutes(dateOnly.getMinutes() - localOffsetMinutes);
2399
+ return normalizedDate;
2410
2400
  }
2411
2401
  //#endregion
2412
2402
  decrementComponentCounterForField(field) {
@@ -3625,21 +3615,21 @@ class DateParserFilter {
3625
3615
  constructor(componentService) {
3626
3616
  this.componentService = componentService;
3627
3617
  }
3628
- transform(value, data) {
3629
- // debugger;
3630
- if (!value) {
3631
- return value;
3618
+ transform(rawValue, field) {
3619
+ if (!rawValue) {
3620
+ return null;
3632
3621
  }
3633
- // filter items array, items which match and return true will be
3634
- // kept, false will be filtered out
3635
3622
  try {
3636
- if (data.IsIgnoreTimeZone) {
3637
- return this.componentService.localizeDateTimeByIgnoringTimeZone(value, data);
3623
+ // For "ignore timezone" fields, normalize via service
3624
+ if (field.IsIgnoreTimeZone) {
3625
+ return this.componentService.localizeDateTimeByIgnoringTimeZone(rawValue, field);
3638
3626
  }
3639
- return new Date(value);
3627
+ // Otherwise, just convert to Date
3628
+ const inputDate = new Date(rawValue);
3629
+ return inputDate;
3640
3630
  }
3641
3631
  catch (error) {
3642
- console.log("DateParserFilter error: ", error);
3632
+ console.log('DateParserFilter error:', error);
3643
3633
  return null;
3644
3634
  }
3645
3635
  }
@@ -7252,12 +7242,13 @@ class ZdatetimeComponent extends InputFieldBase {
7252
7242
  }
7253
7243
  onChange(value) {
7254
7244
  const formControl = this.form.controls[this.data.Value];
7255
- const val = this.convertDateTimeValueToString(value);
7245
+ const dateValue = this.convertDateTimeValueToString(value);
7256
7246
  if (formControl) {
7257
- formControl.setValue(val);
7247
+ formControl.setValue(dateValue);
7258
7248
  formControl.markAsTouched();
7259
7249
  }
7260
- super.onChange(null, val);
7250
+ // Important: pass Date to base, not ISO string
7251
+ super.onChange(null, dateValue);
7261
7252
  }
7262
7253
  setMinAndMaxDateRange() {
7263
7254
  const minDateGroupValue = ZComponentHelper.getGroupValue(this.data.MinDate, this.group);
@@ -7277,24 +7268,39 @@ class ZdatetimeComponent extends InputFieldBase {
7277
7268
  }
7278
7269
  }
7279
7270
  convertDateTimeValueToString(value) {
7280
- if (value == undefined) {
7271
+ if (value === undefined || value === null) {
7281
7272
  return undefined;
7282
7273
  }
7283
- const valueDate = value;
7274
+ const inputDate = new Date(value);
7275
+ // zshortdate → normalize to first day of month
7284
7276
  if (this.data.Type === 'zshortdate') {
7285
- valueDate.setDate(1);
7277
+ const monthStart = new Date(inputDate);
7278
+ monthStart.setDate(1);
7279
+ return monthStart;
7286
7280
  }
7281
+ // Ignore timezone: keep same local wall-clock time regardless of browser TZ
7287
7282
  if (this.data.IsIgnoreTimeZone) {
7288
- const timezoneOffSet = new Date(value).getTimezoneOffset();
7289
- valueDate.setMinutes(valueDate.getMinutes() + (-timezoneOffSet));
7290
- return valueDate.toISOString();
7283
+ return this.adjustForIgnoreTimeZone(inputDate);
7291
7284
  }
7285
+ // For non-time types -> date-only
7292
7286
  if (!['zuidatetime', 'ztime', 'zuitime'].includes(this.data.Type)) {
7293
- return this.parseAnyValueToDateOnly(value).toISOString();
7294
- }
7295
- else {
7296
- return this.parseAnyValueToDate(value).toISOString();
7287
+ // Assuming these helpers already return Date
7288
+ const dateOnly = this.parseAnyValueToDateOnly(inputDate);
7289
+ return dateOnly;
7297
7290
  }
7291
+ // For datetime/time types -> full datetime
7292
+ const dateTime = this.parseAnyValueToDate(inputDate);
7293
+ return dateTime;
7294
+ }
7295
+ /**
7296
+ * Adjusts a Date so that its wall-clock time stays the same
7297
+ * when ignoring the browser timezone.
7298
+ */
7299
+ adjustForIgnoreTimeZone(date) {
7300
+ const adjustedDate = new Date(date);
7301
+ const timezoneOffsetMinutes = adjustedDate.getTimezoneOffset();
7302
+ adjustedDate.setMinutes(adjustedDate.getMinutes() - timezoneOffsetMinutes);
7303
+ return adjustedDate;
7298
7304
  }
7299
7305
  parseAnyValueToDate(value) {
7300
7306
  return new Date(value instanceof Date ? value : new Date(value));
@@ -11854,7 +11860,7 @@ class ZreportComponent extends FieldBase {
11854
11860
  this.onPrintBegin = this.printBegin.bind(this);
11855
11861
  this.onPrintEnd = this.printEnd.bind(this);
11856
11862
  super.initComponent().subscribe(() => {
11857
- this.serviceUrl = this.resourceApiService.getURL(this.data.ResourceURL);
11863
+ this.serviceUrl = this.zcoreService.normalizeUrl(this.resourceApiService.getURL(this.data.ResourceURL));
11858
11864
  if (!this.serviceUrl) {
11859
11865
  console.log("resourceURL is empty.");
11860
11866
  }