forked from hashgraph/guardian
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/refactor form view (hashgraph#4469)
* refator && fixes Signed-off-by: simvalery <[email protected]> * fix Signed-off-by: simvalery <[email protected]> * fix sentinel hub Signed-off-by: simvalery <[email protected]> * fix Signed-off-by: simvalery <[email protected]> * fixes Signed-off-by: simvalery <[email protected]> * fix document view image Signed-off-by: simvalery <[email protected]> * fix from Signed-off-by: simvalery <[email protected]> * fix time array Signed-off-by: simvalery <[email protected]> * fix Signed-off-by: simvalery <[email protected]> * readOnly dateTime input Signed-off-by: simvalery <[email protected]> * invalid border color Signed-off-by: simvalery <[email protected]> * fixes Signed-off-by: simvalery <[email protected]> * fix Signed-off-by: simvalery <[email protected]> --------- Signed-off-by: simvalery <[email protected]>
- Loading branch information
Showing
15 changed files
with
391 additions
and
70 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
frontend/src/app/modules/schema-engine/schema-form/controls/controls.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { DateTimeComponent } from './date-time/date-time.component'; | ||
import { EnumComponent } from './enum/enum'; | ||
import { InputComponent } from './input/input'; | ||
import { InputTextModule } from 'primeng/inputtext'; | ||
import { CalendarModule } from 'primeng/calendar'; | ||
import { InputTextareaModule } from 'primeng/inputtextarea'; | ||
import { InputNumberModule } from 'primeng/inputnumber'; | ||
import { CheckboxModule } from 'primeng/checkbox'; | ||
import { DropdownModule } from 'primeng/dropdown'; | ||
import { NgxMatDatetimePickerModule, NgxMatNativeDateModule, NgxMatTimepickerModule, } from '@angular-material-components/datetime-picker'; | ||
import { MaterialModule } from '../../../common/material.module'; | ||
import { CommonComponentsModule } from '../../../common/common-components.module'; | ||
import { ArtifactEngineModule } from '../../../artifact-engine/artifact-engine.module'; | ||
import { CodemirrorModule } from '@ctrl/ngx-codemirror'; | ||
import { GoogleMapsModule } from '@angular/google-maps'; | ||
|
||
NgModule({ | ||
declarations: [ | ||
DateTimeComponent, | ||
EnumComponent, | ||
InputComponent | ||
], | ||
exports: [ | ||
DateTimeComponent, | ||
EnumComponent, | ||
InputComponent | ||
], | ||
imports: [ | ||
CommonComponentsModule, | ||
CodemirrorModule, | ||
ArtifactEngineModule, | ||
GoogleMapsModule, | ||
MaterialModule, | ||
NgxMatDatetimePickerModule, | ||
NgxMatNativeDateModule, | ||
NgxMatTimepickerModule, | ||
InputTextModule, | ||
FormsModule, | ||
CalendarModule, | ||
InputTextareaModule, | ||
CheckboxModule, | ||
DropdownModule, | ||
InputNumberModule | ||
] | ||
}) | ||
|
||
export class ControlsModule{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
frontend/src/app/modules/schema-engine/schema-form/controls/enum/enum.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<p-calendar #calendar | ||
[dateFormat]="dateFormat" | ||
[formControl]="control" | ||
[showIcon]="showIcon" | ||
[showSeconds]="showSeconds" | ||
[showTime]="showTime" | ||
[timeOnly]="timeOnly" | ||
appendTo='body' | ||
class="guardian-datepicker"></p-calendar> |
20 changes: 20 additions & 0 deletions
20
frontend/src/app/modules/schema-engine/schema-form/controls/enum/enum.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.type-selector { | ||
width: 100%; | ||
} | ||
|
||
.google-map-container { | ||
margin-bottom: 20px; | ||
margin-top: 5px; | ||
box-shadow: 0px 0px 21px 0px rgba(34, 60, 80, 0.2); | ||
border-radius: 5px; | ||
} | ||
|
||
:host .google-map-container ::ng-deep .map-container { | ||
border-radius: 5px; | ||
} | ||
|
||
.switch-btn { | ||
width: 180px; | ||
height: 32px; | ||
margin-bottom: 15px; | ||
} |
82 changes: 82 additions & 0 deletions
82
frontend/src/app/modules/schema-engine/schema-form/controls/enum/enum.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { AfterViewInit, Component, Input, NgZone, OnChanges, OnDestroy, OnInit, ViewChild } from '@angular/core'; | ||
import { UntypedFormControl } from '@angular/forms'; | ||
import * as moment from 'moment'; | ||
import { Subject, Subscription } from 'rxjs'; | ||
|
||
@Component({ | ||
selector: 'enum-control', | ||
templateUrl: './enum.html', | ||
styleUrls: ['./enum.scss'], | ||
}) | ||
export class EnumComponent implements OnInit, AfterViewInit, OnChanges, OnDestroy{ | ||
@Input('control') control: UntypedFormControl; | ||
@Input('showIcon') showIcon: boolean = true; | ||
@Input('showSeconds') showSeconds: boolean = true; | ||
@Input('showTime') showTime: boolean = true; | ||
@Input('timeOnly') timeOnly: boolean = false; | ||
@Input('dateFormat') dateFormat: string = 'yy-mm-dd'; | ||
@Input('item') item: any; | ||
@Input('isMany') isMany: boolean = false; | ||
@Input('index') isDisabled?: number; | ||
@Input('update') update?: Subject<any>; | ||
@Input('value') value?: string; | ||
|
||
@ViewChild('calendar') calendar: any | ||
|
||
private subscription = new Subscription(); | ||
|
||
constructor( | ||
private ngZone: NgZone, | ||
) { | ||
} | ||
|
||
ngOnInit() { | ||
if (this.item.subject) { | ||
this.item.subject.subscribe(() => { | ||
this.fillField(); | ||
}) | ||
} | ||
} | ||
|
||
ngOnDestroy() { | ||
this.subscription.unsubscribe(); | ||
} | ||
|
||
ngAfterViewInit() { | ||
// if (this.isMany) { | ||
this.fillField(); | ||
// } | ||
} | ||
|
||
ngOnChanges() { | ||
this.fillField(); | ||
} | ||
|
||
fillField() { | ||
const comment = this.item?.field?.comment && JSON.parse(this.item.field.comment); | ||
let value: any = null; | ||
if (this.value) { | ||
value = this.value; | ||
} else if (this.timeOnly && comment?.suggest) { | ||
value = comment.suggest; | ||
} else if (this.calendar?.value) { | ||
value = this.calendar?.value; | ||
} else if (this.item.value) { | ||
value = this.item.value; | ||
} | ||
|
||
const input = this.calendar?.el.nativeElement.querySelector('input') | ||
|
||
setTimeout(() => { | ||
if (input && value) { | ||
if (this.timeOnly) { | ||
const date = moment(value, 'hh-mm-ss').toDate(); | ||
this.control.setValue(date); | ||
input.value = value; | ||
} else { | ||
input.value = moment(value).format('YYYY-MM-DD HH:mm:ss'); | ||
} | ||
} | ||
}) | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
frontend/src/app/modules/schema-engine/schema-form/controls/input/input.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<p-calendar #calendar | ||
[dateFormat]="dateFormat" | ||
[formControl]="control" | ||
[showIcon]="showIcon" | ||
[showSeconds]="showSeconds" | ||
[showTime]="showTime" | ||
[timeOnly]="timeOnly" | ||
appendTo='body' | ||
class="guardian-datepicker"></p-calendar> |
20 changes: 20 additions & 0 deletions
20
frontend/src/app/modules/schema-engine/schema-form/controls/input/input.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.type-selector { | ||
width: 100%; | ||
} | ||
|
||
.google-map-container { | ||
margin-bottom: 20px; | ||
margin-top: 5px; | ||
box-shadow: 0px 0px 21px 0px rgba(34, 60, 80, 0.2); | ||
border-radius: 5px; | ||
} | ||
|
||
:host .google-map-container ::ng-deep .map-container { | ||
border-radius: 5px; | ||
} | ||
|
||
.switch-btn { | ||
width: 180px; | ||
height: 32px; | ||
margin-bottom: 15px; | ||
} |
Oops, something went wrong.