diff --git a/projects/swimlane/ngx-ui/src/lib/components/json-editor/json-editor-flat/json-editor-node-flat/json-editor-node-flat.component.html b/projects/swimlane/ngx-ui/src/lib/components/json-editor/json-editor-flat/json-editor-node-flat/json-editor-node-flat.component.html index 8d7e12fd7..15ef3bffe 100644 --- a/projects/swimlane/ngx-ui/src/lib/components/json-editor/json-editor-flat/json-editor-node-flat/json-editor-node-flat.component.html +++ b/projects/swimlane/ngx-ui/src/lib/components/json-editor/json-editor-flat/json-editor-node-flat/json-editor-node-flat.component.html @@ -118,7 +118,7 @@ (); private readonly unsub$: Subject = new Subject(); - constructor(public dialogMngr: DialogService) { + constructor(public dialogMngr: DialogService, private dateFormat: DateFormatPipe) { super(dialogMngr); } @@ -112,4 +114,8 @@ export class JsonEditorNodeFlatComponent extends JsonEditorNode implements OnIni this.expanded = value; } } + + updateDateTime(value: any): void { + this.updateDateTimeModel(value, this.dateFormat); + } } diff --git a/projects/swimlane/ngx-ui/src/lib/components/json-editor/json-editor-node.ts b/projects/swimlane/ngx-ui/src/lib/components/json-editor/json-editor-node.ts index fd095cd98..3707cce50 100644 --- a/projects/swimlane/ngx-ui/src/lib/components/json-editor/json-editor-node.ts +++ b/projects/swimlane/ngx-ui/src/lib/components/json-editor/json-editor-node.ts @@ -14,6 +14,9 @@ import { import { createValueForSchema, inferType, JSONEditorSchema } from './json-editor.helper'; import { DialogComponent } from '../dialog/dialog.component'; import { DialogService } from '../dialog/dialog.service'; +import { DateFormatPipe } from 'ngx-moment'; + +const DATETIME_FORMAT = 'YYYY-MM-DD[T]HH:mm:ss'; @Directive() export class JsonEditorNode implements OnInit, OnChanges { @@ -177,6 +180,10 @@ export class JsonEditorNode implements OnInit, OnChanges { this.modelChange.emit(this.model); } + updateDateTimeModel(value: any, format: DateFormatPipe): void { + this.updateModel(format.transform(value, DATETIME_FORMAT)); + } + /** * Expand click event */ diff --git a/projects/swimlane/ngx-ui/src/lib/components/json-editor/json-editor/json-editor-node/json-editor-node.component.html b/projects/swimlane/ngx-ui/src/lib/components/json-editor/json-editor/json-editor-node/json-editor-node.component.html index 8edd7b411..ffd805038 100644 --- a/projects/swimlane/ngx-ui/src/lib/components/json-editor/json-editor/json-editor-node/json-editor-node.component.html +++ b/projects/swimlane/ngx-ui/src/lib/components/json-editor/json-editor/json-editor-node/json-editor-node.component.html @@ -140,7 +140,7 @@ [placeholder]="placeholder" [ngModel]="model" [disabled]="isDuplicated" - (ngModelChange)="updateModel($event)" + (ngModelChange)="updateDateTime($event)" [required]="required" /> diff --git a/projects/swimlane/ngx-ui/src/lib/components/json-editor/json-editor/json-editor-node/json-editor-node.component.ts b/projects/swimlane/ngx-ui/src/lib/components/json-editor/json-editor/json-editor-node/json-editor-node.component.ts index 5d1213ba6..4f24451ba 100644 --- a/projects/swimlane/ngx-ui/src/lib/components/json-editor/json-editor/json-editor-node/json-editor-node.component.ts +++ b/projects/swimlane/ngx-ui/src/lib/components/json-editor/json-editor/json-editor-node/json-editor-node.component.ts @@ -3,11 +3,13 @@ import { JsonEditorNode } from '../../json-editor-node'; import { DialogService } from '../../../dialog/dialog.service'; import { JSONEditorSchema } from '../../json-editor.helper'; +import { DateFormatPipe } from 'ngx-moment'; @Component({ selector: 'ngx-json-editor-node', templateUrl: 'json-editor-node.component.html', styleUrls: ['./json-editor-node.component.scss'], + providers: [DateFormatPipe], encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush }) @@ -28,7 +30,7 @@ export class JsonEditorNodeComponent extends JsonEditorNode implements OnInit { placeholder = ''; - constructor(public dialogMngr: DialogService) { + constructor(public dialogMngr: DialogService, private dateFormat: DateFormatPipe) { super(dialogMngr); } @@ -39,4 +41,8 @@ export class JsonEditorNodeComponent extends JsonEditorNode implements OnInit { this.placeholder = this.schema.examples.join(', '); } } + + updateDateTime(value: any): void { + this.updateDateTimeModel(value, this.dateFormat); + } }