@iapps/ng-dhis2-ui 1.2.85 → 1.2.87

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.
@@ -30,8 +30,8 @@ import { isObject, isString, debounce, sortBy, isArray, find, camelCase, flatten
30
30
  import cx from 'classnames';
31
31
  import { getNowInCalendar, generateFixedPeriods } from '@dhis2/multi-calendar-dates';
32
32
  import { Pager, DataOrderCriteria, DataQueryFilter, DataFilterCondition, ProgramRuleEngine } from '@iapps/d2-web-sdk';
33
+ import { parseISO, isValid, format, parse as parse$1, addDays } from 'date-fns';
33
34
  import { map as map$1 } from 'rxjs/operators';
34
- import { format, parse as parse$1, addDays } from 'date-fns';
35
35
  import * as XLSX from 'xlsx';
36
36
  import * as i2 from '@angular/forms';
37
37
  import { Validators, UntypedFormControl, UntypedFormGroup, FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
@@ -3328,13 +3328,17 @@ const FilterToolbar = ({ orgUnitLabel, selectedOrgUnit, setSelectedOrgUnit, setO
3328
3328
  //clearable={!!tempStartDateState}
3329
3329
  //date={tempStartDateState || undefined}
3330
3330
  //date={tempStartDateState || "yyyy-mm-dd"}
3331
- clearable: !!tempStartDateState && tempStartDateState !== 'yyyy-mm-dd', date: tempStartDateState || 'yyyy-mm-dd', onDateSelect: (selectedDate) => {
3331
+ clearable: !!tempStartDateState && tempStartDateState !== 'dd-mm-yyyy',
3332
+ // date={tempStartDateState || 'dd-mm-yyyy'}
3333
+ date: formatDateForDisplay(tempStartDateState), onDateSelect: (selectedDate) => {
3332
3334
  setTempStartDateState(selectedDate.calendarDateString);
3333
3335
  if (selectedDate.calendarDateString === null) {
3334
3336
  setStartDateState(selectedDate.calendarDateString);
3335
3337
  }
3336
3338
  } }),
3337
- React__default.createElement(CalendarInput, { label: "End date:", calendar: "gregory", locale: "en-GB", timeZone: "Africa/Dar_es_Salaam", className: "custom-input", clearable: !!tempEndDateState && tempEndDateState !== 'yyyy-mm-dd', date: tempEndDateState || 'yyyy-mm-dd', onDateSelect: (selectedDate) => {
3339
+ React__default.createElement(CalendarInput, { label: "End date:", calendar: "gregory", locale: "en-GB", timeZone: "Africa/Dar_es_Salaam", className: "custom-input", clearable: !!tempEndDateState && tempEndDateState !== 'dd-mm-yyyy',
3340
+ // date={tempEndDateState || 'dd-mm-yyyy'}
3341
+ date: formatDateForDisplay(tempEndDateState), onDateSelect: (selectedDate) => {
3338
3342
  setTempEndDateState(selectedDate.calendarDateString);
3339
3343
  if (selectedDate.calendarDateString === null) {
3340
3344
  setEndDateState(selectedDate.calendarDateString);
@@ -3389,6 +3393,19 @@ const FilterToolbar = ({ orgUnitLabel, selectedOrgUnit, setSelectedOrgUnit, setO
3389
3393
  } },
3390
3394
  React__default.createElement(Button$1, { onClick: handleSearch }, "Search"),
3391
3395
  React__default.createElement(Button$1, { onClick: () => setShowAllFilters(!showAllFilters) }, showAllFilters ? 'Less Filters' : 'More Filters')))));
3396
+ function formatDateForDisplay(dateString) {
3397
+ if (!dateString || dateString === 'dd-mm-yyyy')
3398
+ return 'dd-mm-yyyy';
3399
+ try {
3400
+ const parsedDate = parseISO(dateString);
3401
+ if (!isValid(parsedDate))
3402
+ return 'dd-mm-yyyy';
3403
+ return format(parsedDate, 'dd-MM-yyyy');
3404
+ }
3405
+ catch {
3406
+ return 'dd-mm-yyyy';
3407
+ }
3408
+ }
3392
3409
 
3393
3410
  const TableHeader = ({ columns, allSelected, onSelectAll, selectable, showActionButtons, }) => {
3394
3411
  const handleCheckboxChange = () => {
@@ -6440,6 +6457,13 @@ class FormComponent {
6440
6457
  this.#processRules(this.programRuleActions());
6441
6458
  });
6442
6459
  }
6460
+ ngOnInit() {
6461
+ this.values = this.form().getRawValue();
6462
+ this.formUpdate.emit(new FormValue(this.form(), this.fields()));
6463
+ }
6464
+ // ngOnChanges(changes: SimpleChanges): void {
6465
+ // this.values = this.form.getRawValue();
6466
+ // }
6443
6467
  ngOnChanges(changes) {
6444
6468
  this.values = this.form().getRawValue();
6445
6469
  }