[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
This commit is contained in:
argiro.kokogiannaki 2019-12-23 13:59:56 +00:00
parent 66e46004b8
commit 66375c1a1d
10 changed files with 131 additions and 6 deletions

View File

@ -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';

View File

@ -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: [

View File

@ -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: [

View File

@ -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: [

View File

@ -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: [

View File

@ -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: [

View File

@ -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: `
<mat-form-field *ngIf="type != 'checkbox'" class="uk-width-1-1 uk-padding-remove">
<input *ngIf="type === 'text'" matInput [placeholder]="label"
[formControl]="formControl" [required]="required">
<textarea *ngIf="type === 'textarea'" [rows]="rows" matInput
[placeholder]="label" [formControl]="formControl"></textarea>
<mat-select *ngIf="type === 'select'" [placeholder]="label"
(openedChange)="stopPropagation()" [formControl]="formControl" [disableOptionCentering]="true">
<mat-option *ngFor="let option of options" [value]="option.value">
{{option.label}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-checkbox *ngIf="type === 'checkbox'" [formControl]="formControl" >{{label}}</mat-checkbox>
`
})
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();
}
}
}

View File

@ -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 {
}

View File

@ -0,0 +1,22 @@
import {Component, Input} from "@angular/core";
@Component({
selector: 'loading',
template: `
<div class="uk-flex uk-flex-center uk-margin-small-top">
<div class="md-preloader" [ngClass]="(color)?('md-preloader-' + color):''">
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="48" width="48" viewBox="0 0 75 75">
<circle cx="37.5" cy="37.5" r="33.5" stroke-width="4"></circle>
</svg>
</div>
</div>`
})
export class LoadingComponent {
/**
* Possible values '': blue, 'success': green, 'warning': orange and 'danger': red
*/
@Input() color: 'success' | 'warning' | 'danger' = null;
constructor() {
}
}

View File

@ -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 {
}