From 66375c1a1d23696713a37f6374319ab9ab2c6b8a Mon Sep 17 00:00:00 2001 From: "argiro.kokogiannaki" Date: Mon, 23 Dec 2019 13:59:56 +0000 Subject: [PATCH] [Library|Trunk] Dashboard: move shared components under library git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@57937 d315682c-612b-4755-9ff5-7f18f6832af3 --- dashboard/divId/divIds.module.ts | 2 +- .../div-help-contents.module.ts | 2 +- dashboard/entity/entities.module.ts | 2 +- .../helpTexts/page-help-contents.module.ts | 2 +- dashboard/page/pages.module.ts | 2 +- dashboard/portal/communities.module.ts | 2 +- .../sharedComponents/input/input.component.ts | 59 +++++++++++++++++++ .../sharedComponents/input/input.module.ts | 26 ++++++++ .../loading/loading.component.ts | 22 +++++++ .../loading/loading.module.ts | 18 ++++++ 10 files changed, 131 insertions(+), 6 deletions(-) create mode 100644 dashboard/sharedComponents/input/input.component.ts create mode 100644 dashboard/sharedComponents/input/input.module.ts create mode 100644 dashboard/sharedComponents/loading/loading.component.ts create mode 100644 dashboard/sharedComponents/loading/loading.module.ts diff --git a/dashboard/divId/divIds.module.ts b/dashboard/divId/divIds.module.ts index 9a60cd30..56c8af00 100644 --- a/dashboard/divId/divIds.module.ts +++ b/dashboard/divId/divIds.module.ts @@ -7,7 +7,7 @@ import {DivIdsComponent} from './divIds.component'; import {DivIdsRoutingModule} from './divIds-routing.module'; import {AdminLoginGuard} from "../../login/adminLoginGuard.guard"; import {AdminToolServiceModule} from "../../services/adminToolService.module"; -import {InputModule} from "../../../library/sharedComponents/input/input.module"; +import {InputModule} from "../sharedComponents/input/input.module"; import {MatAutocompleteModule} from '@angular/material/autocomplete'; diff --git a/dashboard/divhelpcontent/div-help-contents.module.ts b/dashboard/divhelpcontent/div-help-contents.module.ts index e2d57851..5a361828 100644 --- a/dashboard/divhelpcontent/div-help-contents.module.ts +++ b/dashboard/divhelpcontent/div-help-contents.module.ts @@ -10,7 +10,7 @@ import {SafeHtmlPipeModule} from '../../utils/pipes/safeHTMLPipe.module'; import {DivHelpContentsComponent} from './div-help-contents.component'; import {MatSlideToggleModule} from '@angular/material'; import {AdminToolServiceModule} from "../../services/adminToolService.module"; -import {InputModule} from "../../../library/sharedComponents/input/input.module"; +import {InputModule} from "../sharedComponents/input/input.module"; @NgModule({ imports: [ diff --git a/dashboard/entity/entities.module.ts b/dashboard/entity/entities.module.ts index e19f1f01..36237cb1 100644 --- a/dashboard/entity/entities.module.ts +++ b/dashboard/entity/entities.module.ts @@ -8,7 +8,7 @@ import {EntitiesRoutingModule} from './entities-routing.module'; import {MatSlideToggleModule} from '@angular/material'; import {IsCommunityOrAdmin} from '../../connect/communityGuard/isCommunityOrAdmin'; import {AdminToolServiceModule} from "../../services/adminToolService.module"; -import {InputModule} from "../../../library/sharedComponents/input/input.module"; +import {InputModule} from "../sharedComponents/input/input.module"; @NgModule({ imports: [ diff --git a/dashboard/helpTexts/page-help-contents.module.ts b/dashboard/helpTexts/page-help-contents.module.ts index fcb07e77..a2322e6b 100644 --- a/dashboard/helpTexts/page-help-contents.module.ts +++ b/dashboard/helpTexts/page-help-contents.module.ts @@ -10,7 +10,7 @@ import {PageHelpContentsComponent} from './page-help-contents.component'; import {SafeHtmlPipeModule} from '../../utils/pipes/safeHTMLPipe.module'; import {MatSlideToggleModule} from '@angular/material'; import {AdminToolServiceModule} from "../../services/adminToolService.module"; -import {InputModule} from "../../../library/sharedComponents/input/input.module"; +import {InputModule} from "../sharedComponents/input/input.module"; @NgModule({ imports: [ diff --git a/dashboard/page/pages.module.ts b/dashboard/page/pages.module.ts index 7bc1bd0c..b7a679fc 100644 --- a/dashboard/page/pages.module.ts +++ b/dashboard/page/pages.module.ts @@ -9,7 +9,7 @@ import {PagesRoutingModule} from './pages-routing.module'; import {MatAutocompleteModule, MatChipsModule, MatFormFieldModule, MatSlideToggleModule} from '@angular/material'; import {IsCommunityOrAdmin} from '../../connect/communityGuard/isCommunityOrAdmin'; import {AdminToolServiceModule} from "../../services/adminToolService.module"; -import {InputModule} from "../../../library/sharedComponents/input/input.module"; +import {InputModule} from "../sharedComponents/input/input.module"; @NgModule({ imports: [ diff --git a/dashboard/portal/communities.module.ts b/dashboard/portal/communities.module.ts index e58ea75c..053d1406 100644 --- a/dashboard/portal/communities.module.ts +++ b/dashboard/portal/communities.module.ts @@ -7,7 +7,7 @@ import {FormsModule, ReactiveFormsModule} from '@angular/forms'; import {AlertModalModule} from '../../utils/modal/alertModal.module'; import {AdminLoginGuard} from '../../login/adminLoginGuard.guard'; import {AdminToolServiceModule} from "../../services/adminToolService.module"; -import {InputModule} from "../../../library/sharedComponents/input/input.module"; +import {InputModule} from "../sharedComponents/input/input.module"; @NgModule({ imports: [ diff --git a/dashboard/sharedComponents/input/input.component.ts b/dashboard/sharedComponents/input/input.component.ts new file mode 100644 index 00000000..310c048b --- /dev/null +++ b/dashboard/sharedComponents/input/input.component.ts @@ -0,0 +1,59 @@ +import {Component, Input, OnDestroy, OnInit} from "@angular/core"; +import {Option} from "../../../../utils/indicator-utils"; +import {AbstractControl} from "@angular/forms"; +import {HelperFunctions} from "../../../utils/HelperFunctions.class"; + +@Component({ + selector: '[dashboard-input]', + template: ` + + + + + + {{option.label}} + + + + + {{label}} + ` +}) +export class InputComponent implements OnInit, OnDestroy { + @Input('formInput') formControl: AbstractControl; + @Input('type') type: string = 'text'; + @Input('label') label: string; + @Input('rows') rows: number = 3; + @Input('options') options: Option[]; + private initValue: any; + + constructor() { + } + + ngOnInit(): void { + this.initValue = HelperFunctions.copy(this.formControl.value); + this.formControl.valueChanges.subscribe(value => { + if(this.initValue === value) { + this.formControl.markAsPristine(); + } + }); + } + + ngOnDestroy(): void { + } + + public get required(): boolean { + return this.formControl && this.formControl.validator + && this.formControl.validator(this.formControl) + && this.formControl.validator(this.formControl).required; + } + + stopPropagation() { + if(event) { + event.stopPropagation(); + } + } +} diff --git a/dashboard/sharedComponents/input/input.module.ts b/dashboard/sharedComponents/input/input.module.ts new file mode 100644 index 00000000..3c8ca054 --- /dev/null +++ b/dashboard/sharedComponents/input/input.module.ts @@ -0,0 +1,26 @@ +import {NgModule} from '@angular/core'; +import {CommonModule} from '@angular/common'; +import {InputComponent} from "./input.component"; +import {SharedModule} from "../../../../shared/shared.module"; +import {MatFormFieldModule} from "@angular/material/form-field"; +import {MatInputModule} from "@angular/material/input"; +import {MatSelectModule} from "@angular/material/select"; +import {MatCheckboxModule} from '@angular/material/checkbox'; +@NgModule({ + imports: [ + CommonModule, + SharedModule, + MatFormFieldModule, + MatInputModule, + MatSelectModule, + MatCheckboxModule + ], + exports: [ + InputComponent + ], + declarations: [ + InputComponent + ] +}) +export class InputModule { +} diff --git a/dashboard/sharedComponents/loading/loading.component.ts b/dashboard/sharedComponents/loading/loading.component.ts new file mode 100644 index 00000000..8ac42695 --- /dev/null +++ b/dashboard/sharedComponents/loading/loading.component.ts @@ -0,0 +1,22 @@ +import {Component, Input} from "@angular/core"; + +@Component({ + selector: 'loading', + template: ` +
+
+ + + +
+
` +}) +export class LoadingComponent { + /** + * Possible values '': blue, 'success': green, 'warning': orange and 'danger': red + */ + @Input() color: 'success' | 'warning' | 'danger' = null; + + constructor() { + } +} diff --git a/dashboard/sharedComponents/loading/loading.module.ts b/dashboard/sharedComponents/loading/loading.module.ts new file mode 100644 index 00000000..5d720242 --- /dev/null +++ b/dashboard/sharedComponents/loading/loading.module.ts @@ -0,0 +1,18 @@ +import {NgModule} from '@angular/core'; +import {CommonModule} from '@angular/common'; +import {LoadingComponent} from "./loading.component"; + +@NgModule({ + imports: [ + CommonModule, + ], + declarations: [ + LoadingComponent + ], + providers: [], + exports: [ + LoadingComponent + ] +}) +export class LoadingModule { +}