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.
@@ -2357,37 +2357,27 @@ class ZComponentService {
2357
2357
  }
2358
2358
  return obsList;
2359
2359
  }
2360
- localizeDateTimeByIgnoringTimeZone(value, data) {
2361
- if (this.timePickerDateType.includes(data.Type)) {
2362
- const userTimeZoneOffSet = this.convertOffsetMinToHour((new Date(value).getTimezoneOffset()));
2363
- const datetimeWithoutTimeZone = this.removeTimeZoneAndConvertToISOString(value);
2364
- //return new Date(`${datetimeWithoutTimeZone.split('.000Z')[0]}${userTimeZoneOffSet}`);
2365
- return new Date(`${datetimeWithoutTimeZone.split('Z')[0]}${userTimeZoneOffSet}`);
2366
- }
2367
- else if (data.Type === 'zshortdate') {
2368
- const dateOnly = value.includes('T') ? value.split('T')[0] : value; // Extract date portion
2369
- const date = new Date(dateOnly); // Create a date object from the extracted date
2370
- date.setUTCDate(1); // Set day to the first of the month
2371
- // Convert to UTC, accounting for the timezone offset
2372
- const timezoneOffset = date.getTimezoneOffset(); // Get timezone offset in minutes
2373
- date.setMinutes(date.getMinutes() + timezoneOffset); // Adjust for timezone offset
2374
- // Return the final date object
2375
- return date;
2376
- }
2377
- else {
2378
- const dateOnly = value.includes('T') ? value.split('T')[0] : value;
2379
- return new Date(dateOnly + " " + new Date(dateOnly).toLocaleTimeString());
2380
- }
2381
- }
2382
- removeTimeZoneAndConvertToISOString(value) {
2383
- const result = value.split('+')[0];
2384
- return new Date(result.endsWith('Z') ? result : `${result}Z`).toISOString();
2385
- }
2386
- convertOffsetMinToHour(num) {
2387
- num = -num;
2388
- const prefix = num.toString().startsWith('-') ? '-' : '+';
2389
- const result = `${(Math.abs(num) / 60).toString().padStart(2, '0')}:00`;
2390
- return `${prefix}${result}`;
2360
+ localizeDateTimeByIgnoringTimeZone(value, field) {
2361
+ // Support both string and Date inputs
2362
+ const originalDate = value instanceof Date ? new Date(value.getTime()) : new Date(value);
2363
+ // Case 1: time / datetime fields → keep wall-clock time stable
2364
+ if (this.timePickerDateType.includes(field.Type)) {
2365
+ const adjusted = new Date(originalDate);
2366
+ const offsetMinutes = originalDate.getTimezoneOffset();
2367
+ adjusted.setMinutes(originalDate.getMinutes() - offsetMinutes);
2368
+ return adjusted;
2369
+ }
2370
+ // Case 2: month-only (zshortdate) → year+month, day fixed to 1
2371
+ if (field.Type === 'zshortdate') {
2372
+ return new Date(originalDate.getFullYear(), originalDate.getMonth(), 1, // day
2373
+ 0, 0, 0, 0);
2374
+ }
2375
+ // Case 3: normal date-only → keep calendar date stable, ignore time
2376
+ const dateOnly = new Date(originalDate.getFullYear(), originalDate.getMonth(), originalDate.getDate(), 0, 0, 0, 0);
2377
+ const normalizedDate = new Date(dateOnly);
2378
+ const localOffsetMinutes = dateOnly.getTimezoneOffset();
2379
+ normalizedDate.setMinutes(dateOnly.getMinutes() - localOffsetMinutes);
2380
+ return normalizedDate;
2391
2381
  }
2392
2382
  //#endregion
2393
2383
  decrementComponentCounterForField(field) {
@@ -3598,21 +3588,21 @@ class DateParserFilter {
3598
3588
  constructor(componentService) {
3599
3589
  this.componentService = componentService;
3600
3590
  }
3601
- transform(value, data) {
3602
- // debugger;
3603
- if (!value) {
3604
- return value;
3591
+ transform(rawValue, field) {
3592
+ if (!rawValue) {
3593
+ return null;
3605
3594
  }
3606
- // filter items array, items which match and return true will be
3607
- // kept, false will be filtered out
3608
3595
  try {
3609
- if (data.IsIgnoreTimeZone) {
3610
- return this.componentService.localizeDateTimeByIgnoringTimeZone(value, data);
3596
+ // For "ignore timezone" fields, normalize via service
3597
+ if (field.IsIgnoreTimeZone) {
3598
+ return this.componentService.localizeDateTimeByIgnoringTimeZone(rawValue, field);
3611
3599
  }
3612
- return new Date(value);
3600
+ // Otherwise, just convert to Date
3601
+ const inputDate = new Date(rawValue);
3602
+ return inputDate;
3613
3603
  }
3614
3604
  catch (error) {
3615
- console.log("DateParserFilter error: ", error);
3605
+ console.log('DateParserFilter error:', error);
3616
3606
  return null;
3617
3607
  }
3618
3608
  }
@@ -7214,12 +7204,13 @@ class ZdatetimeComponent extends InputFieldBase {
7214
7204
  }
7215
7205
  onChange(value) {
7216
7206
  const formControl = this.form.controls[this.data.Value];
7217
- const val = this.convertDateTimeValueToString(value);
7207
+ const dateValue = this.convertDateTimeValueToString(value);
7218
7208
  if (formControl) {
7219
- formControl.setValue(val);
7209
+ formControl.setValue(dateValue);
7220
7210
  formControl.markAsTouched();
7221
7211
  }
7222
- super.onChange(null, val);
7212
+ // Important: pass Date to base, not ISO string
7213
+ super.onChange(null, dateValue);
7223
7214
  }
7224
7215
  setMinAndMaxDateRange() {
7225
7216
  const minDateGroupValue = ZComponentHelper.getGroupValue(this.data.MinDate, this.group);
@@ -7239,24 +7230,39 @@ class ZdatetimeComponent extends InputFieldBase {
7239
7230
  }
7240
7231
  }
7241
7232
  convertDateTimeValueToString(value) {
7242
- if (value == undefined) {
7233
+ if (value === undefined || value === null) {
7243
7234
  return undefined;
7244
7235
  }
7245
- const valueDate = value;
7236
+ const inputDate = new Date(value);
7237
+ // zshortdate → normalize to first day of month
7246
7238
  if (this.data.Type === 'zshortdate') {
7247
- valueDate.setDate(1);
7239
+ const monthStart = new Date(inputDate);
7240
+ monthStart.setDate(1);
7241
+ return monthStart;
7248
7242
  }
7243
+ // Ignore timezone: keep same local wall-clock time regardless of browser TZ
7249
7244
  if (this.data.IsIgnoreTimeZone) {
7250
- const timezoneOffSet = new Date(value).getTimezoneOffset();
7251
- valueDate.setMinutes(valueDate.getMinutes() + (-timezoneOffSet));
7252
- return valueDate.toISOString();
7245
+ return this.adjustForIgnoreTimeZone(inputDate);
7253
7246
  }
7247
+ // For non-time types -> date-only
7254
7248
  if (!['zuidatetime', 'ztime', 'zuitime'].includes(this.data.Type)) {
7255
- return this.parseAnyValueToDateOnly(value).toISOString();
7256
- }
7257
- else {
7258
- return this.parseAnyValueToDate(value).toISOString();
7249
+ // Assuming these helpers already return Date
7250
+ const dateOnly = this.parseAnyValueToDateOnly(inputDate);
7251
+ return dateOnly;
7259
7252
  }
7253
+ // For datetime/time types -> full datetime
7254
+ const dateTime = this.parseAnyValueToDate(inputDate);
7255
+ return dateTime;
7256
+ }
7257
+ /**
7258
+ * Adjusts a Date so that its wall-clock time stays the same
7259
+ * when ignoring the browser timezone.
7260
+ */
7261
+ adjustForIgnoreTimeZone(date) {
7262
+ const adjustedDate = new Date(date);
7263
+ const timezoneOffsetMinutes = adjustedDate.getTimezoneOffset();
7264
+ adjustedDate.setMinutes(adjustedDate.getMinutes() - timezoneOffsetMinutes);
7265
+ return adjustedDate;
7260
7266
  }
7261
7267
  parseAnyValueToDate(value) {
7262
7268
  return new Date(value instanceof Date ? value : new Date(value));
@@ -11809,7 +11815,7 @@ class ZreportComponent extends FieldBase {
11809
11815
  this.onPrintBegin = this.printBegin.bind(this);
11810
11816
  this.onPrintEnd = this.printEnd.bind(this);
11811
11817
  super.initComponent().subscribe(() => {
11812
- this.serviceUrl = this.resourceApiService.getURL(this.data.ResourceURL);
11818
+ this.serviceUrl = this.zcoreService.normalizeUrl(this.resourceApiService.getURL(this.data.ResourceURL));
11813
11819
  if (!this.serviceUrl) {
11814
11820
  console.log("resourceURL is empty.");
11815
11821
  }