Fixed Formatting in files

This commit is contained in:
Ioannis Kalyvas 2018-10-05 18:00:54 +03:00
parent 6ace88ecda
commit 510384cdb7
321 changed files with 9244 additions and 9252 deletions

View File

@ -1,51 +1,51 @@
import { BaseHttpService } from "../utilities/cite-http-service-module/base-http.service";
import { HttpClient, HttpClientModule } from "@angular/common/http";
import { TranslateLoader } from "@ngx-translate/core";
import { TranslateModule } from "@ngx-translate/core";
import { SharedModule } from "../shared/shared.module";
import { FormsModule } from "@angular/forms";
import { CommonModule } from "@angular/common";
import { NgModule } from "@angular/core";
import { TranslateService } from "@ngx-translate/core";
import { TranslateHttpLoader } from "@ngx-translate/http-loader";
import { AboutRoutes } from "./about.routes";
import { AboutComponent } from "./components/about.component";
import { BaseHttpService } from '../utilities/cite-http-service-module/base-http.service';
import { HttpClient, HttpClientModule } from '@angular/common/http';
import { TranslateLoader } from '@ngx-translate/core';
import { TranslateModule } from '@ngx-translate/core';
import { SharedModule } from '../shared/shared.module';
import { FormsModule } from '@angular/forms';
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { AboutRoutes } from './about.routes';
import { AboutComponent } from './components/about.component';
@NgModule({
imports: [
CommonModule,
FormsModule,
SharedModule,
HttpClientModule,
AboutRoutes,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
}
}),
],
imports: [
CommonModule,
FormsModule,
SharedModule,
HttpClientModule,
AboutRoutes,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
}
}),
],
declarations: [
AboutComponent
],
declarations: [
AboutComponent
],
exports: [
AboutComponent
],
providers: [
BaseHttpService
]
exports: [
AboutComponent
],
providers: [
BaseHttpService
]
})
export class AboutModule {
constructor(private translate: TranslateService) {
translate.setDefaultLang('en');
translate.use('en');
}
constructor(private translate: TranslateService) {
translate.setDefaultLang('en');
translate.use('en');
}
}
export function HttpLoaderFactory(httpClient: HttpClient) {
return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json');
return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json');
}

View File

@ -1,8 +1,8 @@
import { AboutComponent } from "./components/about.component";
import { Routes, RouterModule } from "@angular/router";
import { AboutComponent } from './components/about.component';
import { Routes, RouterModule } from '@angular/router';
const routes: Routes = [
{ path: '', component: AboutComponent },
{ path: '', component: AboutComponent },
];
export const AboutRoutes = RouterModule.forChild(routes);

View File

@ -1,6 +1,6 @@
import { Component, ViewEncapsulation, OnInit } from "@angular/core";
import { ActivatedRoute, Router } from "@angular/router";
import { TranslateService } from "@ngx-translate/core";
import { Component, ViewEncapsulation, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
@Component({
selector: 'app-about',

View File

@ -31,7 +31,7 @@ const appRoutes: Routes = [
canActivate: [AuthGuard]
},
{
path: "dmps",
path: 'dmps',
loadChildren: './dmps/dmps.module#DataManagementPlanModule',
data: {
breadcrumb: true
@ -39,7 +39,7 @@ const appRoutes: Routes = [
canActivate: [AuthGuard]
},
{
path: "dmp-profiles",
path: 'dmp-profiles',
loadChildren: './dmp-profiles/dmp-profile.module#DataManagamentPlanProfileModule',
data: {
breadcrumb: true
@ -71,32 +71,32 @@ const appRoutes: Routes = [
pathMatch: 'full'
},
{
path: "unauthorized",
path: 'unauthorized',
loadChildren: './unauthorized/unauthorized.module#UnauthorizedModule',
data: {
breadcrumb: true
},
},
{
path: "users",
path: 'users',
loadChildren: './users/users.module#UsersModule'
},
{
path: "datasetsProfiles",
path: 'datasetsProfiles',
loadChildren: './datasets-admin-listing/dataset-admin.module#DatasetAdminModule',
data: {
breadcrumb: true
},
},
{
path: "welcome",
path: 'welcome',
component: WelcomepageComponent,
data: {
breadcrumb: false
},
},
{
path: "api/oauth/authorized/b2access",
path: 'api/oauth/authorized/b2access',
component: B2AccessLoginComponent,
data: {
},

View File

@ -1,22 +1,22 @@
<app-navigation class="fixed"></app-navigation>
<div class="container-fluid main-container">
<div class="row">
<help-content position="top"></help-content>
</div>
<div class="row">
<div class="col-md-2">
<help-content position="left"></help-content>
</div>
<div class="col-md-8">
<app-breadcrumb *ngIf="this.isAuthenticated() && (hasBreadCrumb | async)"></app-breadcrumb>
<router-outlet (activate)='onActivate($event)' (deactivate)='onDeactivate($event)'></router-outlet>
</div>
<div class="col-md-2">
<help-content position="right"></help-content>
</div>
</div>
<div class="row">
<help-content position="bottom"></help-content>
</div>
<div class="row">
<app-help-content position="top"></app-help-content>
</div>
<div class="row">
<div class="col-md-2">
<app-help-content position="left"></app-help-content>
</div>
<div class="col-md-8">
<app-breadcrumb *ngIf="this.isAuthenticated() && (hasBreadCrumb | async)"></app-breadcrumb>
<router-outlet (activate)='onActivate($event)' (deactivate)='onDeactivate($event)'></router-outlet>
</div>
<div class="col-md-2">
<app-help-content position="right"></app-help-content>
</div>
</div>
<div class="row">
<app-help-content position="bottom"></app-help-content>
</div>
</div>

View File

@ -13,74 +13,74 @@ declare const gapi: any;
declare var $: any;
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
providers: [],
encapsulation: ViewEncapsulation.None
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
providers: [],
encapsulation: ViewEncapsulation.None
})
export class AppComponent implements OnInit {
hasBreadCrumb = Observable.of(false);
sideNavOpen = false;
hasBreadCrumb = Observable.of(false);
sideNavOpen = false;
constructor(
private router: Router,
private route: ActivatedRoute,
private authentication: AuthService,
private translate: TranslateService,
private languageService: LanguageResolverService,
private breadCrumbResolverService: BreadCrumbResolverService,
private cultureService: CultureService
) {
this.initializeServices()
}
constructor(
private router: Router,
private route: ActivatedRoute,
private authentication: AuthService,
private translate: TranslateService,
private languageService: LanguageResolverService,
private breadCrumbResolverService: BreadCrumbResolverService,
private cultureService: CultureService
) {
this.initializeServices();
}
onActivate(event: any) {
this.breadCrumbResolverService.push(event)
}
onActivate(event: any) {
this.breadCrumbResolverService.push(event);
}
onDeactivate(event: any) {
//this.breadCrumbResolverService.clear()
}
onDeactivate(event: any) {
//this.breadCrumbResolverService.clear()
}
ngOnInit() {
this.hasBreadCrumb = this.router.events
.filter(event => event instanceof NavigationEnd)
.map(() => this.route)
.map(route => route.firstChild)
.switchMap(route => route.data)
.map(data => data['breadcrumb'])
}
ngOnInit() {
this.hasBreadCrumb = this.router.events
.filter(event => event instanceof NavigationEnd)
.map(() => this.route)
.map(route => route.firstChild)
.switchMap(route => route.data)
.map(data => data['breadcrumb']);
}
login() {
//redirect to login page
this.router.navigate(['/login'], { queryParams: { /*refresh : Math.random() ,returnUrl: this.state.url*/ } });
}
login() {
//redirect to login page
this.router.navigate(['/login'], { queryParams: { /*refresh : Math.random() ,returnUrl: this.state.url*/ } });
}
logout() {
logout() {
}
}
public isAuthenticated(): boolean {
return !(!this.authentication.current())
}
public isAuthenticated(): boolean {
return !(!this.authentication.current());
}
goToDMPs() {
this.router.navigate(['/dmps'], { queryParams: { /*refresh : Math.random() ,returnUrl: this.state.url*/ } });
}
goToDMPs() {
this.router.navigate(['/dmps'], { queryParams: { /*refresh : Math.random() ,returnUrl: this.state.url*/ } });
}
goToProjects() {
this.router.navigate(['/projects'], { queryParams: { /*refresh : Math.random() ,returnUrl: this.state.url*/ } });
}
goToProjects() {
this.router.navigate(['/projects'], { queryParams: { /*refresh : Math.random() ,returnUrl: this.state.url*/ } });
}
initializeServices() {
// this language will be used as a fallback when a translation isn't found in the current language
this.translate.setDefaultLang('en');
initializeServices() {
// this language will be used as a fallback when a translation isn't found in the current language
this.translate.setDefaultLang('en');
this.authentication.current() && this.authentication.current().culture ? this.cultureService.cultureSelected(this.authentication.current().culture) : this.cultureService.cultureSelected(environment.defaultCulture);
this.authentication.current() && this.authentication.current().culture ? this.cultureService.cultureSelected(this.authentication.current().culture) : this.cultureService.cultureSelected(environment.defaultCulture);
//this.setupChangeListeners();
}
//this.setupChangeListeners();
}
}

View File

@ -4,4 +4,4 @@ export const HostConfiguration = {
App: environment.App,
CacheLifeTimeMillis: 30000,
HelpServiceUrl: environment.HelpServiceUrl
}
};

View File

@ -106,18 +106,18 @@ import { CultureService } from './utilities/culture/culture-service';
HelpContentService,
LanguageService,
LanguageResolverService,
BreadCrumbResolverService,
CultureService,
{
provide: MAT_DATE_LOCALE,
deps: [CultureService],
useFactory: (cultureService) => cultureService.getCurrentCulture()
},
{
provide: LOCALE_ID,
deps: [CultureService],
useFactory: (cultureService) => cultureService.getCurrentCulture()
},
BreadCrumbResolverService,
CultureService,
{
provide: MAT_DATE_LOCALE,
deps: [CultureService],
useFactory: (cultureService) => cultureService.getCurrentCulture()
},
{
provide: LOCALE_ID,
deps: [CultureService],
useFactory: (cultureService) => cultureService.getCurrentCulture()
},
],
bootstrap: [AppComponent]
})

View File

@ -57,8 +57,8 @@
</div>
</div>
<field-form *ngIf="!isComposite" [form]="form.get('fields').get(''+0)" [dataModel]="dataModel.fields[0]" [showMultiplicity]="false"
[indexPath]="indexPath + 'f' + 0"></field-form>
<app-field-form *ngIf="!isComposite" [form]="form.get('fields').get(''+0)" [dataModel]="dataModel.fields[0]" [showMultiplicity]="false"
[indexPath]="indexPath + 'f' + 0"></app-field-form>
<div *ngIf="isComposite">
<mat-expansion-panel *ngFor="let field of dataModel.fields let i=index;" #panel>
@ -71,7 +71,7 @@
</div>
</mat-expansion-panel-header>
<div id="{{indexPath + 'f' + i}}" *ngIf="panel.expanded">
<field-form [form]="form.get('fields').get(''+i)" [dataModel]="field" [indexPath]="indexPath + 'f' + i"></field-form>
<app-field-form [form]="form.get('fields').get(''+i)" [dataModel]="field" [indexPath]="indexPath + 'f' + i"></app-field-form>
</div>
</mat-expansion-panel>
</div>

View File

@ -1,57 +1,59 @@
import { Component, Input } from '@angular/core';
import { Component, Input, OnInit } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { FormArray, FormControl } from '@angular/forms';
import { FieldSet } from '../../models/datasetProfileAdmin/FieldSet';
import { Field } from '../../models/datasetProfileAdmin/Field';
@Component({
selector: 'compositefield-form',
templateUrl: './compositefield-form.component.html',
styleUrls: ['./compositefield-form.component.scss']
selector: 'app-compositefield-form',
templateUrl: './compositefield-form.component.html',
styleUrls: ['./compositefield-form.component.scss']
})
export class CompositeFieldFormComponent {
@Input() form: FormGroup;
@Input() dataModel: FieldSet;
@Input() indexPath: string;
export class CompositeFieldFormComponent implements OnInit {
@Input() form: FormGroup;
@Input() dataModel: FieldSet;
@Input() indexPath: string;
isComposite: boolean = false;
isMultiplicityEnabled: boolean = false;
isComposite = false;
isMultiplicityEnabled = false;
constructon() { }
constructon() { }
ngOnInit() {
//this.addNewField();
if (this.form.get("multiplicity"))
if (this.form.get("multiplicity").value.min > 1 || this.form.get("multiplicity").value.max > 1)
this.isMultiplicityEnabled = true;
this.isComposite = this.dataModel.fields.length > 1;
}
ngOnInit() {
//this.addNewField();
if (this.form.get('multiplicity')) {
if (this.form.get('multiplicity').value.min > 1 || this.form.get('multiplicity').value.max > 1) {
this.isMultiplicityEnabled = true;
}
}
this.isComposite = this.dataModel.fields.length > 1;
}
onIsCompositeChange(isComposite: boolean) {
if (!isComposite && (<FormArray>this.form.get("fields")).length > 1) {
for (let i = 0; i < (<FormArray>this.form.get("fields")).length - 1; i++) {
(<FormArray>this.form.get("fields")).removeAt(1);
}
this.dataModel.fields.splice(1);
}
}
onIsCompositeChange(isComposite: boolean) {
if (!isComposite && (<FormArray>this.form.get('fields')).length > 1) {
for (let i = 0; i < (<FormArray>this.form.get('fields')).length - 1; i++) {
(<FormArray>this.form.get('fields')).removeAt(1);
}
this.dataModel.fields.splice(1);
}
}
onIsMultiplicityEnabledChange(isMultiplicityEnabled: boolean) {
if (!isMultiplicityEnabled) {
(<FormControl>this.form.get('multiplicity').get("min")).setValue(0);
(<FormControl>this.form.get('multiplicity').get("max")).setValue(0);
}
}
onIsMultiplicityEnabledChange(isMultiplicityEnabled: boolean) {
if (!isMultiplicityEnabled) {
(<FormControl>this.form.get('multiplicity').get('min')).setValue(0);
(<FormControl>this.form.get('multiplicity').get('max')).setValue(0);
}
}
addNewField() {
let field: Field = new Field();
this.dataModel.fields.push(field);
(<FormArray>this.form.get("fields")).push(field.buildForm());
}
addNewField() {
const field: Field = new Field();
this.dataModel.fields.push(field);
(<FormArray>this.form.get('fields')).push(field.buildForm());
}
DeleteField(index) {
this.dataModel.fields.splice(index, 1);
(<FormArray>this.form.get("fields")).removeAt(index);
}
DeleteField(index) {
this.dataModel.fields.splice(index, 1);
(<FormArray>this.form.get('fields')).removeAt(index);
}
}

View File

@ -1,14 +1,14 @@
import { RouterModule, Routes } from '@angular/router';
import { FormComponent } from 'app/dataset-profile-form/form/form.component';
import { FormComponent } from './form/form.component';
export const DatasetProfileRoutes: Routes = [
{
path: ':id',
component: FormComponent
},
{
path: '',
component: FormComponent
}
{
path: ':id',
component: FormComponent
},
{
path: '',
component: FormComponent
}
];

View File

@ -64,22 +64,22 @@
<div fxLayout="row" fxLayoutAlign="start center" [ngSwitch]="form.get('viewStyle').get('renderStyle').value">
<div class="full-width" *ngSwitchCase="'combobox'">
<combobox-component [form]="form" [dataModel]="dataModel"></combobox-component>
<app-combobox-component [form]="form" [dataModel]="dataModel"></app-combobox-component>
</div>
<div class="full-width" *ngSwitchCase="'radiobox'">
<radiobox-component [form]="form" [dataModel]="dataModel"></radiobox-component>
<app-radiobox-component [form]="form" [dataModel]="dataModel"></app-radiobox-component>
</div>
<div class="full-width" *ngSwitchCase="'freetext'">
<freetext-component [form]="form" [dataModel]="dataModel"></freetext-component>
<app-freetext-component [form]="form" [dataModel]="dataModel"></app-freetext-component>
</div>
<div class="full-width" *ngSwitchCase="'textarea'">
<textarea-component [form]="form" [dataModel]="dataModel"></textarea-component>
<app-textarea-component [form]="form" [dataModel]="dataModel"></app-textarea-component>
</div>
<div class="full-width" *ngSwitchCase="'booleanDecision'">
<booleanDecision-component [form]="form" [dataModel]="dataModel"></booleanDecision-component>
<app-boolean-decision-component [form]="form" [dataModel]="dataModel"></app-boolean-decision-component>
</div>
<div class="full-width" *ngSwitchCase="'checkBox'">
<checkbox-component [form]="form" [dataModel]="dataModel"></checkbox-component>
<app-checkbox-component [form]="form" [dataModel]="dataModel"></app-checkbox-component>
</div>
</div>
<mat-checkbox *ngIf="showMultiplicity" [(ngModel)]="isFieldMultiplicityEnabled" (ngModelChange)="onIsFieldMultiplicityEnabledChange(isFieldMultiplicityEnabled)">Multiplicity</mat-checkbox>
@ -99,7 +99,7 @@
</button>
</div>
</mat-expansion-panel-header>
<rule-form *ngIf="panel.expanded" [form]="form.get('visible').get('rules').get(''+i)" [dataModel]="rule"></rule-form>
<app-rule-form *ngIf="panel.expanded" [form]="form.get('visible').get('rules').get(''+i)" [dataModel]="rule"></app-rule-form>
</mat-expansion-panel>

View File

@ -1,54 +1,56 @@

import { Component, Input } from '@angular/core';
import { Component, Input, OnInit } from '@angular/core';
import { FormGroup, FormControl, FormArray } from '@angular/forms';
import { ValidationTypes } from '../../models/common/ValidationTypes';
import { Field } from '../../models/datasetProfileAdmin/Field';
import { Rule } from '../../models/datasetProfileAdmin/Rule';
@Component({
selector: 'field-form',
templateUrl: './field-form.component.html',
styleUrls: ['./field-form.component.scss']
selector: 'app-field-form',
templateUrl: './field-form.component.html',
styleUrls: ['./field-form.component.scss']
})
export class FieldFormComponent {
@Input() form: FormGroup;
@Input() dataModel: Field;
@Input() showMultiplicity: boolean = true;
@Input() indexPath: string;
validationsOptions: Array<any>;
isFieldMultiplicityEnabled: boolean = false;
export class FieldFormComponent implements OnInit {
@Input() form: FormGroup;
@Input() dataModel: Field;
@Input() showMultiplicity = true;
@Input() indexPath: string;
validationsOptions: Array<any>;
isFieldMultiplicityEnabled = false;
constructon() {
}
constructon() {
}
ngOnInit() {
if (this.form.get("multiplicity"))
if (this.form.get("multiplicity").value.min > 1 || this.form.get("multiplicity").value.max > 1)
this.isFieldMultiplicityEnabled = true;
this.validationsOptions = [{ key: 0, value: ValidationTypes[0] }, { key: 1, value: ValidationTypes[1] }]
// this.addNewRule();
}
ngOnInit() {
if (this.form.get('multiplicity')) {
if (this.form.get('multiplicity').value.min > 1 || this.form.get('multiplicity').value.max > 1) {
this.isFieldMultiplicityEnabled = true;
}
}
this.validationsOptions = [{ key: 0, value: ValidationTypes[0] }, { key: 1, value: ValidationTypes[1] }];
// this.addNewRule();
}
onIsFieldMultiplicityEnabledChange(isFieldMultiplicityEnabled: boolean) {
if (!isFieldMultiplicityEnabled) {
(<FormControl>this.form.get('multiplicity').get("min")).setValue(0);
(<FormControl>this.form.get('multiplicity').get("max")).setValue(0);
}
}
onIsFieldMultiplicityEnabledChange(isFieldMultiplicityEnabled: boolean) {
if (!isFieldMultiplicityEnabled) {
(<FormControl>this.form.get('multiplicity').get('min')).setValue(0);
(<FormControl>this.form.get('multiplicity').get('max')).setValue(0);
}
}
addNewRule() {
let rule: Rule = new Rule();
this.dataModel.visible.rules.push(rule);
(<FormArray>this.form.get("visible").get("rules")).push(rule.buildForm());
}
addNewRule() {
const rule: Rule = new Rule();
this.dataModel.visible.rules.push(rule);
(<FormArray>this.form.get('visible').get('rules')).push(rule.buildForm());
}
DeleteRule(index) {
this.dataModel.visible.rules.splice(index, 1);
(<FormArray>this.form.get("visible").get("rules")).removeAt(index);
}
DeleteRule(index) {
this.dataModel.visible.rules.splice(index, 1);
(<FormArray>this.form.get('visible').get('rules')).removeAt(index);
}
onchangeCombo() {
if (this.form.get("data")) this.form.removeControl("data");
}
onchangeCombo() {
if (this.form.get('data')) { this.form.removeControl('data'); }
}
}

View File

@ -30,7 +30,7 @@
</mat-expansion-panel-header>
<div id="{{'p' + i}}" *ngIf="panel.expanded">
<div>
<page-form [form]="form.get('pages').at(i)" [dataModel]="page"></page-form>
<app-page-form [form]="form.get('pages').at(i)" [dataModel]="page"></app-page-form>
</div>
</div>
</mat-expansion-panel>
@ -56,7 +56,7 @@
</mat-expansion-panel-header>
<div id="{{'s' + i}}" *ngIf="panel.expanded">
<div>
<section-form [form]="form.get('sections').get(''+i)" [dataModel]="section" [indexPath]="'s' + i"></section-form>
<app-section-form [form]="form.get('sections').get(''+i)" [dataModel]="section" [indexPath]="'s' + i"></app-section-form>
</div>
</div>
</mat-expansion-panel>

View File

@ -4,108 +4,108 @@ import { DatasetProfileModelAdmin } from '../../models/datasetProfileAdmin/Datas
import { Page } from '../../models/datasetProfileAdmin/Page';
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormControl } from '@angular/forms';
import { SectionFormComponent } from '../section-form/section-form.component';
import { FormArray } from '@angular/forms';
import { Router, ActivatedRoute, ParamMap, Params } from '@angular/router';
import { PageFormComponent } from '../page-form/page-component'
import { Router, ActivatedRoute } from '@angular/router';
import { DatasetProfileAdmin } from '../../services/datasetProfileAdmin/datasetProfileAfmin.service';
import { Section } from '../../models/datasetProfileAdmin/Section';
import { MatDialog } from '@angular/material';
import { DatasetProfilePreviewerComponent } from '../previewer/dataset-profile-previewer.component';
@Component({
selector: 'form-comp',
templateUrl: './form.component.html',
providers: [DatasetProfileAdmin, DatasetProfileService],
styleUrls: ['./form.component.scss']
selector: 'app-form-comp',
templateUrl: './form.component.html',
providers: [DatasetProfileAdmin, DatasetProfileService],
styleUrls: ['./form.component.scss']
})
export class FormComponent {
export class FormComponent implements OnInit {
dataModel: DatasetProfileModelAdmin;
form: FormGroup;
private profileID: string;
dataModel: DatasetProfileModelAdmin;
form: FormGroup;
private profileID: string;
constructor(
public datasetprofileAdmin: DatasetProfileAdmin,
private datasetProfileService: DatasetProfileService,
private route: ActivatedRoute,
private router: Router,
public dialog: MatDialog,
) {
this.profileID = route.snapshot.params['id'];
}
constructor(
public datasetprofileAdmin: DatasetProfileAdmin,
private datasetProfileService: DatasetProfileService,
private route: ActivatedRoute,
private router: Router,
public dialog: MatDialog,
) {
this.profileID = route.snapshot.params['id'];
}
ngOnInit() {
ngOnInit() {
this.dataModel = JsonSerializer.fromJSONObject(new DatasetProfileModelAdmin(), DatasetProfileModelAdmin);
this.form = this.dataModel.buildForm();
if (this.profileID) {
this.datasetProfileService.getDatasetProfileById(this.profileID).subscribe((data) => {
this.dataModel = JsonSerializer.fromJSONObject(data, DatasetProfileModelAdmin);
this.form = this.dataModel.buildForm();
});
}
else {
this.addSection();
this.addPage();
}
}
this.dataModel = JsonSerializer.fromJSONObject(new DatasetProfileModelAdmin(), DatasetProfileModelAdmin);
this.form = this.dataModel.buildForm();
if (this.profileID) {
this.datasetProfileService.getDatasetProfileById(this.profileID).subscribe((data) => {
this.dataModel = JsonSerializer.fromJSONObject(data, DatasetProfileModelAdmin);
this.form = this.dataModel.buildForm();
});
} else {
this.addSection();
this.addPage();
}
}
onIsMultiplicityEnabledChange(isMultiplicityEnabled: boolean) {
if (!isMultiplicityEnabled) {
(<FormControl>this.form.get('multiplicity').get("min")).setValue(0);
(<FormControl>this.form.get('multiplicity').get("max")).setValue(0);
}
}
onIsMultiplicityEnabledChange(isMultiplicityEnabled: boolean) {
if (!isMultiplicityEnabled) {
(<FormControl>this.form.get('multiplicity').get('min')).setValue(0);
(<FormControl>this.form.get('multiplicity').get('max')).setValue(0);
}
}
addSection() {
let section: Section = new Section();
this.dataModel.sections.push(section);
(<FormArray>this.form.get("sections")).push(section.buildForm());
}
addSection() {
const section: Section = new Section();
this.dataModel.sections.push(section);
(<FormArray>this.form.get('sections')).push(section.buildForm());
}
addPage() {
let page: Page = new Page(this.dataModel.pages.length);
this.dataModel.pages.push(page);
(<FormArray>this.form.get("pages")).push(page.buildForm());
}
addPage() {
const page: Page = new Page(this.dataModel.pages.length);
this.dataModel.pages.push(page);
(<FormArray>this.form.get('pages')).push(page.buildForm());
}
DeleteSection(index) {
this.dataModel.sections.splice(index, 1);
(<FormArray>this.form.get("sections")).removeAt(index)
}
DeleteSection(index) {
this.dataModel.sections.splice(index, 1);
(<FormArray>this.form.get('sections')).removeAt(index);
}
DeletePage(index) {
this.dataModel.pages.splice(index, 1);
(<FormArray>this.form.get("pages")).removeAt(index)
}
DeletePage(index) {
this.dataModel.pages.splice(index, 1);
(<FormArray>this.form.get('pages')).removeAt(index);
}
createForm(data) {
return this.datasetprofileAdmin.createForm(data);
}
updateForm(id, data) {
return this.datasetprofileAdmin.updateForm(id, data);
}
onSubmit() {
let data = this.form.value;
createForm(data) {
return this.datasetprofileAdmin.createForm(data);
}
updateForm(id, data) {
return this.datasetprofileAdmin.updateForm(id, data);
}
onSubmit() {
const data = this.form.value;
if (this.profileID) this.updateForm(this.profileID, data).subscribe(() => {
this.router.navigate(['/datasetsProfiles'])
});
else this.createForm(data).subscribe(() => {
this.router.navigate(['/datasetsProfiles'])
});
}
if (this.profileID) {
this.updateForm(this.profileID, data).subscribe(() => {
this.router.navigate(['/datasetsProfiles']);
});
} else {
this.createForm(data).subscribe(() => {
this.router.navigate(['/datasetsProfiles']);
});
}
}
preview() {
let dialogRef = this.dialog.open(DatasetProfilePreviewerComponent, {
height: '355px',
width: '700px',
data: {
model: this.dataModel
}
});
}
preview() {
const dialogRef = this.dialog.open(DatasetProfilePreviewerComponent, {
height: '355px',
width: '700px',
data: {
model: this.dataModel
}
});
}
}

View File

@ -1,10 +1,10 @@
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { FormGroup } from '@angular/forms'
import { FormGroup } from '@angular/forms';
import { Page } from '../../models/datasetProfileAdmin/Page';
@Component({
selector: 'page-form',
selector: 'app-page-form',
templateUrl: './page-component.html',
styleUrls: ['./page-component.scss']
})

View File

@ -1,2 +1,2 @@
<dynamic-form *ngIf="formGroup" [form]="this.formGroup"
[dataModel]="datasetWizardModel"></dynamic-form>
<app-dynamic-form *ngIf="formGroup" [form]="this.formGroup"
[dataModel]="datasetWizardModel"></app-dynamic-form>

View File

@ -1,36 +1,36 @@
import { ViewEncapsulation, Component, Inject } from "@angular/core";
import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material";
import { FormGroup } from "@angular/forms";
import { DatasetProfileDefinitionModel } from "../../models/DatasetProfileDefinitionModel";
import { JsonSerializer } from "../../utilities/JsonSerializer";
import { DatasetModel } from "../../models/datasets/DatasetModel";
import { DatasetWizardModel } from "../../models/datasets/DatasetWizardModel";
import { DatasetProfileService } from "../../services/dataset-profile.service";
import { DatasetProfileAdmin } from "../../services/datasetProfileAdmin/datasetProfileAfmin.service";
import { ViewEncapsulation, Component, Inject, OnInit } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
import { FormGroup } from '@angular/forms';
import { DatasetProfileDefinitionModel } from '../../models/DatasetProfileDefinitionModel';
import { JsonSerializer } from '../../utilities/JsonSerializer';
import { DatasetModel } from '../../models/datasets/DatasetModel';
import { DatasetWizardModel } from '../../models/datasets/DatasetWizardModel';
import { DatasetProfileService } from '../../services/dataset-profile.service';
import { DatasetProfileAdmin } from '../../services/datasetProfileAdmin/datasetProfileAfmin.service';
@Component({
selector: 'dataset-profile-previewer',
templateUrl: './dataset-profile-previewer.component.html',
styleUrls: ['./dataset-profile-previewer.component.scss'],
encapsulation: ViewEncapsulation.None
selector: 'app-dataset-profile-previewer',
templateUrl: './dataset-profile-previewer.component.html',
styleUrls: ['./dataset-profile-previewer.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class DatasetProfilePreviewerComponent {
formGroup: FormGroup
datasetWizardModel: DatasetWizardModel
constructor(
private datasetProfileAdminService: DatasetProfileAdmin,
public dialogRef: MatDialogRef<DatasetProfilePreviewerComponent>,
@Inject(MAT_DIALOG_DATA) public data: any
) { }
export class DatasetProfilePreviewerComponent implements OnInit {
formGroup: FormGroup;
datasetWizardModel: DatasetWizardModel;
constructor(
private datasetProfileAdminService: DatasetProfileAdmin,
public dialogRef: MatDialogRef<DatasetProfilePreviewerComponent>,
@Inject(MAT_DIALOG_DATA) public data: any
) { }
ngOnInit(): void {
ngOnInit(): void {
this.datasetProfileAdminService.preview(this.data['model']).subscribe(x => {
this.datasetWizardModel = new DatasetWizardModel();
this.datasetWizardModel.datasetProfileDefinition = JsonSerializer.fromJSONObject(x, DatasetProfileDefinitionModel)
this.formGroup = this.datasetWizardModel.buildForm();
})
this.datasetProfileAdminService.preview(this.data['model']).subscribe(x => {
this.datasetWizardModel = new DatasetWizardModel();
this.datasetWizardModel.datasetProfileDefinition = JsonSerializer.fromJSONObject(x, DatasetProfileDefinitionModel);
this.formGroup = this.datasetWizardModel.buildForm();
});
}
}
}

View File

@ -54,7 +54,7 @@
</div>
</mat-expansion-panel-header>
<div id="{{indexPath + 's' + i}}" *ngIf="panel.expanded">
<section-form [form]="form.get('sections').get(''+i)" [dataModel]="section" [indexPath]="indexPath + 's' + i"></section-form>
<app-section-form [form]="form.get('sections').get(''+i)" [dataModel]="section" [indexPath]="indexPath + 's' + i"></app-section-form>
</div>
</mat-expansion-panel>
</div>
@ -92,7 +92,7 @@
</div>
</mat-expansion-panel-header>
<compositefield-form *ngIf="panel.expanded" [form]="form.get('fieldSets').get(''+i)" [dataModel]="field" [indexPath]="indexPath + 'cf' + i"></compositefield-form>
<app-compositefield-form *ngIf="panel.expanded" [form]="form.get('fieldSets').get(''+i)" [dataModel]="field" [indexPath]="indexPath + 'cf' + i"></app-compositefield-form>
</mat-expansion-panel>
</div>

View File

@ -9,54 +9,56 @@ import { Page } from '../../models/datasetProfileAdmin/Page';
import { JsonSerializer } from '../../utilities/JsonSerializer';
@Component({
selector: 'section-form',
templateUrl: './section-form.component.html',
styleUrls: ['./section-form.component.scss'],
encapsulation: ViewEncapsulation.None
selector: 'app-section-form',
templateUrl: './section-form.component.html',
styleUrls: ['./section-form.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class SectionFormComponent {
@Input() form: FormGroup;
@Input() dataModel: Section;
@Input() indexPath: string;
export class SectionFormComponent implements OnInit {
@Input() form: FormGroup;
@Input() dataModel: Section;
@Input() indexPath: string;
constructor() { }
constructor() { }
ngOnInit() {
this.form.root.get("pages").valueChanges.subscribe(x =>
this.keepPageSelectionValid(x)
);
}
ngOnInit() {
this.form.root.get('pages').valueChanges.subscribe(x =>
this.keepPageSelectionValid(x)
);
}
addField() {
let fieldSet: FieldSet = new FieldSet();
let field: Field = new Field();
fieldSet.fields.push(field);
if (this.dataModel.fieldSets)
this.dataModel.fieldSets.push(fieldSet);
(<FormArray>this.form.get("fieldSets")).push(fieldSet.buildForm());
}
addField() {
const fieldSet: FieldSet = new FieldSet();
const field: Field = new Field();
fieldSet.fields.push(field);
if (this.dataModel.fieldSets) {
this.dataModel.fieldSets.push(fieldSet);
}
(<FormArray>this.form.get('fieldSets')).push(fieldSet.buildForm());
}
addSectioninSection() {
let section: Section = new Section();
this.dataModel.sections.push(section);
(<FormArray>this.form.get("sections")).push(section.buildForm());
}
addSectioninSection() {
const section: Section = new Section();
this.dataModel.sections.push(section);
(<FormArray>this.form.get('sections')).push(section.buildForm());
}
DeleteSectionInSection(index) {
this.dataModel.sections.splice(index);
(<FormArray>this.form.get("sections")).removeAt(index);
}
DeleteSectionInSection(index) {
this.dataModel.sections.splice(index);
(<FormArray>this.form.get('sections')).removeAt(index);
}
DeleteFieldSet(index) {
this.dataModel.fieldSets.splice(index, 1);
(<FormArray>this.form.get("fieldSets")).removeAt(index);
}
DeleteFieldSet(index) {
this.dataModel.fieldSets.splice(index, 1);
(<FormArray>this.form.get('fieldSets')).removeAt(index);
}
keepPageSelectionValid(pagesJson: Array<any>) {
let selectedPage = this.form.get("page").value as String;
let pages: Array<Page> = JsonSerializer.fromJSONArray(pagesJson, Page);
if (pages.find(elem => elem.id === selectedPage) === undefined)
this.form.get("page").reset();
}
keepPageSelectionValid(pagesJson: Array<any>) {
const selectedPage = this.form.get('page').value as String;
const pages: Array<Page> = JsonSerializer.fromJSONArray(pagesJson, Page);
if (pages.find(elem => elem.id === selectedPage) === undefined) {
this.form.get('page').reset();
}
}
}

View File

@ -1,156 +1,156 @@
import { DataTableRequest } from '../models/data-table/DataTableRequest';
import { DatasetListingModel } from '../models/datasets/DatasetListingModel';
import { DatasetCriteria } from '../models/criteria/dataset/DatasetCriteria';
import { Component, ViewChild, OnInit, AfterViewInit } from "@angular/core";
import { MatPaginator, MatSort, MatSnackBar } from "@angular/material";
import { Router, Params, ActivatedRoute } from "@angular/router";
import { TranslateService } from "@ngx-translate/core";
import { DataSource } from "@angular/cdk/table";
import { Component, ViewChild, OnInit, AfterViewInit } from '@angular/core';
import { MatPaginator, MatSort, MatSnackBar } from '@angular/material';
import { Router, Params, ActivatedRoute } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { DataSource } from '@angular/cdk/table';
import { Observable } from "rxjs/Observable";
import { Observable } from 'rxjs/Observable';
import { PageEvent } from '@angular/material';
import { DataManagementPlanService } from "../services/data-management-plan/data-management-plan.service";
import { DataManagementPlanModel } from "../models/data-managemnt-plans/DataManagementPlanModel";
import { DataManagementPlanService } from '../services/data-management-plan/data-management-plan.service';
import { DataManagementPlanModel } from '../models/data-managemnt-plans/DataManagementPlanModel';
import { DatasetCriteriaComponent } from '../shared/components/criteria/datasets/datasets-criteria.component';
import { DatasetProfileAdmin } from '../services/datasetProfileAdmin/datasetProfileAfmin.service';
@Component({
selector: 'app-dataset-admin-listing-component',
templateUrl: 'dataset-admin-listing.component.html',
styleUrls: ['./dataset-admin-listing.component.scss'],
providers: [DatasetProfileAdmin, DataManagementPlanService]
selector: 'app-dataset-admin-listing-component',
templateUrl: 'dataset-admin-listing.component.html',
styleUrls: ['./dataset-admin-listing.component.scss'],
providers: [DatasetProfileAdmin, DataManagementPlanService]
})
export class DatasetAdminListingComponent implements OnInit {
@ViewChild(MatPaginator) _paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
@ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent;
@ViewChild(MatPaginator) _paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
@ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent;
dataSource: DatasetDataSource | null;
displayedColumns: String[] = ['label', 'dmp', 'profile', 'dataRepositories', 'registries', 'services', 'description', 'created', 'actions'];
pageEvent: PageEvent;
titlePrefix: String;
dmpId: String;
dataSource: DatasetDataSource | null;
displayedColumns: String[] = ['label', 'dmp', 'profile', 'dataRepositories', 'registries', 'services', 'description', 'created', 'actions'];
pageEvent: PageEvent;
titlePrefix: String;
dmpId: String;
statuses = [
{ value: '0', viewValue: 'Active' },
{ value: '1', viewValue: 'Inactive' }
];
statuses = [
{ value: '0', viewValue: 'Active' },
{ value: '1', viewValue: 'Inactive' }
];
constructor(
private datasetService: DatasetProfileAdmin,
private router: Router,
private languageService: TranslateService,
public snackBar: MatSnackBar,
public route: ActivatedRoute,
public dataManagementPlanService: DataManagementPlanService
) {
constructor(
private datasetService: DatasetProfileAdmin,
private router: Router,
private languageService: TranslateService,
public snackBar: MatSnackBar,
public route: ActivatedRoute,
public dataManagementPlanService: DataManagementPlanService
) {
}
}
ngOnInit() {
this.route.params.subscribe((params: Params) => {
this.dmpId = params['dmpId'];
if (this.dmpId != null) this.setDmpTitle(this.dmpId);
this.criteria.setCriteria(this.getDefaultCriteria(this.dmpId));
this.refresh();
this.criteria.setRefreshCallback(() => this.refresh());
});
}
ngOnInit() {
this.route.params.subscribe((params: Params) => {
this.dmpId = params['dmpId'];
if (this.dmpId != null) { this.setDmpTitle(this.dmpId); }
this.criteria.setCriteria(this.getDefaultCriteria(this.dmpId));
this.refresh();
this.criteria.setRefreshCallback(() => this.refresh());
});
}
setDmpTitle(dmpId: String) {
this.dataManagementPlanService.getSingle(dmpId).map(data => data as DataManagementPlanModel)
.subscribe(data => {
this.titlePrefix = data.label;
});
}
setDmpTitle(dmpId: String) {
this.dataManagementPlanService.getSingle(dmpId).map(data => data as DataManagementPlanModel)
.subscribe(data => {
this.titlePrefix = data.label;
});
}
refresh() {
this.dataSource = new DatasetDataSource(this.datasetService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria);
}
refresh() {
this.dataSource = new DatasetDataSource(this.datasetService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria);
}
rowClick(rowId: String) {
this.router.navigate(['form/' + rowId]);
}
rowClick(rowId: String) {
this.router.navigate(['form/' + rowId]);
}
getDefaultCriteria(dmpId: String): DatasetCriteria {
const defaultCriteria = new DatasetCriteria();
if (dmpId != null) {
defaultCriteria.dmpIds.push(dmpId);
}
return defaultCriteria;
}
getDefaultCriteria(dmpId: String): DatasetCriteria {
const defaultCriteria = new DatasetCriteria();
if (dmpId != null) {
defaultCriteria.dmpIds.push(dmpId);
}
return defaultCriteria;
}
// makeItPublic(id: String) {
// debugger;
// this.datasetService.makeDatasetPublic(id).subscribe();
// }
// makeItPublic(id: String) {
// debugger;
// this.datasetService.makeDatasetPublic(id).subscribe();
// }
}
export class DatasetDataSource extends DataSource<DatasetListingModel> {
totalCount = 0;
isLoadingResults = false;
totalCount = 0;
isLoadingResults = false;
constructor(
private _service: DatasetProfileAdmin,
private _paginator: MatPaginator,
private _sort: MatSort,
private _languageService: TranslateService,
private _snackBar: MatSnackBar,
private _criteria: DatasetCriteriaComponent
) {
super();
constructor(
private _service: DatasetProfileAdmin,
private _paginator: MatPaginator,
private _sort: MatSort,
private _languageService: TranslateService,
private _snackBar: MatSnackBar,
private _criteria: DatasetCriteriaComponent
) {
super();
}
}
connect(): Observable<DatasetListingModel[]> {
const displayDataChanges = [
this._paginator.page
//this._sort.matSortChange
];
connect(): Observable<DatasetListingModel[]> {
const displayDataChanges = [
this._paginator.page
//this._sort.matSortChange
];
return Observable.merge(...displayDataChanges)
.startWith(null)
.switchMap(() => {
setTimeout(() => {
this.isLoadingResults = true;
});
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
let fields: Array<string> = new Array()
if (this._sort.active) fields = this._sort.direction === "asc" ? ["+" + this._sort.active] : ["-" + this._sort.active];
const request = new DataTableRequest<DatasetCriteria>(startIndex, this._paginator.pageSize, { fields: fields });
request.criteria = this._criteria.criteria;
return this._service.getPaged(request);
})
/*.catch((error: any) => {
this._snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService },
duration: 3000,
extraClasses: ['snackbar-warning']
});
//this._criteria.criteria.onCallbackError(error);
return Observable.of(null);
})*/
.map(result => {
setTimeout(() => {
this.isLoadingResults = false;
});
return result;
})
.map(result => {
if (!result) { return []; }
if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; }
return result.data;
});
}
return Observable.merge(...displayDataChanges)
.startWith(null)
.switchMap(() => {
setTimeout(() => {
this.isLoadingResults = true;
});
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
let fields: Array<string> = new Array();
if (this._sort.active) { fields = this._sort.direction === 'asc' ? ['+' + this._sort.active] : ['-' + this._sort.active]; }
const request = new DataTableRequest<DatasetCriteria>(startIndex, this._paginator.pageSize, { fields: fields });
request.criteria = this._criteria.criteria;
return this._service.getPaged(request);
})
/*.catch((error: any) => {
this._snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService },
duration: 3000,
extraClasses: ['snackbar-warning']
});
//this._criteria.criteria.onCallbackError(error);
return Observable.of(null);
})*/
.map(result => {
setTimeout(() => {
this.isLoadingResults = false;
});
return result;
})
.map(result => {
if (!result) { return []; }
if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; }
return result.data;
});
}
disconnect() {
// No-op
}
disconnect() {
// No-op
}
}

View File

@ -10,45 +10,45 @@ import { HttpClient, HttpClientModule } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { SharedModule } from '../shared/shared.module'
import { SharedModule } from '../shared/shared.module';
@NgModule({
imports: [
CommonModule,
FormsModule,
HttpClientModule,
SharedModule,
RouterModule.forChild(DatasetAdminRoutes),
ReactiveFormsModule,
DynamicFormModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
}
}),
],
imports: [
CommonModule,
FormsModule,
HttpClientModule,
SharedModule,
RouterModule.forChild(DatasetAdminRoutes),
ReactiveFormsModule,
DynamicFormModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
}
}),
],
declarations: [
DatasetAdminListingComponent,
],
declarations: [
DatasetAdminListingComponent,
],
exports: [
DatasetAdminListingComponent,
RouterModule
],
providers: [
DatasetService
]
exports: [
DatasetAdminListingComponent,
RouterModule
],
providers: [
DatasetService
]
})
export class DatasetAdminModule {
constructor(private translate: TranslateService) {
translate.setDefaultLang('en');
translate.use('en');
}
constructor(private translate: TranslateService) {
translate.setDefaultLang('en');
translate.use('en');
}
}
export function HttpLoaderFactory(httpClient: HttpClient) {
return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json');
return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json');
}

View File

@ -3,5 +3,5 @@ import { RouterModule, Routes } from '@angular/router';
import { AuthGuard } from '../shared/guards/auth.guard';
export const DatasetAdminRoutes: Routes = [
{ path: '', component: DatasetAdminListingComponent, canActivate: [AuthGuard] },
{ path: '', component: DatasetAdminListingComponent, canActivate: [AuthGuard] },
];

View File

@ -1,152 +1,153 @@
import { OnInit, Component, ViewChild } from "@angular/core";
import { MatSort, MatPaginator, PageEvent, MatSnackBar } from "@angular/material";
import { DatasetCriteriaComponent } from "../../shared/components/criteria/datasets/datasets-criteria.component";
import { Observable } from "rxjs";
import { BreadcrumbItem } from "../../shared/components/breadcrumb/definition/breadcrumb-item";
import { DatasetService } from "../../services/dataset/dataset.service";
import { Router, ActivatedRoute, Params } from "@angular/router";
import { TranslateService } from "@ngx-translate/core";
import { DataManagementPlanService } from "../../services/data-management-plan/data-management-plan.service";
import { DatasetCriteria } from "../../models/criteria/dataset/DatasetCriteria";
import { DataSource } from "@angular/cdk/table";
import { DatasetListingModel } from "../../models/datasets/DatasetListingModel";
import { DataTableRequest } from "../../models/data-table/DataTableRequest";
import { FacetSearchCriteriaModel } from "../../models/facet-search/FacetSearchCriteriaModel";
import { OnInit, Component, ViewChild } from '@angular/core';
import { MatSort, MatPaginator, PageEvent, MatSnackBar } from '@angular/material';
import { DatasetCriteriaComponent } from '../../shared/components/criteria/datasets/datasets-criteria.component';
import { Observable } from 'rxjs';
import { BreadcrumbItem } from '../../shared/components/breadcrumb/definition/breadcrumb-item';
import { DatasetService } from '../../services/dataset/dataset.service';
import { Router, ActivatedRoute, Params } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { DataManagementPlanService } from '../../services/data-management-plan/data-management-plan.service';
import { DatasetCriteria } from '../../models/criteria/dataset/DatasetCriteria';
import { DataSource } from '@angular/cdk/table';
import { DatasetListingModel } from '../../models/datasets/DatasetListingModel';
import { DataTableRequest } from '../../models/data-table/DataTableRequest';
import { FacetSearchCriteriaModel } from '../../models/facet-search/FacetSearchCriteriaModel';
@Component({
selector: 'app-dataset-public-listing-component',
templateUrl: 'dataset-public-listing.component.html',
styleUrls: ['./dataset-public-listing.component.scss'],
selector: 'app-dataset-public-listing-component',
templateUrl: 'dataset-public-listing.component.html',
styleUrls: ['./dataset-public-listing.component.scss'],
})
export class DatasetPublicListingComponent implements OnInit {
@ViewChild(MatPaginator) _paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
@ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent;
@ViewChild(MatPaginator) _paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
@ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent;
dataSource: DatasetDataSource | null;
displayedColumns: String[] = ['label', 'dmp', 'profile', 'status', 'description', 'created'];
pageEvent: PageEvent;
titlePrefix: String;
dmpId: string;
dataSource: DatasetDataSource | null;
displayedColumns: String[] = ['label', 'dmp', 'profile', 'status', 'description', 'created'];
pageEvent: PageEvent;
titlePrefix: String;
dmpId: string;
constructor(
private datasetService: DatasetService,
private router: Router,
private languageService: TranslateService,
public snackBar: MatSnackBar,
public route: ActivatedRoute,
public dataManagementPlanService: DataManagementPlanService
) {
constructor(
private datasetService: DatasetService,
private router: Router,
private languageService: TranslateService,
public snackBar: MatSnackBar,
public route: ActivatedRoute,
public dataManagementPlanService: DataManagementPlanService
) {
}
}
ngOnInit() {
this.route.params.subscribe(async (params: Params) => {
this.dmpId = params['dmpId'];
this.criteria.setCriteria(this.getDefaultCriteria(this.dmpId));
this.refresh();
this.criteria.setRefreshCallback(() => this.refresh());
if (this.dmpId != null) {
let dmp = await this.dataManagementPlanService.getSingle(this.dmpId).toPromise()
if (params['dmpLabel'] != undefined)
this.titlePrefix = "for " + params['dmpLabel'];
}
});
}
ngOnInit() {
this.route.params.subscribe(async (params: Params) => {
this.dmpId = params['dmpId'];
this.criteria.setCriteria(this.getDefaultCriteria(this.dmpId));
this.refresh();
this.criteria.setRefreshCallback(() => this.refresh());
if (this.dmpId != null) {
const dmp = await this.dataManagementPlanService.getSingle(this.dmpId).toPromise();
if (params['dmpLabel'] !== undefined) {
this.titlePrefix = 'for ' + params['dmpLabel'];
}
}
});
}
onCriteriaChange(event){
//console.log(event)
this.criteria.setCriteria(event);
this.refresh();
}
onCriteriaChange(event) {
//console.log(event)
this.criteria.setCriteria(event);
this.refresh();
}
refresh() {
this.dataSource = new DatasetDataSource(this.datasetService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria, this.dmpId);
}
refresh() {
this.dataSource = new DatasetDataSource(this.datasetService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria, this.dmpId);
}
rowClick(rowId: String) {
this.router.navigate(['/datasets/publicEdit/' + rowId]);
}
rowClick(rowId: String) {
this.router.navigate(['/datasets/publicEdit/' + rowId]);
}
getDefaultCriteria(dmpId: String): DatasetCriteria {
const defaultCriteria = new DatasetCriteria();
if (dmpId != null) {
defaultCriteria.dmpIds.push(dmpId);
}
return defaultCriteria;
}
getDefaultCriteria(dmpId: String): DatasetCriteria {
const defaultCriteria = new DatasetCriteria();
if (dmpId != null) {
defaultCriteria.dmpIds.push(dmpId);
}
return defaultCriteria;
}
makeItPublic(id: String) {
this.datasetService.makeDatasetPublic(id).subscribe();
}
makeItPublic(id: String) {
this.datasetService.makeDatasetPublic(id).subscribe();
}
}
export class DatasetDataSource extends DataSource<DatasetListingModel> {
totalCount = 0;
isLoadingResults = false;
constructor(
private _service: DatasetService,
private _paginator: MatPaginator,
private _sort: MatSort,
private _languageService: TranslateService,
private _snackBar: MatSnackBar,
private _criteria: DatasetCriteriaComponent,
private dmpId: String
) {
super();
totalCount = 0;
isLoadingResults = false;
constructor(
private _service: DatasetService,
private _paginator: MatPaginator,
private _sort: MatSort,
private _languageService: TranslateService,
private _snackBar: MatSnackBar,
private _criteria: DatasetCriteriaComponent,
private dmpId: String
) {
super();
}
}
connect(): Observable<DatasetListingModel[]> {
const displayDataChanges = [
this._paginator.page
//this._sort.matSortChange
];
connect(): Observable<DatasetListingModel[]> {
const displayDataChanges = [
this._paginator.page
//this._sort.matSortChange
];
return Observable.merge(...displayDataChanges)
.startWith(null)
.switchMap(() => {
setTimeout(() => {
this.isLoadingResults = true;
});
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
let fields: Array<string> = new Array()
if (this._sort.active) fields = this._sort.direction === "asc" ? ["+" + this._sort.active] : ["-" + this._sort.active];
const request = new DataTableRequest<FacetSearchCriteriaModel>(startIndex, this._paginator.pageSize, { fields: fields });
request.criteria = this._criteria.criteria;
//if (this.dmpId) request.criteria.allVersions = true;
return this._service.getPublicPaged(request);
})
/*.catch((error: any) => {
this._snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService },
duration: 3000,
extraClasses: ['snackbar-warning']
});
//this._criteria.criteria.onCallbackError(error);
return Observable.of(null);
})*/
.map(result => {
setTimeout(() => {
this.isLoadingResults = false;
});
return result;
})
.map(result => {
if (!result) { return []; }
if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; }
return result.data;
});
}
return Observable.merge(...displayDataChanges)
.startWith(null)
.switchMap(() => {
setTimeout(() => {
this.isLoadingResults = true;
});
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
let fields: Array<string> = new Array();
if (this._sort.active) { fields = this._sort.direction === 'asc' ? ['+' + this._sort.active] : ['-' + this._sort.active]; }
const request = new DataTableRequest<FacetSearchCriteriaModel>(startIndex, this._paginator.pageSize, { fields: fields });
request.criteria = this._criteria.criteria;
//if (this.dmpId) request.criteria.allVersions = true;
return this._service.getPublicPaged(request);
})
/*.catch((error: any) => {
this._snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService },
duration: 3000,
extraClasses: ['snackbar-warning']
});
//this._criteria.criteria.onCallbackError(error);
return Observable.of(null);
})*/
.map(result => {
setTimeout(() => {
this.isLoadingResults = false;
});
return result;
})
.map(result => {
if (!result) { return []; }
if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; }
return result.data;
});
}
disconnect() {
// No-op
}
disconnect() {
// No-op
}
}

View File

@ -1,36 +1,36 @@
import { Component, ViewEncapsulation, OnInit, Inject } from "@angular/core";
import { FormGroup } from "@angular/forms";
import { DataRepositoryService } from "../../../services/datarepository/datarepository.service";
import { Router, ActivatedRoute } from "@angular/router";
import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material";
import { DataRepositoryModel } from "../../../models/dataRepositories/DataRepositoryModel";
import { Component, ViewEncapsulation, OnInit, Inject } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { DataRepositoryService } from '../../../services/datarepository/datarepository.service';
import { Router, ActivatedRoute } from '@angular/router';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
import { DataRepositoryModel } from '../../../models/dataRepositories/DataRepositoryModel';
@Component({
selector: 'app-datarepository-referenced-model-helper',
templateUrl: 'datarepository-referenced-model-helper.component.html',
styleUrls: ['./datarepository-referenced-model-helper.component.scss'],
encapsulation: ViewEncapsulation.None
selector: 'app-datarepository-referenced-model-helper',
templateUrl: 'datarepository-referenced-model-helper.component.html',
styleUrls: ['./datarepository-referenced-model-helper.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class DataRepositoryReferencedModelHelperComponent implements OnInit {
public formGroup: FormGroup;
public formGroup: FormGroup;
constructor(
private dataRepositoryService: DataRepositoryService,
private route: ActivatedRoute,
public router: Router,
public dialogRef: MatDialogRef<DataRepositoryReferencedModelHelperComponent>,
@Inject(MAT_DIALOG_DATA) public data: any
) { }
constructor(
private dataRepositoryService: DataRepositoryService,
private route: ActivatedRoute,
public router: Router,
public dialogRef: MatDialogRef<DataRepositoryReferencedModelHelperComponent>,
@Inject(MAT_DIALOG_DATA) public data: any
) { }
ngOnInit(): void {
let datarepo = new DataRepositoryModel();
this.formGroup = datarepo.buildForm();
}
ngOnInit(): void {
const datarepo = new DataRepositoryModel();
this.formGroup = datarepo.buildForm();
}
send(value: any) {
this.dataRepositoryService.create(this.formGroup.value).subscribe(
(item)=> this.dialogRef.close(item)
);
}
send(value: any) {
this.dataRepositoryService.create(this.formGroup.value).subscribe(
(item) => this.dialogRef.close(item)
);
}
}

View File

@ -1,36 +1,36 @@
import { ExternalDatasetModel } from "../../../models/external-dataset/ExternalDatasetModel";
import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material";
import { Inject, ViewEncapsulation, Component, OnInit } from "@angular/core";
import { ActivatedRoute, Router } from "@angular/router";
import { ExternalDatasetService } from "../../../services/external-dataset/external-dataset.service";
import { FormGroup } from "@angular/forms";
import { ExternalDatasetModel } from '../../../models/external-dataset/ExternalDatasetModel';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
import { Inject, ViewEncapsulation, Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { ExternalDatasetService } from '../../../services/external-dataset/external-dataset.service';
import { FormGroup } from '@angular/forms';
@Component({
selector: 'app-externaldataset-referenced-model-helper',
templateUrl: 'externaldataset-referenced-model-helper.component.html',
styleUrls: ['./externaldataset-referenced-model-helper.component.scss'],
encapsulation: ViewEncapsulation.None
selector: 'app-externaldataset-referenced-model-helper',
templateUrl: 'externaldataset-referenced-model-helper.component.html',
styleUrls: ['./externaldataset-referenced-model-helper.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class ExternalDatasetReferencedModelHelperComponent implements OnInit {
public formGroup: FormGroup;
public formGroup: FormGroup;
constructor(
private externalDatasetService: ExternalDatasetService,
private route: ActivatedRoute,
public router: Router,
public dialogRef: MatDialogRef<ExternalDatasetReferencedModelHelperComponent>,
@Inject(MAT_DIALOG_DATA) public data: any
) { }
constructor(
private externalDatasetService: ExternalDatasetService,
private route: ActivatedRoute,
public router: Router,
public dialogRef: MatDialogRef<ExternalDatasetReferencedModelHelperComponent>,
@Inject(MAT_DIALOG_DATA) public data: any
) { }
ngOnInit(): void {
let externalDatasetModel = new ExternalDatasetModel();
this.formGroup = externalDatasetModel.buildForm();
}
ngOnInit(): void {
const externalDatasetModel = new ExternalDatasetModel();
this.formGroup = externalDatasetModel.buildForm();
}
send(value: any) {
this.externalDatasetService.create(this.formGroup.value).subscribe(
(item)=> this.dialogRef.close(item)
);
}
send(value: any) {
this.externalDatasetService.create(this.formGroup.value).subscribe(
(item) => this.dialogRef.close(item)
);
}
}

View File

@ -1,36 +1,36 @@
import { Component, ViewEncapsulation, OnInit, Inject } from "@angular/core";
import { FormGroup } from "@angular/forms";
import { ActivatedRoute, Router } from "@angular/router";
import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material";
import { RegisterModel } from "../../../models/registers/RegisterModel";
import { RegistryService } from "../../../services/registries/registry.service";
import { Component, ViewEncapsulation, OnInit, Inject } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
import { RegisterModel } from '../../../models/registers/RegisterModel';
import { RegistryService } from '../../../services/registries/registry.service';
@Component({
selector: 'app-registry-referenced-model-helper',
templateUrl: 'registry-referenced-model-helper.component.html',
styleUrls: ['./registry-referenced-model-helper.component.scss'],
encapsulation: ViewEncapsulation.None
selector: 'app-registry-referenced-model-helper',
templateUrl: 'registry-referenced-model-helper.component.html',
styleUrls: ['./registry-referenced-model-helper.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class RegistryReferencedModelHelperComponent implements OnInit {
public formGroup: FormGroup;
public formGroup: FormGroup;
constructor(
private registryService: RegistryService,
private route: ActivatedRoute,
public router: Router,
public dialogRef: MatDialogRef<RegistryReferencedModelHelperComponent>,
@Inject(MAT_DIALOG_DATA) public data: any
) { }
constructor(
private registryService: RegistryService,
private route: ActivatedRoute,
public router: Router,
public dialogRef: MatDialogRef<RegistryReferencedModelHelperComponent>,
@Inject(MAT_DIALOG_DATA) public data: any
) { }
ngOnInit(): void {
let registryModel = new RegisterModel();
this.formGroup = registryModel.buildForm();
}
ngOnInit(): void {
const registryModel = new RegisterModel();
this.formGroup = registryModel.buildForm();
}
send(value: any) {
this.registryService.create(this.formGroup.value).subscribe(
(item)=> this.dialogRef.close(item)
);
}
send(value: any) {
this.registryService.create(this.formGroup.value).subscribe(
(item) => this.dialogRef.close(item)
);
}
}

View File

@ -1,36 +1,36 @@
import { ViewEncapsulation, Component, OnInit, Inject } from "@angular/core";
import { FormGroup } from "@angular/forms";
import { ActivatedRoute, Router } from "@angular/router";
import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material";
import { ServiceModel } from "../../../models/services/ServiceModel";
import { ServicesDataService } from "../../../services/services/services-data.service";
import { ViewEncapsulation, Component, OnInit, Inject } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
import { ServiceModel } from '../../../models/services/ServiceModel';
import { ServicesDataService } from '../../../services/services/services-data.service';
@Component({
selector: 'app-services-referenced-model-helper',
templateUrl: 'services-referenced-model-helper.component.html',
styleUrls: ['./services-referenced-model-helper.component.scss'],
encapsulation: ViewEncapsulation.None
selector: 'app-services-referenced-model-helper',
templateUrl: 'services-referenced-model-helper.component.html',
styleUrls: ['./services-referenced-model-helper.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class ServicesReferencedModelHelperComponent implements OnInit {
public formGroup: FormGroup;
public formGroup: FormGroup;
constructor(
private registryService: ServicesDataService,
private route: ActivatedRoute,
public router: Router,
public dialogRef: MatDialogRef<ServicesReferencedModelHelperComponent>,
@Inject(MAT_DIALOG_DATA) public data: any
) { }
constructor(
private registryService: ServicesDataService,
private route: ActivatedRoute,
public router: Router,
public dialogRef: MatDialogRef<ServicesReferencedModelHelperComponent>,
@Inject(MAT_DIALOG_DATA) public data: any
) { }
ngOnInit(): void {
let serviceModel = new ServiceModel();
this.formGroup = serviceModel.buildForm();
}
ngOnInit(): void {
const serviceModel = new ServiceModel();
this.formGroup = serviceModel.buildForm();
}
send() {
this.registryService.create(this.formGroup.value).subscribe(
(item)=> this.dialogRef.close(item)
);
}
send() {
this.registryService.create(this.formGroup.value).subscribe(
(item) => this.dialogRef.close(item)
);
}
}

View File

@ -225,8 +225,8 @@
</mat-step>
<mat-step>
<ng-template matStepLabel>{{'DATASET-WIZARD.THIRD-STEP.TITLE' | translate}}</ng-template>
<dynamic-form class="full-width" *ngIf="formGroup && datasetWizardModel && datasetWizardModel.datasetProfileDefinition" [form]="this.formGroup.get('datasetProfileDefinition')"
[dataModel]="datasetWizardModel"></dynamic-form>
<app-dynamic-form class="full-width" *ngIf="formGroup && datasetWizardModel && datasetWizardModel.datasetProfileDefinition" [form]="this.formGroup.get('datasetProfileDefinition')"
[dataModel]="datasetWizardModel"></app-dynamic-form>
<div class="navigation-buttons-container">
<button style="margin-top:10px;" matStepperPrevious mat-raised-button color="primary">{{'DATASET-WIZARD.ACTIONS.BACK'
| translate}}</button>

View File

@ -15,10 +15,10 @@ import { ExternalSourcesService } from '../../services/external-sources/external
import { DatasetWizardService } from '../../services/dataset-wizard/dataset-wizard.service';
import { TranslateService } from '@ngx-translate/core';
import { ActivatedRoute, Router, Params } from '@angular/router';
import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation, TemplateRef, ChangeDetectionStrategy } from "@angular/core";
import { FormGroup, Validators, FormBuilder, FormArray } from "@angular/forms";
import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation, TemplateRef, ChangeDetectionStrategy } from '@angular/core';
import { FormGroup, Validators, FormBuilder, FormArray } from '@angular/forms';
import * as FileSaver from 'file-saver';
import { MatPaginator, MatSort, MatSnackBar, MatStepper, MatDialog } from "@angular/material";
import { MatPaginator, MatSort, MatSnackBar, MatStepper, MatDialog } from '@angular/material';
import { ExternalDatasetCriteria } from '../../models/criteria/external-dataset/ExternalDatasetCriteria';
import { ExternalDatasetModel } from '../../models/external-dataset/ExternalDatasetModel';
import { RegistryCriteria } from '../../models/criteria/registry/RegistryCriteria';
@ -43,423 +43,421 @@ import { ExternalDatasetReferencedModelHelperComponent } from '../dataset-refere
import { ServicesReferencedModelHelperComponent } from '../dataset-referenced-models-helper/services/services-referenced-model-helper.component';
@Component({
selector: 'app-dataset-wizard-component',
templateUrl: 'dataset-wizard.component.html',
styleUrls: ['./dataset-wizard.component.scss'],
encapsulation: ViewEncapsulation.None,
selector: 'app-dataset-wizard-component',
templateUrl: 'dataset-wizard.component.html',
styleUrls: ['./dataset-wizard.component.scss'],
encapsulation: ViewEncapsulation.None,
})
export class DatasetWizardComponent implements OnInit, IBreadCrumbComponent {
breadCrumbs: Observable<BreadcrumbItem[]>;
viewOnly = false;
@ViewChild('stepper') stepper: MatStepper;
//autocomplete Display Functions;
externalDatasetDisplayFunc = (item) => item ? item.label : null;
registriesDisplayFunc = (item) => item ? item.label : null;
dataRepositoryDisplayFunc = (item) => item ? item.name : null;
servicesDisplayFunc = (item) => item ? item.label : null;
tagsDisplayFunc = (item) => item ? item.name : null;
export class DatasetWizardComponent implements OnInit, AfterViewInit, IBreadCrumbComponent {
breadCrumbs: Observable<BreadcrumbItem[]>;
viewOnly = false;
@ViewChild('stepper') stepper: MatStepper;
//autocomplete Display Functions;
//autocomplete Configurations;
externalDatasetAutoCompleteConfiguration: AutoCompleteConfiguration;
registriesAutoCompleteConfiguration: AutoCompleteConfiguration;
dataRepositoriesAutoCompleteConfiguration: AutoCompleteConfiguration;
servicesAutoCompleteConfiguration: AutoCompleteConfiguration;
tagsAutoCompleteConfiguration: AutoCompleteConfiguration;
dmpAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
externalSourcesConfiguration: ExternalSourcesConfiguration;
datasetWizardModel: DatasetWizardModel;
isNew = true;
formGroup: FormGroup;
datasetProfileDefinitionModel: DatasetProfileDefinitionModel;
availableProfiles: DatasetProfileModel[] = [];
itemId: string;
isLinear = false;
firstStepFormGroup: FormGroup;
secondFormGroup: FormGroup;
externalDatasetDisplayFunc = (item) => item ? item.label : null;
registriesDisplayFunc = (item) => item ? item.label : null;
dataRepositoryDisplayFunc = (item) => item ? item.name : null;
servicesDisplayFunc = (item) => item ? item.label : null;
tagsDisplayFunc = (item) => item ? item.name : null;
externalDatasetDisplaySubtitleFunc = (item) => item ? item.tag : null;
registriesDisplaySubtitleFunc = (item) => item ? item.tag : null;
dataRepositoryDisplaySubtitleFunc = (item) => item ? item.tag : null;
servicesDisplaySubtitleFunc = (item) => item ? item.tag : null;
tagsDisplaySubtitleFunc = (item) => item ? item.tag : null;
constructor(
private datasetWizardService: DatasetWizardService,
private formBuilder: FormBuilder,
private datasetService: DatasetService,
private route: ActivatedRoute,
public snackBar: MatSnackBar,
public router: Router,
public language: TranslateService,
public externalSourcesService: ExternalSourcesService,
public dataManagementPlanService: DataManagementPlanService,
public dialog: MatDialog,
public externalSourcesConfigurationService: ExternalSourcesConfigurationService
) {
}
//autocomplete Display Functions;
externalDatasetDisplaySubtitleFunc = (item) => item ? item.tag : null;
registriesDisplaySubtitleFunc = (item) => item ? item.tag : null;
dataRepositoryDisplaySubtitleFunc = (item) => item ? item.tag : null;
servicesDisplaySubtitleFunc = (item) => item ? item.tag : null;
tagsDisplaySubtitleFunc = (item) => item ? item.tag : null;
ngOnInit() {
this.route
.data
.subscribe(v => this.viewOnly = v['public']);
//autocomplete Configurations;
externalDatasetAutoCompleteConfiguration: AutoCompleteConfiguration;
registriesAutoCompleteConfiguration: AutoCompleteConfiguration;
dataRepositoriesAutoCompleteConfiguration: AutoCompleteConfiguration;
servicesAutoCompleteConfiguration: AutoCompleteConfiguration;
tagsAutoCompleteConfiguration: AutoCompleteConfiguration;
dmpAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
const dmpRequestItem: RequestItem<DataManagementPlanCriteria> = new RequestItem();
dmpRequestItem.criteria = new DataManagementPlanCriteria();
externalSourcesConfiguration: ExternalSourcesConfiguration;
const externalDatasetRequestItem: RequestItem<ExternalDatasetCriteria> = new RequestItem();
externalDatasetRequestItem.criteria = new ExternalDatasetCriteria();
this.externalDatasetAutoCompleteConfiguration = new AutoCompleteConfiguration(this.externalSourcesService.searchDatasetSExternalDatasetservice.bind(this.externalSourcesService), externalDatasetRequestItem);
datasetWizardModel: DatasetWizardModel;
isNew = true;
formGroup: FormGroup;
datasetProfileDefinitionModel: DatasetProfileDefinitionModel;
const registriesRequestItem: RequestItem<RegistryCriteria> = new RequestItem();
registriesRequestItem.criteria = new RegistryCriteria();
this.registriesAutoCompleteConfiguration = new AutoCompleteConfiguration(this.externalSourcesService.searchDatasetRegistry.bind(this.externalSourcesService), registriesRequestItem);
availableProfiles: DatasetProfileModel[] = [];
itemId: string
constructor(
private datasetWizardService: DatasetWizardService,
private formBuilder: FormBuilder,
private datasetService: DatasetService,
private route: ActivatedRoute,
public snackBar: MatSnackBar,
public router: Router,
public language: TranslateService,
public externalSourcesService: ExternalSourcesService,
public dataManagementPlanService: DataManagementPlanService,
public dialog: MatDialog,
public externalSourcesConfigurationService: ExternalSourcesConfigurationService
) {
const dataRepositoriesRequestItem: RequestItem<DataRepositoryCriteria> = new RequestItem();
dataRepositoriesRequestItem.criteria = new DataRepositoryCriteria();
this.dataRepositoriesAutoCompleteConfiguration = new AutoCompleteConfiguration(this.externalSourcesService.searchDatasetRepository.bind(this.externalSourcesService), dataRepositoriesRequestItem);
}
const servicesRequestItem: RequestItem<ServicesCriteria> = new RequestItem();
servicesRequestItem.criteria = new ServicesCriteria();
this.servicesAutoCompleteConfiguration = new AutoCompleteConfiguration(this.externalSourcesService.searchDatasetService.bind(this.externalSourcesService), servicesRequestItem);
isLinear = false;
firstStepFormGroup: FormGroup;
secondFormGroup: FormGroup;
const tagsRequestItem: RequestItem<TagsCriteria> = new RequestItem();
tagsRequestItem.criteria = new TagsCriteria();
this.tagsAutoCompleteConfiguration = new AutoCompleteConfiguration(this.externalSourcesService.searchDatasetTags.bind(this.externalSourcesService), tagsRequestItem);
ngOnInit() {
this.externalSourcesConfigurationService.getExternalSourcesConfiguration().subscribe(result => {
this.externalSourcesConfiguration = result;
this.externalSourcesConfiguration.dataRepositories.push({ key: '', label: 'All' });
this.externalSourcesConfiguration.externalDatasets.push({ key: '', label: 'All' });
this.externalSourcesConfiguration.registries.push({ key: '', label: 'All' });
this.externalSourcesConfiguration.services.push({ key: '', label: 'All' });
this.externalSourcesConfiguration.tags.push({ key: '', label: 'All' });
});
this.dmpAutoCompleteConfiguration = {
filterFn: this.searchDmp.bind(this),
items: this.searchDmp(''),
displayFn: (item) => item['label'],
titleFn: (item) => item['label'],
//mapFn: (item) => new JsonSerializer<ProjectReference>().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()),
loadDataOnStart: true
};
this.route.params.subscribe((params: Params) => {
this.itemId = params['id'];
const dmpId = params['dmpId'];
if (this.itemId != null) {
this.isNew = false;
this.datasetWizardService.getSingle(this.itemId).map(data => data as DatasetWizardModel)
.subscribe(data => {
this.datasetWizardModel = JsonSerializer.fromJSONObject(data, DatasetWizardModel);
this.breadCrumbs = Observable.of([
{
parentComponentName: null,
label: 'Datasets',
url: '/datasets',
notFoundResolver: [
{
parentComponentName: null,
label: this.datasetWizardModel.dmp.project.label,
url: '/projects/edit/' + this.datasetWizardModel.dmp.project.id
},
{
parentComponentName: null,
label: this.datasetWizardModel.dmp.label,
url: '/dmps/edit/' + this.datasetWizardModel.dmp.id,
},
]
}]);
this.formGroup = this.datasetWizardModel.buildForm();
if (this.datasetWizardModel.status === 1) {
this.formGroup.disable();
this.viewOnly = true;
}
if (this.viewOnly) { this.formGroup.disable(); }
this.loadDatasetProfiles();
});
} else if (dmpId != null) {
this.isNew = true;
this.dataManagementPlanService.getSingle(dmpId).map(data => data as DataManagementPlanModel)
.subscribe(data => {
this.datasetWizardModel = new DatasetWizardModel();
setTimeout(() => {
this.datasetWizardModel.dmp = data;
this.formGroup = this.datasetWizardModel.buildForm();
if (this.datasetWizardModel.status === 1) {
this.formGroup.disable();
this.viewOnly = true;
}
this.loadDatasetProfiles();
this.breadCrumbs = Observable.of([
{
parentComponentName: null,
label: 'Datasets',
url: '/datasets',
notFoundResolver: [
{
parentComponentName: null,
label: this.datasetWizardModel.dmp.project.label,
url: '/projects/edit/' + this.datasetWizardModel.dmp.project.id
},
{
parentComponentName: null,
label: this.datasetWizardModel.dmp.label,
url: '/dmps/edit/' + this.datasetWizardModel.dmp.id,
}]
}]);
});
});
} else {
this.datasetWizardModel = new DatasetWizardModel();
this.formGroup = this.datasetWizardModel.buildForm();
if (this.datasetWizardModel.status === 1) {
this.formGroup.disable();
this.viewOnly = true;
}
if (this.viewOnly) { this.formGroup.disable(); }
this.formGroup.get('dmp').valueChanges.subscribe(x => {
this.loadDatasetProfiles();
});
}
});
}
ngAfterViewInit() {
this.route.params.subscribe((params: Params) => {
const itemId = params['id'];
if (itemId != null) { this.stepper.selectedIndex = 2; }
});
}
searchDmp(query: string): Observable<DataManagementPlanListingModel[]> {
const dmpRequestItem: RequestItem<DataManagementPlanCriteria> = new RequestItem();
dmpRequestItem.criteria = new DataManagementPlanCriteria();
dmpRequestItem.criteria.like = query;
return this.dataManagementPlanService.get(dmpRequestItem);
}
loadDatasetProfiles() {
const datasetProfileRequestItem: RequestItem<DatasetProfileCriteria> = new RequestItem();
datasetProfileRequestItem.criteria = new DatasetProfileCriteria();
datasetProfileRequestItem.criteria.id = this.formGroup.get('dmp').value.id;
if (datasetProfileRequestItem.criteria.id) {
this.datasetWizardService.getAvailableProfiles(datasetProfileRequestItem).subscribe(items => {
this.availableProfiles = JsonSerializer.fromJSONArray(items, DatasetProfileModel);
});
}
}
public cancel(): void {
//this.router.navigate(['/dataManagementPlans']);
}
getDefinition() {
if (this.isNew) {
this.datasetWizardService.getDefinition(this.formGroup.get('profile').get('id').value).subscribe(item => {
this.datasetWizardModel.datasetProfileDefinition = JsonSerializer.fromJSONObject(item, DatasetProfileDefinitionModel);
this.datasetProfileDefinitionModel = this.datasetWizardModel.datasetProfileDefinition;
this.formGroup.addControl('datasetProfileDefinition', this.datasetProfileDefinitionModel.buildForm());
});
}
}
this.route
.data
.subscribe(v => this.viewOnly = v["public"]);
formSubmit(): void {
if (!this.isFormValid()) { return; }
this.onSubmit();
}
let dmpRequestItem: RequestItem<DataManagementPlanCriteria> = new RequestItem();
dmpRequestItem.criteria = new DataManagementPlanCriteria();
public isFormValid() {
return this.formGroup.valid;
}
let externalDatasetRequestItem: RequestItem<ExternalDatasetCriteria> = new RequestItem();
externalDatasetRequestItem.criteria = new ExternalDatasetCriteria();
this.externalDatasetAutoCompleteConfiguration = new AutoCompleteConfiguration(this.externalSourcesService.searchDatasetSExternalDatasetservice.bind(this.externalSourcesService), externalDatasetRequestItem)
onSubmit(): void {
this.datasetWizardService.createDataset(this.formGroup.value).subscribe(
complete => {
this.datasetWizardService.getSingle(complete.id).subscribe(
result => {
this.datasetWizardModel = JsonSerializer.fromJSONObject(result, DatasetWizardModel);
}
);
this.onCallbackSuccess();
},
error => this.onCallbackError(error)
);
}
let registriesRequestItem: RequestItem<RegistryCriteria> = new RequestItem();
registriesRequestItem.criteria = new RegistryCriteria();
this.registriesAutoCompleteConfiguration = new AutoCompleteConfiguration(this.externalSourcesService.searchDatasetRegistry.bind(this.externalSourcesService), registriesRequestItem)
let dataRepositoriesRequestItem: RequestItem<DataRepositoryCriteria> = new RequestItem();
dataRepositoriesRequestItem.criteria = new DataRepositoryCriteria();
this.dataRepositoriesAutoCompleteConfiguration = new AutoCompleteConfiguration(this.externalSourcesService.searchDatasetRepository.bind(this.externalSourcesService), dataRepositoriesRequestItem)
let servicesRequestItem: RequestItem<ServicesCriteria> = new RequestItem();
servicesRequestItem.criteria = new ServicesCriteria();
this.servicesAutoCompleteConfiguration = new AutoCompleteConfiguration(this.externalSourcesService.searchDatasetService.bind(this.externalSourcesService), servicesRequestItem)
let tagsRequestItem: RequestItem<TagsCriteria> = new RequestItem();
tagsRequestItem.criteria = new TagsCriteria();
this.tagsAutoCompleteConfiguration = new AutoCompleteConfiguration(this.externalSourcesService.searchDatasetTags.bind(this.externalSourcesService), tagsRequestItem)
this.externalSourcesConfigurationService.getExternalSourcesConfiguration().subscribe(result => {
this.externalSourcesConfiguration = result;
this.externalSourcesConfiguration.dataRepositories.push({ key: '', label: "All" })
this.externalSourcesConfiguration.externalDatasets.push({ key: '', label: "All" })
this.externalSourcesConfiguration.registries.push({ key: '', label: "All" })
this.externalSourcesConfiguration.services.push({ key: '', label: "All" })
this.externalSourcesConfiguration.tags.push({ key: '', label: "All" })
})
this.dmpAutoCompleteConfiguration = {
filterFn: this.searchDmp.bind(this),
items: this.searchDmp(''),
displayFn: (item) => item["label"],
titleFn: (item) => item["label"],
//mapFn: (item) => new JsonSerializer<ProjectReference>().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()),
loadDataOnStart: true
};
this.route.params.subscribe((params: Params) => {
this.itemId = params['id'];
const dmpId = params['dmpId'];
if (this.itemId != null) {
this.isNew = false;
this.datasetWizardService.getSingle(this.itemId).map(data => data as DatasetWizardModel)
.subscribe(data => {
this.datasetWizardModel = JsonSerializer.fromJSONObject(data, DatasetWizardModel);
this.breadCrumbs = Observable.of([
{
parentComponentName: null,
label: "Datasets",
url: "/datasets",
notFoundResolver: [
{
parentComponentName: null,
label: this.datasetWizardModel.dmp.project.label,
url: "/projects/edit/" + this.datasetWizardModel.dmp.project.id
},
{
parentComponentName: null,
label: this.datasetWizardModel.dmp.label,
url: "/dmps/edit/" + this.datasetWizardModel.dmp.id,
},
]
}])
this.formGroup = this.datasetWizardModel.buildForm();
if (this.datasetWizardModel.status == 1) {
this.formGroup.disable()
this.viewOnly = true;
}
if (this.viewOnly) this.formGroup.disable();
this.loadDatasetProfiles();
});
} else if (dmpId != null) {
this.isNew = true;
this.dataManagementPlanService.getSingle(dmpId).map(data => data as DataManagementPlanModel)
.subscribe(data => {
this.datasetWizardModel = new DatasetWizardModel();
setTimeout(() => {
this.datasetWizardModel.dmp = data;
this.formGroup = this.datasetWizardModel.buildForm();
if (this.datasetWizardModel.status == 1) {
this.formGroup.disable()
this.viewOnly = true;
}
this.loadDatasetProfiles();
this.breadCrumbs = Observable.of([
{
parentComponentName: null,
label: "Datasets",
url: "/datasets",
notFoundResolver: [
{
parentComponentName: null,
label: this.datasetWizardModel.dmp.project.label,
url: "/projects/edit/" + this.datasetWizardModel.dmp.project.id
},
{
parentComponentName: null,
label: this.datasetWizardModel.dmp.label,
url: "/dmps/edit/" + this.datasetWizardModel.dmp.id,
}]
}])
});
});
} else {
this.datasetWizardModel = new DatasetWizardModel();
this.formGroup = this.datasetWizardModel.buildForm()
if (this.datasetWizardModel.status == 1) {
this.formGroup.disable()
this.viewOnly = true;
}
if (this.viewOnly) this.formGroup.disable();
this.formGroup.get('dmp').valueChanges.subscribe(x => {
this.loadDatasetProfiles();
})
}
});
}
ngAfterViewInit() {
this.route.params.subscribe((params: Params) => {
let itemId = params['id'];
if (itemId != null) this.stepper.selectedIndex = 2;
})
}
searchDmp(query: string): Observable<DataManagementPlanListingModel[]> {
let dmpRequestItem: RequestItem<DataManagementPlanCriteria> = new RequestItem();
dmpRequestItem.criteria = new DataManagementPlanCriteria();
dmpRequestItem.criteria.like = query;
return this.dataManagementPlanService.get(dmpRequestItem);
}
loadDatasetProfiles() {
let datasetProfileRequestItem: RequestItem<DatasetProfileCriteria> = new RequestItem();
datasetProfileRequestItem.criteria = new DatasetProfileCriteria();
datasetProfileRequestItem.criteria.id = this.formGroup.get("dmp").value.id;
if (datasetProfileRequestItem.criteria.id) this.datasetWizardService.getAvailableProfiles(datasetProfileRequestItem).subscribe(items => {
this.availableProfiles = JsonSerializer.fromJSONArray(items, DatasetProfileModel);
});
}
public cancel(): void {
//this.router.navigate(['/dataManagementPlans']);
}
getDefinition() {
if (this.isNew) {
this.datasetWizardService.getDefinition(this.formGroup.get("profile").get("id").value).subscribe(item => {
this.datasetWizardModel.datasetProfileDefinition = JsonSerializer.fromJSONObject(item, DatasetProfileDefinitionModel);
this.datasetProfileDefinitionModel = this.datasetWizardModel.datasetProfileDefinition;
this.formGroup.addControl("datasetProfileDefinition", this.datasetProfileDefinitionModel.buildForm())
})
}
}
submit() {
this.datasetWizardService.createDataset(this.formGroup.value).subscribe(data => {
this.router.navigateByUrl('/datasets/dmp/' + this.formGroup.get('dmp').value.id);
});
}
formSubmit(): void {
if (!this.isFormValid()) { return; }
this.onSubmit();
}
save() {
if (!this.isFormValid()) { return; }
this.formGroup.get('status').setValue('0');
this.submit();
}
public isFormValid() {
return this.formGroup.valid;
}
saveFinalize() {
if (!this.isFormValid()) { return; }
this.formGroup.get('status').setValue('1');
this.submit();
}
onSubmit(): void {
this.datasetWizardService.createDataset(this.formGroup.value).subscribe(
complete => {
this.datasetWizardService.getSingle(complete.id).subscribe(
result => {
this.datasetWizardModel = JsonSerializer.fromJSONObject(result, DatasetWizardModel);
}
)
this.onCallbackSuccess()
},
error => this.onCallbackError(error)
);
}
onCallbackSuccess(): void {
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
duration: 3000,
});
}
submit() {
this.datasetWizardService.createDataset(this.formGroup.value).subscribe(data => {
this.router.navigateByUrl("/datasets/dmp/" + this.formGroup.get("dmp").value.id);
});
}
onCallbackError(error: any) {
this.setErrorModel(error.error);
}
public setErrorModel(errorModel: BaseErrorModel) {
Object.keys(errorModel).forEach(item => {
(<any>this.datasetWizardModel.errorModel)[item] = (<any>errorModel)[item];
});
}
downloadPDF(): void {
this.datasetWizardService.downloadPDF(this.itemId).subscribe(response => {
const blob = new Blob([response.body], { type: 'application/pdf' });
const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
FileSaver.saveAs(blob, filename);
});
}
downloadXML(): void {
this.datasetWizardService.downloadXML(this.itemId).subscribe(response => {
const blob = new Blob([response.body], { type: 'application/xml' });
const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
FileSaver.saveAs(blob, filename);
});
}
getFilenameFromContentDispositionHeader(header: string): string {
const regex: RegExp = new RegExp(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/g);
const matches = header.match(regex);
let filename: string;
for (let i = 0; i < matches.length; i++) {
const match = matches[i];
if (match.includes('filename="')) {
filename = match.substring(10, match.length - 1);
break;
} else if (match.includes('filename=')) {
filename = match.substring(9);
break;
}
}
return filename;
}
public redirectToProject() {
this.router.navigate(['projects/edit/' + this.datasetWizardModel.dmp.project.id]);
}
public redirectToDmp() {
this.router.navigate(['dmps/edit/' + this.datasetWizardModel.dmp.id]);
}
externalDatasetsOnItemChange(event) {
const externalDatasetModel = new ExternalDatasetModel(event.id, event.abbreviation, event.label, event.reference);
(<FormArray>this.formGroup.get('externalDatasets')).push(externalDatasetModel.buildForm());
}
registriesOnItemChange(event) {
const registryModel = new RegisterModel(event.abbreviation, event.definition, event.id, event.label, event.reference, event.uri);
(<FormArray>this.formGroup.get('registries')).push(registryModel.buildForm());
}
servicesOnItemChange(event) {
const serviceModel = new ServiceModel(event.abbreviation, event.definition, event.id, event.label, event.reference, event.uri);
(<FormArray>this.formGroup.get('services')).push(serviceModel.buildForm());
}
tagsOnItemChange(event) {
const serviceModel = new TagModel(event.id, event.name);
(<FormArray>this.formGroup.get('tags')).push(serviceModel.buildForm());
}
save() {
if (!this.isFormValid()) { return; }
this.formGroup.get("status").setValue("0");
this.submit();
}
dataRepositoriesOnItemChange(event) {
const dataRepositoryModel = new DataRepositoryModel(event.id, event.name, event.abbreviation, event.uri, event.pid);
(<FormArray>this.formGroup.get('dataRepositories')).push(dataRepositoryModel.buildForm());
}
saveFinalize() {
if (!this.isFormValid()) { return; }
this.formGroup.get("status").setValue("1");
this.submit();
}
addDataRepository() {
const dialogRef = this.dialog.open(DataRepositoryReferencedModelHelperComponent, {
height: '255px',
width: '700px',
data: {
onCallbackSuccess(): void {
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
duration: 3000,
})
}
}
});
dialogRef.afterClosed().subscribe(result => {
if (!result) { return; }
const dataRepositoryModel = new DataRepositoryModel(result.id, result.label, result.pid, result.uri, result.reference);
(<FormArray>this.formGroup.get('dataRepositories')).push(dataRepositoryModel.buildForm());
});
}
onCallbackError(error: any) {
this.setErrorModel(error.error);
}
addRegistry() {
const dialogRef = this.dialog.open(RegistryReferencedModelHelperComponent, {
height: '255px',
width: '700px',
data: {
public setErrorModel(errorModel: BaseErrorModel) {
Object.keys(errorModel).forEach(item => {
(<any>this.datasetWizardModel.errorModel)[item] = (<any>errorModel)[item];
})
}
}
});
dialogRef.afterClosed().subscribe(result => {
if (!result) { return; }
const registryModel = new RegisterModel(result.abbreviation, result.definition, result.id, result.label, result.reference, result.uri);
(<FormArray>this.formGroup.get('registries')).push(registryModel.buildForm());
});
}
downloadPDF(): void {
this.datasetWizardService.downloadPDF(this.itemId).subscribe(response => {
const blob = new Blob([response.body], { type: 'application/pdf' })
const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
addExternalDataset() {
const dialogRef = this.dialog.open(ExternalDatasetReferencedModelHelperComponent, {
height: '255px',
width: '700px',
data: {
FileSaver.saveAs(blob, filename)
})
}
}
});
dialogRef.afterClosed().subscribe(result => {
if (!result) { return; }
const externalDatasetModel = new ExternalDatasetModel(result.id, result.abbreviation, result.label, result.reference);
(<FormArray>this.formGroup.get('externalDatasets')).push(externalDatasetModel.buildForm());
});
}
downloadXML(): void {
this.datasetWizardService.downloadXML(this.itemId).subscribe(response => {
const blob = new Blob([response.body], { type: 'application/xml' })
const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
addService() {
const dialogRef = this.dialog.open(ServicesReferencedModelHelperComponent, {
height: '255px',
width: '700px',
data: {
FileSaver.saveAs(blob, filename)
})
}
getFilenameFromContentDispositionHeader(header: string): string {
const regex: RegExp = new RegExp(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/g);
const matches = header.match(regex);
let filename: string;
for (let i = 0; i < matches.length; i++) {
const match = matches[i];
if (match.includes('filename="')) {
filename = match.substring(10, match.length - 1);
break;
} else if (match.includes('filename=')) {
filename = match.substring(9);
break;
}
}
return filename;
}
public redirectToProject() {
this.router.navigate(["projects/edit/" + this.datasetWizardModel.dmp.project.id])
}
public redirectToDmp() {
this.router.navigate(["dmps/edit/" + this.datasetWizardModel.dmp.id])
}
externalDatasetsOnItemChange(event) {
let externalDatasetModel = new ExternalDatasetModel(event.id, event.abbreviation, event.label, event.reference);
(<FormArray>this.formGroup.get("externalDatasets")).push(externalDatasetModel.buildForm());
}
registriesOnItemChange(event) {
let registryModel = new RegisterModel(event.abbreviation, event.definition, event.id, event.label, event.reference, event.uri);
(<FormArray>this.formGroup.get("registries")).push(registryModel.buildForm());
}
servicesOnItemChange(event) {
let serviceModel = new ServiceModel(event.abbreviation, event.definition, event.id, event.label, event.reference, event.uri);
(<FormArray>this.formGroup.get("services")).push(serviceModel.buildForm());
}
tagsOnItemChange(event) {
let serviceModel = new TagModel(event.id, event.name);
(<FormArray>this.formGroup.get("tags")).push(serviceModel.buildForm());
}
dataRepositoriesOnItemChange(event) {
let dataRepositoryModel = new DataRepositoryModel(event.id, event.name, event.abbreviation, event.uri, event.pid);
(<FormArray>this.formGroup.get("dataRepositories")).push(dataRepositoryModel.buildForm());
}
addDataRepository() {
let dialogRef = this.dialog.open(DataRepositoryReferencedModelHelperComponent, {
height: '255px',
width: '700px',
data: {
}
});
dialogRef.afterClosed().subscribe(result => {
if (!result) return
let dataRepositoryModel = new DataRepositoryModel(result.id, result.label, result.pid, result.uri, result.reference);
(<FormArray>this.formGroup.get("dataRepositories")).push(dataRepositoryModel.buildForm());
});
}
addRegistry() {
let dialogRef = this.dialog.open(RegistryReferencedModelHelperComponent, {
height: '255px',
width: '700px',
data: {
}
});
dialogRef.afterClosed().subscribe(result => {
if (!result) return
let registryModel = new RegisterModel(result.abbreviation, result.definition, result.id, result.label, result.reference, result.uri);
(<FormArray>this.formGroup.get("registries")).push(registryModel.buildForm());
});
}
addExternalDataset() {
let dialogRef = this.dialog.open(ExternalDatasetReferencedModelHelperComponent, {
height: '255px',
width: '700px',
data: {
}
});
dialogRef.afterClosed().subscribe(result => {
if (!result) return
let externalDatasetModel = new ExternalDatasetModel(result.id, result.abbreviation, result.label, result.reference);
(<FormArray>this.formGroup.get("externalDatasets")).push(externalDatasetModel.buildForm());
});
}
addService() {
let dialogRef = this.dialog.open(ServicesReferencedModelHelperComponent, {
height: '255px',
width: '700px',
data: {
}
});
dialogRef.afterClosed().subscribe(result => {
if (!result) return
let serviceModel = new ServiceModel(result.id, result.abbreviation, result.definition, result.uri, result.label, result.reference);
(<FormArray>this.formGroup.get("services")).push(serviceModel.buildForm());
});
}
}
});
dialogRef.afterClosed().subscribe(result => {
if (!result) { return; }
const serviceModel = new ServiceModel(result.id, result.abbreviation, result.definition, result.uri, result.label, result.reference);
(<FormArray>this.formGroup.get('services')).push(serviceModel.buildForm());
});
}
}

View File

@ -12,7 +12,7 @@ import { HttpClient, HttpClientModule } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { SharedModule } from '../shared/shared.module'
import { SharedModule } from '../shared/shared.module';
import { BaseHttpService } from '../utilities/cite-http-service-module/base-http.service';
import { BaseHttpModule } from '../utilities/cite-http-service-module/cite-http.module';
import { MaterialModule } from '../shared/material/material.module';
@ -30,73 +30,73 @@ import { ServicesDataService } from '../services/services/services-data.service'
import { DataRepositoryService } from '../services/datarepository/datarepository.service';
import { ExternalDatasetService } from '../services/external-dataset/external-dataset.service';
@NgModule({
imports: [
CommonModule,
FormsModule,
HttpClientModule,
SharedModule,
MaterialModule,
RouterModule.forChild(DatasetRoutes),
ReactiveFormsModule,
DynamicFormModule,
imports: [
CommonModule,
FormsModule,
HttpClientModule,
SharedModule,
MaterialModule,
RouterModule.forChild(DatasetRoutes),
ReactiveFormsModule,
DynamicFormModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
}
}),
],
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
}
}),
],
declarations: [
DatasetListingComponent,
DatasetEditorComponent,
DatasetWizardComponent,
DatasetPublicListingComponent,
DataRepositoryReferencedModelHelperComponent,
ExternalDatasetReferencedModelHelperComponent,
ServicesReferencedModelHelperComponent,
RegistryReferencedModelHelperComponent,
],
declarations: [
DatasetListingComponent,
DatasetEditorComponent,
DatasetWizardComponent,
DatasetPublicListingComponent,
DataRepositoryReferencedModelHelperComponent,
ExternalDatasetReferencedModelHelperComponent,
ServicesReferencedModelHelperComponent,
RegistryReferencedModelHelperComponent,
],
exports: [
DatasetListingComponent,
DatasetEditorComponent,
DatasetWizardComponent,
DataRepositoryReferencedModelHelperComponent,
ExternalDatasetReferencedModelHelperComponent,
ServicesReferencedModelHelperComponent,
RegistryReferencedModelHelperComponent,
DatasetPublicListingComponent,
RouterModule
],
providers: [
DatasetWizardService,
ExternalSourcesService,
ExternalSourcesConfigurationService,
DataManagementPlanService,
DatasetService,
DataRepositoryService,
ExternalDatasetService,
ServicesDataService,
RegistryService
],
entryComponents:[
DataRepositoryReferencedModelHelperComponent,
ExternalDatasetReferencedModelHelperComponent,
ServicesReferencedModelHelperComponent,
RegistryReferencedModelHelperComponent
]
exports: [
DatasetListingComponent,
DatasetEditorComponent,
DatasetWizardComponent,
DataRepositoryReferencedModelHelperComponent,
ExternalDatasetReferencedModelHelperComponent,
ServicesReferencedModelHelperComponent,
RegistryReferencedModelHelperComponent,
DatasetPublicListingComponent,
RouterModule
],
providers: [
DatasetWizardService,
ExternalSourcesService,
ExternalSourcesConfigurationService,
DataManagementPlanService,
DatasetService,
DataRepositoryService,
ExternalDatasetService,
ServicesDataService,
RegistryService
],
entryComponents: [
DataRepositoryReferencedModelHelperComponent,
ExternalDatasetReferencedModelHelperComponent,
ServicesReferencedModelHelperComponent,
RegistryReferencedModelHelperComponent
]
})
export class DatasetModule {
constructor(private translate: TranslateService) {
translate.setDefaultLang('en');
translate.use('en');
}
constructor(private translate: TranslateService) {
translate.setDefaultLang('en');
translate.use('en');
}
}
export function HttpLoaderFactory(httpClient: HttpClient) {
return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json');
return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json');
}

View File

@ -5,58 +5,58 @@ import { AuthGuard } from '../shared/guards/auth.guard';
import { DatasetPublicListingComponent } from './dataset-public/dataset-public-listing.component';
export const DatasetRoutes: Routes = [
{
path: "new/:dmpId",
component: DatasetWizardComponent,
canActivate: [AuthGuard],
data: {
breadcrumb: true
},
},
{
path: "edit/:id",
component: DatasetWizardComponent,
canActivate: [AuthGuard],
data: {
breadcrumb: true,
public: false
},
},
{
path: "publicEdit/:id",
component: DatasetWizardComponent,
//canActivate: [AuthGuard],
data: {
public: true
}
},
{
path: "new",
component: DatasetWizardComponent,
canActivate: [AuthGuard],
data: {
breadcrumb: true
},
},
{
path: '',
component: DatasetListingComponent,
//canActivate: [AuthGuard],
data: {
breadcrumb: true
},
},
{
path: 'public',
component: DatasetPublicListingComponent,
//canActivate: [AuthGuard],
},
{
path: "dmp/:dmpId",
component: DatasetListingComponent,
//canActivate: [AuthGuard],
data: {
breadcrumb: true
},
}
{
path: 'new/:dmpId',
component: DatasetWizardComponent,
canActivate: [AuthGuard],
data: {
breadcrumb: true
},
},
{
path: 'edit/:id',
component: DatasetWizardComponent,
canActivate: [AuthGuard],
data: {
breadcrumb: true,
public: false
},
},
{
path: 'publicEdit/:id',
component: DatasetWizardComponent,
//canActivate: [AuthGuard],
data: {
public: true
}
},
{
path: 'new',
component: DatasetWizardComponent,
canActivate: [AuthGuard],
data: {
breadcrumb: true
},
},
{
path: '',
component: DatasetListingComponent,
//canActivate: [AuthGuard],
data: {
breadcrumb: true
},
},
{
path: 'public',
component: DatasetPublicListingComponent,
//canActivate: [AuthGuard],
},
{
path: 'dmp/:dmpId',
component: DatasetListingComponent,
//canActivate: [AuthGuard],
data: {
breadcrumb: true
},
}
];

View File

@ -1,127 +1,127 @@
import { AfterViewInit, Component, Input, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
import { MatPaginator, MatSort, MatSnackBar } from "@angular/material";
import { Router, ActivatedRoute, Params } from "@angular/router";
import { TranslateService } from "@ngx-translate/core";
import { DataSource } from "@angular/cdk/table";
import { Observable } from "rxjs/Observable";
import { JsonSerializer } from "../../utilities/JsonSerializer";
import { FormGroup } from "@angular/forms";
import { SnackBarNotificationComponent } from "../../shared/components/notificaiton/snack-bar-notification.component";
import { BaseErrorModel } from "../../models/error/BaseErrorModel";
import { DatasetService } from "../../services/dataset/dataset.service";
import { DatasetModel } from "../../models/datasets/DatasetModel";
import { ExternalSourcesService } from "../../services/external-sources/external-sources.service";
import { ExternalSourcesItemModel } from "../../models/external-sources/ExternalSourcesItemModel";
import { MatPaginator, MatSort, MatSnackBar } from '@angular/material';
import { Router, ActivatedRoute, Params } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { DataSource } from '@angular/cdk/table';
import { Observable } from 'rxjs/Observable';
import { JsonSerializer } from '../../utilities/JsonSerializer';
import { FormGroup } from '@angular/forms';
import { SnackBarNotificationComponent } from '../../shared/components/notificaiton/snack-bar-notification.component';
import { BaseErrorModel } from '../../models/error/BaseErrorModel';
import { DatasetService } from '../../services/dataset/dataset.service';
import { DatasetModel } from '../../models/datasets/DatasetModel';
import { ExternalSourcesService } from '../../services/external-sources/external-sources.service';
import { ExternalSourcesItemModel } from '../../models/external-sources/ExternalSourcesItemModel';
@Component({
selector: 'app-dataset-editor-component',
templateUrl: 'dataset-editor.component.html',
styleUrls: ['./dataset-editor.component.scss'],
encapsulation: ViewEncapsulation.None
selector: 'app-dataset-editor-component',
templateUrl: 'dataset-editor.component.html',
styleUrls: ['./dataset-editor.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class DatasetEditorComponent implements AfterViewInit {
isNew = true;
dataset: DatasetModel;
@Input() formGroup: FormGroup = null;
isNew = true;
dataset: DatasetModel;
@Input() formGroup: FormGroup = null;
// filtereddataRepositoriesAsync: boolean = false;
// filteredRegistriesAsync: boolean = false;
// filteredServicesAsync: boolean = false;
// filtereddataRepositoriesAsync: boolean = false;
// filteredRegistriesAsync: boolean = false;
// filteredServicesAsync: boolean = false;
// filtereddataRepositories: ExternalSourcesItemModel[];
// filteredRegistries: ExternalSourcesItemModel[];
// filteredServices: ExternalSourcesItemModel[];
// filtereddataRepositories: ExternalSourcesItemModel[];
// filteredRegistries: ExternalSourcesItemModel[];
// filteredServices: ExternalSourcesItemModel[];
constructor(
private datasetService: DatasetService,
private externalSourcesService: ExternalSourcesService,
private route: ActivatedRoute,
public snackBar: MatSnackBar,
public router: Router,
public language: TranslateService,
) {
constructor(
private datasetService: DatasetService,
private externalSourcesService: ExternalSourcesService,
private route: ActivatedRoute,
public snackBar: MatSnackBar,
public router: Router,
public language: TranslateService,
) {
}
}
ngAfterViewInit() {
/* this.route.params.subscribe((params: Params) => {
const itemId = params['id'];
ngAfterViewInit() {
/* this.route.params.subscribe((params: Params) => {
const itemId = params['id'];
if (itemId != null) {
this.isNew = false;
this.datasetService.getSingle(itemId).map(data => data as DatasetModel)
.subscribe(data => {
this.dataset = new JsonSerializer<DatasetModel>().fromJSONObject(data, DatasetModel);
this.formGroup = this.dataset.buildForm();
});
} else {
this.dataset = new DatasetModel();
setTimeout(() => {
this.formGroup = this.dataset.buildForm();
});
}
}); */
}
if (itemId != null) {
this.isNew = false;
this.datasetService.getSingle(itemId).map(data => data as DatasetModel)
.subscribe(data => {
this.dataset = new JsonSerializer<DatasetModel>().fromJSONObject(data, DatasetModel);
this.formGroup = this.dataset.buildForm();
});
} else {
this.dataset = new DatasetModel();
setTimeout(() => {
this.formGroup = this.dataset.buildForm();
});
}
}); */
}
public cancel(): void {
this.router.navigate(['/datasets']);
}
public cancel(): void {
this.router.navigate(['/datasets']);
}
// filterdataRepositories(value: string): void {
// filterdataRepositories(value: string): void {
// this.filtereddataRepositories = undefined;
// if (value) {
// this.filtereddataRepositoriesAsync = true;
// this.filtereddataRepositories = undefined;
// if (value) {
// this.filtereddataRepositoriesAsync = true;
// this.externalSourcesService.searchDMPOrganizations(value).subscribe(items => {
// this.filtereddataRepositories = items;
// this.filtereddataRepositoriesAsync = false;
// this.externalSourcesService.searchDMPOrganizations(value).subscribe(items => {
// this.filtereddataRepositories = items;
// this.filtereddataRepositoriesAsync = false;
// // this.filteredOrganisations = items.filter((filteredObj: any) => {
// // return this.objectsModel ? this.objectsModel.indexOf(filteredObj) < 0 : true;
// // });
// // this.filteredOrganisations = items.filter((filteredObj: any) => {
// // return this.objectsModel ? this.objectsModel.indexOf(filteredObj) < 0 : true;
// // });
// });
// }
// }
// });
// }
// }
// filterRegistries(value: string): void {
// filterRegistries(value: string): void {
// this.filteredRegistries = undefined;
// if (value) {
// this.filteredRegistriesAsync = true;
// this.filteredRegistries = undefined;
// if (value) {
// this.filteredRegistriesAsync = true;
// this.externalSourcesService.searchDMPResearchers(value).subscribe(items => {
// this.filteredRegistries = items;
// this.filteredRegistriesAsync = false;
// this.externalSourcesService.searchDMPResearchers(value).subscribe(items => {
// this.filteredRegistries = items;
// this.filteredRegistriesAsync = false;
// // this.filteredOrganisations = items.filter((filteredObj: any) => {
// // return this.objectsModel ? this.objectsModel.indexOf(filteredObj) < 0 : true;
// // });
// // this.filteredOrganisations = items.filter((filteredObj: any) => {
// // return this.objectsModel ? this.objectsModel.indexOf(filteredObj) < 0 : true;
// // });
// });
// }
// }
// });
// }
// }
// filterServices(value: string): void {
// filterServices(value: string): void {
// this.filteredServices = undefined;
// if (value) {
// this.filteredServicesAsync = true;
// this.filteredServices = undefined;
// if (value) {
// this.filteredServicesAsync = true;
// this.externalSourcesService.searchDatasetService(value).subscribe(items => {
// this.filteredServices = items;
// this.filteredServicesAsync = false;
// this.externalSourcesService.searchDatasetService(value).subscribe(items => {
// this.filteredServices = items;
// this.filteredServicesAsync = false;
// // this.filteredOrganisations = items.filter((filteredObj: any) => {
// // return this.objectsModel ? this.objectsModel.indexOf(filteredObj) < 0 : true;
// // });
// // this.filteredOrganisations = items.filter((filteredObj: any) => {
// // return this.objectsModel ? this.objectsModel.indexOf(filteredObj) < 0 : true;
// // });
// });
// }
// }
// });
// }
// }
}

View File

@ -3,16 +3,16 @@ import { DataTableRequest } from '../../models/data-table/DataTableRequest';
import { DatasetListingModel } from '../../models/datasets/DatasetListingModel';
import { DatasetCriteria } from '../../models/criteria/dataset/DatasetCriteria';
import { DatasetService } from '../../services/dataset/dataset.service';
import { Component, ViewChild, OnInit, AfterViewInit } from "@angular/core";
import { MatPaginator, MatSort, MatSnackBar } from "@angular/material";
import { Router, Params, ActivatedRoute } from "@angular/router";
import { TranslateService } from "@ngx-translate/core";
import { DataSource } from "@angular/cdk/table";
import { Component, ViewChild, OnInit, AfterViewInit } from '@angular/core';
import { MatPaginator, MatSort, MatSnackBar } from '@angular/material';
import { Router, Params, ActivatedRoute } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { DataSource } from '@angular/cdk/table';
import { Observable } from "rxjs/Observable";
import { Observable } from 'rxjs/Observable';
import { PageEvent } from '@angular/material';
import { DataManagementPlanService } from "../../services/data-management-plan/data-management-plan.service";
import { DataManagementPlanModel } from "../../models/data-managemnt-plans/DataManagementPlanModel";
import { DataManagementPlanService } from '../../services/data-management-plan/data-management-plan.service';
import { DataManagementPlanModel } from '../../models/data-managemnt-plans/DataManagementPlanModel';
import { DatasetCriteriaComponent } from '../../shared/components/criteria/datasets/datasets-criteria.component';
import { BreadcrumbItem } from '../../shared/components/breadcrumb/definition/breadcrumb-item';
import { IBreadCrumbComponent } from '../../shared/components/breadcrumb/definition/IBreadCrumbComponent';
@ -21,148 +21,149 @@ import { JsonSerializer } from '../../utilities/JsonSerializer';
@Component({
selector: 'app-dataset-listing-component',
templateUrl: 'dataset-listing.component.html',
styleUrls: ['./dataset-listing.component.scss'],
providers:[Utilities]
selector: 'app-dataset-listing-component',
templateUrl: 'dataset-listing.component.html',
styleUrls: ['./dataset-listing.component.scss'],
providers: [Utilities]
})
export class DatasetListingComponent implements OnInit, IBreadCrumbComponent {
@ViewChild(MatPaginator) _paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
@ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent;
@ViewChild(MatPaginator) _paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
@ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent;
breadCrumbs: Observable<BreadcrumbItem[]>;
breadCrumbs: Observable<BreadcrumbItem[]>;
dataSource: DatasetDataSource | null;
displayedColumns: String[] = ['label', 'dmp', 'profile', 'status', 'description', 'created', 'actions'];
pageEvent: PageEvent;
titlePrefix: String;
dmpId: string;
dataSource: DatasetDataSource | null;
displayedColumns: String[] = ['label', 'dmp', 'profile', 'status', 'description', 'created', 'actions'];
pageEvent: PageEvent;
titlePrefix: String;
dmpId: string;
statuses = [
{ value: '0', viewValue: 'Active' },
{ value: '1', viewValue: 'Inactive' }
];
statuses = [
{ value: '0', viewValue: 'Active' },
{ value: '1', viewValue: 'Inactive' }
];
constructor(
private datasetService: DatasetService,
private router: Router,
private languageService: TranslateService,
public snackBar: MatSnackBar,
public route: ActivatedRoute,
public dataManagementPlanService: DataManagementPlanService,
public utilities: Utilities
) {
constructor(
private datasetService: DatasetService,
private router: Router,
private languageService: TranslateService,
public snackBar: MatSnackBar,
public route: ActivatedRoute,
public dataManagementPlanService: DataManagementPlanService,
public utilities: Utilities
) {
}
}
ngOnInit() {
ngOnInit() {
this.route.params.subscribe(async (params: Params) => {
this.dmpId = params['dmpId'];
this.criteria.setCriteria(this.getDefaultCriteria(this.dmpId));
this.refresh();
this.criteria.setRefreshCallback(() => this.refresh());
if (this.dmpId != null) {
let dmp = await this.dataManagementPlanService.getSingle(this.dmpId).toPromise()
this.breadCrumbs = Observable.of([{ parentComponentName: "DataManagementPlanEditorComponent", label: dmp.label, url: "dmps/edit/" + this.dmpId }])
if (params['dmpLabel'] != undefined)
this.titlePrefix = "for " + params['dmpLabel'];
} else {
this.breadCrumbs = Observable.of([])
}
});
}
this.route.params.subscribe(async (params: Params) => {
this.dmpId = params['dmpId'];
this.criteria.setCriteria(this.getDefaultCriteria(this.dmpId));
this.refresh();
this.criteria.setRefreshCallback(() => this.refresh());
if (this.dmpId != null) {
const dmp = await this.dataManagementPlanService.getSingle(this.dmpId).toPromise();
this.breadCrumbs = Observable.of([{ parentComponentName: 'DataManagementPlanEditorComponent', label: dmp.label, url: 'dmps/edit/' + this.dmpId }]);
if (params['dmpLabel'] !== undefined) {
this.titlePrefix = 'for ' + params['dmpLabel'];
}
} else {
this.breadCrumbs = Observable.of([]);
}
});
}
refresh() {
this.dataSource = new DatasetDataSource(this.datasetService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria, this.dmpId);
}
refresh() {
this.dataSource = new DatasetDataSource(this.datasetService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria, this.dmpId);
}
rowClick(rowId: String) {
this.router.navigate(['/datasets/edit/' + rowId]);
}
rowClick(rowId: String) {
this.router.navigate(['/datasets/edit/' + rowId]);
}
getDefaultCriteria(dmpId: String): DatasetCriteria {
const defaultCriteria = new DatasetCriteria();
if (dmpId != null) {
defaultCriteria.dmpIds.push(dmpId);
}
return defaultCriteria;
}
getDefaultCriteria(dmpId: String): DatasetCriteria {
const defaultCriteria = new DatasetCriteria();
if (dmpId != null) {
defaultCriteria.dmpIds.push(dmpId);
}
return defaultCriteria;
}
makeItPublic(id: String) {
this.datasetService.makeDatasetPublic(id).subscribe();
}
makeItPublic(id: String) {
this.datasetService.makeDatasetPublic(id).subscribe();
}
}
export class DatasetDataSource extends DataSource<DatasetListingModel> {
totalCount = 0;
isLoadingResults = false;
constructor(
private _service: DatasetService,
private _paginator: MatPaginator,
private _sort: MatSort,
private _languageService: TranslateService,
private _snackBar: MatSnackBar,
private _criteria: DatasetCriteriaComponent,
private dmpId: String
) {
super();
totalCount = 0;
isLoadingResults = false;
constructor(
private _service: DatasetService,
private _paginator: MatPaginator,
private _sort: MatSort,
private _languageService: TranslateService,
private _snackBar: MatSnackBar,
private _criteria: DatasetCriteriaComponent,
private dmpId: String
) {
super();
}
}
connect(): Observable<DatasetListingModel[]> {
const displayDataChanges = [
this._paginator.page
//this._sort.matSortChange
];
connect(): Observable<DatasetListingModel[]> {
const displayDataChanges = [
this._paginator.page
//this._sort.matSortChange
];
return Observable.merge(...displayDataChanges)
.startWith(null)
.switchMap(() => {
setTimeout(() => {
this.isLoadingResults = true;
});
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
let fields: Array<string> = new Array()
if (this._sort.active) fields = this._sort.direction === "asc" ? ["+" + this._sort.active] : ["-" + this._sort.active];
const request = new DataTableRequest<DatasetCriteria>(startIndex, this._paginator.pageSize, { fields: fields });
request.criteria = this._criteria.criteria;
if (this.dmpId) request.criteria.allVersions = true;
return this._service.getPaged(request);
})
/*.catch((error: any) => {
this._snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService },
duration: 3000,
extraClasses: ['snackbar-warning']
});
//this._criteria.criteria.onCallbackError(error);
return Observable.of(null);
})*/
.map(result => {
result.data = JsonSerializer.fromJSONArray(result.data, DatasetListingModel)
return result;
})
.map(result => {
setTimeout(() => {
this.isLoadingResults = false;
});
return result;
})
.map(result => {
if (!result) { return []; }
if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; }
return result.data;
});
}
return Observable.merge(...displayDataChanges)
.startWith(null)
.switchMap(() => {
setTimeout(() => {
this.isLoadingResults = true;
});
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
let fields: Array<string> = new Array();
if (this._sort.active) { fields = this._sort.direction === 'asc' ? ['+' + this._sort.active] : ['-' + this._sort.active]; }
const request = new DataTableRequest<DatasetCriteria>(startIndex, this._paginator.pageSize, { fields: fields });
request.criteria = this._criteria.criteria;
if (this.dmpId) { request.criteria.allVersions = true; }
return this._service.getPaged(request);
})
/*.catch((error: any) => {
this._snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService },
duration: 3000,
extraClasses: ['snackbar-warning']
});
//this._criteria.criteria.onCallbackError(error);
return Observable.of(null);
})*/
.map(result => {
result.data = JsonSerializer.fromJSONArray(result.data, DatasetListingModel);
return result;
})
.map(result => {
setTimeout(() => {
this.isLoadingResults = false;
});
return result;
})
.map(result => {
if (!result) { return []; }
if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; }
return result.data;
});
}
disconnect() {
// No-op
}
disconnect() {
// No-op
}
}

View File

@ -1,63 +1,68 @@
<div class="dmp-profile-editor">
<form *ngIf="formGroup" (ngSubmit)="formSubmit()" [formGroup]="formGroup">
<mat-card>
<mat-card-header>
<mat-card-title *ngIf="isNew">{{'DMP-PROFILE-EDITOR.TITLE.NEW' | translate}}</mat-card-title>
<mat-card-title *ngIf="!isNew">{{formGroup.get('label').value}}</mat-card-title>
<form *ngIf="formGroup" (ngSubmit)="formSubmit()" [formGroup]="formGroup">
<mat-card>
<mat-card-header>
<mat-card-title *ngIf="isNew">{{'DMP-PROFILE-EDITOR.TITLE.NEW' | translate}}</mat-card-title>
<mat-card-title *ngIf="!isNew">{{formGroup.get('label').value}}</mat-card-title>
</mat-card-header>
<mat-card-content>
</mat-card-header>
<mat-card-content>
<mat-form-field class="full-width">
<input matInput placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.LABEL' | translate}}" type="text" name="label" formControlName="label"
required>
<mat-error *ngIf="formGroup.get('label').errors?.backendError">{{baseErrorModel.label}}</mat-error>
<mat-error *ngIf="formGroup.get('label').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-form-field class="full-width">
<input matInput placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.LABEL' | translate}}" type="text" name="label"
formControlName="label" required>
<mat-error *ngIf="formGroup.get('label').errors?.backendError">{{baseErrorModel.label}}</mat-error>
<mat-error *ngIf="formGroup.get('label').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<div formGroupName="definition">
<mat-list formArrayName="fields">
<mat-list-item *ngFor="let field of formGroup.controls.definition.controls.fields.controls;let i=index">
<div [formGroupName]="i">
<mat-form-field>
<input matInput placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.LABEL' | translate}}" type="text" name="label" formControlName="label"
required>
<mat-error *ngIf="formGroup.get('definition').get('fields').get(''+i).get('label').errors?.required">{{baseErrorModel.label}}</mat-error>
<mat-error *ngIf="formGroup.get('definition').get('fields').get(''+i).get('label').errors?.backendError">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-form-field>
<mat-select placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.TYPE' | translate}}" formControlName="type">
<mat-option *ngFor="let fieldType of getDMPProfileFieldTypeValues()" [value]="fieldType">{{ getDMPProfileFieldTypeWithLanguage(fieldType) | translate}}</mat-option>
</mat-select>
<mat-error *ngIf="formGroup.get('definition').get('fields').get(''+i).get('type').errors?.required">{{baseErrorModel.type}}</mat-error>
<mat-error *ngIf="formGroup.get('definition').get('fields').get(''+i).get('type').errors?.backendError">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-form-field>
<mat-select placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.DATATYPE' | translate}}" formControlName="dataType">
<mat-option *ngFor="let fieldDataType of getDMPProfileFieldDataTypeValues()" [value]="fieldDataType">{{ getDMPProfileFieldDataTypeWithLanguage(fieldDataType) | translate}}</mat-option>
</mat-select>
<mat-error *ngIf="formGroup.get('definition').get('fields').get(''+i).get('dataType').errors?.required">{{baseErrorModel.dataType}}</mat-error>
<mat-error *ngIf="formGroup.get('definition').get('fields').get(''+i).get('dataType').errors?.backendError">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-checkbox formControlName="required">
{{'DMP-PROFILE-EDITOR.FIELDS.REQUIRED' | translate}}
</mat-checkbox>
</div>
</mat-list-item>
<button mat-fab class="mat-fab-bottom-right" color="primary" type="button" (click)="addField()">
<mat-icon class="mat-24">add</mat-icon>
</button>
</mat-list>
</div>
<div layout="row" class="full-width text-right" align="end">
<button mat-raised-button color="primary" (click)="cancel()" type="button">{{'DMP-PROFILE-EDITOR.ACTIONS.CANCEL' | translate}}</button>
<button mat-raised-button color="primary" type="submit">{{'DMP-PROFILE-EDITOR.ACTIONS.SAVE' | translate}}</button>
<button *ngIf="!isNew" mat-raised-button color="primary" type="button" (click)="delete()">{{'DMP-PROFILE-EDITOR.ACTIONS.DELETE' | translate}}</button>
</div>
<div formGroupName="definition">
<mat-list formArrayName="fields">
<mat-list-item *ngFor="let field of formGroup.controls.definition.controls.fields.controls;let i=index">
<div [formGroupName]="i">
<mat-form-field>
<input matInput placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.LABEL' | translate}}" type="text" name="label"
formControlName="label" required>
<mat-error *ngIf="formGroup.get('definition').get('fields').get(''+i).get('label').errors?.required">{{baseErrorModel.label}}</mat-error>
<mat-error *ngIf="formGroup.get('definition').get('fields').get(''+i).get('label').errors?.backendError">{{'GENERAL.VALIDATION.REQUIRED'
| translate}}</mat-error>
</mat-form-field>
<mat-form-field>
<mat-select placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.TYPE' | translate}}" formControlName="type">
<mat-option *ngFor="let fieldType of getDMPProfileFieldTypeValues()" [value]="fieldType">{{
getDMPProfileFieldTypeWithLanguage(fieldType) | translate}}</mat-option>
</mat-select>
<mat-error *ngIf="formGroup.get('definition').get('fields').get(''+i).get('type').errors?.required">{{baseErrorModel.type}}</mat-error>
<mat-error *ngIf="formGroup.get('definition').get('fields').get(''+i).get('type').errors?.backendError">{{'GENERAL.VALIDATION.REQUIRED'
| translate}}</mat-error>
</mat-form-field>
<mat-form-field>
<mat-select placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.DATATYPE' | translate}}" formControlName="dataType">
<mat-option *ngFor="let fieldDataType of getDMPProfileFieldDataTypeValues()" [value]="fieldDataType">{{
getDMPProfileFieldDataTypeWithLanguage(fieldDataType) | translate}}</mat-option>
</mat-select>
<mat-error *ngIf="formGroup.get('definition').get('fields').get(''+i).get('dataType').errors?.required">{{baseErrorModel.dataType}}</mat-error>
<mat-error *ngIf="formGroup.get('definition').get('fields').get(''+i).get('dataType').errors?.backendError">{{'GENERAL.VALIDATION.REQUIRED'
| translate}}</mat-error>
</mat-form-field>
<mat-checkbox formControlName="required">
{{'DMP-PROFILE-EDITOR.FIELDS.REQUIRED' | translate}}
</mat-checkbox>
</div>
</mat-list-item>
<button mat-fab class="mat-fab-bottom-right" color="primary" type="button" (click)="addField()">
<mat-icon class="mat-24">add</mat-icon>
</button>
</mat-list>
</div>
<div layout="row" class="full-width text-right" align="end">
<button mat-raised-button color="primary" (click)="cancel()" type="button">{{'DMP-PROFILE-EDITOR.ACTIONS.CANCEL' |
translate}}</button>
<button mat-raised-button color="primary" type="submit">{{'DMP-PROFILE-EDITOR.ACTIONS.SAVE' | translate}}</button>
<button *ngIf="!isNew" mat-raised-button color="primary" type="button" (click)="delete()">{{'DMP-PROFILE-EDITOR.ACTIONS.DELETE'
| translate}}</button>
</div>
</mat-card-content>
</mat-card>
</form>
</mat-card-content>
</mat-card>
</form>
</div>

View File

@ -1,177 +1,175 @@
import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from "@angular/core";
import { MatPaginator, MatSort, MatSnackBar } from "@angular/material";
import { Router, ActivatedRoute, Params } from "@angular/router";
import { TranslateService } from "@ngx-translate/core";
import { DataSource } from "@angular/cdk/table";
import { Observable } from "rxjs/Observable";
import { DataManagementPlanService } from "../../services/data-management-plan/data-management-plan.service";
import { ProjectModel } from "../../models/projects/ProjectModel";
import { JsonSerializer } from "../../utilities/JsonSerializer";
import { FormGroup, AbstractControl, FormControl, FormArray } from "@angular/forms";
import { SnackBarNotificationComponent } from "../../shared/components/notificaiton/snack-bar-notification.component";
import { BaseErrorModel } from "../../models/error/BaseErrorModel";
import { TdDialogService } from "@covalent/core";
import { HostConfiguration } from "../../app.constants";
import { DataManagementPlanProfileService } from "../../services/data-management-plan-profile/datamanagement-profile.service";
import { DataManagementPlanProfileModel } from "../../models/data-management-plan-profile/DataManagementPlanProfileModel";
import { DMPProfileFieldDataType, DMPProfileType, DataManagementProfileField } from "../../models/data-management-plan-profile/DataManagementProfileField";
import { Utilities } from "../../utilities/utilities";
import { DataManagementPlanProfileListingModel } from "../../models/data-management-plan-profile/DataManagementPlanProfileListingModel";
import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from '@angular/core';
import { MatPaginator, MatSort, MatSnackBar } from '@angular/material';
import { Router, ActivatedRoute, Params } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { DataSource } from '@angular/cdk/table';
import { Observable } from 'rxjs/Observable';
import { DataManagementPlanService } from '../../services/data-management-plan/data-management-plan.service';
import { ProjectModel } from '../../models/projects/ProjectModel';
import { JsonSerializer } from '../../utilities/JsonSerializer';
import { FormGroup, AbstractControl, FormControl, FormArray } from '@angular/forms';
import { SnackBarNotificationComponent } from '../../shared/components/notificaiton/snack-bar-notification.component';
import { BaseErrorModel } from '../../models/error/BaseErrorModel';
import { TdDialogService } from '@covalent/core';
import { HostConfiguration } from '../../app.constants';
import { DataManagementPlanProfileService } from '../../services/data-management-plan-profile/datamanagement-profile.service';
import { DataManagementPlanProfileModel } from '../../models/data-management-plan-profile/DataManagementPlanProfileModel';
import { DMPProfileFieldDataType, DMPProfileType, DataManagementProfileField } from '../../models/data-management-plan-profile/DataManagementProfileField';
import { Utilities } from '../../utilities/utilities';
import { DataManagementPlanProfileListingModel } from '../../models/data-management-plan-profile/DataManagementPlanProfileListingModel';
@Component({
selector: 'app-dmp-profile-editor-component',
templateUrl: 'dmp-profile-editor.component.html',
styleUrls: ['./dmp-profile-editor.component.scss'],
providers: [DataManagementPlanProfileService],
encapsulation: ViewEncapsulation.None
selector: 'app-dmp-profile-editor-component',
templateUrl: 'dmp-profile-editor.component.html',
styleUrls: ['./dmp-profile-editor.component.scss'],
providers: [DataManagementPlanProfileService, Utilities],
encapsulation: ViewEncapsulation.None
})
export class DataManagementPlanProfileEditorComponent implements AfterViewInit {
isNew = true;
dataManagementPlanProfileModel: DataManagementPlanProfileModel;
formGroup: FormGroup = null;
host = HostConfiguration.Server;
baseErrorModel: BaseErrorModel;
constructor(
private dmpProfileService: DataManagementPlanProfileService,
private route: ActivatedRoute,
public snackBar: MatSnackBar,
public router: Router,
public language: TranslateService,
private dialogService: TdDialogService,
private utilities: Utilities
) {
}
isNew = true;
dataManagementPlanProfileModel: DataManagementPlanProfileModel;
formGroup: FormGroup = null;
host = HostConfiguration.Server;
baseErrorModel: BaseErrorModel;
constructor(
private dmpProfileService: DataManagementPlanProfileService,
private route: ActivatedRoute,
public snackBar: MatSnackBar,
public router: Router,
public language: TranslateService,
private dialogService: TdDialogService,
private utilities: Utilities
) {
}
ngAfterViewInit() {
this.route.params.subscribe((params: Params) => {
const itemId = params['id'];
ngAfterViewInit() {
this.route.params.subscribe((params: Params) => {
const itemId = params['id'];
if (itemId != null) {
this.isNew = false;
this.dmpProfileService.getSingle(itemId).map(data => data as DataManagementPlanProfileModel)
.subscribe(data => {
this.dataManagementPlanProfileModel = JsonSerializer.fromJSONObject(data, DataManagementPlanProfileModel);
this.baseErrorModel = this.dataManagementPlanProfileModel.errorModel;
this.formGroup = this.dataManagementPlanProfileModel.buildForm();
});
} else {
this.dataManagementPlanProfileModel = new DataManagementPlanProfileModel();
this.baseErrorModel = this.dataManagementPlanProfileModel.errorModel;
if (itemId != null) {
this.isNew = false;
this.dmpProfileService.getSingle(itemId).map(data => data as DataManagementPlanProfileModel)
.subscribe(data => {
this.dataManagementPlanProfileModel = JsonSerializer.fromJSONObject(data, DataManagementPlanProfileModel);
this.baseErrorModel = this.dataManagementPlanProfileModel.errorModel;
this.formGroup = this.dataManagementPlanProfileModel.buildForm();
});
} else {
this.dataManagementPlanProfileModel = new DataManagementPlanProfileModel();
this.baseErrorModel = this.dataManagementPlanProfileModel.errorModel;
setTimeout(() => {
this.formGroup = this.dataManagementPlanProfileModel.buildForm();
});
}
});
}
setTimeout(() => {
this.formGroup = this.dataManagementPlanProfileModel.buildForm();
});
}
});
}
formSubmit(): void {
this.touchAllFormFields(this.formGroup);
if (!this.isFormValid()) { return; }
this.onSubmit();
}
formSubmit(): void {
this.touchAllFormFields(this.formGroup);
if (!this.isFormValid()) { return; }
this.onSubmit();
}
public isFormValid() {
return this.formGroup.valid;
}
public isFormValid() {
return this.formGroup.valid;
}
onSubmit(): void {
this.dmpProfileService.createDataManagementPlan(this.formGroup.value).subscribe(
complete => this.onCallbackSuccess(),
error => this.onCallbackError(error)
);
}
onSubmit(): void {
this.dmpProfileService.createDataManagementPlan(this.formGroup.value).subscribe(
complete => this.onCallbackSuccess(),
error => this.onCallbackError(error)
);
}
onCallbackSuccess(): void {
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
duration: 3000,
})
this.router.navigate(['/dmp-profiles']);
}
onCallbackSuccess(): void {
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
duration: 3000,
});
this.router.navigate(['/dmp-profiles']);
}
onCallbackError(errorResponse: any) {
this.setErrorModel(errorResponse.error);
this.validateAllFormFields(this.formGroup);
}
onCallbackError(errorResponse: any) {
this.setErrorModel(errorResponse.error);
this.validateAllFormFields(this.formGroup);
}
public setErrorModel(errorModel: BaseErrorModel) {
Object.keys(errorModel).forEach(item => {
(<any>this.dataManagementPlanProfileModel.errorModel)[item] = (<any>errorModel)[item];
})
}
public setErrorModel(errorModel: BaseErrorModel) {
Object.keys(errorModel).forEach(item => {
(<any>this.dataManagementPlanProfileModel.errorModel)[item] = (<any>errorModel)[item];
});
}
public cancel(): void {
this.router.navigate(['/dmp-profiles']);
}
public cancel(): void {
this.router.navigate(['/dmp-profiles']);
}
public touchAllFormFields(formControl: AbstractControl) {
if (formControl instanceof FormControl) {
formControl.markAsTouched();
} else if (formControl instanceof FormGroup) {
Object.keys(formControl.controls).forEach(item => {
const control = formControl.get(item);
this.touchAllFormFields(control);
})
}
else if (formControl instanceof FormArray) {
formControl.controls.forEach(item => {
this.touchAllFormFields(item);
})
}
}
public touchAllFormFields(formControl: AbstractControl) {
if (formControl instanceof FormControl) {
formControl.markAsTouched();
} else if (formControl instanceof FormGroup) {
Object.keys(formControl.controls).forEach(item => {
const control = formControl.get(item);
this.touchAllFormFields(control);
});
} else if (formControl instanceof FormArray) {
formControl.controls.forEach(item => {
this.touchAllFormFields(item);
});
}
}
public validateAllFormFields(formControl: AbstractControl) {
if (formControl instanceof FormControl) {
formControl.updateValueAndValidity({ emitEvent: false })
} else if (formControl instanceof FormGroup) {
Object.keys(formControl.controls).forEach(item => {
const control = formControl.get(item);
this.validateAllFormFields(control);
})
}
else if (formControl instanceof FormArray) {
formControl.controls.forEach(item => {
this.validateAllFormFields(item);
})
}
}
public validateAllFormFields(formControl: AbstractControl) {
if (formControl instanceof FormControl) {
formControl.updateValueAndValidity({ emitEvent: false });
} else if (formControl instanceof FormGroup) {
Object.keys(formControl.controls).forEach(item => {
const control = formControl.get(item);
this.validateAllFormFields(control);
});
} else if (formControl instanceof FormArray) {
formControl.controls.forEach(item => {
this.validateAllFormFields(item);
});
}
}
addField() {
(<FormArray>this.formGroup.get("definition").get("fields")).push(new DataManagementProfileField().buildForm())
}
addField() {
(<FormArray>this.formGroup.get('definition').get('fields')).push(new DataManagementProfileField().buildForm());
}
getDMPProfileFieldDataTypeValues(): Number[] {
let keys: string[] = Object.keys(DMPProfileFieldDataType);
keys = keys.slice(0, keys.length / 2);
const values: Number[] = keys.map(Number);
return values;
}
getDMPProfileFieldDataTypeValues(): Number[] {
let keys: string[] = Object.keys(DMPProfileFieldDataType);
keys = keys.slice(0, keys.length / 2);
const values: Number[] = keys.map(Number);
return values;
}
getDMPProfileFieldDataTypeWithLanguage(role: DMPProfileFieldDataType): string {
let result = '';
this.language.get(this.utilities.convertFromDMPProfileDataType(role)).subscribe((value: string) => {
result = value;
});
return result;
}
getDMPProfileFieldDataTypeWithLanguage(role: DMPProfileFieldDataType): string {
let result = '';
this.language.get(this.utilities.convertFromDMPProfileDataType(role)).subscribe((value: string) => {
result = value;
});
return result;
}
getDMPProfileFieldTypeValues(): Number[] {
let keys: string[] = Object.keys(DMPProfileType);
keys = keys.slice(0, keys.length / 2);
const values: Number[] = keys.map(Number);
return values;
}
getDMPProfileFieldTypeValues(): Number[] {
let keys: string[] = Object.keys(DMPProfileType);
keys = keys.slice(0, keys.length / 2);
const values: Number[] = keys.map(Number);
return values;
}
getDMPProfileFieldTypeWithLanguage(role: DMPProfileType): string {
let result = '';
this.language.get(this.utilities.convertFromDMPProfileType(role)).subscribe((value: string) => {
result = value;
});
return result;
}
getDMPProfileFieldTypeWithLanguage(role: DMPProfileType): string {
let result = '';
this.language.get(this.utilities.convertFromDMPProfileType(role)).subscribe((value: string) => {
result = value;
});
return result;
}
}

View File

@ -1,117 +1,117 @@
import { Component, ViewChild, OnInit } from "@angular/core";
import { MatPaginator, MatSort, PageEvent, MatSnackBar } from "@angular/material";
import { DataManagementPlanProfileCriteriaComponent } from "../../shared/components/criteria/datamanagementplanprofile/dmp-profile-criteria.component";
import { ActivatedRoute, Router, Params } from "@angular/router";
import { TranslateService } from "@ngx-translate/core";
import { DataSource } from "@angular/cdk/table";
import { DataManagementPlanProfileCriteria } from "../../models/criteria/dmp-profile/DataManagementPlanProfileCriteria";
import { Observable } from "rxjs";
import { DataTableRequest } from "../../models/data-table/DataTableRequest";
import { DataManagementPlanProfileListingModel } from "../../models/data-management-plan-profile/DataManagementPlanProfileListingModel";
import { DataManagementPlanProfileService } from "../../services/data-management-plan-profile/datamanagement-profile.service";
import { Component, ViewChild, OnInit } from '@angular/core';
import { MatPaginator, MatSort, PageEvent, MatSnackBar } from '@angular/material';
import { DataManagementPlanProfileCriteriaComponent } from '../../shared/components/criteria/datamanagementplanprofile/dmp-profile-criteria.component';
import { ActivatedRoute, Router, Params } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { DataSource } from '@angular/cdk/table';
import { DataManagementPlanProfileCriteria } from '../../models/criteria/dmp-profile/DataManagementPlanProfileCriteria';
import { Observable } from 'rxjs';
import { DataTableRequest } from '../../models/data-table/DataTableRequest';
import { DataManagementPlanProfileListingModel } from '../../models/data-management-plan-profile/DataManagementPlanProfileListingModel';
import { DataManagementPlanProfileService } from '../../services/data-management-plan-profile/datamanagement-profile.service';
@Component({
selector: 'app-dmp-profile-listing-component',
templateUrl: 'dmp-profile-listing.component.html',
styleUrls: ['./dmp-profile-listing.component.scss'],
providers: [DataManagementPlanProfileService]
selector: 'app-dmp-profile-listing-component',
templateUrl: 'dmp-profile-listing.component.html',
styleUrls: ['./dmp-profile-listing.component.scss'],
providers: [DataManagementPlanProfileService]
})
export class DataManagementPlanProfileListingComponent implements OnInit {
@ViewChild(MatPaginator) _paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
@ViewChild(DataManagementPlanProfileCriteriaComponent) criteria: DataManagementPlanProfileCriteriaComponent;
@ViewChild(MatPaginator) _paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
@ViewChild(DataManagementPlanProfileCriteriaComponent) criteria: DataManagementPlanProfileCriteriaComponent;
dataSource: DatasetDataSource | null;
displayedColumns: String[] = ['label', 'status', 'created'];
pageEvent: PageEvent;
titlePrefix: String;
dmpId: String;
dataSource: DatasetDataSource | null;
displayedColumns: String[] = ['label', 'status', 'created'];
pageEvent: PageEvent;
titlePrefix: String;
dmpId: String;
statuses = [
{ value: '0', viewValue: 'Active' },
{ value: '1', viewValue: 'Inactive' }
];
statuses = [
{ value: '0', viewValue: 'Active' },
{ value: '1', viewValue: 'Inactive' }
];
constructor(
private router: Router,
private languageService: TranslateService,
public snackBar: MatSnackBar,
public route: ActivatedRoute,
public dataManagementPlanService: DataManagementPlanProfileService
) {
constructor(
private router: Router,
private languageService: TranslateService,
public snackBar: MatSnackBar,
public route: ActivatedRoute,
public dataManagementPlanService: DataManagementPlanProfileService
) {
}
}
ngOnInit() {
this.route.params.subscribe((params: Params) => {
this.dmpId = params['dmpId'];
this.criteria.setCriteria(this.getDefaultCriteria());
this.refresh();
this.criteria.setRefreshCallback(() => this.refresh());
});
}
ngOnInit() {
this.route.params.subscribe((params: Params) => {
this.dmpId = params['dmpId'];
this.criteria.setCriteria(this.getDefaultCriteria());
this.refresh();
this.criteria.setRefreshCallback(() => this.refresh());
});
}
refresh() {
this.dataSource = new DatasetDataSource(this.dataManagementPlanService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria);
}
refresh() {
this.dataSource = new DatasetDataSource(this.dataManagementPlanService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria);
}
rowClick(rowId: String) {
this.router.navigate(['dmp-profiles/' + rowId]);
}
rowClick(rowId: String) {
this.router.navigate(['dmp-profiles/' + rowId]);
}
getDefaultCriteria(): DataManagementPlanProfileCriteria {
const defaultCriteria = new DataManagementPlanProfileCriteria();
return defaultCriteria;
}
getDefaultCriteria(): DataManagementPlanProfileCriteria {
const defaultCriteria = new DataManagementPlanProfileCriteria();
return defaultCriteria;
}
// makeItPublic(id: String) {
// debugger;
// this.datasetService.makeDatasetPublic(id).subscribe();
// }
// makeItPublic(id: String) {
// debugger;
// this.datasetService.makeDatasetPublic(id).subscribe();
// }
}
export class DatasetDataSource extends DataSource<DataManagementPlanProfileListingModel> {
totalCount = 0;
isLoadingResults = false;
totalCount = 0;
isLoadingResults = false;
constructor(
private _service: DataManagementPlanProfileService,
private _paginator: MatPaginator,
private _sort: MatSort,
private _languageService: TranslateService,
private _snackBar: MatSnackBar,
private _criteria: DataManagementPlanProfileCriteriaComponent
) {
super();
constructor(
private _service: DataManagementPlanProfileService,
private _paginator: MatPaginator,
private _sort: MatSort,
private _languageService: TranslateService,
private _snackBar: MatSnackBar,
private _criteria: DataManagementPlanProfileCriteriaComponent
) {
super();
}
}
connect(): Observable<DataManagementPlanProfileListingModel[]> {
const displayDataChanges = [
this._paginator.page
//this._sort.matSortChange
];
connect(): Observable<DataManagementPlanProfileListingModel[]> {
const displayDataChanges = [
this._paginator.page
//this._sort.matSortChange
];
return Observable.merge(...displayDataChanges)
.startWith(null)
.switchMap(() => {
setTimeout(() => {
this.isLoadingResults = true;
});
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
let fields: Array<string> = new Array()
if (this._sort.active) fields = this._sort.direction === "asc" ? ["+" + this._sort.active] : ["-" + this._sort.active];
const request = new DataTableRequest<DataManagementPlanProfileCriteria>(startIndex, this._paginator.pageSize, { fields: fields });
request.criteria = this._criteria.criteria;
return this._service.getPaged(request);
})
/*.catch((error: any) => {
return Observable.merge(...displayDataChanges)
.startWith(null)
.switchMap(() => {
setTimeout(() => {
this.isLoadingResults = true;
});
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
let fields: Array<string> = new Array();
if (this._sort.active) { fields = this._sort.direction === 'asc' ? ['+' + this._sort.active] : ['-' + this._sort.active]; }
const request = new DataTableRequest<DataManagementPlanProfileCriteria>(startIndex, this._paginator.pageSize, { fields: fields });
request.criteria = this._criteria.criteria;
return this._service.getPaged(request);
})
/*.catch((error: any) => {
this._snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService },
duration: 3000,
@ -120,20 +120,20 @@ export class DatasetDataSource extends DataSource<DataManagementPlanProfileListi
//this._criteria.criteria.onCallbackError(error);
return Observable.of(null);
})*/
.map(result => {
setTimeout(() => {
this.isLoadingResults = false;
});
return result;
})
.map(result => {
if (!result) { return []; }
if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; }
return result.data;
});
}
.map(result => {
setTimeout(() => {
this.isLoadingResults = false;
});
return result;
})
.map(result => {
if (!result) { return []; }
if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; }
return result.data;
});
}
disconnect() {
// No-op
}
disconnect() {
// No-op
}
}

View File

@ -8,50 +8,50 @@ import { HttpClient, HttpClientModule } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { SharedModule } from '../shared/shared.module'
import { SharedModule } from '../shared/shared.module';
import { DataManagementPlanProfileRoutes } from './dmp-profile.routes';
import { DataManagementPlanProfileEditorComponent } from './dmp-profile-editor/dmp-profile-editor.component';
import { DataManagementPlanProfileListingComponent } from './dmp-profile-listing/dmp-profile-listing.component';
@NgModule({
imports: [
CommonModule,
FormsModule,
HttpClientModule,
SharedModule,
RouterModule.forChild(DataManagementPlanProfileRoutes),
ReactiveFormsModule,
DynamicFormModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
}
}),
],
imports: [
CommonModule,
FormsModule,
HttpClientModule,
SharedModule,
RouterModule.forChild(DataManagementPlanProfileRoutes),
ReactiveFormsModule,
DynamicFormModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
}
}),
],
declarations: [
DataManagementPlanProfileEditorComponent,
DataManagementPlanProfileListingComponent
],
declarations: [
DataManagementPlanProfileEditorComponent,
DataManagementPlanProfileListingComponent
],
exports: [
DataManagementPlanProfileEditorComponent,
DataManagementPlanProfileListingComponent,
RouterModule
],
providers: [
DatasetService
]
exports: [
DataManagementPlanProfileEditorComponent,
DataManagementPlanProfileListingComponent,
RouterModule
],
providers: [
DatasetService
]
})
export class DataManagamentPlanProfileModule {
constructor(private translate: TranslateService) {
translate.setDefaultLang('en');
translate.use('en');
}
constructor(private translate: TranslateService) {
translate.setDefaultLang('en');
translate.use('en');
}
}
export function HttpLoaderFactory(httpClient: HttpClient) {
return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json');
return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json');
}

View File

@ -4,7 +4,7 @@ import { DataManagementPlanProfileEditorComponent } from './dmp-profile-editor/d
import { AuthGuard } from '../shared/guards/auth.guard';
export const DataManagementPlanProfileRoutes: Routes = [
{ path: '', component: DataManagementPlanProfileListingComponent, canActivate: [AuthGuard] },
{ path: 'new', component: DataManagementPlanProfileEditorComponent, canActivate: [AuthGuard] },
{ path: ':id', component: DataManagementPlanProfileEditorComponent, canActivate: [AuthGuard] },
{ path: '', component: DataManagementPlanProfileListingComponent, canActivate: [AuthGuard] },
{ path: 'new', component: DataManagementPlanProfileEditorComponent, canActivate: [AuthGuard] },
{ path: ':id', component: DataManagementPlanProfileEditorComponent, canActivate: [AuthGuard] },
];

View File

@ -15,10 +15,10 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { CommonModule } from '@angular/common';
import { CovalentDialogsModule } from '@covalent/core';
import { SharedModule } from '../shared/shared.module'
import { SharedModule } from '../shared/shared.module';
import { NgModule } from '@angular/core';
import { AvailableProfilesComponent } from '../shared/components/available-profiles/available-profiles.component';
import { DynamicDmpFieldResolver } from './editor/dynamic-field-resolver/dynamic-dmp-field-resolver.component';
import { DynamicDmpFieldResolverComponent } from './editor/dynamic-field-resolver/dynamic-dmp-field-resolver.component';
import { DynamicFieldsProjectComponent } from './editor/dynamic-fields-project/dynamic-fields-project.component';
import { DynamicFieldProjectComponent } from './editor/dynamic-fields-project/dynamic-field-project/dynamic-field-project.component';
import { BaseHttpModule } from '../utilities/cite-http-service-module/cite-http.module';
@ -34,76 +34,76 @@ import { DatasetService } from '../services/dataset/dataset.service';
import { FlexLayoutModule } from '@angular/flex-layout';
@NgModule({
imports: [
CommonModule,
FormsModule,
HttpClientModule,
SharedModule,
MaterialModule,
RouterModule.forChild(DataManagementPlanRoutes),
ReactiveFormsModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
}
}),
CovalentDialogsModule
],
imports: [
CommonModule,
FormsModule,
HttpClientModule,
SharedModule,
MaterialModule,
RouterModule.forChild(DataManagementPlanRoutes),
ReactiveFormsModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
}
}),
CovalentDialogsModule
],
declarations: [
DataManagementPlanListingComponent,
DataManagementPlanEditorComponent,
InvitationComponent,
InvitationAcceptedComponent,
DataManagementPlanWizardComponent,
DataManagementPlanWizardEditorComponent,
DatasetWizardListingComponent,
AddResearchersComponent,
AvailableProfilesComponent,
DynamicDmpFieldResolver,
DynamicFieldsProjectComponent,
DynamicFieldProjectComponent
],
declarations: [
DataManagementPlanListingComponent,
DataManagementPlanEditorComponent,
InvitationComponent,
InvitationAcceptedComponent,
DataManagementPlanWizardComponent,
DataManagementPlanWizardEditorComponent,
DatasetWizardListingComponent,
AddResearchersComponent,
AvailableProfilesComponent,
DynamicDmpFieldResolverComponent,
DynamicFieldsProjectComponent,
DynamicFieldProjectComponent
],
exports: [
DataManagementPlanListingComponent,
DataManagementPlanEditorComponent,
InvitationComponent,
InvitationAcceptedComponent,
DataManagementPlanWizardComponent,
DataManagementPlanWizardEditorComponent,
DatasetWizardListingComponent,
AddResearchersComponent,
AvailableProfilesComponent,
DynamicFieldsProjectComponent,
DynamicFieldProjectComponent,
RouterModule
],
entryComponents: [
InvitationComponent,
AddResearchersComponent,
AvailableProfilesComponent
],
providers: [
ProjectService,
ResearcherService,
DatasetService,
InvitationService,
DataManagementPlanService,
ExternalSourcesService,
DataManagementPlanProfileService
]
exports: [
DataManagementPlanListingComponent,
DataManagementPlanEditorComponent,
InvitationComponent,
InvitationAcceptedComponent,
DataManagementPlanWizardComponent,
DataManagementPlanWizardEditorComponent,
DatasetWizardListingComponent,
AddResearchersComponent,
AvailableProfilesComponent,
DynamicFieldsProjectComponent,
DynamicFieldProjectComponent,
RouterModule
],
entryComponents: [
InvitationComponent,
AddResearchersComponent,
AvailableProfilesComponent
],
providers: [
ProjectService,
ResearcherService,
DatasetService,
InvitationService,
DataManagementPlanService,
ExternalSourcesService,
DataManagementPlanProfileService
]
})
export class DataManagementPlanModule {
constructor(private translate: TranslateService) {
translate.setDefaultLang('en');
translate.use('en');
}
constructor(private translate: TranslateService) {
translate.setDefaultLang('en');
translate.use('en');
}
}
export function HttpLoaderFactory(httpClient: HttpClient) {
return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json');
return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json');
}

View File

@ -6,62 +6,62 @@ import { RouterModule, Routes } from '@angular/router';
import { InvitationAcceptedComponent } from '../shared/components/invitation-accepted/invitation-accepted.component';
export const DataManagementPlanRoutes: Routes = [
{
path: '',
component: DataManagementPlanListingComponent,
data: {
breadcrumb: true
},
},
{
path: 'viewversions/:groupId',
component: DataManagementPlanListingComponent,
data: {
breadcrumb: true
},
},
{
path: 'project/:projectId',
component: DataManagementPlanListingComponent,
data: {
breadcrumb: true
},
},
{
path: 'edit/:id',
component: DataManagementPlanEditorComponent,
data: {
breadcrumb: true
},
},
{
path: 'new',
component: DataManagementPlanEditorComponent,
data: {
breadcrumbs: 'new'
}
},
{
path: 'new_version/:id',
component: DataManagementPlanWizardComponent,
data: {
clone: false,
breadcrumb: true
},
},
{
path: 'clone/:id',
component: DataManagementPlanWizardComponent,
data: {
clone: false,
breadcrumb: true
},
},
{
path: "invitation/:id",
component: InvitationAcceptedComponent,
data: {
breadcrumb: true
},
}
{
path: '',
component: DataManagementPlanListingComponent,
data: {
breadcrumb: true
},
},
{
path: 'viewversions/:groupId',
component: DataManagementPlanListingComponent,
data: {
breadcrumb: true
},
},
{
path: 'project/:projectId',
component: DataManagementPlanListingComponent,
data: {
breadcrumb: true
},
},
{
path: 'edit/:id',
component: DataManagementPlanEditorComponent,
data: {
breadcrumb: true
},
},
{
path: 'new',
component: DataManagementPlanEditorComponent,
data: {
breadcrumbs: 'new'
}
},
{
path: 'new_version/:id',
component: DataManagementPlanWizardComponent,
data: {
clone: false,
breadcrumb: true
},
},
{
path: 'clone/:id',
component: DataManagementPlanWizardComponent,
data: {
clone: false,
breadcrumb: true
},
},
{
path: 'invitation/:id',
component: InvitationAcceptedComponent,
data: {
breadcrumb: true
},
}
];

View File

@ -1,129 +1,138 @@
<div class="data-management-plan-editor">
<mat-card-title *ngIf="isNew">{{'DMP-EDITOR.TITLE.NEW' | translate}}</mat-card-title>
<mat-card-title *ngIf="!isNew">
<h3>{{formGroup?.get('label')?.value}} </h3>
</mat-card-title>
<form *ngIf="formGroup" (ngSubmit)="formSubmit()" [formGroup]="formGroup">
<mat-card>
<mat-card-header>
<div class="fill-space"></div>
<div *ngIf="!isNew">
<!-- <div fxFlex>
<mat-card-title *ngIf="isNew">{{'DMP-EDITOR.TITLE.NEW' | translate}}</mat-card-title>
<mat-card-title *ngIf="!isNew">
<h3>{{formGroup?.get('label')?.value}} </h3>
</mat-card-title>
<form *ngIf="formGroup" (ngSubmit)="formSubmit()" [formGroup]="formGroup">
<mat-card>
<mat-card-header>
<div class="fill-space"></div>
<div *ngIf="!isNew">
<!-- <div fxFlex>
<button mat-button type="button" (click)="redirectToProject()">
<mat-icon>arrow_right_alt</mat-icon>{{'DMP-EDITOR.ACTIONS.GO-TO-PROJECT' | translate}}</button>
</div> -->
<div>
<button mat-button type="button" (click)="redirectToDatasets()">
<mat-icon>arrow_right_alt</mat-icon>{{'DMP-EDITOR.ACTIONS.GO-TO-DATASETS' | translate}}</button>
</div>
<mat-menu #actionsMenu="matMenu">
<button mat-menu-item (click)="newVersion(this.dataManagementPlan.id, this.dataManagementPlan.label)">
<mat-icon>queue</mat-icon>{{'DMP-LISTING.ACTIONS.NEW-VERSION' | translate}}</button>
<button mat-menu-item (click)="clone(this.dataManagementPlan.id)">
<mat-icon>filter_none</mat-icon>{{'DMP-LISTING.ACTIONS.CLONE' | translate}}</button>
<button mat-menu-item (click)="viewVersions(this.dataManagementPlan.groupId, this.dataManagementPlan.label)">
<mat-icon>library_books</mat-icon>{{'DMP-LISTING.ACTIONS.VIEW-VERSION' | translate}}</button>
</mat-menu>
<div>
<button mat-icon-button type="button" [matMenuTriggerFor]="actionsMenu">
<mat-icon>more_vert</mat-icon>
</button>
</div>
</div>
</mat-card-header>
<mat-card-content>
<div class="row">
<mat-form-field class="col-md-12">
<input matInput placeholder="{{'DMP-EDITOR.FIELDS.NAME' | translate}}" type="text" name="label" formControlName="label" required>
<mat-error *ngIf="formGroup.get('label').errors?.backendError">{{baseErrorModel.label}}</mat-error>
<mat-error *ngIf="formGroup.get('label').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<div>
<button mat-button type="button" (click)="redirectToDatasets()">
<mat-icon>arrow_right_alt</mat-icon>{{'DMP-EDITOR.ACTIONS.GO-TO-DATASETS' | translate}}
</button>
</div>
<mat-menu #actionsMenu="matMenu">
<button mat-menu-item (click)="newVersion(this.dataManagementPlan.id, this.dataManagementPlan.label)">
<mat-icon>queue</mat-icon>{{'DMP-LISTING.ACTIONS.NEW-VERSION' | translate}}
</button>
<button mat-menu-item (click)="clone(this.dataManagementPlan.id)">
<mat-icon>filter_none</mat-icon>{{'DMP-LISTING.ACTIONS.CLONE' | translate}}
</button>
<button mat-menu-item (click)="viewVersions(this.dataManagementPlan.groupId, this.dataManagementPlan.label)">
<mat-icon>library_books</mat-icon>{{'DMP-LISTING.ACTIONS.VIEW-VERSION' | translate}}
</button>
</mat-menu>
<div>
<button mat-icon-button type="button" [matMenuTriggerFor]="actionsMenu">
<mat-icon>more_vert</mat-icon>
</button>
</div>
</div>
</mat-card-header>
<mat-card-content>
<div class="row">
<mat-form-field class="col-md-12">
<input matInput placeholder="{{'DMP-EDITOR.FIELDS.NAME' | translate}}" type="text" name="label" formControlName="label"
required>
<mat-error *ngIf="formGroup.get('label').errors?.backendError">{{baseErrorModel.label}}</mat-error>
<mat-error *ngIf="formGroup.get('label').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-form-field class="col-md-12">
<textarea matInput class="description-area" placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION' | translate}}" formControlName="description"
required></textarea>
<mat-error *ngIf="formGroup.get('description').errors?.backendError">{{errorModel.description}}</mat-error>
<mat-error *ngIf="formGroup.get('description').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-form-field class="col-md-12">
<textarea matInput class="description-area" placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION' | translate}}"
formControlName="description" required></textarea>
<mat-error *ngIf="formGroup.get('description').errors?.backendError">{{errorModel.description}}</mat-error>
<mat-error *ngIf="formGroup.get('description').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<div class="col-md-6">
<app-single-auto-complete required='true' [reactiveFormControl]="formGroup.get('project')" placeholder="{{this.languageResolverService.getBy('dmpEditor') | translate}}"
[configuration]="projectAutoCompleteConfiguration">
</app-single-auto-complete>
</div>
<!-- <app-dynamic-fields-project [formGroup]="formGroup"></app-dynamic-fields-project> -->
<div class="col-md-6">
<div class="row">
<app-multiple-auto-complete required='true' class="col-md-10" [reactiveFormControl]="formGroup.get('profiles')" placeholder="{{'DMP-EDITOR.FIELDS.PROFILES' | translate}}"
[configuration]="profilesAutoCompleteConfiguration">
</app-multiple-auto-complete>
<div class="col-md-2">
<button mat-icon-button type="button" (click)="availableProfiles()">
<mat-icon>view_list</mat-icon>
</button>
</div>
</div>
</div>
<!-- <button mat-button (click)="availableProfiles()">View All</button> -->
<div class="col-md-6">
<app-single-auto-complete required='true' [reactiveFormControl]="formGroup.get('project')" placeholder="{{this.languageResolverService.getBy('dmpEditor') | translate}}"
[configuration]="projectAutoCompleteConfiguration">
</app-single-auto-complete>
</div>
<!-- <app-dynamic-fields-project [formGroup]="formGroup"></app-dynamic-fields-project> -->
<div class="col-md-6">
<div class="row">
<app-multiple-auto-complete required='true' class="col-md-10" [reactiveFormControl]="formGroup.get('profiles')"
placeholder="{{'DMP-EDITOR.FIELDS.PROFILES' | translate}}" [configuration]="profilesAutoCompleteConfiguration">
</app-multiple-auto-complete>
<div class="col-md-2">
<button mat-icon-button type="button" (click)="availableProfiles()">
<mat-icon>view_list</mat-icon>
</button>
</div>
</div>
</div>
<!-- <button mat-button (click)="availableProfiles()">View All</button> -->
<div class="col-md-6">
<app-multiple-auto-complete [reactiveFormControl]="formGroup.get('organisations')" placeholder="{{'DMP-EDITOR.FIELDS.ORGANISATIONS' | translate}}"
[configuration]="organisationsAutoCompleteConfiguration">
</app-multiple-auto-complete>
</div>
<div class="col-md-6">
<div class="row">
<div class="col-md-10">
<app-multiple-auto-complete [reactiveFormControl]="formGroup.get('researchers')" placeholder="{{'DMP-EDITOR.FIELDS.RESEARCHERS' | translate}}"
[configuration]="researchersAutoCompleteConfiguration">
</app-multiple-auto-complete>
</div>
<div class="col-md-2">
<button mat-icon-button type="button" (click)="addResearcher()">
<mat-icon>add_circle</mat-icon>
</button>
</div>
</div>
</div>
<div class="col-md-6">
<app-multiple-auto-complete [reactiveFormControl]="formGroup.get('organisations')" placeholder="{{'DMP-EDITOR.FIELDS.ORGANISATIONS' | translate}}"
[configuration]="organisationsAutoCompleteConfiguration">
</app-multiple-auto-complete>
</div>
<div class="col-md-6">
<div class="row">
<div class="col-md-10">
<app-multiple-auto-complete [reactiveFormControl]="formGroup.get('researchers')" placeholder="{{'DMP-EDITOR.FIELDS.RESEARCHERS' | translate}}"
[configuration]="researchersAutoCompleteConfiguration">
</app-multiple-auto-complete>
</div>
<div class="col-md-2">
<button mat-icon-button type="button" (click)="addResearcher()">
<mat-icon>add_circle</mat-icon>
</button>
</div>
</div>
</div>
<h3 mat-subheader class="col-md-12">{{'DMP-EDITOR.FIELDS.PROFILE' | translate}}</h3>
<h3 mat-subheader class="col-md-12">{{'DMP-EDITOR.FIELDS.PROFILE' | translate}}</h3>
<mat-form-field class="col-md-6">
<input type="text" placeholder="{{'DMP-EDITOR.FIELDS.PROFILE' | translate}}" [formControl]="textCtrl" matInput [matAutocomplete]="auto">
<mat-autocomplete #auto="matAutocomplete" [displayWith]="displayWith">
<mat-option *ngFor="let option of filteredOptions | async" [value]="option" (click)="selectOption(option)">
{{ option.label }}
</mat-option>
</mat-autocomplete>
</mat-form-field>
<app-dynamic-dmp-field-resolver class="col-md-12" *ngIf="dataManagementPlan.definition" [formGroup]="formGroup" [dataManagementPlanProfile]="dataManagementPlan.definition"></app-dynamic-dmp-field-resolver>
<mat-form-field class="col-md-6">
<input type="text" placeholder="{{'DMP-EDITOR.FIELDS.PROFILE' | translate}}" [formControl]="textCtrl" matInput
[matAutocomplete]="auto">
<mat-autocomplete #auto="matAutocomplete" [displayWith]="displayWith">
<mat-option *ngFor="let option of filteredOptions | async" [value]="option" (click)="selectOption(option)">
{{ option.label }}
</mat-option>
</mat-autocomplete>
</mat-form-field>
<app-dynamic-dmp-field-resolver class="col-md-12" *ngIf="dataManagementPlan.definition" [formGroup]="formGroup"
[dataManagementPlanProfile]="dataManagementPlan.definition"></app-dynamic-dmp-field-resolver>
<mat-form-field class="col-md-6">
<input matInput placeholder="Version" disabled [value]="formGroup.get('version').value== undefined ?0 :formGroup.get('version').value">
</mat-form-field>
<mat-form-field class="col-md-6">
<input matInput placeholder="Version" disabled [value]="formGroup.get('version').value== undefined ?0 :formGroup.get('version').value">
</mat-form-field>
<div class="col-md-12">
<mat-list *ngIf="associatedUsers?.length" role="list" class="col-md-12">
<h3 mat-subheader>Associated Users</h3>
<mat-list-item role="listitem" *ngFor="let user of associatedUsers">
<mat-icon mat-list-icon>person</mat-icon>
<div>{{user.name}}</div>
</mat-list-item>
</mat-list>
</div>
<div class="col-md-12">
<mat-list *ngIf="associatedUsers?.length" role="list" class="col-md-12">
<h3 mat-subheader>Associated Users</h3>
<mat-list-item role="listitem" *ngFor="let user of associatedUsers">
<mat-icon mat-list-icon>person</mat-icon>
<div>{{user.name}}</div>
</mat-list-item>
</mat-list>
</div>
<div class="col-md-12">
<div class="right-button">
<button mat-raised-button color="primary" (click)="cancel()" type="button">{{'DMP-EDITOR.ACTIONS.CANCEL' | translate}}</button>
<!-- <button *ngIf="!isNew" mat-raised-button color="primary" (click)="invite()" type="button">{{'DMP-EDITOR.ACTIONS.INVITE' | translate}}</button> -->
<button mat-raised-button color="primary" type="submit">{{'DMP-EDITOR.ACTIONS.SAVE' | translate}}</button>
<button *ngIf="!isNew" mat-raised-button color="primary" type="button" (click)="openConfirm(formGroup.get('label').value, formGroup.get('id').value)">{{'DMP-EDITOR.ACTIONS.DELETE' | translate}}</button>
</div>
</div>
</div>
</mat-card-content>
</mat-card>
</form>
<!-- <div *ngIf="formGroup"> {{ formGroup.value | json }}</div> -->
<div class="col-md-12">
<div class="right-button">
<button mat-raised-button color="primary" (click)="cancel()" type="button">{{'DMP-EDITOR.ACTIONS.CANCEL' |
translate}}</button>
<!-- <button *ngIf="!isNew" mat-raised-button color="primary" (click)="invite()" type="button">{{'DMP-EDITOR.ACTIONS.INVITE' | translate}}</button> -->
<button mat-raised-button color="primary" type="submit">{{'DMP-EDITOR.ACTIONS.SAVE' | translate}}</button>
<button *ngIf="!isNew" mat-raised-button color="primary" type="button" (click)="openConfirm(formGroup.get('label').value, formGroup.get('id').value)">{{'DMP-EDITOR.ACTIONS.DELETE'
| translate}}</button>
</div>
</div>
</div>
</mat-card-content>
</mat-card>
</form>
<!-- <div *ngIf="formGroup"> {{ formGroup.value | json }}</div> -->
</div>

View File

@ -1,331 +1,331 @@
import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from "@angular/core";
import { MatPaginator, MatSort, MatSnackBar, MatDialog, MatChipList, MatChip } from "@angular/material";
import { Router, ActivatedRoute, Params } from "@angular/router";
import { TranslateService } from "@ngx-translate/core";
import { DataSource } from "@angular/cdk/table";
import { Observable } from "rxjs/Observable";
import { JsonSerializer } from "../../utilities/JsonSerializer";
import { FormGroup, FormControl } from "@angular/forms";
import { SnackBarNotificationComponent } from "../../shared/components/notificaiton/snack-bar-notification.component";
import { BaseErrorModel } from "../../models/error/BaseErrorModel";
import { DataManagementPlanService } from "../../services/data-management-plan/data-management-plan.service";
import { DataManagementPlanModel } from "../../models/data-managemnt-plans/DataManagementPlanModel";
import { ExternalSourcesService } from "../../services/external-sources/external-sources.service";
import { ExternalSourcesItemModel } from "../../models/external-sources/ExternalSourcesItemModel";
import { RequestItem } from "../../models/criteria/RequestItem";
import { DatasetProfileCriteria } from "../../models/criteria/dataset/DatasetProfileCriteria";
import { DataManagementPlanCriteriaComponent } from "../../shared/components/criteria/data-management-plan/dmp-criteria.component";
import { DatasetProfileModel } from "../../models/datasets/DatasetProfileModel";
import { ProjectCriteria } from "../../models/criteria/project/ProjectCriteria";
import { ProjectService } from "../../services/project/project.service";
import { DmpUsersModel } from "../../models/dmpUsers/DmpUsersModel";
import { AddResearchersComponent } from "../../shared/components/add-researchers/add-researchers.component";
import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from '@angular/core';
import { MatPaginator, MatSort, MatSnackBar, MatDialog, MatChipList, MatChip } from '@angular/material';
import { Router, ActivatedRoute, Params } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { DataSource } from '@angular/cdk/table';
import { Observable } from 'rxjs/Observable';
import { JsonSerializer } from '../../utilities/JsonSerializer';
import { FormGroup, FormControl } from '@angular/forms';
import { SnackBarNotificationComponent } from '../../shared/components/notificaiton/snack-bar-notification.component';
import { BaseErrorModel } from '../../models/error/BaseErrorModel';
import { DataManagementPlanService } from '../../services/data-management-plan/data-management-plan.service';
import { DataManagementPlanModel } from '../../models/data-managemnt-plans/DataManagementPlanModel';
import { ExternalSourcesService } from '../../services/external-sources/external-sources.service';
import { ExternalSourcesItemModel } from '../../models/external-sources/ExternalSourcesItemModel';
import { RequestItem } from '../../models/criteria/RequestItem';
import { DatasetProfileCriteria } from '../../models/criteria/dataset/DatasetProfileCriteria';
import { DataManagementPlanCriteriaComponent } from '../../shared/components/criteria/data-management-plan/dmp-criteria.component';
import { DatasetProfileModel } from '../../models/datasets/DatasetProfileModel';
import { ProjectCriteria } from '../../models/criteria/project/ProjectCriteria';
import { ProjectService } from '../../services/project/project.service';
import { DmpUsersModel } from '../../models/dmpUsers/DmpUsersModel';
import { AddResearchersComponent } from '../../shared/components/add-researchers/add-researchers.component';
import { ViewContainerRef } from '@angular/core';
import { TdDialogService } from '@covalent/core';
import { AvailableProfilesComponent } from "../../shared/components/available-profiles/available-profiles.component";
import { BaseCriteria } from "../../models/criteria/BaseCriteria";
import { DataManagementPlanProfileService } from "../../services/data-management-plan-profile/datamanagement-profile.service";
import { DataManagementPlanProfileListingModel } from "../../models/data-management-plan-profile/DataManagementPlanProfileListingModel";
import { DataManagementPlanProfileCriteria } from "../../models/criteria/dmp-profile/DataManagementPlanProfileCriteria";
import { DataManagementPlanProfile } from "../../models/data-management-plan-profile/DataManagementPlanProfile";
import { LanguageResolverService } from "../../services/language-resolver/language-resolver.service";
import { IBreadCrumbComponent } from "../../shared/components/breadcrumb/definition/IBreadCrumbComponent";
import { BreadcrumbItem } from "../../shared/components/breadcrumb/definition/breadcrumb-item";
import { SingleAutoCompleteConfiguration } from "../../shared/components/autocompletes/single/single-auto-complete-configuration";
import { MultipleAutoCompleteConfiguration } from "../../shared/components/autocompletes/multiple/multiple-auto-complete-configuration";
import { AvailableProfilesComponent } from '../../shared/components/available-profiles/available-profiles.component';
import { BaseCriteria } from '../../models/criteria/BaseCriteria';
import { DataManagementPlanProfileService } from '../../services/data-management-plan-profile/datamanagement-profile.service';
import { DataManagementPlanProfileListingModel } from '../../models/data-management-plan-profile/DataManagementPlanProfileListingModel';
import { DataManagementPlanProfileCriteria } from '../../models/criteria/dmp-profile/DataManagementPlanProfileCriteria';
import { DataManagementPlanProfile } from '../../models/data-management-plan-profile/DataManagementPlanProfile';
import { LanguageResolverService } from '../../services/language-resolver/language-resolver.service';
import { IBreadCrumbComponent } from '../../shared/components/breadcrumb/definition/IBreadCrumbComponent';
import { BreadcrumbItem } from '../../shared/components/breadcrumb/definition/breadcrumb-item';
import { SingleAutoCompleteConfiguration } from '../../shared/components/autocompletes/single/single-auto-complete-configuration';
import { MultipleAutoCompleteConfiguration } from '../../shared/components/autocompletes/multiple/multiple-auto-complete-configuration';
@Component({
selector: 'app-dmp-editor-component',
templateUrl: 'dmp-editor.component.html',
styleUrls: ['./dmp-editor.component.scss'],
encapsulation: ViewEncapsulation.None
selector: 'app-dmp-editor-component',
templateUrl: 'dmp-editor.component.html',
styleUrls: ['./dmp-editor.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class DataManagementPlanEditorComponent implements AfterViewInit, IBreadCrumbComponent {
breadCrumbs: Observable<BreadcrumbItem[]>;
isNew = true;
textCtrl = new FormControl();
dataManagementPlan: DataManagementPlanModel;
formGroup: FormGroup = null;
breadCrumbs: Observable<BreadcrumbItem[]>;
isNew = true;
textCtrl = new FormControl();
dataManagementPlan: DataManagementPlanModel;
formGroup: FormGroup = null;
filteringOrganisationsAsync: boolean = false;
filteringResearchersAsync: boolean = false;
filteredProfilesAsync: boolean = false;
filteredOrganisations: ExternalSourcesItemModel[];
filteredResearchers: ExternalSourcesItemModel[];
filteredProfiles: DatasetProfileModel[];
filteringOrganisationsAsync = false;
filteringResearchersAsync = false;
filteredProfilesAsync = false;
filteredOrganisations: ExternalSourcesItemModel[];
filteredResearchers: ExternalSourcesItemModel[];
filteredProfiles: DatasetProfileModel[];
projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
organisationsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
researchersAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
organisationsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
researchersAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
createNewVersion;
associatedUsers: Array<DmpUsersModel>
filteredOptions: Observable<DataManagementPlanProfileListingModel>
createNewVersion;
associatedUsers: Array<DmpUsersModel>;
filteredOptions: Observable<DataManagementPlanProfileListingModel>;
constructor(
private dmpProfileService: DataManagementPlanProfileService,
private dataManagementPlanService: DataManagementPlanService,
private projectService: ProjectService,
private externalSourcesService: ExternalSourcesService,
private route: ActivatedRoute,
public snackBar: MatSnackBar,
public router: Router,
public language: TranslateService,
private _service: DataManagementPlanService,
public dialog: MatDialog,
private _dialogService: TdDialogService,
private _viewContainerRef: ViewContainerRef,
private languageResolverService: LanguageResolverService
) {
this.filteredOptions = dmpProfileService.getAll({ criteria: new DataManagementPlanProfileCriteria() });
}
constructor(
private dmpProfileService: DataManagementPlanProfileService,
private dataManagementPlanService: DataManagementPlanService,
private projectService: ProjectService,
private externalSourcesService: ExternalSourcesService,
private route: ActivatedRoute,
public snackBar: MatSnackBar,
public router: Router,
public language: TranslateService,
private _service: DataManagementPlanService,
public dialog: MatDialog,
private _dialogService: TdDialogService,
private _viewContainerRef: ViewContainerRef,
private languageResolverService: LanguageResolverService
) {
this.filteredOptions = dmpProfileService.getAll({ criteria: new DataManagementPlanProfileCriteria() });
}
ngAfterViewInit() {
this.route.params.subscribe((params: Params) => {
const itemId = params['id'];
ngAfterViewInit() {
this.route.params.subscribe((params: Params) => {
const itemId = params['id'];
let projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
projectRequestItem.criteria = new ProjectCriteria();
let organisationRequestItem: RequestItem<BaseCriteria> = new RequestItem();
organisationRequestItem.criteria = new BaseCriteria();
//this.projectAutoCompleteConfiguration = new AutoCompleteConfiguration(this.projectService.getWithExternal.bind(this.projectService), projectRequestItem);
const projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
projectRequestItem.criteria = new ProjectCriteria();
const organisationRequestItem: RequestItem<BaseCriteria> = new RequestItem();
organisationRequestItem.criteria = new BaseCriteria();
//this.projectAutoCompleteConfiguration = new AutoCompleteConfiguration(this.projectService.getWithExternal.bind(this.projectService), projectRequestItem);
this.projectAutoCompleteConfiguration = {
filterFn: this.searchProject.bind(this),
items: this.searchProject(''),
displayFn: (item) => item["label"],
titleFn: (item) => item["label"],
//mapFn: (item) => new JsonSerializer<ProjectReference>().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()),
loadDataOnStart: true
};
this.projectAutoCompleteConfiguration = {
filterFn: this.searchProject.bind(this),
items: this.searchProject(''),
displayFn: (item) => item['label'],
titleFn: (item) => item['label'],
//mapFn: (item) => new JsonSerializer<ProjectReference>().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()),
loadDataOnStart: true
};
this.profilesAutoCompleteConfiguration = {
filterFn: this.filterProfiles.bind(this),
initialItems: (excludedItems: any[]) => this.filterProfiles('').map(result => result.filter(x => excludedItems.map(x => x.id).indexOf(x.id) == -1)),
displayFn: (item) => item["label"],
titleFn: (item) => item["label"],
//mapFn: (item) => new JsonSerializer<ProjectReference>().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()),
loadDataOnStart: true
};
this.profilesAutoCompleteConfiguration = {
filterFn: this.filterProfiles.bind(this),
initialItems: (excludedItems: any[]) => this.filterProfiles('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)),
displayFn: (item) => item['label'],
titleFn: (item) => item['label'],
//mapFn: (item) => new JsonSerializer<ProjectReference>().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()),
loadDataOnStart: true
};
this.organisationsAutoCompleteConfiguration = {
filterFn: this.filterOrganisations.bind(this),
initialItems: (excludedItems: any[]) => this.filterOrganisations('').map(result => result.filter(x => excludedItems.map(x => x.id).indexOf(x.id) == -1)),
displayFn: (item) => item["name"],
titleFn: (item) => item["name"],
loadDataOnStart: true
};
this.organisationsAutoCompleteConfiguration = {
filterFn: this.filterOrganisations.bind(this),
initialItems: (excludedItems: any[]) => this.filterOrganisations('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)),
displayFn: (item) => item['name'],
titleFn: (item) => item['name'],
loadDataOnStart: true
};
this.researchersAutoCompleteConfiguration = {
filterFn: this.filterResearchers.bind(this),
initialItems: (excludedItems: any[]) => this.filterResearchers('').map(result => result.filter(x => excludedItems.map(x => x.id).indexOf(x.id) == -1)),
displayFn: (item) => item["name"],
titleFn: (item) => item["name"],
loadDataOnStart: true
};
this.researchersAutoCompleteConfiguration = {
filterFn: this.filterResearchers.bind(this),
initialItems: (excludedItems: any[]) => this.filterResearchers('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)),
displayFn: (item) => item['name'],
titleFn: (item) => item['name'],
loadDataOnStart: true
};
if (itemId != null) {
this.isNew = false;
this.dataManagementPlanService.getSingle(itemId).map(data => data as DataManagementPlanModel)
.subscribe(async data => {
this.dataManagementPlan = JsonSerializer.fromJSONObject(data, DataManagementPlanModel);
this.formGroup = this.dataManagementPlan.buildForm();
if (this.formGroup.get("profile") && this.formGroup.get("profile").value) {
this.textCtrl.patchValue(this.formGroup.get("profile").value);
}
this.breadCrumbs = Observable.of([
{
parentComponentName: "DataManagementPlanListingComponent",
label: 'DMPs',
url: "dmps",
notFoundResolver: [await this.projectService.getSingle(this.dataManagementPlan.project.id).map(x => ({ label: x.label, url: '/projects/edit/' + x.id }) as BreadcrumbItem).toPromise()]
}
]
)
this.associatedUsers = data.associatedUsers;
});
} else {
this.dataManagementPlan = new DataManagementPlanModel();
setTimeout(async () => {
this.formGroup = this.dataManagementPlan.buildForm();
if (this.formGroup.get("profile") && this.formGroup.get("profile").value) {
this.textCtrl.patchValue(this.formGroup.get("profile").value);
}
this.breadCrumbs = Observable.of([
{
parentComponentName: "DataManagementPlanListingComponent",
label: 'DMPs',
url: "dmps",
}
])
});
}
if (itemId != null) {
this.isNew = false;
this.dataManagementPlanService.getSingle(itemId).map(data => data as DataManagementPlanModel)
.subscribe(async data => {
this.dataManagementPlan = JsonSerializer.fromJSONObject(data, DataManagementPlanModel);
this.formGroup = this.dataManagementPlan.buildForm();
if (this.formGroup.get('profile') && this.formGroup.get('profile').value) {
this.textCtrl.patchValue(this.formGroup.get('profile').value);
}
this.breadCrumbs = Observable.of([
{
parentComponentName: 'DataManagementPlanListingComponent',
label: 'DMPs',
url: 'dmps',
notFoundResolver: [await this.projectService.getSingle(this.dataManagementPlan.project.id).map(x => ({ label: x.label, url: '/projects/edit/' + x.id }) as BreadcrumbItem).toPromise()]
}
]
);
this.associatedUsers = data.associatedUsers;
});
} else {
this.dataManagementPlan = new DataManagementPlanModel();
setTimeout(async () => {
this.formGroup = this.dataManagementPlan.buildForm();
if (this.formGroup.get('profile') && this.formGroup.get('profile').value) {
this.textCtrl.patchValue(this.formGroup.get('profile').value);
}
this.breadCrumbs = Observable.of([
{
parentComponentName: 'DataManagementPlanListingComponent',
label: 'DMPs',
url: 'dmps',
}
]);
});
}
});
this.route
.queryParams
.subscribe(params => {
this.createNewVersion = params["clone"];
});
}
});
this.route
.queryParams
.subscribe(params => {
this.createNewVersion = params['clone'];
});
}
searchProject(query: string) {
let projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
projectRequestItem.criteria = new ProjectCriteria();
projectRequestItem.criteria.like = query;
return this.projectService.getWithExternal(projectRequestItem);
}
searchProject(query: string) {
const projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
projectRequestItem.criteria = new ProjectCriteria();
projectRequestItem.criteria.like = query;
return this.projectService.getWithExternal(projectRequestItem);
}
formSubmit(): void {
//this.touchAllFormFields(this.formGroup);
if (!this.isFormValid()) { return; }
this.onSubmit();
}
formSubmit(): void {
//this.touchAllFormFields(this.formGroup);
if (!this.isFormValid()) { return; }
this.onSubmit();
}
public isFormValid() {
return this.formGroup.valid;
}
public isFormValid() {
return this.formGroup.valid;
}
onSubmit(): void {
this.dataManagementPlanService.createDataManagementPlan(this.formGroup.value).subscribe(
complete => this.onCallbackSuccess(),
error => this.onCallbackError(error)
)
}
onSubmit(): void {
this.dataManagementPlanService.createDataManagementPlan(this.formGroup.value).subscribe(
complete => this.onCallbackSuccess(),
error => this.onCallbackError(error)
);
}
onCallbackSuccess(): void {
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
duration: 3000,
})
this.router.navigate(['/dmps']);
}
onCallbackSuccess(): void {
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
duration: 3000,
});
this.router.navigate(['/dmps']);
}
onCallbackError(error: any) {
this.setErrorModel(error.error);
//this.validateAllFormFields(this.formGroup);
}
onCallbackError(error: any) {
this.setErrorModel(error.error);
//this.validateAllFormFields(this.formGroup);
}
public setErrorModel(errorModel: BaseErrorModel) {
Object.keys(errorModel).forEach(item => {
(<any>this.dataManagementPlan.errorModel)[item] = (<any>errorModel)[item];
})
}
public setErrorModel(errorModel: BaseErrorModel) {
Object.keys(errorModel).forEach(item => {
(<any>this.dataManagementPlan.errorModel)[item] = (<any>errorModel)[item];
});
}
public cancel(): void {
this.router.navigate(['/dmps']);
}
public cancel(): void {
this.router.navigate(['/dmps']);
}
public invite(): void {
this.router.navigate(['/invite/' + this.dataManagementPlan.id]);
}
public invite(): void {
this.router.navigate(['/invite/' + this.dataManagementPlan.id]);
}
filterOrganisations(value: string): Observable<ExternalSourcesItemModel[]> {
filterOrganisations(value: string): Observable<ExternalSourcesItemModel[]> {
this.filteredOrganisations = undefined;
this.filteringOrganisationsAsync = true;
this.filteredOrganisations = undefined;
this.filteringOrganisationsAsync = true;
return this.externalSourcesService.searchDMPOrganizations(value)
}
return this.externalSourcesService.searchDMPOrganizations(value);
}
filterResearchers(value: string): Observable<ExternalSourcesItemModel[]> {
filterResearchers(value: string): Observable<ExternalSourcesItemModel[]> {
this.filteredResearchers = undefined;
this.filteringResearchersAsync = true;
this.filteredResearchers = undefined;
this.filteringResearchersAsync = true;
return this.externalSourcesService.searchDMPResearchers({ criteria: { name: value, like: null } })
}
return this.externalSourcesService.searchDMPResearchers({ criteria: { name: value, like: null } });
}
filterProfiles(value: string): Observable<DatasetProfileModel[]> {
filterProfiles(value: string): Observable<DatasetProfileModel[]> {
this.filteredProfiles = undefined;
this.filteredProfilesAsync = true;
this.filteredProfiles = undefined;
this.filteredProfilesAsync = true;
const request = new RequestItem<DatasetProfileCriteria>();
let criteria = new DatasetProfileCriteria();
criteria.like = value;
request.criteria = criteria;
return this._service.searchDMPProfiles(request)
}
const request = new RequestItem<DatasetProfileCriteria>();
const criteria = new DatasetProfileCriteria();
criteria.like = value;
request.criteria = criteria;
return this._service.searchDMPProfiles(request);
}
addResearcher(rowId: any, rowName: any) {
let dialogRef = this.dialog.open(AddResearchersComponent, {
height: '255px',
width: '700px',
data: {
dmpId: rowId,
dmpName: rowName
}
});
addResearcher(rowId: any, rowName: any) {
const dialogRef = this.dialog.open(AddResearchersComponent, {
height: '255px',
width: '700px',
data: {
dmpId: rowId,
dmpName: rowName
}
});
}
}
availableProfiles() {
let dialogRef = this.dialog.open(AvailableProfilesComponent, {
height: '355px',
width: '700px',
data: {
profiles: this.formGroup.get("profiles")
}
});
availableProfiles() {
const dialogRef = this.dialog.open(AvailableProfilesComponent, {
height: '355px',
width: '700px',
data: {
profiles: this.formGroup.get('profiles')
}
});
return false;
}
return false;
}
openConfirm(dmpLabel, id): void {
this._dialogService.openConfirm({
message: 'Are you sure you want to delete the "' + dmpLabel + '"',
disableClose: true || false, // defaults to false
viewContainerRef: this._viewContainerRef, //OPTIONAL
title: 'Confirm', //OPTIONAL, hides if not provided
cancelButton: 'No', //OPTIONAL, defaults to 'CANCEL'
acceptButton: 'Yes' //OPTIONAL, defaults to 'ACCEPT'
// width: '500px', //OPTIONAL, defaults to 400px
}).afterClosed().subscribe((accept: boolean) => {
if (accept) {
this.dataManagementPlanService.delete(id).subscribe(() => {
this.router.navigate(['/dmps'])
});
} else {
// DO SOMETHING ELSE
}
});
}
openConfirm(dmpLabel, id): void {
this._dialogService.openConfirm({
message: 'Are you sure you want to delete the "' + dmpLabel + '"',
disableClose: true || false, // defaults to false
viewContainerRef: this._viewContainerRef, //OPTIONAL
title: 'Confirm', //OPTIONAL, hides if not provided
cancelButton: 'No', //OPTIONAL, defaults to 'CANCEL'
acceptButton: 'Yes' //OPTIONAL, defaults to 'ACCEPT'
// width: '500px', //OPTIONAL, defaults to 400px
}).afterClosed().subscribe((accept: boolean) => {
if (accept) {
this.dataManagementPlanService.delete(id).subscribe(() => {
this.router.navigate(['/dmps']);
});
} else {
// DO SOMETHING ELSE
}
});
}
selectOption(option: any) {
this.dataManagementPlan.definition = null;
this.formGroup.get("profile").patchValue(option, { emitEvent: false })
this.dmpProfileService.getSingle(option.id).subscribe(result => {
this.dataManagementPlan.definition = result.definition;
})
}
selectOption(option: any) {
this.dataManagementPlan.definition = null;
this.formGroup.get('profile').patchValue(option, { emitEvent: false });
this.dmpProfileService.getSingle(option.id).subscribe(result => {
this.dataManagementPlan.definition = result.definition;
});
}
displayWith(item: any) {
if (!item) return null;
return item["label"];
}
displayWith(item: any) {
if (!item) { return null; }
return item['label'];
}
redirectToProject() {
this.router.navigate(["projects/edit/" + this.dataManagementPlan.project.id])
}
redirectToProject() {
this.router.navigate(['projects/edit/' + this.dataManagementPlan.project.id]);
}
redirectToDatasets() {
this.router.navigate(["datasets/dmp/" + this.dataManagementPlan.id])
}
redirectToDatasets() {
this.router.navigate(['datasets/dmp/' + this.dataManagementPlan.id]);
}
newVersion(id: String, label: String) {
this.router.navigate(['/dmps/new_version/' + id, { dmpLabel: label }]);
}
newVersion(id: String, label: String) {
this.router.navigate(['/dmps/new_version/' + id, { dmpLabel: label }]);
}
clone(id: String) {
this.router.navigate(['/dmps/clone/' + id]);
}
viewVersions(rowId: String, rowLabel: String) {
this.router.navigate(['/dmps/viewversions/' + rowId], { queryParams: { groupLabel: rowLabel } });
}
clone(id: String) {
this.router.navigate(['/dmps/clone/' + id]);
}
viewVersions(rowId: String, rowLabel: String) {
this.router.navigate(['/dmps/viewversions/' + rowId], { queryParams: { groupLabel: rowLabel } });
}
}

View File

@ -1,40 +1,40 @@
import { Component, ViewEncapsulation, AfterViewInit, Input, OnInit, OnDestroy } from "@angular/core";
import { DataManagementPlanProfile } from "../../../models/data-management-plan-profile/DataManagementPlanProfile";
import { DMPProfileFieldDataType, DMPProfileType } from "../../../models/data-management-plan-profile/DataManagementProfileField";
import { FormGroup, FormBuilder, FormArray } from "@angular/forms";
import { LanguageResolverService } from "../../../services/language-resolver/language-resolver.service";
import { Component, ViewEncapsulation, AfterViewInit, Input, OnInit, OnDestroy } from '@angular/core';
import { DataManagementPlanProfile } from '../../../models/data-management-plan-profile/DataManagementPlanProfile';
import { DMPProfileFieldDataType, DMPProfileType } from '../../../models/data-management-plan-profile/DataManagementProfileField';
import { FormGroup, FormBuilder, FormArray } from '@angular/forms';
import { LanguageResolverService } from '../../../services/language-resolver/language-resolver.service';
@Component({
selector: 'app-dynamic-dmp-field-resolver',
templateUrl: 'dynamic-dmp-field-resolver.component.html',
styleUrls: ['./dynamic-dmp-field-resolver.component.scss'],
encapsulation: ViewEncapsulation.None
selector: 'app-dynamic-dmp-field-resolver',
templateUrl: 'dynamic-dmp-field-resolver.component.html',
styleUrls: ['./dynamic-dmp-field-resolver.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class DynamicDmpFieldResolver implements OnInit, OnDestroy {
export class DynamicDmpFieldResolverComponent implements OnInit, OnDestroy {
DMPProfileFieldDataType = DMPProfileFieldDataType;
DMPProfileType = DMPProfileType;
DMPProfileFieldDataType = DMPProfileFieldDataType;
DMPProfileType = DMPProfileType;
@Input()
dataManagementPlanProfile: DataManagementPlanProfile;
@Input()
dataManagementPlanProfile: DataManagementPlanProfile;
@Input()
formGroup: FormGroup
@Input()
formGroup: FormGroup;
ngOnInit(): void {
this.formGroup.addControl("properties", new FormBuilder().group([]));
(<FormGroup>this.formGroup.get("properties")).addControl("fields", new FormBuilder().array([]))
ngOnInit(): void {
this.formGroup.addControl('properties', new FormBuilder().group([]));
(<FormGroup>this.formGroup.get('properties')).addControl('fields', new FormBuilder().array([]));
this.dataManagementPlanProfile.fields.forEach(item => {
(<FormArray>this.formGroup.get("properties").get("fields")).push(new FormBuilder().group({
id: [item.id],
value: [item.value]
}))
})
}
this.dataManagementPlanProfile.fields.forEach(item => {
(<FormArray>this.formGroup.get('properties').get('fields')).push(new FormBuilder().group({
id: [item.id],
value: [item.value]
}));
});
}
ngOnDestroy(): void {
this.formGroup.removeControl("properties")
}
ngOnDestroy(): void {
this.formGroup.removeControl('properties');
}
}

View File

@ -1,84 +1,84 @@
import { Component, ViewEncapsulation, OnInit, Input, ViewChild } from "@angular/core";
import { FormGroup } from "@angular/forms";
import { DataManagementPlanService } from "../../../../services/data-management-plan/data-management-plan.service";
import { RequestItem } from "../../../../models/criteria/RequestItem";
import { DynamicFieldProjectCriteria, DynamicFieldProjectCriteriaDependencies } from "../../../../models/dynamic-field-project/DynamicFieldProjectCriteria";
import { AutoCompleteComponent } from "../../../../shared/components/auto-complete/auto-complete.component";
import { DynamicFieldDependency } from "../../../../models/data-managemnt-plans/DynamicFieldDependency";
import { LanguageResolverService } from "../../../../services/language-resolver/language-resolver.service";
import { AutoCompleteConfiguration } from "../../../../shared/components/auto-complete/AutoCompleteConfiguration";
import { Component, ViewEncapsulation, OnInit, Input, ViewChild } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { DataManagementPlanService } from '../../../../services/data-management-plan/data-management-plan.service';
import { RequestItem } from '../../../../models/criteria/RequestItem';
import { DynamicFieldProjectCriteria, DynamicFieldProjectCriteriaDependencies } from '../../../../models/dynamic-field-project/DynamicFieldProjectCriteria';
import { AutoCompleteComponent } from '../../../../shared/components/auto-complete/auto-complete.component';
import { DynamicFieldDependency } from '../../../../models/data-managemnt-plans/DynamicFieldDependency';
import { LanguageResolverService } from '../../../../services/language-resolver/language-resolver.service';
import { AutoCompleteConfiguration } from '../../../../shared/components/auto-complete/AutoCompleteConfiguration';
@Component({
selector: 'app-dynamic-field-project',
templateUrl: 'dynamic-field-project.component.html',
styleUrls: ['./dynamic-field-project.component.scss'],
encapsulation: ViewEncapsulation.None
selector: 'app-dynamic-field-project',
templateUrl: 'dynamic-field-project.component.html',
styleUrls: ['./dynamic-field-project.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class DynamicFieldProjectComponent implements OnInit {
constructor(private languageResolverService: LanguageResolverService, private dmpService: DataManagementPlanService) { }
constructor(private languageResolverService: LanguageResolverService, private dmpService: DataManagementPlanService) { }
@Input()
dependencies: Array<FormGroup>
@Input()
dependencies: Array<FormGroup>;
@Input()
formGroup: FormGroup;
@Input()
formGroup: FormGroup;
@ViewChild(AutoCompleteComponent)
autocomplete: AutoCompleteComponent
@ViewChild(AutoCompleteComponent)
autocomplete: AutoCompleteComponent;
autoCompleteConfiguration: AutoCompleteConfiguration
autoCompleteConfiguration: AutoCompleteConfiguration;
ngOnInit(): void {
let requestItem = new RequestItem<DynamicFieldProjectCriteria>()
requestItem.criteria = { id: this.formGroup.get("id").value, dynamicFields: this.buildDependencies() }
this.autoCompleteConfiguration = new AutoCompleteConfiguration(this.dmpService.getDynamicField.bind(this.dmpService), requestItem);
}
ngOnInit(): void {
const requestItem = new RequestItem<DynamicFieldProjectCriteria>();
requestItem.criteria = { id: this.formGroup.get('id').value, dynamicFields: this.buildDependencies() };
this.autoCompleteConfiguration = new AutoCompleteConfiguration(this.dmpService.getDynamicField.bind(this.dmpService), requestItem);
}
hasUnResolvedDependencies() {
if (this.dependencies == null || this.dependencies.length == 0) {
if (this.formGroup.get("value").disabled) {
this.updateConfiguration();
this.formGroup.get("value").enable({ onlySelf: true, emitEvent: false })
}
return false;
}
for (let i = 0; i < this.dependencies.length; i++) {
if (!this.dependencies[i].get("value").value) {
this.formGroup.get("value").disable({ onlySelf: true, emitEvent: false })
return true;
}
}
if (this.formGroup.get("value").disabled) {
this.updateConfiguration();
this.formGroup.get("value").enable({ onlySelf: true, emitEvent: false })
}
return false;
}
hasUnResolvedDependencies() {
if (this.dependencies == null || this.dependencies.length === 0) {
if (this.formGroup.get('value').disabled) {
this.updateConfiguration();
this.formGroup.get('value').enable({ onlySelf: true, emitEvent: false });
}
return false;
}
for (let i = 0; i < this.dependencies.length; i++) {
if (!this.dependencies[i].get('value').value) {
this.formGroup.get('value').disable({ onlySelf: true, emitEvent: false });
return true;
}
}
if (this.formGroup.get('value').disabled) {
this.updateConfiguration();
this.formGroup.get('value').enable({ onlySelf: true, emitEvent: false });
}
return false;
}
updateConfiguration() {
let requestItem = new RequestItem<DynamicFieldProjectCriteria>()
requestItem.criteria = { id: this.formGroup.get("id").value, dynamicFields: this.buildDependencies() }
this.autoCompleteConfiguration = new AutoCompleteConfiguration(this.dmpService.getDynamicField.bind(this.dmpService), requestItem);
this.autocomplete.inputData = this.autoCompleteConfiguration;
}
updateConfiguration() {
const requestItem = new RequestItem<DynamicFieldProjectCriteria>();
requestItem.criteria = { id: this.formGroup.get('id').value, dynamicFields: this.buildDependencies() };
this.autoCompleteConfiguration = new AutoCompleteConfiguration(this.dmpService.getDynamicField.bind(this.dmpService), requestItem);
this.autocomplete.inputData = this.autoCompleteConfiguration;
}
buildDependencies(): Array<DynamicFieldProjectCriteriaDependencies> {
if (!this.dependencies || this.dependencies.length == 0) return []
let dependencies = new Array<DynamicFieldProjectCriteriaDependencies>();
for (let i = 0; i < this.dependencies.length; i++) {
dependencies.push({ property: this.dependencies[i].get("id").value, value: this.assignFunction(this.dependencies[i].get("value").value) })
}
return dependencies;
}
buildDependencies(): Array<DynamicFieldProjectCriteriaDependencies> {
if (!this.dependencies || this.dependencies.length === 0) { return []; }
const dependencies = new Array<DynamicFieldProjectCriteriaDependencies>();
for (let i = 0; i < this.dependencies.length; i++) {
dependencies.push({ property: this.dependencies[i].get('id').value, value: this.assignFunction(this.dependencies[i].get('value').value) });
}
return dependencies;
}
displayFunction(item: any): any {
if (!item) return null;
return item["label"];
}
displayFunction(item: any): any {
if (!item) { return null; }
return item['label'];
}
assignFunction(item: any): any {
if (!item) return null;
return item["id"];
}
assignFunction(item: any): any {
if (!item) { return null; }
return item['id'];
}
}

View File

@ -1,33 +1,33 @@
import { Component, ViewEncapsulation, OnInit, OnDestroy, Input } from "@angular/core";
import { FormGroup, FormArray } from "@angular/forms";
import { DynamicFieldDependency } from "../../../models/data-managemnt-plans/DynamicFieldDependency";
import { Component, ViewEncapsulation, OnInit, OnDestroy, Input } from '@angular/core';
import { FormGroup, FormArray } from '@angular/forms';
import { DynamicFieldDependency } from '../../../models/data-managemnt-plans/DynamicFieldDependency';
@Component({
selector: 'app-dynamic-fields-project',
templateUrl: 'dynamic-fields-project.component.html',
styleUrls: ['./dynamic-fields-project.component.scss'],
encapsulation: ViewEncapsulation.None
selector: 'app-dynamic-fields-project',
templateUrl: 'dynamic-fields-project.component.html',
styleUrls: ['./dynamic-fields-project.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class DynamicFieldsProjectComponent implements OnInit {
@Input()
formGroup: FormGroup;
@Input()
formGroup: FormGroup;
ngOnInit(): void {
}
ngOnInit(): void {
}
findDependencies(id: number) {
let formGroupDependencies: Array<FormGroup> = new Array<FormGroup>();
let dynamicFieldDependency: DynamicFieldDependency[] = (<FormArray>this.formGroup.get("dynamicFields")).at(id).get("dependencies").value
if (dynamicFieldDependency.length > 0) {
dynamicFieldDependency.forEach(item => {
let length = (<FormArray>this.formGroup.get("dynamicFields")).length;
for (let i = 0; i < length; i++) {
let formGroup = (<FormArray>this.formGroup.get("dynamicFields")).at(i);
if (formGroup.get("id").value === item.id) formGroupDependencies.push(<FormGroup>formGroup);
}
})
}
return formGroupDependencies;
}
findDependencies(id: number) {
const formGroupDependencies: Array<FormGroup> = new Array<FormGroup>();
const dynamicFieldDependency: DynamicFieldDependency[] = (<FormArray>this.formGroup.get('dynamicFields')).at(id).get('dependencies').value;
if (dynamicFieldDependency.length > 0) {
dynamicFieldDependency.forEach(item => {
const length = (<FormArray>this.formGroup.get('dynamicFields')).length;
for (let i = 0; i < length; i++) {
const formGroup = (<FormArray>this.formGroup.get('dynamicFields')).at(i);
if (formGroup.get('id').value === item.id) { formGroupDependencies.push(<FormGroup>formGroup); }
}
});
}
return formGroupDependencies;
}
}

View File

@ -3,15 +3,15 @@ import { DataManagementPlanListingModel } from '../../models/data-managemnt-plan
import { InvitationComponent } from '../../shared/components/invitation/invitation.component';
import { DataManagementPlanCriteria } from '../../models/criteria/data-management-plan/DataManagementPlanCriteria';
import {
DataManagementPlanCriteriaComponent,
DataManagementPlanCriteriaComponent,
} from '../../shared/components/criteria/data-management-plan/dmp-criteria.component';
import { DataManagementPlanService } from '../../services/data-management-plan/data-management-plan.service';
import { Component, ViewChild, OnInit, AfterViewInit } from "@angular/core";
import { MatPaginator, MatSort, MatSnackBar, MatDialog } from "@angular/material";
import { Router, ActivatedRoute, ActivatedRouteSnapshot } from "@angular/router";
import { TranslateService } from "@ngx-translate/core";
import { DataSource } from "@angular/cdk/table";
import { Observable } from "rxjs/Observable";
import { Component, ViewChild, OnInit, AfterViewInit } from '@angular/core';
import { MatPaginator, MatSort, MatSnackBar, MatDialog } from '@angular/material';
import { Router, ActivatedRoute, ActivatedRouteSnapshot } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { DataSource } from '@angular/cdk/table';
import { Observable } from 'rxjs/Observable';
import { DataManagementPlanRoutes } from '../../dmps/dmps.routes';
import { DatasetRoutes } from '../../datasets/dataset.routes';
import { ProjectModel } from '../../models/projects/ProjectModel';
@ -22,182 +22,184 @@ import { JsonSerializer } from '../../utilities/JsonSerializer';
@Component({
selector: 'app-dmp-listing-component',
templateUrl: 'dmp-listing.component.html',
styleUrls: ['./dmp-listing.component.scss'],
selector: 'app-dmp-listing-component',
templateUrl: 'dmp-listing.component.html',
styleUrls: ['./dmp-listing.component.scss'],
})
export class DataManagementPlanListingComponent implements OnInit, IBreadCrumbComponent {
@ViewChild(MatPaginator) _paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
@ViewChild(DataManagementPlanCriteriaComponent) criteria: DataManagementPlanCriteriaComponent;
@ViewChild(MatPaginator) _paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
@ViewChild(DataManagementPlanCriteriaComponent) criteria: DataManagementPlanCriteriaComponent;
breadCrumbs: Observable<BreadcrumbItem[]> = Observable.of([]);
dataSource: DataManagementPlanDataSource | null;
displayedColumns: String[] = ['name', 'project', 'creationTime', 'organisations', 'version', 'datasets', 'actions'];
itemId: string;
projectId: string;
showProject: boolean;
titlePrefix: string;
constructor(
private dataManagementPlanService: DataManagementPlanService,
private router: Router,
private route: ActivatedRoute,
private languageService: TranslateService,
public snackBar: MatSnackBar,
public dialog: MatDialog
) {
breadCrumbs: Observable<BreadcrumbItem[]> = Observable.of([]);
dataSource: DataManagementPlanDataSource | null;
displayedColumns: String[] = ['name', 'project', 'creationTime', 'organisations', 'version', 'datasets', 'actions'];
itemId: string;
projectId: string;
showProject: boolean;
titlePrefix: string;
constructor(
private dataManagementPlanService: DataManagementPlanService,
private router: Router,
private route: ActivatedRoute,
private languageService: TranslateService,
public snackBar: MatSnackBar,
public dialog: MatDialog
) {
}
}
ngOnInit() {
this.route.params.subscribe(async params => {
let projectLabel;
if (params["projectId"]) {
this.projectId = params["projectId"];
this.showProject = false;
let project = new ProjectModel();
project.id = this.projectId;
this.criteria.setCriteria({ like: null, projects: [project], groupIds: null, allVersions: false })
this.refresh();
projectLabel = this.route.snapshot.queryParams.projectLabel
this.breadCrumbs = Observable.of([{ parentComponentName: "ProjectEditorComponent", label: projectLabel, url: "/projects/edit/" + this.projectId }])
this.criteria.setRefreshCallback(() => this.refresh());
} else {
this.itemId = params['groupId'];
this.showProject = true;
let breadCrumbs = [];
ngOnInit() {
this.route.params.subscribe(async params => {
let projectLabel;
if (params['projectId']) {
this.projectId = params['projectId'];
this.showProject = false;
const project = new ProjectModel();
project.id = this.projectId;
this.criteria.setCriteria({ like: null, projects: [project], groupIds: null, allVersions: false });
this.refresh();
projectLabel = this.route.snapshot.queryParams.projectLabel;
this.breadCrumbs = Observable.of([{ parentComponentName: 'ProjectEditorComponent', label: projectLabel, url: '/projects/edit/' + this.projectId }]);
this.criteria.setRefreshCallback(() => this.refresh());
} else {
this.itemId = params['groupId'];
this.showProject = true;
const breadCrumbs = [];
if (this.itemId) {
let dmplabel = this.route.snapshot.queryParams.groupLabel
breadCrumbs.push(
{ parentComponentName: null, label: 'DMPs', url: "/dmps" },
)
}
//else breadCrumbs.push({ parentComponentName: null, label: 'DMPs', url: "/dmps" })
this.breadCrumbs = Observable.of(breadCrumbs)
if (this.itemId) {
const dmplabel = this.route.snapshot.queryParams.groupLabel;
breadCrumbs.push(
{ parentComponentName: null, label: 'DMPs', url: '/dmps' },
);
}
//else breadCrumbs.push({ parentComponentName: null, label: 'DMPs', url: "/dmps" })
this.breadCrumbs = Observable.of(breadCrumbs);
this.criteria.setCriteria(this.getDefaultCriteria());
this.refresh();
this.criteria.setRefreshCallback(() => this.refresh());
}
this.criteria.setCriteria(this.getDefaultCriteria());
this.refresh();
this.criteria.setRefreshCallback(() => this.refresh());
}
if (this.projectId != null)
if (projectLabel != undefined)
this.titlePrefix = "for " + projectLabel;
})
if (this.projectId != null) {
if (projectLabel !== undefined) {
this.titlePrefix = 'for ' + projectLabel;
}
}
});
}
}
refresh() {
this.dataSource = new DataManagementPlanDataSource(this.dataManagementPlanService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria, this.itemId);
}
refresh() {
this.dataSource = new DataManagementPlanDataSource(this.dataManagementPlanService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria, this.itemId);
}
rowClick(rowId: String) {
this.router.navigate(['/dmps/edit/' + rowId]);
}
rowClick(rowId: String) {
this.router.navigate(['/dmps/edit/' + rowId]);
}
addDataset(rowId: String) {
this.router.navigate(['/datasets/new/' + rowId]);
}
addDataset(rowId: String) {
this.router.navigate(['/datasets/new/' + rowId]);
}
showDatasets(rowId: String, rowLabel: String) {
this.router.navigate(['/datasets/dmp/' + rowId, { dmpLabel: rowLabel }]);
}
showDatasets(rowId: String, rowLabel: String) {
this.router.navigate(['/datasets/dmp/' + rowId, { dmpLabel: rowLabel }]);
}
viewVersions(rowId: String, rowLabel: String) {
this.router.navigate(['/dmps/viewversions/' + rowId], { queryParams: { groupLabel: rowLabel } });
}
viewVersions(rowId: String, rowLabel: String) {
this.router.navigate(['/dmps/viewversions/' + rowId], { queryParams: { groupLabel: rowLabel } });
}
getDefaultCriteria(): DataManagementPlanCriteria {
const defaultCriteria = new DataManagementPlanCriteria();
return defaultCriteria;
}
getDefaultCriteria(): DataManagementPlanCriteria {
const defaultCriteria = new DataManagementPlanCriteria();
return defaultCriteria;
}
openShareDialog(rowId: any, rowName: any) {
let dialogRef = this.dialog.open(InvitationComponent, {
height: '200px',
width: '700px',
data: {
dmpId: rowId,
dmpName: rowName
}
});
}
openShareDialog(rowId: any, rowName: any) {
const dialogRef = this.dialog.open(InvitationComponent, {
height: '200px',
width: '700px',
data: {
dmpId: rowId,
dmpName: rowName
}
});
}
}
export class DataManagementPlanDataSource extends DataSource<DataManagementPlanListingModel> {
totalCount = 0;
isLoadingResults = false;
constructor(
private _service: DataManagementPlanService,
private _paginator: MatPaginator,
private _sort: MatSort,
private _languageService: TranslateService,
private _snackBar: MatSnackBar,
private _criteria: DataManagementPlanCriteriaComponent,
private itemId
) {
super();
}
totalCount = 0;
isLoadingResults = false;
constructor(
private _service: DataManagementPlanService,
private _paginator: MatPaginator,
private _sort: MatSort,
private _languageService: TranslateService,
private _snackBar: MatSnackBar,
private _criteria: DataManagementPlanCriteriaComponent,
private itemId
) {
super();
}
connect(): Observable<DataManagementPlanListingModel[]> {
const displayDataChanges = [
this._paginator.page
];
connect(): Observable<DataManagementPlanListingModel[]> {
const displayDataChanges = [
this._paginator.page
];
return Observable.merge(...displayDataChanges)
.startWith(null)
.switchMap(() => {
setTimeout(() => {
this.isLoadingResults = true;
});
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
let fields: Array<string> = new Array()
if (this._sort.active) fields = this._sort.direction === "asc" ? ["+" + this._sort.active] : ["-" + this._sort.active];
const request = new DataTableRequest<DataManagementPlanCriteria>(startIndex, this._paginator.pageSize, { fields: fields });
request.criteria = this._criteria.formGroup.value;
if (this.itemId) {
request.criteria.groupIds = [this.itemId];
request.criteria.allVersions = true;
}
return this._service.getPaged(request);
})
/*.catch((error: any) => {
this._snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService },
duration: 3000,
extraClasses: ['snackbar-warning']
});
return Observable.of(null);
})*/
.map(result => {
result.data = JsonSerializer.fromJSONArray(result.data, DataManagementPlanListingModel)
return result;
})
.map(result => {
setTimeout(() => {
this.isLoadingResults = false;
});
return result;
})
.map(result => {
if (!result) { return []; }
if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; }
return result.data.map(item => {
item["datasets"].map(dmp => {
dmp.url = "datasets/edit/" + dmp.url;
dmp.all = "datasets/dmp/" + item.id
return dmp;
})
return item;
});
});
}
return Observable.merge(...displayDataChanges)
.startWith(null)
.switchMap(() => {
setTimeout(() => {
this.isLoadingResults = true;
});
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
let fields: Array<string> = new Array();
if (this._sort.active) { fields = this._sort.direction === 'asc' ? ['+' + this._sort.active] : ['-' + this._sort.active]; }
const request = new DataTableRequest<DataManagementPlanCriteria>(startIndex, this._paginator.pageSize, { fields: fields });
request.criteria = this._criteria.formGroup.value;
if (this.itemId) {
request.criteria.groupIds = [this.itemId];
request.criteria.allVersions = true;
}
return this._service.getPaged(request);
})
/*.catch((error: any) => {
this._snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService },
duration: 3000,
extraClasses: ['snackbar-warning']
});
return Observable.of(null);
})*/
.map(result => {
result.data = JsonSerializer.fromJSONArray(result.data, DataManagementPlanListingModel);
return result;
})
.map(result => {
setTimeout(() => {
this.isLoadingResults = false;
});
return result;
})
.map(result => {
if (!result) { return []; }
if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; }
return result.data.map(item => {
item['datasets'].map(dmp => {
dmp.url = 'datasets/edit/' + dmp.url;
dmp.all = 'datasets/dmp/' + item.id;
return dmp;
});
return item;
});
});
}
disconnect() {
}
disconnect() {
}
}

View File

@ -12,73 +12,72 @@ import { IBreadCrumbComponent } from '../../shared/components/breadcrumb/definit
import { Observable } from 'rxjs/Observable';
import { BreadcrumbItem } from '../../shared/components/breadcrumb/definition/breadcrumb-item';
@Component({
selector: 'app-dmp-wizard-component',
templateUrl: 'dmp-wizard.component.html',
styleUrls: ['./dmp-wizard.component.scss'],
selector: 'app-dmp-wizard-component',
templateUrl: 'dmp-wizard.component.html',
styleUrls: ['./dmp-wizard.component.scss'],
})
export class DataManagementPlanWizardComponent implements OnInit, IBreadCrumbComponent {
breadCrumbs: Observable<BreadcrumbItem[]>;
constructor(
private dataManagementPlanService: DataManagementPlanService,
private language: TranslateService,
public snackBar: MatSnackBar,
public route: ActivatedRoute,
private router: Router
) { }
breadCrumbs: Observable<BreadcrumbItem[]>;
constructor(
private dataManagementPlanService: DataManagementPlanService,
private language: TranslateService,
public snackBar: MatSnackBar,
public route: ActivatedRoute,
private router: Router
) { }
public itemId: string
public dataManagementPlan: DataManagementPlanModel;
public formGroup: FormGroup
public isClone: boolean
public itemId: string;
public dataManagementPlan: DataManagementPlanModel;
public formGroup: FormGroup;
public isClone: boolean;
ngOnInit(): void {
ngOnInit(): void {
this.route.params.subscribe((params: Params) => {
this.itemId = params['id'];
this.dataManagementPlanService.getSingle(this.itemId).map(data => data as DataManagementPlanModel)
.subscribe(data => {
this.dataManagementPlan = JsonSerializer.fromJSONObject(data, DataManagementPlanModel);
this.isClone = this.route.snapshot.data.clone;
if (this.isClone == false) this.dataManagementPlan.version = this.dataManagementPlan.version + 1;
this.formGroup = this.dataManagementPlan.buildForm();
});
})
}
this.route.params.subscribe((params: Params) => {
this.itemId = params['id'];
this.dataManagementPlanService.getSingle(this.itemId).map(data => data as DataManagementPlanModel)
.subscribe(data => {
this.dataManagementPlan = JsonSerializer.fromJSONObject(data, DataManagementPlanModel);
this.isClone = this.route.snapshot.data.clone;
if (this.isClone === false) { this.dataManagementPlan.version = this.dataManagementPlan.version + 1; }
this.formGroup = this.dataManagementPlan.buildForm();
});
});
}
submit() {
if (this.isClone) {
this.dataManagementPlanService.clone(this.formGroup.getRawValue(), this.itemId).subscribe(
complete => this.onCallbackSuccess(),
error => this.onCallbackError(error)
);
} else {
this.dataManagementPlanService.newVersion(this.formGroup.getRawValue(), this.itemId).subscribe(
complete => this.onCallbackSuccess(),
error => this.onCallbackError(error)
);
}
}
submit() {
if (this.isClone) {
this.dataManagementPlanService.clone(this.formGroup.getRawValue(), this.itemId).subscribe(
complete => this.onCallbackSuccess(),
error => this.onCallbackError(error)
);
} else {
this.dataManagementPlanService.newVersion(this.formGroup.getRawValue(), this.itemId).subscribe(
complete => this.onCallbackSuccess(),
error => this.onCallbackError(error)
);
}
}
onCallbackSuccess(): void {
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
duration: 3000,
})
this.router.navigate(['/dmps']);
}
onCallbackSuccess(): void {
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
duration: 3000,
});
this.router.navigate(['/dmps']);
}
onCallbackError(error: any) {
this.setErrorModel(error.error);
//this.validateAllFormFields(this.formGroup);
}
onCallbackError(error: any) {
this.setErrorModel(error.error);
//this.validateAllFormFields(this.formGroup);
}
public setErrorModel(errorModel: BaseErrorModel) {
Object.keys(errorModel).forEach(item => {
// (<any>this.dataManagementPlan.errorModel)[item] = (<any>errorModel)[item];
})
}
public setErrorModel(errorModel: BaseErrorModel) {
Object.keys(errorModel).forEach(item => {
// (<any>this.dataManagementPlan.errorModel)[item] = (<any>errorModel)[item];
});
}
}

View File

@ -1,79 +1,79 @@
<div class="data-management-plan-wizard-editor">
<form *ngIf="formGroup" (ngSubmit)="formSubmit()" [formGroup]="formGroup">
<mat-card>
<mat-card-content>
<mat-form-field class="full-width">
<input matInput placeholder="{{'DMP-EDITOR.FIELDS.NAME' | translate}}" type="text" name="label" formControlName="label" required
[attr.disabled]="labelDisabled">
<mat-error *ngIf="formGroup.get('label').errors?.backendError">{{baseErrorModel.label}}</mat-error>
<mat-error *ngIf="formGroup.get('label').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<form *ngIf="formGroup" (ngSubmit)="formSubmit()" [formGroup]="formGroup">
<mat-card>
<mat-card-content>
<mat-form-field class="full-width">
<input matInput placeholder="{{'DMP-EDITOR.FIELDS.NAME' | translate}}" type="text" name="label" formControlName="label"
required [attr.disabled]="labelDisabled">
<mat-error *ngIf="formGroup.get('label').errors?.backendError">{{baseErrorModel.label}}</mat-error>
<mat-error *ngIf="formGroup.get('label').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-form-field class="full-width">
<textarea matInput class="description-area" placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION' | translate}}" formControlName="description"
required></textarea>
<mat-error *ngIf="formGroup.get('description').errors?.backendError">{{errorModel.description}}</mat-error>
<mat-error *ngIf="formGroup.get('description').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-form-field class="full-width">
<textarea matInput class="description-area" placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION' | translate}}"
formControlName="description" required></textarea>
<mat-error *ngIf="formGroup.get('description').errors?.backendError">{{errorModel.description}}</mat-error>
<mat-error *ngIf="formGroup.get('description').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<div class="col-md-6">
<app-single-auto-complete [reactiveFormControl]="formGroup.get('project')" placeholder="{{this.languageResolverService.getBy('dmpEditor') | translate}}"
[configuration]="projectAutoCompleteConfiguration">
</app-single-auto-complete>
</div>
<!-- <app-dynamic-fields-project [formGroup]="formGroup"></app-dynamic-fields-project> -->
<div class="col-md-6">
<div class="row">
<app-multiple-auto-complete class="col-md-10" [reactiveFormControl]="formGroup.get('profiles')" placeholder="{{'DMP-EDITOR.FIELDS.PROFILES' | translate}}"
[configuration]="profilesAutoCompleteConfiguration">
</app-multiple-auto-complete>
<div class="col-md-2">
<button mat-icon-button type="button" (click)="availableProfiles()">
<mat-icon>view_list</mat-icon>
</button>
</div>
</div>
</div>
<!-- <button mat-button (click)="availableProfiles()">View All</button> -->
<div class="col-md-6">
<app-single-auto-complete [reactiveFormControl]="formGroup.get('project')" placeholder="{{this.languageResolverService.getBy('dmpEditor') | translate}}"
[configuration]="projectAutoCompleteConfiguration">
</app-single-auto-complete>
</div>
<!-- <app-dynamic-fields-project [formGroup]="formGroup"></app-dynamic-fields-project> -->
<div class="col-md-6">
<div class="row">
<app-multiple-auto-complete class="col-md-10" [reactiveFormControl]="formGroup.get('profiles')" placeholder="{{'DMP-EDITOR.FIELDS.PROFILES' | translate}}"
[configuration]="profilesAutoCompleteConfiguration">
</app-multiple-auto-complete>
<div class="col-md-2">
<button mat-icon-button type="button" (click)="availableProfiles()">
<mat-icon>view_list</mat-icon>
</button>
</div>
</div>
</div>
<!-- <button mat-button (click)="availableProfiles()">View All</button> -->
<div class="col-md-6">
<app-multiple-auto-complete [reactiveFormControl]="formGroup.get('organisations')" placeholder="{{'DMP-EDITOR.FIELDS.ORGANISATIONS' | translate}}"
[configuration]="organisationsAutoCompleteConfiguration">
</app-multiple-auto-complete>
</div>
<div class="col-md-6">
<div class="row">
<div class="col-md-10">
<app-multiple-auto-complete [reactiveFormControl]="formGroup.get('researchers')" placeholder="{{'DMP-EDITOR.FIELDS.RESEARCHERS' | translate}}"
[configuration]="researchersAutoCompleteConfiguration">
</app-multiple-auto-complete>
</div>
<div class="col-md-2">
<button mat-icon-button type="button" (click)="addResearcher()">
<mat-icon>add_circle</mat-icon>
</button>
</div>
</div>
</div>
<div class="col-md-6">
<app-multiple-auto-complete [reactiveFormControl]="formGroup.get('organisations')" placeholder="{{'DMP-EDITOR.FIELDS.ORGANISATIONS' | translate}}"
[configuration]="organisationsAutoCompleteConfiguration">
</app-multiple-auto-complete>
</div>
<div class="col-md-6">
<div class="row">
<div class="col-md-10">
<app-multiple-auto-complete [reactiveFormControl]="formGroup.get('researchers')" placeholder="{{'DMP-EDITOR.FIELDS.RESEARCHERS' | translate}}"
[configuration]="researchersAutoCompleteConfiguration">
</app-multiple-auto-complete>
</div>
<div class="col-md-2">
<button mat-icon-button type="button" (click)="addResearcher()">
<mat-icon>add_circle</mat-icon>
</button>
</div>
</div>
</div>
<mat-form-field class="full-width">
<input matInput placeholder="Version" formControlName="version">
<!--disabled doesn't work -->
</mat-form-field>
<mat-form-field class="full-width">
<input matInput placeholder="Version" formControlName="version">
<!--disabled doesn't work -->
</mat-form-field>
<mat-list *ngIf="associatedUsers?.length" role="list">
<h3 mat-subheader>Associated Users</h3>
<mat-list-item role="listitem" *ngFor="let user of associatedUsers">
<mat-icon mat-list-icon>person</mat-icon>
<div>{{user.name}}</div>
</mat-list-item>
</mat-list>
</mat-card-content>
</mat-card>
</form>
<!-- <div *ngIf="formGroup"> {{ formGroup.value | json }}</div> -->
<mat-list *ngIf="associatedUsers?.length" role="list">
<h3 mat-subheader>Associated Users</h3>
<mat-list-item role="listitem" *ngFor="let user of associatedUsers">
<mat-icon mat-list-icon>person</mat-icon>
<div>{{user.name}}</div>
</mat-list-item>
</mat-list>
</mat-card-content>
</mat-card>
</form>
<!-- <div *ngIf="formGroup"> {{ formGroup.value | json }}</div> -->
</div>

View File

@ -11,12 +11,12 @@ import { DataManagementPlanModel } from '../../../models/data-managemnt-plans/Da
import { ProjectService } from '../../../services/project/project.service';
import { ExternalSourcesService } from '../../../services/external-sources/external-sources.service';
import { DataManagementPlanService } from '../../../services/data-management-plan/data-management-plan.service';
import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation, Input } from "@angular/core";
import { MatPaginator, MatSort, MatSnackBar } from "@angular/material";
import { Router, ActivatedRoute, Params } from "@angular/router";
import { TranslateService } from "@ngx-translate/core";
import { DataSource } from "@angular/cdk/table";
import { Observable } from "rxjs/Observable";
import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation, Input } from '@angular/core';
import { MatPaginator, MatSort, MatSnackBar } from '@angular/material';
import { Router, ActivatedRoute, Params } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { DataSource } from '@angular/cdk/table';
import { Observable } from 'rxjs/Observable';
import { FormGroup } from '@angular/forms';
import { BaseCriteria } from '../../../models/criteria/BaseCriteria';
import { SingleAutoCompleteConfiguration } from '../../../shared/components/autocompletes/single/single-auto-complete-configuration';
@ -25,168 +25,168 @@ import { MultipleAutoCompleteConfiguration } from '../../../shared/components/au
@Component({
selector: 'app-dmp-wizard-editor-component',
templateUrl: 'dmp-wizard-editor.component.html',
styleUrls: ['./dmp-wizard-editor.component.scss'],
encapsulation: ViewEncapsulation.None
selector: 'app-dmp-wizard-editor-component',
templateUrl: 'dmp-wizard-editor.component.html',
styleUrls: ['./dmp-wizard-editor.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class DataManagementPlanWizardEditorComponent implements OnInit {
isNew = true;
@Input() formGroup: FormGroup = null;
isNew = true;
@Input() formGroup: FormGroup = null;
filteringOrganisationsAsync: boolean = false;
filteringResearchersAsync: boolean = false;
filteredProfilesAsync: boolean = false;
filteredOrganisations: ExternalSourcesItemModel[];
filteredResearchers: ExternalSourcesItemModel[];
filteredProfiles: DatasetProfileModel[];
filteringOrganisationsAsync = false;
filteringResearchersAsync = false;
filteredProfilesAsync = false;
filteredOrganisations: ExternalSourcesItemModel[];
filteredResearchers: ExternalSourcesItemModel[];
filteredProfiles: DatasetProfileModel[];
projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
organisationsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
researchersAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
createNewVersion;
associatedUsers: Array<DmpUsersModel>
labelDisabled: boolean = false;
projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
organisationsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
researchersAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
createNewVersion;
associatedUsers: Array<DmpUsersModel>;
labelDisabled = false;
constructor(
private dataManagementPlanService: DataManagementPlanService,
private projectService: ProjectService,
private externalSourcesService: ExternalSourcesService,
private route: ActivatedRoute,
public snackBar: MatSnackBar,
public router: Router,
public language: TranslateService,
private _service: DataManagementPlanService,
private languageResolverService: LanguageResolverService
) {
constructor(
private dataManagementPlanService: DataManagementPlanService,
private projectService: ProjectService,
private externalSourcesService: ExternalSourcesService,
private route: ActivatedRoute,
public snackBar: MatSnackBar,
public router: Router,
public language: TranslateService,
private _service: DataManagementPlanService,
private languageResolverService: LanguageResolverService
) {
}
}
ngOnInit() {
ngOnInit() {
let projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
projectRequestItem.criteria = new ProjectCriteria();
this.projectAutoCompleteConfiguration = {
filterFn: this.searchProject.bind(this.projectService),
items: this.searchProject(''),
displayFn: (item) => item["label"],
titleFn: (item) => item["label"],
//mapFn: (item) => new JsonSerializer<ProjectReference>().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()),
loadDataOnStart: true
};
const projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
projectRequestItem.criteria = new ProjectCriteria();
this.projectAutoCompleteConfiguration = {
filterFn: this.searchProject.bind(this.projectService),
items: this.searchProject(''),
displayFn: (item) => item['label'],
titleFn: (item) => item['label'],
//mapFn: (item) => new JsonSerializer<ProjectReference>().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()),
loadDataOnStart: true
};
this.profilesAutoCompleteConfiguration = {
filterFn: this.filterProfiles.bind(this),
initialItems: (excludedItems: any[]) => this.filterProfiles('').map(result => result.filter(x => excludedItems.map(x => x.id).indexOf(x.id) == -1)),
displayFn: (item) => item["label"],
titleFn: (item) => item["label"],
//mapFn: (item) => new JsonSerializer<ProjectReference>().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()),
loadDataOnStart: true
};
this.profilesAutoCompleteConfiguration = {
filterFn: this.filterProfiles.bind(this),
initialItems: (excludedItems: any[]) => this.filterProfiles('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)),
displayFn: (item) => item['label'],
titleFn: (item) => item['label'],
//mapFn: (item) => new JsonSerializer<ProjectReference>().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()),
loadDataOnStart: true
};
this.organisationsAutoCompleteConfiguration = {
filterFn: this.filterOrganisations.bind(this),
initialItems: (excludedItems: any[]) => this.filterOrganisations('').map(result => result.filter(x => excludedItems.map(x => x.id).indexOf(x.id) == -1)),
displayFn: (item) => item["name"],
titleFn: (item) => item["name"],
loadDataOnStart: true
};
this.organisationsAutoCompleteConfiguration = {
filterFn: this.filterOrganisations.bind(this),
initialItems: (excludedItems: any[]) => this.filterOrganisations('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)),
displayFn: (item) => item['name'],
titleFn: (item) => item['name'],
loadDataOnStart: true
};
this.researchersAutoCompleteConfiguration = {
filterFn: this.filterResearchers.bind(this),
initialItems: (excludedItems: any[]) => this.filterResearchers('').map(result => result.filter(x => excludedItems.map(x => x.id).indexOf(x.id) == -1)),
displayFn: (item) => item["name"],
titleFn: (item) => item["name"],
loadDataOnStart: true
};
this.researchersAutoCompleteConfiguration = {
filterFn: this.filterResearchers.bind(this),
initialItems: (excludedItems: any[]) => this.filterResearchers('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)),
displayFn: (item) => item['name'],
titleFn: (item) => item['name'],
loadDataOnStart: true
};
let organisationRequestItem: RequestItem<BaseCriteria> = new RequestItem();
organisationRequestItem.criteria = new BaseCriteria();
const organisationRequestItem: RequestItem<BaseCriteria> = new RequestItem();
organisationRequestItem.criteria = new BaseCriteria();
this.route.data.subscribe(value => {
if (value.clone == false && this.formGroup.get("label").value) {
this.labelDisabled = true;
}
this.formGroup.controls["version"].disable();
})
}
this.route.data.subscribe(value => {
if (value.clone === false && this.formGroup.get('label').value) {
this.labelDisabled = true;
}
this.formGroup.controls['version'].disable();
});
}
searchProject(query: string) {
let projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
projectRequestItem.criteria = new ProjectCriteria();
projectRequestItem.criteria.like = query;
return this.projectService.getWithExternal(projectRequestItem);
}
searchProject(query: string) {
const projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
projectRequestItem.criteria = new ProjectCriteria();
projectRequestItem.criteria.like = query;
return this.projectService.getWithExternal(projectRequestItem);
}
formSubmit(): void {
//this.touchAllFormFields(this.formGroup);
if (!this.isFormValid()) { return; }
this.onSubmit();
}
formSubmit(): void {
//this.touchAllFormFields(this.formGroup);
if (!this.isFormValid()) { return; }
this.onSubmit();
}
public isFormValid() {
return this.formGroup.valid;
}
public isFormValid() {
return this.formGroup.valid;
}
onSubmit(): void {
this.dataManagementPlanService.createDataManagementPlan(this.formGroup.getRawValue()).subscribe(
complete => this.onCallbackSuccess(),
error => this.onCallbackError(error)
);
}
onSubmit(): void {
this.dataManagementPlanService.createDataManagementPlan(this.formGroup.getRawValue()).subscribe(
complete => this.onCallbackSuccess(),
error => this.onCallbackError(error)
);
}
onCallbackSuccess(): void {
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
duration: 3000,
})
this.router.navigate(['/dmps']);
}
onCallbackSuccess(): void {
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
duration: 3000,
});
this.router.navigate(['/dmps']);
}
onCallbackError(error: any) {
this.setErrorModel(error.error);
//this.validateAllFormFields(this.formGroup);
}
onCallbackError(error: any) {
this.setErrorModel(error.error);
//this.validateAllFormFields(this.formGroup);
}
public setErrorModel(errorModel: BaseErrorModel) {
Object.keys(errorModel).forEach(item => {
// (<any>this.dataManagementPlan.errorModel)[item] = (<any>errorModel)[item];
})
}
public setErrorModel(errorModel: BaseErrorModel) {
Object.keys(errorModel).forEach(item => {
// (<any>this.dataManagementPlan.errorModel)[item] = (<any>errorModel)[item];
});
}
public cancel(): void {
this.router.navigate(['/dmps']);
}
public cancel(): void {
this.router.navigate(['/dmps']);
}
filterOrganisations(value: string): Observable<ExternalSourcesItemModel[]> {
filterOrganisations(value: string): Observable<ExternalSourcesItemModel[]> {
this.filteredOrganisations = undefined;
this.filteringOrganisationsAsync = true;
this.filteredOrganisations = undefined;
this.filteringOrganisationsAsync = true;
return this.externalSourcesService.searchDMPOrganizations(value)
}
return this.externalSourcesService.searchDMPOrganizations(value);
}
filterResearchers(value: string): Observable<ExternalSourcesItemModel[]> {
filterResearchers(value: string): Observable<ExternalSourcesItemModel[]> {
this.filteredResearchers = undefined;
this.filteringResearchersAsync = true;
this.filteredResearchers = undefined;
this.filteringResearchersAsync = true;
return this.externalSourcesService.searchDMPResearchers({ criteria: { name: value, like: null } })
}
return this.externalSourcesService.searchDMPResearchers({ criteria: { name: value, like: null } });
}
filterProfiles(value: string): Observable<DatasetProfileModel[]> {
filterProfiles(value: string): Observable<DatasetProfileModel[]> {
this.filteredProfiles = undefined;
this.filteredProfilesAsync = true;
this.filteredProfiles = undefined;
this.filteredProfilesAsync = true;
const request = new RequestItem<DatasetProfileCriteria>();
let criteria = new DatasetProfileCriteria();
criteria.like = value;
request.criteria = criteria;
return this._service.searchDMPProfiles(request)
}
const request = new RequestItem<DatasetProfileCriteria>();
const criteria = new DatasetProfileCriteria();
criteria.like = value;
request.criteria = criteria;
return this._service.searchDMPProfiles(request);
}
}

View File

@ -7,74 +7,76 @@ import { DataManagementPlanModel } from '../../../models/data-managemnt-plans/Da
import { DatasetCriteriaComponent } from '../../../shared/components/criteria/datasets/datasets-criteria.component';
import { DataManagementPlanService } from '../../../services/data-management-plan/data-management-plan.service';
import { DatasetService } from '../../../services/dataset/dataset.service';
import { Component, ViewChild, OnInit, AfterViewInit, Input } from "@angular/core";
import { MatPaginator, MatSort, MatSnackBar } from "@angular/material";
import { Router, Params, ActivatedRoute } from "@angular/router";
import { TranslateService } from "@ngx-translate/core";
import { DataSource } from "@angular/cdk/table";
import { FormGroup, FormBuilder, FormControl, FormArray } from "@angular/forms"
import { Observable } from "rxjs/Observable";
import { Component, ViewChild, OnInit, AfterViewInit, Input } from '@angular/core';
import { MatPaginator, MatSort, MatSnackBar } from '@angular/material';
import { Router, Params, ActivatedRoute } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { DataSource } from '@angular/cdk/table';
import { FormGroup, FormBuilder, FormControl, FormArray } from '@angular/forms';
import { Observable } from 'rxjs/Observable';
import { PageEvent } from '@angular/material';
import { SelectionModel } from '@angular/cdk/collections';
@Component({
selector: 'app-dataset-wizard-listing-component',
templateUrl: 'dataset-wizard-listing.component.html',
styleUrls: ['./dataset-wizard-listing.component.scss'],
selector: 'app-dataset-wizard-listing-component',
templateUrl: 'dataset-wizard-listing.component.html',
styleUrls: ['./dataset-wizard-listing.component.scss'],
})
export class DatasetWizardListingComponent implements OnInit {
@ViewChild(MatPaginator) _paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
@ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent;
@ViewChild(MatPaginator) _paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
@ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent;
titlePrefix: String;
datasets: DatasetListingModel[] = []
titlePrefix: String;
datasets: DatasetListingModel[] = [];
@Input() dmpId: String;
@Input() formGroup: FormGroup
selection = new SelectionModel<Element>(true, []);
@Input() dmpId: String;
@Input() formGroup: FormGroup;
selection = new SelectionModel<Element>(true, []);
statuses = [
{ value: '0', viewValue: 'Active' },
{ value: '1', viewValue: 'Inactive' }
];
statuses = [
{ value: '0', viewValue: 'Active' },
{ value: '1', viewValue: 'Inactive' }
];
constructor(
private datasetService: DatasetService,
private router: Router,
private languageService: TranslateService,
public snackBar: MatSnackBar,
public route: ActivatedRoute,
public dataManagementPlanService: DataManagementPlanService
) {
constructor(
private datasetService: DatasetService,
private router: Router,
private languageService: TranslateService,
public snackBar: MatSnackBar,
public route: ActivatedRoute,
public dataManagementPlanService: DataManagementPlanService
) {
}
}
ngOnInit() {
this.route.params.subscribe((params: Params) => {
if (this.dmpId != null)
if (params['dmpLabel'] != undefined)
this.titlePrefix = "for " + params['dmpLabel'];
});
let request: DataTableRequest<DatasetCriteria> = new DataTableRequest<DatasetCriteria>(null, null, null);
request.criteria = new DatasetCriteria();
request.criteria.dmpIds = [this.dmpId];
this.datasetService.getPaged(request).subscribe(items => {
this.datasets = JsonSerializer.fromJSONArray(items.data, DatasetListingModel)
})
this.formGroup.addControl("datasets", new FormBuilder().array(new Array<FormControl>()))
}
ngOnInit() {
this.route.params.subscribe((params: Params) => {
if (this.dmpId != null) {
if (params['dmpLabel'] !== undefined) {
this.titlePrefix = 'for ' + params['dmpLabel'];
}
}
});
const request: DataTableRequest<DatasetCriteria> = new DataTableRequest<DatasetCriteria>(null, null, null);
request.criteria = new DatasetCriteria();
request.criteria.dmpIds = [this.dmpId];
this.datasetService.getPaged(request).subscribe(items => {
this.datasets = JsonSerializer.fromJSONArray(items.data, DatasetListingModel);
});
this.formGroup.addControl('datasets', new FormBuilder().array(new Array<FormControl>()));
}
selectionChanged(event, selectedItems) {
this.formGroup.removeControl("datasets");
this.formGroup.addControl("datasets", new FormBuilder().array(new Array<FormControl>()))
selectedItems.selectedOptions.selected.forEach(element => {
(<FormArray>this.formGroup.get("datasets")).push(new FormBuilder().group({ id: element.value }))
});
}
selectionChanged(event, selectedItems) {
this.formGroup.removeControl('datasets');
this.formGroup.addControl('datasets', new FormBuilder().array(new Array<FormControl>()));
selectedItems.selectedOptions.selected.forEach(element => {
(<FormArray>this.formGroup.get('datasets')).push(new FormBuilder().group({ id: element.value }));
});
}
}

View File

@ -11,52 +11,51 @@ declare var $: any;
@Component({
selector: 'df-autocomplete',
templateUrl: './autocomplete-remote.component.html',
styleUrls: ['./autocomplete-remote.component.css'],
encapsulation: ViewEncapsulation.None,
selector: 'app-df-autocomplete',
templateUrl: './autocomplete-remote.component.html',
styleUrls: ['./autocomplete-remote.component.css'],
encapsulation: ViewEncapsulation.None,
})
export class AutocompleteRemoteComponent implements OnInit/* , ControlValueAccessor */ {
@Input() field: Field;
@Input() disabled = false
@Input() form: FormGroup;
@Input() field: Field;
@Input() disabled = false;
@Input() form: FormGroup;
public autoCompleteConfiguration: AutoCompleteConfiguration;
public loading: boolean;
public datasetId;
public values: any[] = new Array();
public typeaheadMS: number = 1400;
public autoCompleteConfiguration: AutoCompleteConfiguration;
public loading: boolean;
public datasetId;
public values: any[] = new Array();
public typeaheadMS = 1400;
constructor(private datasetProfileService: DatasetProfileService, route: ActivatedRoute) {
this.datasetId = route.snapshot.params['id'];
}
constructor(private datasetProfileService: DatasetProfileService, route: ActivatedRoute) {
this.datasetId = route.snapshot.params['id'];
}
ngOnInit() {
let autocompleteRequestItem: RequestItem<AutocompleteLookupItem> = new RequestItem();
autocompleteRequestItem.criteria = new AutocompleteLookupItem();
autocompleteRequestItem.criteria.fieldID = this.field.id;
autocompleteRequestItem.criteria.profileID = this.datasetId;
this.autoCompleteConfiguration = new AutoCompleteConfiguration(this.datasetProfileService.queryAutocomplete.bind(this.datasetProfileService), autocompleteRequestItem);
ngOnInit() {
const autocompleteRequestItem: RequestItem<AutocompleteLookupItem> = new RequestItem();
autocompleteRequestItem.criteria = new AutocompleteLookupItem();
autocompleteRequestItem.criteria.fieldID = this.field.id;
autocompleteRequestItem.criteria.profileID = this.datasetId;
this.autoCompleteConfiguration = new AutoCompleteConfiguration(this.datasetProfileService.queryAutocomplete.bind(this.datasetProfileService), autocompleteRequestItem);
}
}
displayWith(item: any) {
if (!item) return null;
if (typeof item === 'string') item = this.transform(item);
return item["label"];
}
displayWith(item: any) {
if (!item) { return null; }
if (typeof item === 'string') { item = this.transform(item); }
return item['label'];
}
assign(item: any) {
if (!item) return null;
return this.transform(item);
}
assign(item: any) {
if (!item) { return null; }
return this.transform(item);
}
transform(item: any) {
if (typeof item === 'string') return JSON.parse(item)
else return JSON.stringify(item);
}
transform(item: any) {
if (typeof item === 'string') { return JSON.parse(item); } else { return JSON.stringify(item); }
}
}

View File

@ -3,18 +3,18 @@ import { Field } from '../../../models/Field';
import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core';
@Component({
selector: 'df-booleanDecision',
templateUrl: './dynamic-field-boolean-decision.component.html',
styleUrls: [
'./dynamic-field-boolean-decision.component.css'
],
encapsulation: ViewEncapsulation.None
selector: 'app-df-boolean-decision',
templateUrl: './dynamic-field-boolean-decision.component.html',
styleUrls: [
'./dynamic-field-boolean-decision.component.css'
],
encapsulation: ViewEncapsulation.None
})
export class DynamicFieldBooleanDecisionComponent implements OnInit {
@Input() field: Field;
@Input() form: FormGroup;
@Input() field: Field;
@Input() form: FormGroup;
ngOnInit() {
ngOnInit() {
}
}
}

View File

@ -3,15 +3,15 @@ import { FormGroup } from '@angular/forms';
import { Component, Input, ViewEncapsulation, OnInit } from '@angular/core';
@Component({
selector: 'df-checkbox',
templateUrl: './dynamic-field-checkbox.html',
styleUrls: [
'./dynamic-field-checkbox.css'
],
encapsulation: ViewEncapsulation.None
selector: 'app-df-checkbox',
templateUrl: './dynamic-field-checkbox.html',
styleUrls: [
'./dynamic-field-checkbox.css'
],
encapsulation: ViewEncapsulation.None
})
export class DynamicFieldCheckBoxComponent {
@Input() field: Field;
@Input() form: FormGroup;
@Input() field: Field;
@Input() form: FormGroup;
}

View File

@ -3,18 +3,18 @@ import { Field } from '../../../models/Field';
import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core';
@Component({
selector: 'df-dropdown',
templateUrl: './dynamic-field-dropdown.html',
styleUrls: [
'./dynamic-field-dropdown.css'
],
encapsulation: ViewEncapsulation.None
selector: 'app-df-dropdown',
templateUrl: './dynamic-field-dropdown.html',
styleUrls: [
'./dynamic-field-dropdown.css'
],
encapsulation: ViewEncapsulation.None
})
export class DynamicFieldDropdownComponent implements OnInit {
@Input() field: Field;
@Input() form: FormGroup;
@Input() field: Field;
@Input() form: FormGroup;
ngOnInit() {
ngOnInit() {
}
}
}

View File

@ -4,18 +4,18 @@ import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core';
@Component({
selector: 'df-radiobox',
templateUrl: './dynamic-field-radiobox.component.html',
styleUrls: [
'./dynamic-field-radiobox.component.css'
],
encapsulation: ViewEncapsulation.None
selector: 'app-df-radiobox',
templateUrl: './dynamic-field-radiobox.component.html',
styleUrls: [
'./dynamic-field-radiobox.component.css'
],
encapsulation: ViewEncapsulation.None
})
export class DynamicFieldRadioBoxComponent implements OnInit {
@Input() field: Field;
@Input() form: FormGroup;
@Input() field: Field;
@Input() form: FormGroup;
ngOnInit() {
ngOnInit() {
}
}
}

View File

@ -19,16 +19,16 @@
<div *ngSwitchCase="'combobox'">
<!--TODO-->
<div *ngIf="this.field.data.type === 'autocomplete'">
<df-autocomplete [form]="form" [field]="field"></df-autocomplete>
<app-df-autocomplete [form]="form" [field]="field"></app-df-autocomplete>
</div>
<div *ngIf="this.field.data.type === 'wordlist'">
<df-dropdown [form]="form" [field]="field"></df-dropdown>
<app-df-dropdown [form]="form" [field]="field"></app-df-dropdown>
</div>
</div>
<div *ngSwitchCase="'checkBox'" class="checkbox">
<df-checkbox [form]="form" [field]="field"></df-checkbox>
<app-df-checkbox [form]="form" [field]="field"></app-df-checkbox>
</div>
<div *ngSwitchCase="'textarea'">
@ -44,11 +44,11 @@
</div>
<div *ngSwitchCase="'booleanDecision'">
<df-booleanDecision [form]="form" [field]="field"></df-booleanDecision>
<app-df-boolean-decision [form]="form" [field]="field"></app-df-boolean-decision>
</div>
<div *ngSwitchCase="'radiobox'">
<df-radiobox [form]="form" [field]="field"></df-radiobox>
<app-df-radiobox [form]="form" [field]="field"></app-df-radiobox>
</div>
<div *ngSwitchCase="'label'"> </div>

View File

@ -1,5 +1,5 @@
import { Field } from '../../models/Field';
import { Component, Input, OnInit, ViewEncapsulation, ChangeDetectionStrategy } from '@angular/core';
import { Component, Input, OnInit, ViewEncapsulation, ChangeDetectionStrategy, OnChanges, OnDestroy } from '@angular/core';
import { FormGroup, ValidatorFn, AbstractControl, Validators } from '@angular/forms';
import { ActivatedRoute } from '@angular/router';
import { VisibilityRulesService } from '../../utilities/visibility-rules/visibility-rules.service';
@ -7,60 +7,58 @@ import { Subscription } from 'rxjs';
@Component({
selector: 'df-field',
templateUrl: './dynamic-form-field.component.html',
// styles: ['.checkBoxLabelCustom {font-weight: 700;}']
styleUrls: [
'./dynamic-form-field.component.css'
],
encapsulation: ViewEncapsulation.None
selector: 'app-df-field',
templateUrl: './dynamic-form-field.component.html',
// styles: ['.checkBoxLabelCustom {font-weight: 700;}']
styleUrls: [
'./dynamic-form-field.component.css'
],
encapsulation: ViewEncapsulation.None
})
export class DynamicFormFieldComponent implements OnInit {
@Input() field: Field;
form: FormGroup;
@Input() pathName: string;
@Input() path: string;
change: Subscription;
trackByFn = (index, item) => item ? item["id"] : null
constructor(private route: ActivatedRoute, public visibilityRulesService: VisibilityRulesService) {
export class DynamicFormFieldComponent implements OnInit, OnChanges, OnDestroy {
@Input() field: Field;
form: FormGroup;
@Input() pathName: string;
@Input() path: string;
change: Subscription;
trackByFn = (index, item) => item ? item['id'] : null;
constructor(private route: ActivatedRoute, public visibilityRulesService: VisibilityRulesService) {
}
}
ngOnInit() {
if (this.field) {
this.form = this.visibilityRulesService.getFormGroup(this.field.id)
if (!this.form) debugger;
if (!this.form.get('value')) debugger;
this.change = this.form.get('value').valueChanges.subscribe(item => {
this.visibilityRulesService.updateValueAndVisibility(this.field.id)
})
}
}
ngOnInit() {
if (this.field) {
this.form = this.visibilityRulesService.getFormGroup(this.field.id);
this.change = this.form.get('value').valueChanges.subscribe(item => {
this.visibilityRulesService.updateValueAndVisibility(this.field.id);
});
}
}
ngOnChanges(changeRecord) {
ngOnChanges(changeRecord) {
}
}
ngOnDestroy(): void {
//Called once, before the instance is destroyed.
//Add 'implements OnDestroy' to the class.
if(this.change) this.change.unsubscribe()
}
ngOnDestroy(): void {
//Called once, before the instance is destroyed.
//Add 'implements OnDestroy' to the class.
if (this.change) { this.change.unsubscribe(); }
}
clearInput() {
}
clearInput() {
}
get isValid() {
return this.form.get("value").valid;
}
get isValidRequired() {
return this.form.get("value").hasError("required");
}
get isValidPattern() {
return this.form.get("value").hasError("pattern");
}
get isValidCustom() {
return this.form.get("value").hasError("forbiddenName");
}
get isValid() {
return this.form.get('value').valid;
}
get isValidRequired() {
return this.form.get('value').hasError('required');
}
get isValidPattern() {
return this.form.get('value').hasError('pattern');
}
get isValidCustom() {
return this.form.get('value').hasError('forbiddenName');
}
}

View File

@ -1,40 +1,40 @@
<div *ngIf="form" [id]="compositeField.id" [formGroup]="form">
<div *ngIf="compositeField.fields.length == 1" class="fieldset-component">
<h5 *ngIf="compositeField.title" style="font-weight:bold; color: #3a3737;">{{compositeField.title}}</h5>
<div class="content-left-margin">
<h5 *ngIf="compositeField.description">{{compositeField.description}}</h5>
<h5 *ngIf="compositeField.extendedDescription" class="fieldset-extended-desc">
<i>{{compositeField.extendedDescription}}</i>
</h5>
<df-field *ngIf="compositeField.fields.length == 1" [field]="compositeField.fields[0]" [pathName]="pathName+'.fields.'+0"></df-field>
</div>
</div>
<div *ngIf="compositeField.fields.length == 1" class="fieldset-component">
<h5 *ngIf="compositeField.title" style="font-weight:bold; color: #3a3737;">{{compositeField.title}}</h5>
<div class="content-left-margin">
<h5 *ngIf="compositeField.description">{{compositeField.description}}</h5>
<h5 *ngIf="compositeField.extendedDescription" class="fieldset-extended-desc">
<i>{{compositeField.extendedDescription}}</i>
</h5>
<app-df-field *ngIf="compositeField.fields.length == 1" [field]="compositeField.fields[0]" [pathName]="pathName+'.fields.'+0"></app-df-field>
</div>
</div>
<div *ngIf="compositeField.fields.length > 1" class="fieldset-component">
<h5 *ngIf="compositeField.title" style="font-weight:bold; color: #3a3737;">{{compositeField.title}}</h5>
<div class="content-left-margin">
<h5 *ngIf="compositeField.description">{{compositeField.description}}</h5>
<h5 *ngIf="compositeField.extendedDescription" class="fieldset-extended-desc">
<i>{{compositeField.extendedDescription}}</i>
</h5>
<div *ngFor="let field of compositeField.fields; let i = index; trackBy: trackByFn ">
<div>
<div *ngIf="(field?.multiplicity?.max - 1) > (field?.multiplicityItems?.length)">
<a (click)="addMultipleField(i)" style="cursor: pointer">
Add one more field +
</a>
</div>
</div>
<div *ngIf="compositeField.fields.length > 1" class="fieldset-component">
<h5 *ngIf="compositeField.title" style="font-weight:bold; color: #3a3737;">{{compositeField.title}}</h5>
<div class="content-left-margin">
<h5 *ngIf="compositeField.description">{{compositeField.description}}</h5>
<h5 *ngIf="compositeField.extendedDescription" class="fieldset-extended-desc">
<i>{{compositeField.extendedDescription}}</i>
</h5>
<div *ngFor="let field of compositeField.fields; let i = index; trackBy: trackByFn ">
<div>
<div *ngIf="(field?.multiplicity?.max - 1) > (field?.multiplicityItems?.length)">
<a (click)="addMultipleField(i)" style="cursor: pointer">
Add one more field +
</a>
</div>
</div>
<df-field [field]="field" [pathName]="pathName+'.fields.'+i"></df-field>
<div *ngIf="field">
<div *ngFor="let multipleField of field.multiplicityItems; let j = index; trackBy: trackByFn">
<df-field [field]="multipleField" [pathName]="pathName+'.fields.'+i+'.multiplicityItems.'+j"></df-field>
</div>
</div>
</div>
</div>
</div>
<app-df-field [field]="field" [pathName]="pathName+'.fields.'+i"></app-df-field>
<div *ngIf="field">
<div *ngFor="let multipleField of field.multiplicityItems; let j = index; trackBy: trackByFn">
<app-df-field [field]="multipleField" [pathName]="pathName+'.fields.'+i+'.multiplicityItems.'+j"></app-df-field>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -4,34 +4,34 @@ import { FormGroup, FormArray } from '@angular/forms';
import { Component, Input, OnInit, ViewEncapsulation, ChangeDetectionStrategy } from '@angular/core';
import { Field } from '../../models/Field';
@Component({
selector: 'df-composite-field',
templateUrl: './dynamic-form-composite-field.html',
styleUrls: [
'./dynamic-form-composite-field.css'
],
encapsulation: ViewEncapsulation.None,
selector: 'app-df-composite-field',
templateUrl: './dynamic-form-composite-field.html',
styleUrls: [
'./dynamic-form-composite-field.css'
],
encapsulation: ViewEncapsulation.None,
})
export class DynamicFormCompositeFieldComponent implements OnInit {
@Input() compositeField: CompositeField
form: FormGroup;
@Input() pathName: string;
@Input() path: string;
trackByFn = (index, item) => item ? item["id"] : null
@Input() compositeField: CompositeField;
form: FormGroup;
@Input() pathName: string;
@Input() path: string;
trackByFn = (index, item) => item ? item['id'] : null;
constructor(private visibilityRulesService: VisibilityRulesService) {
}
constructor(private visibilityRulesService: VisibilityRulesService) {
}
ngOnInit() {
if (this.compositeField) {
this.form = this.visibilityRulesService.getFormGroup(this.compositeField.id)
}
}
ngOnInit() {
if (this.compositeField) {
this.form = this.visibilityRulesService.getFormGroup(this.compositeField.id);
}
}
addMultipleField(fieldIndex: number) {
let field: Field = this.compositeField.fields[fieldIndex].cloneForMultiplicity(fieldIndex, "");
this.compositeField.fields[fieldIndex].multiplicityItems.push(field);
(<FormArray>(this.form.get("fields").get('' + fieldIndex).get('multiplicityItems'))).push(field.buildForm());
}
addMultipleField(fieldIndex: number) {
const field: Field = this.compositeField.fields[fieldIndex].cloneForMultiplicity(fieldIndex, '');
this.compositeField.fields[fieldIndex].multiplicityItems.push(field);
(<FormArray>(this.form.get('fields').get('' + fieldIndex).get('multiplicityItems'))).push(field.buildForm());
}
}

View File

@ -9,10 +9,10 @@
</a>
</div>
</div>
<df-composite-field [compositeField]="compositeField" [path]="path" [pathName]="pathName+'.compositeFields.'+i"></df-composite-field>
<app-df-composite-field [compositeField]="compositeField" [path]="path" [pathName]="pathName+'.compositeFields.'+i"></app-df-composite-field>
<div *ngIf="compositeField">
<div *ngFor="let multipleCompositeField of compositeField.multiplicityItems; let j = index; trackBy: trackByFn">
<df-composite-field [compositeField]="multipleCompositeField" [pathName]="pathName+'.compositeFields.'+i+'.multiplicityItems.'+j"></df-composite-field>
<app-df-composite-field [compositeField]="multipleCompositeField" [pathName]="pathName+'.compositeFields.'+i+'.multiplicityItems.'+j"></app-df-composite-field>
</div>
</div>
</div>

View File

@ -8,36 +8,36 @@ import { CompositeField } from '../../models/CompositeField';
@Component({
selector: 'df-group',
templateUrl: './dynamic-form-group.component.html',
styleUrls: ['./dynamic-form-group.component.css'],
encapsulation: ViewEncapsulation.None,
selector: 'app-df-group',
templateUrl: './dynamic-form-group.component.html',
styleUrls: ['./dynamic-form-group.component.css'],
encapsulation: ViewEncapsulation.None,
})
export class DynamicFormGroupComponent implements OnInit {
@Input() group: FieldGroup
form: FormGroup;
@Input() pathName: string;
@Input() group: FieldGroup;
form: FormGroup;
@Input() pathName: string;
@Input() path: string;
trackByFn = (index, item) => item ? item["id"] : null
constructor(public visibilityRulesService: VisibilityRulesService) {
}
@Input() path: string;
trackByFn = (index, item) => item ? item['id'] : null;
constructor(public visibilityRulesService: VisibilityRulesService) {
}
ngOnInit() {
if (this.group) {
this.form = this.visibilityRulesService.getFormGroup(this.group.id)
}
}
ngOnInit() {
if (this.group) {
this.form = this.visibilityRulesService.getFormGroup(this.group.id);
}
}
addMultipleField(fieldsetIndex: number) {
let compositeField: CompositeField = this.group.compositeFields[fieldsetIndex].cloneForMultiplicity(fieldsetIndex);
this.group.compositeFields[fieldsetIndex].multiplicityItems.push(compositeField);
(<FormArray>(this.form.get("compositeFields").get('' + fieldsetIndex).get('multiplicityItems'))).push(compositeField.buildForm());
}
addMultipleField(fieldsetIndex: number) {
const compositeField: CompositeField = this.group.compositeFields[fieldsetIndex].cloneForMultiplicity(fieldsetIndex);
this.group.compositeFields[fieldsetIndex].multiplicityItems.push(compositeField);
(<FormArray>(this.form.get('compositeFields').get('' + fieldsetIndex).get('multiplicityItems'))).push(compositeField.buildForm());
}
addFieldSet() {
addFieldSet() {
}
}
}

View File

@ -18,10 +18,10 @@
Add one more fieldset +
</a>
</div>
<df-composite-field [compositeField]="compositeField" [path]="path" [pathName]="pathName+'.compositeFields.'+i"></df-composite-field>
<app-df-composite-field [compositeField]="compositeField" [path]="path" [pathName]="pathName+'.compositeFields.'+i"></app-df-composite-field>
<div *ngIf="compositeField">
<div *ngFor="let multipleCompositeField of compositeField.multiplicityItems; let j = index; trackBy: trackByFn">
<df-composite-field [compositeField]="multipleCompositeField" [pathName]="pathName+'.compositeFields.'+i+'.multiplicityItems.'+j"></df-composite-field>
<app-df-composite-field [compositeField]="multipleCompositeField" [pathName]="pathName+'.compositeFields.'+i+'.multiplicityItems.'+j"></app-df-composite-field>
</div>
<div *ngIf="compositeField.hasCommentField" [formGroup]="form.get('compositeFields').get(''+i)">
<mat-form-field>
@ -35,7 +35,7 @@
<div *ngIf="section?.sections">
<div *ngFor="let itemsection of section.sections; let j = index;">
<df-section [section]="itemsection" [path]="path+'.'+(j+1)" [pathName]="pathName+'.sections.'+j"></df-section>
<app-df-section [section]="itemsection" [path]="path+'.'+(j+1)" [pathName]="pathName+'.sections.'+j"></app-df-section>
</div>
</div>
</mat-expansion-panel>

View File

@ -1,49 +1,50 @@
import { VisibilityRulesService } from '../../utilities/visibility-rules/visibility-rules.service';
import { FormGroup, Form, FormArray } from '@angular/forms';
import { Component, Input, OnInit, ViewEncapsulation, ChangeDetectionStrategy } from '@angular/core';
import { Component, Input, OnInit, ViewEncapsulation, ChangeDetectionStrategy, AfterViewInit } from '@angular/core';
import { CompositeField } from '../../models/CompositeField';
import { Section } from '../../models/Section';
@Component({
selector: 'df-section',
templateUrl: './dynamic-form-section.html',
styleUrls: [
'./dynamic-form-section.css'
],
encapsulation: ViewEncapsulation.None,
selector: 'app-df-section',
templateUrl: './dynamic-form-section.html',
styleUrls: [
'./dynamic-form-section.css'
],
encapsulation: ViewEncapsulation.None,
})
export class DynamicFormSectionComponent implements OnInit {
export class DynamicFormSectionComponent implements OnInit, AfterViewInit {
@Input() section: Section
form: FormGroup;
@Input() pathName: string;
@Input() path: string;
trackByFn = (index, item) => item ? item["id"] : null
constructor(public visibilityRulesService: VisibilityRulesService) { }
@Input() section: Section;
form: FormGroup;
@Input() pathName: string;
@Input() path: string;
trackByFn = (index, item) => item ? item['id'] : null;
constructor(public visibilityRulesService: VisibilityRulesService) { }
ngOnInit() {
if (this.section) {
this.form = this.visibilityRulesService.getFormGroup(this.section.id)
}
}
ngOnInit() {
if (this.section) {
this.form = this.visibilityRulesService.getFormGroup(this.section.id);
}
}
ngAfterViewInit() {
this.visibilityRulesService.triggerVisibilityEvaluation()
}
ngAfterViewInit() {
this.visibilityRulesService.triggerVisibilityEvaluation();
}
addMultipleField(fieldsetIndex: number) {
let compositeField: CompositeField = this.section.compositeFields[fieldsetIndex].cloneForMultiplicity(fieldsetIndex);
this.section.compositeFields[fieldsetIndex].multiplicityItems.push(compositeField);
(<FormArray>(this.form.get("compositeFields").get('' + fieldsetIndex).get('multiplicityItems'))).push(compositeField.buildForm());
}
addMultipleField(fieldsetIndex: number) {
const compositeField: CompositeField = this.section.compositeFields[fieldsetIndex].cloneForMultiplicity(fieldsetIndex);
this.section.compositeFields[fieldsetIndex].multiplicityItems.push(compositeField);
(<FormArray>(this.form.get('compositeFields').get('' + fieldsetIndex).get('multiplicityItems'))).push(compositeField.buildForm());
}
isElementVisible(fieldSet: CompositeField): boolean {
if (!fieldSet) return false;
for (var i = 0; i < fieldSet.fields.length; i++) {
if (fieldSet.fields[i])
return true;
}
return false;
}
isElementVisible(fieldSet: CompositeField): boolean {
if (!fieldSet) { return false; }
for (let i = 0; i < fieldSet.fields.length; i++) {
if (fieldSet.fields[i]) {
return true;
}
}
return false;
}
}

View File

@ -8,16 +8,16 @@ import { DynamicFormSectionComponent } from './dynamic-form-section/dynamic-form
import { DynamicFieldDropdownComponent } from './dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown';
import { AutocompleteRemoteComponent } from './dynamic-fields/dynamic-field-autocomplete/autocomplete-remote.component';
import {
TableOfContentsSectionComponent,
TableOfContentsSectionComponent,
} from './tableOfContents/table-of-content-section/table-of-content-section.component';
import { TableOfContentsGroupComponent } from './tableOfContents/table-of-content-group/table-of-content-group.component';
import {
TableOfContentsFieldSetComponent,
TableOfContentsFieldSetComponent,
} from './tableOfContents/table-of-content-fieldset/table-of-content-fieldset.component';
import { DynamicFieldRadioBoxComponent } from './dynamic-fields/dynamic-field-radiobox/dynamic-field-radiobox.component';
import { TableOfContentsComponent } from './tableOfContents/table-of-contents.component';
import {
DynamicFieldBooleanDecisionComponent,
DynamicFieldBooleanDecisionComponent,
} from './dynamic-fields/dynamic-field-boolean-decision/dynamic-field-boolean-decision.component';
import { DynamicFormGroupComponent } from './dynamic-form-group/dynamic-form-group.component';
import { DynamicFormCompositeFieldComponent } from './dynamic-form-composite-field/dynamic-form-composite-field';
@ -28,76 +28,76 @@ import { SharedModule } from '../shared/shared.module';
import { HttpClient, HttpClientModule } from '@angular/common/http';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { CommonModule } from '@angular/common';
import { NgModule } from "@angular/core";
import { NgModule } from '@angular/core';
import { DatasetProfileAdmin } from '../services/datasetProfileAdmin/datasetProfileAfmin.service';
import { DatasetProfileService } from '../services/dataset-profile.service';
import { DatasetWizardService } from '../services/dataset-wizard/dataset-wizard.service';
@NgModule({
imports: [
CommonModule,
FormsModule,
HttpClientModule,
SharedModule,
ReactiveFormsModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
}
}),
],
imports: [
CommonModule,
FormsModule,
HttpClientModule,
SharedModule,
ReactiveFormsModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
}
}),
],
declarations: [
DynamicFormComponent,
DynamicFormFieldComponent,
DynamicFormGroupComponent,
DynamicFormCompositeFieldComponent,
DynamicFieldBooleanDecisionComponent,
DynamicFieldRadioBoxComponent,
TableOfContentsComponent,
TableOfContentsFieldSetComponent,
TableOfContentsGroupComponent,
TableOfContentsSectionComponent,
AutocompleteRemoteComponent,
DynamicFieldDropdownComponent,
DynamicFormSectionComponent,
TableOfContentsFieldComponent,
ProgressBarComponent,
DynamicFieldCheckBoxComponent,
],
declarations: [
DynamicFormComponent,
DynamicFormFieldComponent,
DynamicFormGroupComponent,
DynamicFormCompositeFieldComponent,
DynamicFieldBooleanDecisionComponent,
DynamicFieldRadioBoxComponent,
TableOfContentsComponent,
TableOfContentsFieldSetComponent,
TableOfContentsGroupComponent,
TableOfContentsSectionComponent,
AutocompleteRemoteComponent,
DynamicFieldDropdownComponent,
DynamicFormSectionComponent,
TableOfContentsFieldComponent,
ProgressBarComponent,
DynamicFieldCheckBoxComponent,
],
exports: [
DynamicFormComponent,
DynamicFormFieldComponent,
DynamicFormGroupComponent,
DynamicFormCompositeFieldComponent,
DynamicFieldBooleanDecisionComponent,
DynamicFieldRadioBoxComponent,
TableOfContentsComponent,
TableOfContentsFieldSetComponent,
TableOfContentsGroupComponent,
TableOfContentsSectionComponent,
AutocompleteRemoteComponent,
DynamicFieldDropdownComponent,
DynamicFormSectionComponent,
TableOfContentsFieldComponent,
ProgressBarComponent,
DynamicFieldCheckBoxComponent,
],
providers: [
VisibilityRulesService,
PaginationService,
DatasetProfileService,
DatasetProfileAdmin,
DatasetWizardService
]
exports: [
DynamicFormComponent,
DynamicFormFieldComponent,
DynamicFormGroupComponent,
DynamicFormCompositeFieldComponent,
DynamicFieldBooleanDecisionComponent,
DynamicFieldRadioBoxComponent,
TableOfContentsComponent,
TableOfContentsFieldSetComponent,
TableOfContentsGroupComponent,
TableOfContentsSectionComponent,
AutocompleteRemoteComponent,
DynamicFieldDropdownComponent,
DynamicFormSectionComponent,
TableOfContentsFieldComponent,
ProgressBarComponent,
DynamicFieldCheckBoxComponent,
],
providers: [
VisibilityRulesService,
PaginationService,
DatasetProfileService,
DatasetProfileAdmin,
DatasetWizardService
]
})
export class DynamicFormModule { }
export function HttpLoaderFactory(httpClient: HttpClient) {
return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json');
return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json');
}

View File

@ -1,44 +1,44 @@
<div class="dynamic-form-editor">
<!-- <mat-sidenav-container class="ng-sidebar-container"> -->
<!-- <mat-sidenav mode="push" position="right" [(opened)]="visibleSidebar">
<!-- <mat-sidenav-container class="ng-sidebar-container"> -->
<!-- <mat-sidenav mode="push" position="right" [(opened)]="visibleSidebar">
<table-of-content class="toc-container full-height" [model]="datasetProfileDefinitionModel"></table-of-content>
</mat-sidenav> -->
<!-- <mat-sidenav-content> -->
<!-- <button mat-raised-button color="primary" style="margin: 15px;" (click)="toggleSidebar()" icon="fa-arrow-left">Table Of Contents</button> -->
<form *ngIf="form" novalidate [formGroup]="form">
<!-- <button mat-raised-button color="primary" *ngIf="dataModel&&dataModel.status.toString() != 1" style="margin-top: 15px;margin-bottom: 15px;margin-right: 15px;"
<!-- <mat-sidenav-content> -->
<!-- <button mat-raised-button color="primary" style="margin: 15px;" (click)="toggleSidebar()" icon="fa-arrow-left">Table Of Contents</button> -->
<form *ngIf="form" novalidate [formGroup]="form">
<!-- <button mat-raised-button color="primary" *ngIf="dataModel&&dataModel.status.toString() != 1" style="margin-top: 15px;margin-bottom: 15px;margin-right: 15px;"
(click)="save();" type="button">Save</button>
<button mat-raised-button color="primary" *ngIf="dataModel&&dataModel?.status != 1" style="margin-top: 15px;margin-bottom: 15px;margin-right: 15px;"
(click)="saveFinalize();" type="button">Save and Finalize</button> -->
<div>
<div class="alignment-center">
<!-- <ngb-pagination *ngIf="pages" [collectionSize]="pages.length*10" [page]="currentPageIndex" (pageChange)="changePageIndex($event)" aria-label="Default pagination"></ngb-pagination> -->
<progress-bar *ngIf="form" [formGroup]="form"></progress-bar>
</div>
</div>
<div>
<div class="alignment-center">
<!-- <ngb-pagination *ngIf="pages" [collectionSize]="pages.length*10" [page]="currentPageIndex" (pageChange)="changePageIndex($event)" aria-label="Default pagination"></ngb-pagination> -->
<app-progress-bar *ngIf="form" [formGroup]="form"></app-progress-bar>
</div>
</div>
<div *ngIf='datasetProfileDefinitionModel' class="col-md-12" id="form-container">
<!-- <form *ngIf="form" novalidate [formGroup]="form" (ngSubmit)="onSubmit()"> -->
<mat-vertical-stepper #stepper [linear]="false">
<div *ngFor="let page of datasetProfileDefinitionModel.pages; let z=index; trackBy: pageTrackByFn">
<div *ngFor="let section of page.sections; let i = index; trackBy: trackByFn">
<mat-step [stepControl]="section">
<ng-template matStepLabel>{{page.title}}</ng-template>
<div *ngIf="stepper.selectedIndex == z">
<df-section [section]="section" [path]="z+1" [pathName]="'pages.'+z+'.sections.'+i"></df-section>
</div>
</mat-step>
</div>
</div>
</mat-vertical-stepper>
<!-- <div *ngFor="let section of datasetProfileDefinitionModel.sections; let i = index;">
<div *ngIf='datasetProfileDefinitionModel' class="col-md-12" id="form-container">
<!-- <form *ngIf="form" novalidate [formGroup]="form" (ngSubmit)="onSubmit()"> -->
<mat-vertical-stepper #stepper [linear]="false">
<div *ngFor="let page of datasetProfileDefinitionModel.pages; let z=index; trackBy: pageTrackByFn">
<div *ngFor="let section of page.sections; let i = index; trackBy: trackByFn">
<mat-step [stepControl]="section">
<ng-template matStepLabel>{{page.title}}</ng-template>
<div *ngIf="stepper.selectedIndex == z">
<app-df-section [section]="section" [path]="z+1" [pathName]="'pages.'+z+'.sections.'+i"></app-df-section>
</div>
</mat-step>
</div>
</div>
</mat-vertical-stepper>
<!-- <div *ngFor="let section of datasetProfileDefinitionModel.sections; let i = index;">
<df-section *ngIf='this.shouldDisplaySection(section)' [section]="section" [form]="form.get('sections').get(''+i)" [path]="i+1"
[pathName]="'sections.'+i"></df-section>
</div> -->
</div>
</form>
<!-- </mat-sidenav-content>
</div>
</form>
<!-- </mat-sidenav-content>
</mat-sidenav-container> -->
</div>
<!-- <p>Form value: {{ form.value | json }}</p> -->

View File

@ -17,122 +17,123 @@ import { MatSidenavModule } from '@angular/material/sidenav';
declare function simple_notifier(type: string, title: string, message: string): any;
@Component({
selector: 'dynamic-form',
templateUrl: './dynamic-form.component.html',
styleUrls: [
'./dynamic-form.component.scss'
],
providers: [
],
encapsulation: ViewEncapsulation.None,
selector: 'app-dynamic-form',
templateUrl: './dynamic-form.component.html',
styleUrls: [
'./dynamic-form.component.scss'
],
providers: [
],
encapsulation: ViewEncapsulation.None,
})
export class DynamicFormComponent implements OnInit, AfterViewInit {
pathName: string;
pages: Array<number>;
activeStepperIndex = 1;
visibleSidebar = false;
datasetProfileDefinitionModel: DatasetProfileDefinitionModel;
private progressbar = false;
private currentPageIndex = 0;
@Input() dataModel: DatasetWizardModel = new DatasetWizardModel();
@Input() path: string;
@Input() form: FormGroup;
id: string;
trackByFn = (index, item) => item ? item["id"] : null
pageTrackByFn = (index, item) => item["id"]
private fragment: string;
@Input() dataModel: DatasetWizardModel = new DatasetWizardModel();
@Input() path: string;
@Input() form: FormGroup;
id: string;
trackByFn = (index, item) => item ? item['id'] : null;
pageTrackByFn = (index, item) => item['id'];
// @Input() datasetId: string;
pathName: string;
pages: Array<number>;
activeStepperIndex: number = 1;
visibleSidebar: boolean = false;
datasetProfileDefinitionModel: DatasetProfileDefinitionModel
private progressbar: boolean = false;
private currentPageIndex: number = 0;
// @Input() datasetId: string;
private fragment: string;
constructor(private router: Router,
private _location: Location,
private route: ActivatedRoute,
private visibilityRulesService: VisibilityRulesService,
private http: BaseHttpService,
private datasetWizardService: DatasetWizardService,
) {
//this.datasetId = route.snapshot.params['id'];
}
constructor(private router: Router,
private _location: Location,
private route: ActivatedRoute,
private visibilityRulesService: VisibilityRulesService,
private http: BaseHttpService,
private datasetWizardService: DatasetWizardService,
) {
//this.datasetId = route.snapshot.params['id'];
}
getSubForm(subformName) {
return this.form.controls[subformName];
}
getSubForm(subformName) {
return this.form.controls[subformName];
}
ngOnInit() {
ngOnInit() {
let rules: Rule[] = JsonSerializer.fromJSONArray(this.dataModel.datasetProfileDefinition.rules, Rule);
this.visibilityRulesService.formGroup = this.form;
this.visibilityRulesService.buildVisibilityRules(rules)
this.datasetProfileDefinitionModel = this.dataModel.datasetProfileDefinition
this.visibilityRulesService.setModel(this.datasetProfileDefinitionModel)
this.createPagination();
this.progressbar = true;
const rules: Rule[] = JsonSerializer.fromJSONArray(this.dataModel.datasetProfileDefinition.rules, Rule);
this.visibilityRulesService.formGroup = this.form;
this.visibilityRulesService.buildVisibilityRules(rules);
this.datasetProfileDefinitionModel = this.dataModel.datasetProfileDefinition;
this.visibilityRulesService.setModel(this.datasetProfileDefinitionModel);
this.createPagination();
this.progressbar = true;
this.route.fragment.subscribe((fragment: string) => {
var self = this;
setTimeout(function () { self.scrollTo(fragment) });
});
this.route.fragment.subscribe((fragment: string) => {
const self = this;
setTimeout(function () { self.scrollTo(fragment); });
});
this.route.queryParams.subscribe((params) => {
if (params && "page" in params)
this.changeCurrentPage(params["page"]);
});
}
this.route.queryParams.subscribe((params) => {
if (params && 'page' in params) {
this.changeCurrentPage(params['page']);
}
});
}
ngAfterViewInit() {
this.visibilityRulesService.triggerVisibilityEvaluation()
}
ngAfterViewInit() {
this.visibilityRulesService.triggerVisibilityEvaluation();
}
toggleSidebar() {
this.visibleSidebar = !this.visibleSidebar;
}
toggleSidebar() {
this.visibleSidebar = !this.visibleSidebar;
}
// getPages(model: DatasetProfileDefinitionModel): Array<number> {
// let pageSet = new Set<number>();
// getPages(model: DatasetProfileDefinitionModel): Array<number> {
// let pageSet = new Set<number>();
// model.sections.forEach(section => {
// pageSet.add(section.page);
// });
// model.sections.forEach(section => {
// pageSet.add(section.page);
// });
// return Array.from(pageSet).sort((a, b) => a - b);
// }
// return Array.from(pageSet).sort((a, b) => a - b);
// }
shouldDisplaySection(section: Section): Boolean {
return (section.page) == this.currentPageIndex;
}
shouldDisplaySection(section: Section): Boolean {
return (section.page) === this.currentPageIndex;
}
createPagination() {
/*this.pages.forEach(item => {
this.stepperItems.push({
label: '',
})
});*/
}
createPagination() {
/*this.pages.forEach(item => {
this.stepperItems.push({
label: '',
})
});*/
}
changePageIndex(index: any) {
this.router.navigate([this.route.snapshot.url[0] + "/" + this.route.snapshot.url[1]], { queryParams: { page: this.pages[index - 1] } });
}
changePageIndex(index: any) {
this.router.navigate([this.route.snapshot.url[0] + '/' + this.route.snapshot.url[1]], { queryParams: { page: this.pages[index - 1] } });
}
scrollTo(sectionID: string) {
if (!sectionID) return;
var element = document.querySelector('#' + sectionID);
if (!element) return;
element.scrollIntoView();
this.visibleSidebar = true;
var scrollElement = document.querySelector('.scrollableContent');
//scrollElement.scrollTop = topElement.offsetTop;
}
scrollTo(sectionID: string) {
if (!sectionID) { return; }
const element = document.querySelector('#' + sectionID);
if (!element) { return; }
element.scrollIntoView();
this.visibleSidebar = true;
const scrollElement = document.querySelector('.scrollableContent');
//scrollElement.scrollTop = topElement.offsetTop;
}
changeCurrentPage(pageString: string) {
if (!pageString) return;
var page = parseInt(pageString);
if (isNaN(page)) return;
var pageIndex = this.pages.indexOf(page);
if (pageIndex === -1) return;
this.currentPageIndex = page;
}
changeCurrentPage(pageString: string) {
if (!pageString) { return; }
const page = parseInt(pageString);
if (isNaN(page)) { return; }
const pageIndex = this.pages.indexOf(page);
if (pageIndex === -1) { return; }
this.currentPageIndex = page;
}
}

View File

@ -1,9 +1,9 @@
export class DropdownField {
controlType = 'dropdown';
options: {key: string, value: string}[] =[];
controlType = 'dropdown';
options: { key: string, value: string }[] = [];
constructor(options: {} = {}){
this.options = options['options'] || [];
}
constructor(options: {} = {}) {
this.options = options['options'] || [];
}
}

View File

@ -1,18 +1,18 @@
import { Injectable } from '@angular/core'
import { Injectable } from '@angular/core';
@Injectable()
export class PaginationService {
private currentPageIndex: number;
private currentPageIndex: number;
public setCurrentIndex(currentPageIndex: number): void {
this.currentPageIndex = currentPageIndex;
}
public setCurrentIndex(currentPageIndex: number): void {
this.currentPageIndex = currentPageIndex;
}
public getCurrentIndex():number{
return this.currentPageIndex;
}
public getCurrentIndex(): number {
return this.currentPageIndex;
}
public isElementVisible(elementPage: number):boolean {
return elementPage == this.currentPageIndex ; //TODO
}
public isElementVisible(elementPage: number): boolean {
return elementPage === this.currentPageIndex; //TODO
}
}

View File

@ -2,68 +2,65 @@
import { ViewEncapsulation } from '@angular/core';
import { Component, Input, OnInit } from '@angular/core';
import { FormGroup, FormControl, FormArray } from '@angular/forms'
import { FormGroup, FormControl, FormArray } from '@angular/forms';
@Component({
selector: 'progress-bar',
templateUrl: './progress-bar.component.html',
styles: ['.alwaysVisible .ui-progressbar-label { display:block!important; }'],
encapsulation: ViewEncapsulation.None
selector: 'app-progress-bar',
templateUrl: './progress-bar.component.html',
styles: ['.alwaysVisible .ui-progressbar-label { display:block!important; }'],
encapsulation: ViewEncapsulation.None
})
export class ProgressBarComponent implements OnInit {
@Input() formGroup: FormGroup
@Input("progressValueAccuracy") public accuracy: number = 1;
determinateProgressValue: number;
@Input() formGroup: FormGroup;
@Input() public progressValueAccuracy = 1;
determinateProgressValue: number;
constructor(private visibilityRulesService: VisibilityRulesService) { }
constructor(private visibilityRulesService: VisibilityRulesService) { }
public value: number = 0;
ngOnInit() {
this.calculateValueForProgressbar()
this.formGroup
.valueChanges
.subscribe(control => {
this.calculateValueForProgressbar();
});
}
public value = 0;
ngOnInit() {
this.calculateValueForProgressbar();
this.formGroup
.valueChanges
.subscribe(control => {
this.calculateValueForProgressbar();
});
}
calculateValueForProgressbar() {
var progressSoFar = this.countFormControlsWithValue(this.formGroup);
var total = this.getFormControlDepthLength(this.formGroup);
var perc = (progressSoFar / total) * 100;
this.value = Number.parseFloat(perc.toPrecision(this.accuracy));
}
calculateValueForProgressbar() {
const progressSoFar = this.countFormControlsWithValue(this.formGroup);
const total = this.getFormControlDepthLength(this.formGroup);
const perc = (progressSoFar / total) * 100;
this.value = Number.parseFloat(perc.toPrecision(this.progressValueAccuracy));
}
countFormControlsWithValue(form: FormGroup): number {
let value = 0;
Object.keys(form.controls).forEach(key => {
let control = form.controls[key]
if (control instanceof FormGroup) value += this.countFormControlsWithValue(control);
else if (control instanceof FormArray) {
let formArray = (<FormArray>control);
for (let i = 0; i < formArray.length; i++) {
value += this.countFormControlsWithValue(<FormGroup>formArray.get("" + i))
}
}
else if (key === "value" && control.value != null && control.value != "") value++;
});
return value;
}
countFormControlsWithValue(form: FormGroup): number {
let value = 0;
Object.keys(form.controls).forEach(key => {
const control = form.controls[key];
if (control instanceof FormGroup) { value += this.countFormControlsWithValue(control); } else if (control instanceof FormArray) {
const formArray = (<FormArray>control);
for (let i = 0; i < formArray.length; i++) {
value += this.countFormControlsWithValue(<FormGroup>formArray.get('' + i));
}
} else if (key === 'value' && control.value != null && control.value !== '') { value++; }
});
return value;
}
getFormControlDepthLength(form: FormGroup): number {
let value = 0;
Object.keys(form.controls).forEach(key => {
let control = form.controls[key];
if (control instanceof FormGroup) { value += this.getFormControlDepthLength(control); }
else if (control instanceof FormArray) {
let formArray = (<FormArray>control);
for (let i = 0; i < formArray.length; i++) {
//if (<FormGroup>formArray.get("" + i).value && this.visibilityRulesService.isElementVisible(null, formArray.get("" + i).value.id))
//value += this.getFormControlDepthLength(<FormGroup>formArray.get("" + i))
}
}
//else if (key === "value" && this.visibilityRulesService.isElementVisible(null, form.controls["id"].value))
//value++;
});
return value;
}
getFormControlDepthLength(form: FormGroup): number {
let value = 0;
Object.keys(form.controls).forEach(key => {
const control = form.controls[key];
if (control instanceof FormGroup) { value += this.getFormControlDepthLength(control); } else if (control instanceof FormArray) {
const formArray = (<FormArray>control);
for (let i = 0; i < formArray.length; i++) {
//if (<FormGroup>formArray.get("" + i).value && this.visibilityRulesService.isElementVisible(null, formArray.get("" + i).value.id))
//value += this.getFormControlDepthLength(<FormGroup>formArray.get("" + i))
}
}
//else if (key === "value" && this.visibilityRulesService.isElementVisible(null, form.controls["id"].value))
//value++;
});
return value;
}
}

View File

@ -1,10 +1,10 @@
import { ActivatedRouteSnapshot, Router, ActivatedRoute } from '@angular/router';
export class BaseTableOfContent {
constructor(public router: Router, public route: ActivatedRoute) { }
constructor(public router: Router, public route: ActivatedRoute) { }
scrollToId(elementId, page: number) {
//this.paginationService.setCurrentIndex(page-1);
this.router.navigate([this.route.snapshot.url[0] + "/" + this.route.snapshot.url[1]], { fragment: elementId, queryParams: { page: page } });
}
scrollToId(elementId, page: number) {
//this.paginationService.setCurrentIndex(page-1);
this.router.navigate([this.route.snapshot.url[0] + '/' + this.route.snapshot.url[1]], { fragment: elementId, queryParams: { page: page } });
}
}

View File

@ -4,20 +4,20 @@ import { CompositeField } from '../../../models/CompositeField';
import { Field } from '../../../models/Field';
import { Section } from '../../../models/Section';
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router'
import { Router, ActivatedRoute } from '@angular/router';
@Component({
selector: 'table-of-contents-field',
templateUrl: './table-of-content-field.component.html',
providers: []
selector: 'app-table-of-contents-field',
templateUrl: './table-of-content-field.component.html',
providers: []
})
export class TableOfContentsFieldComponent extends BaseTableOfContent {
@Input() model: Field;
@Input() index: number;
@Input() public path: string;
@Input() public page: number;
constructor(public router: Router, public route: ActivatedRoute, private visibilityRulesService: VisibilityRulesService) {
super(router, route)
}
@Input() model: Field;
@Input() index: number;
@Input() public path: string;
@Input() public page: number;
constructor(public router: Router, public route: ActivatedRoute, private visibilityRulesService: VisibilityRulesService) {
super(router, route);
}
}

View File

@ -4,23 +4,23 @@ import { CompositeField } from '../../../models/CompositeField';
import { FieldGroup } from '../../../models/FieldGroup';
import { Section } from '../../../models/Section';
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router'
import { Router, ActivatedRoute } from '@angular/router';
//import * as $ from '../../../../node_modules/jquery/dist/jquery'
@Component({
selector: 'table-of-contents-fieldset',
templateUrl: './table-of-content-fieldset.component.html',
providers: []
selector: 'app-table-of-contents-fieldset',
templateUrl: './table-of-content-fieldset.component.html',
providers: []
})
export class TableOfContentsFieldSetComponent extends BaseTableOfContent {
@Input() model: CompositeField;
@Input() index: number;
@Input() public path: string;
@Input() public page: number;
constructor(public router: Router, public route: ActivatedRoute, private visibilityRulesService: VisibilityRulesService) {
super(router, route)
}
@Input() model: CompositeField;
@Input() index: number;
@Input() public path: string;
@Input() public page: number;
constructor(public router: Router, public route: ActivatedRoute, private visibilityRulesService: VisibilityRulesService) {
super(router, route);
}
}

View File

@ -3,28 +3,28 @@ import { BaseTableOfContent } from '../base-table-of-content.component';
import { FieldGroup } from '../../../models/FieldGroup';
import { Section } from '../../../models/Section';
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router'
import { Router, ActivatedRoute } from '@angular/router';
//import * as $ from '../../../../node_modules/jquery/dist/jquery'
@Component({
selector: 'table-of-contents-group',
templateUrl: './table-of-content-group.component.html',
providers: []
selector: 'app-table-of-contents-group',
templateUrl: './table-of-content-group.component.html',
providers: []
})
export class TableOfContentsGroupComponent extends BaseTableOfContent {
@Input() model: FieldGroup;
@Input() index: number;
@Input() public path: string;
@Input() public page: number;
/* @Output()
setPage:EventEmitter<number> = new EventEmitter<number>();
@Input() model: FieldGroup;
@Input() index: number;
@Input() public path: string;
@Input() public page: number;
/* @Output()
setPage:EventEmitter<number> = new EventEmitter<number>();
*/
constructor(public router: Router, public route: ActivatedRoute, private visibilityRulesService: VisibilityRulesService) {
super(router, route)
}
*/
constructor(public router: Router, public route: ActivatedRoute, private visibilityRulesService: VisibilityRulesService) {
super(router, route);
}
}

View File

@ -5,6 +5,6 @@
<!-- All contents in the first page -->
<ul>
<li *ngFor="let sectionModel of model.sections let i = index">
<table-of-contents-section [page]='page' [model]="sectionModel" [index]="i" [path]="path+'.'+(i+1)"> </table-of-contents-section>
<app-table-of-contents-section [page]='page' [model]="sectionModel" [index]="i" [path]="path+'.'+(i+1)"> </app-table-of-contents-section>
</li>
</ul>

View File

@ -8,21 +8,21 @@ import { ActivatedRouteSnapshot, Router, ActivatedRoute } from '@angular/router'
@Component({
selector: 'table-of-contents-section',
templateUrl: './table-of-content-section.component.html',
providers: []
selector: 'app-table-of-contents-section',
templateUrl: './table-of-content-section.component.html',
providers: []
})
export class TableOfContentsSectionComponent extends BaseTableOfContent implements OnInit {
@Input() model: Section;
@Input() index: number;
@Input() public path: string;
@Input() public page: number;
constructor(public router: Router, public route: ActivatedRoute, private visibilityRulesService: VisibilityRulesService) {
super(router, route)
}
ngOnInit() {
@Input() model: Section;
@Input() index: number;
@Input() public path: string;
@Input() public page: number;
constructor(public router: Router, public route: ActivatedRoute, private visibilityRulesService: VisibilityRulesService) {
super(router, route);
}
ngOnInit() {
}
}
}

View File

@ -2,6 +2,6 @@
<ul>
<li *ngFor="let section of model['sections'] let i = index">
<!-- && field.label for sections without field label as data summery -->
<table-of-contents-section [page]='section.page' [model]="section" [index]="i+1" [path]="i+1"> </table-of-contents-section>
<app-table-of-contents-section [page]='section.page' [model]="section" [index]="i+1" [path]="i+1"> </app-table-of-contents-section>
</li>
</ul>

View File

@ -6,21 +6,21 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
//import * as scroll from '../../../assets/jquery.scrollTo.min.js';
@Component({
selector: 'table-of-content',
templateUrl: './table-of-contents.component.html',
styleUrls: ['./toc.component.css'],
providers: []
selector: 'app-table-of-content',
templateUrl: './table-of-contents.component.html',
styleUrls: ['./toc.component.css'],
providers: []
})
export class TableOfContentsComponent implements OnInit {
@Input()
public model: DatasetProfileDefinitionModel;
public path: string = "";
@Input()
public model: DatasetProfileDefinitionModel;
public path = '';
/* @Output()
setPage:EventEmitter<number> = new EventEmitter<number>();
*/ ngOnInit() {
}
}
}

View File

@ -16,110 +16,110 @@ import { SearchBarItem } from '../models/dashboard/SearchBarItem';
import { SearchBarType } from '../shared/components/search-bar/types/search-bar-type';
@Component({
selector: 'homepage',
templateUrl: './homepage.component.html',
styleUrls: ['./homepage.component.scss'],
providers: [ProjectService, UserReferenceService]
selector: 'app-homepage',
templateUrl: './homepage.component.html',
styleUrls: ['./homepage.component.scss'],
providers: [ProjectService, UserReferenceService]
})
export class HomepageComponent implements OnInit {
public userInfo: any;
datasetActivities: any[];
projectActivities: any[];
dmpActivities: any[];
public dashboardStatisticsData: DashboardStatisticsModel = new DashboardStatisticsModel();
public formControl = new FormControl();
projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
public searchControl = new FormControl();
filteredOptions: Observable<SearchBarItem[]>;
RecentActivityTypes = RecentActivityTypes
public search = false;
public userInfo: any;
datasetActivities: any[];
projectActivities: any[];
dmpActivities: any[];
public dashboardStatisticsData: DashboardStatisticsModel = new DashboardStatisticsModel();
public formControl = new FormControl();
projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
public searchControl = new FormControl();
filteredOptions: Observable<SearchBarItem[]>;
RecentActivityTypes = RecentActivityTypes;
public search = false;
constructor(
private route: ActivatedRoute,
private router: Router,
private projectService: ProjectService,
private dashBoardService: DashboardService,
private authentication: AuthService,
private userReferenceService: UserReferenceService
constructor(
private route: ActivatedRoute,
private router: Router,
private projectService: ProjectService,
private dashBoardService: DashboardService,
private authentication: AuthService,
private userReferenceService: UserReferenceService
) {
this.dashboardStatisticsData.totalDataManagementPlanCount = 0;
this.dashboardStatisticsData.totalDataSetCount = 0;
this.dashboardStatisticsData.totalProjectCount = 0;
}
) {
this.dashboardStatisticsData.totalDataManagementPlanCount = 0;
this.dashboardStatisticsData.totalDataSetCount = 0;
this.dashboardStatisticsData.totalProjectCount = 0;
}
ngOnInit() {
ngOnInit() {
if (this.isAuthenticated()) {
this.userReferenceService.getRecentActivity().subscribe(response => {
this.datasetActivities = response["recentDatasetActivities"];
this.dmpActivities = response["recentDmpActivities"];
this.projectActivities = response["recentProjectActivities"];
})
}
if (this.isAuthenticated()) {
this.userReferenceService.getRecentActivity().subscribe(response => {
this.datasetActivities = response['recentDatasetActivities'];
this.dmpActivities = response['recentDmpActivities'];
this.projectActivities = response['recentProjectActivities'];
});
}
this.projectAutoCompleteConfiguration = {
filterFn: this.searchProject.bind(this),
items: this.searchProject(''),
displayFn: (item) => item["label"],
titleFn: (item) => item["label"],
//mapFn: (item) => new JsonSerializer<ProjectReference>().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()),
loadDataOnStart: true
};
this.projectAutoCompleteConfiguration = {
filterFn: this.searchProject.bind(this),
items: this.searchProject(''),
displayFn: (item) => item['label'],
titleFn: (item) => item['label'],
//mapFn: (item) => new JsonSerializer<ProjectReference>().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()),
loadDataOnStart: true
};
if (!this.isAuthenticated()) {
this.dashBoardService.getStatistics().subscribe(results => {
//let data = results['payload'];
this.dashboardStatisticsData = JsonSerializer.fromJSONObject(results, DashboardStatisticsModel);
})
} else {
this.dashBoardService.getStatisticsSpecificuser().subscribe(results => {
this.dashboardStatisticsData = JsonSerializer.fromJSONObject(results, DashboardStatisticsModel);
})
}
if (!this.isAuthenticated()) {
this.dashBoardService.getStatistics().subscribe(results => {
//let data = results['payload'];
this.dashboardStatisticsData = JsonSerializer.fromJSONObject(results, DashboardStatisticsModel);
});
} else {
this.dashBoardService.getStatisticsSpecificuser().subscribe(results => {
this.dashboardStatisticsData = JsonSerializer.fromJSONObject(results, DashboardStatisticsModel);
});
}
this.filteredOptions = this.searchControl.valueChanges.flatMap(x => {
return this.dashBoardService.searchUserItems(x);
})
this.filteredOptions = this.searchControl.valueChanges.flatMap(x => {
return this.dashBoardService.searchUserItems(x);
});
}
}
public isAuthenticated(): boolean {
return !(!this.authentication.current())
}
public isAuthenticated(): boolean {
return !(!this.authentication.current());
}
searchProject(query: string) {
let projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
projectRequestItem.criteria = new ProjectCriteria();
projectRequestItem.criteria.like = query;
return this.projectService.getWithExternal(projectRequestItem);
}
searchProject(query: string) {
const projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
projectRequestItem.criteria = new ProjectCriteria();
projectRequestItem.criteria.like = query;
return this.projectService.getWithExternal(projectRequestItem);
}
redirect(id: string, type: RecentActivityTypes) {
switch (type) {
case RecentActivityTypes.PROJECT: {
this.router.navigate(["projects/edit/" + id]);
return;
}
case RecentActivityTypes.DATASET: {
this.router.navigate(["datasets/edit/" + id]);
return;
}
case RecentActivityTypes.DMP: {
this.router.navigate(["dmps/edit/" + id]);
return;
}
default: throw new Error("Unsupported Activity Type ")
}
redirect(id: string, type: RecentActivityTypes) {
switch (type) {
case RecentActivityTypes.PROJECT: {
this.router.navigate(['projects/edit/' + id]);
return;
}
case RecentActivityTypes.DATASET: {
this.router.navigate(['datasets/edit/' + id]);
return;
}
case RecentActivityTypes.DMP: {
this.router.navigate(['dmps/edit/' + id]);
return;
}
default: throw new Error('Unsupported Activity Type ');
}
}
}
onOptionSelected(event: any) {
let selectedSearchBarItem = event.option.value;
if (selectedSearchBarItem.type == SearchBarType.DATASET) this.router.navigate(["datasets/edit/" + selectedSearchBarItem.id])
if (selectedSearchBarItem.type == SearchBarType.PROJECT) this.router.navigate(["projects/edit/" + selectedSearchBarItem.id])
if (selectedSearchBarItem.type == SearchBarType.DATAMANAGEMENTPLAN) this.router.navigate(["dmps/edit/" + selectedSearchBarItem.id])
}
onOptionSelected(event: any) {
const selectedSearchBarItem = event.option.value;
if (selectedSearchBarItem.type === SearchBarType.DATASET) { this.router.navigate(['datasets/edit/' + selectedSearchBarItem.id]); }
if (selectedSearchBarItem.type === SearchBarType.PROJECT) { this.router.navigate(['projects/edit/' + selectedSearchBarItem.id]); }
if (selectedSearchBarItem.type === SearchBarType.DATAMANAGEMENTPLAN) { this.router.navigate(['dmps/edit/' + selectedSearchBarItem.id]); }
}
}

View File

@ -1,4 +1,4 @@
import { FormBuilder } from '@angular/forms';
export abstract class BaseModel{
public formBuilder:FormBuilder = new FormBuilder();
export abstract class BaseModel {
public formBuilder: FormBuilder = new FormBuilder();
}

View File

@ -2,73 +2,73 @@ import { FormGroup } from '@angular/forms';
import { JsonSerializer } from '../utilities/JsonSerializer';
import { Serializable } from './interfaces/Serializable';
import { BaseModel } from './BaseModel';
import { Field } from './Field'
import { Field } from './Field';
import { Multiplicity } from './Multiplicity';
export class CompositeField extends BaseModel implements Serializable<CompositeField> {
public fields: Array<Field> = new Array<Field>();
public ordinal: number
public id: string
public multiplicity: Multiplicity;
public multiplicityItems: Array<CompositeField> = new Array<CompositeField>();
public title: string
public description: string
public extendedDescription: string
public hasCommentField: boolean;
public commentFieldValue: string;
public fields: Array<Field> = new Array<Field>();
public ordinal: number;
public id: string;
public multiplicity: Multiplicity;
public multiplicityItems: Array<CompositeField> = new Array<CompositeField>();
public title: string;
public description: string;
public extendedDescription: string;
public hasCommentField: boolean;
public commentFieldValue: string;
fromJSONObject(item: any): CompositeField {
fromJSONObject(item: any): CompositeField {
this.fields = JsonSerializer.fromJSONArray(item.fields, Field);
this.ordinal = item.ordinal;
this.id = item.id;
this.title = item.title;
this.description = item.description;
this.extendedDescription = item.extendedDescription;
this.hasCommentField = item.hasCommentField;
this.commentFieldValue = item.commentFieldValue;
this.multiplicity = JsonSerializer.fromJSONObject(item.multiplicity, Multiplicity);
//this.multiplicity = new Multiplicity();
//this.multiplicity.max = 2;
if(item.multiplicityItems)this.multiplicityItems = JsonSerializer.fromJSONArray(item.multiplicityItems, CompositeField);
return this;
}
this.fields = JsonSerializer.fromJSONArray(item.fields, Field);
this.ordinal = item.ordinal;
this.id = item.id;
this.title = item.title;
this.description = item.description;
this.extendedDescription = item.extendedDescription;
this.hasCommentField = item.hasCommentField;
this.commentFieldValue = item.commentFieldValue;
this.multiplicity = JsonSerializer.fromJSONObject(item.multiplicity, Multiplicity);
//this.multiplicity = new Multiplicity();
//this.multiplicity.max = 2;
if (item.multiplicityItems) {this.multiplicityItems = JsonSerializer.fromJSONArray(item.multiplicityItems, CompositeField); }
return this;
}
buildForm(): FormGroup {
let formGroup = this.formBuilder.group({
id: this.id,
ordinal: this.ordinal,
title: this.title,
description: this.description,
extendedDescription: this.extendedDescription,
hasCommentField: this.hasCommentField,
commentFieldValue: this.commentFieldValue
});
buildForm(): FormGroup {
const formGroup = this.formBuilder.group({
id: this.id,
ordinal: this.ordinal,
title: this.title,
description: this.description,
extendedDescription: this.extendedDescription,
hasCommentField: this.hasCommentField,
commentFieldValue: this.commentFieldValue
});
let fieldsFormArray = new Array<FormGroup>();
this.fields.forEach(item => {
let form: FormGroup = item.buildForm();
fieldsFormArray.push(form)
})
formGroup.addControl('fields', this.formBuilder.array(fieldsFormArray));
const fieldsFormArray = new Array<FormGroup>();
this.fields.forEach(item => {
const form: FormGroup = item.buildForm();
fieldsFormArray.push(form);
});
formGroup.addControl('fields', this.formBuilder.array(fieldsFormArray));
let multiplicityItemsFormArray = new Array<FormGroup>();
this.multiplicityItems.forEach(item => {
let form: FormGroup = item.buildForm();
multiplicityItemsFormArray.push(form)
})
formGroup.addControl('multiplicityItems', this.formBuilder.array(multiplicityItemsFormArray));
const multiplicityItemsFormArray = new Array<FormGroup>();
this.multiplicityItems.forEach(item => {
const form: FormGroup = item.buildForm();
multiplicityItemsFormArray.push(form);
});
formGroup.addControl('multiplicityItems', this.formBuilder.array(multiplicityItemsFormArray));
return formGroup;
}
return formGroup;
}
cloneForMultiplicity(index: number): CompositeField {
let newItem: CompositeField = new CompositeField();
newItem.id = 'multiple_' + this.id + '_' + index;
this.fields.forEach(field => {
newItem.fields.push(field.cloneForMultiplicity(this.fields.indexOf(field), newItem.id + "_"));
});
newItem.ordinal = this.ordinal;
cloneForMultiplicity(index: number): CompositeField {
const newItem: CompositeField = new CompositeField();
newItem.id = 'multiple_' + this.id + '_' + index;
this.fields.forEach(field => {
newItem.fields.push(field.cloneForMultiplicity(this.fields.indexOf(field), newItem.id + '_'));
});
newItem.ordinal = this.ordinal;
return newItem;
}
return newItem;
}
}

View File

@ -1,32 +1,32 @@
import { DataField } from './DataField';
import { FormGroup } from '@angular/forms'
import { FormGroup } from '@angular/forms';
import { ListingItem } from '../common/ListingItem';
import { JsonSerializer } from '../../utilities/JsonSerializer';
export class AutocompleteData extends DataField<AutocompleteData>{
export class AutocompleteData extends DataField<AutocompleteData> {
public type: string;
public url: string;
public optionsRoot: string;
public autoCompleteOptions: ListingItem = new ListingItem();
public type: string;
public url: string;
public optionsRoot: string;
public autoCompleteOptions: ListingItem = new ListingItem();
buildForm(): FormGroup {
let formGroup = this.formBuilder.group({
label: [this.label],
type: [this.type],
url: [this.url],
optionsRoot: [this.optionsRoot]
})
formGroup.addControl("autoCompleteOptions", this.autoCompleteOptions.buildForm());
return formGroup;
}
buildForm(): FormGroup {
const formGroup = this.formBuilder.group({
label: [this.label],
type: [this.type],
url: [this.url],
optionsRoot: [this.optionsRoot]
});
formGroup.addControl('autoCompleteOptions', this.autoCompleteOptions.buildForm());
return formGroup;
}
fromJSONObject(item: any): AutocompleteData {
this.type = item.type;
this.url = item.url;
this.label = item.label;
this.optionsRoot = item.optionsRoot;
this.autoCompleteOptions = JsonSerializer.fromJSONObject(item.autoCompleteOptions, ListingItem);
return this;
}
fromJSONObject(item: any): AutocompleteData {
this.type = item.type;
this.url = item.url;
this.label = item.label;
this.optionsRoot = item.optionsRoot;
this.autoCompleteOptions = JsonSerializer.fromJSONObject(item.autoCompleteOptions, ListingItem);
return this;
}
}

View File

@ -1,16 +1,16 @@
import { DataField } from './DataField';
import { FormGroup } from '@angular/forms';
export class BooleanDecisionData extends DataField<BooleanDecisionData>{
export class BooleanDecisionData extends DataField<BooleanDecisionData> {
buildForm():FormGroup{
let formGroup = this.formBuilder.group({
label:this.label
});
return formGroup;
}
buildForm(): FormGroup {
const formGroup = this.formBuilder.group({
label: this.label
});
return formGroup;
}
fromJSONObject(item:any):BooleanDecisionData{
this.label = item.label
return this;
}
fromJSONObject(item: any): BooleanDecisionData {
this.label = item.label;
return this;
}
}

View File

@ -1,16 +1,16 @@
import { DataField } from './DataField';
import { FormGroup } from '@angular/forms';
export class CheckBoxData extends DataField<CheckBoxData>{
export class CheckBoxData extends DataField<CheckBoxData> {
buildForm():FormGroup{
let formGroup = this.formBuilder.group({
label:this.label
});
return formGroup;
}
buildForm(): FormGroup {
const formGroup = this.formBuilder.group({
label: this.label
});
return formGroup;
}
fromJSONObject(item:any):CheckBoxData{
this.label = item.label
return this;
}
fromJSONObject(item: any): CheckBoxData {
this.label = item.label;
return this;
}
}

View File

@ -1,16 +1,16 @@
import { BaseModel } from '../BaseModel';
import { FormGenerator } from '../interfaces/FormGenerator';
import { Serializable } from '../interfaces/Serializable';
import { FormGroup } from '@angular/forms'
export abstract class DataField<T> extends BaseModel implements Serializable<T>,FormGenerator<FormGroup>{
public label:string;
import { FormGroup } from '@angular/forms';
export abstract class DataField<T> extends BaseModel implements Serializable<T>, FormGenerator<FormGroup> {
public label: string;
buildForm():FormGroup{
throw new Error("Build Form Is not not correctly overriden");
}
buildForm(): FormGroup {
throw new Error('Build Form Is not not correctly overriden');
}
fromJSONObject(item:any):T{
throw new Error("From Json Object is not correctly overriden")
}
fromJSONObject(item: any): T {
throw new Error('From Json Object is not correctly overriden');
}
}

View File

@ -1,16 +1,16 @@
import { DataField } from './DataField';
import { FormGroup } from '@angular/forms';
export class FreeTextData extends DataField<FreeTextData>{
export class FreeTextData extends DataField<FreeTextData> {
buildForm():FormGroup{
let formGroup = this.formBuilder.group({
label:this.label
});
return formGroup;
}
buildForm(): FormGroup {
const formGroup = this.formBuilder.group({
label: this.label
});
return formGroup;
}
fromJSONObject(item:any):FreeTextData{
this.label = item.label
return this;
}
fromJSONObject(item: any): FreeTextData {
this.label = item.label;
return this;
}
}

View File

@ -1,29 +1,29 @@
import { JsonSerializer } from '../../utilities/JsonSerializer';
import { DataField } from './DataField';
import { ListingItem } from '../common/ListingItem';
import { FormGroup } from '@angular/forms'
import { FormGroup } from '@angular/forms';
export class RadioBoxData extends DataField<RadioBoxData>{
public options: Array<ListingItem>;
export class RadioBoxData extends DataField<RadioBoxData> {
public options: Array<ListingItem>;
buildForm(): FormGroup {
let formGroup = this.formBuilder.group({
label: [this.label]
});
let optionsFormArray = new Array<FormGroup>();
if (this.options) {
this.options.forEach(item => {
let form: FormGroup = item.buildForm();
optionsFormArray.push(form)
})
}
formGroup.addControl('options', this.formBuilder.array(optionsFormArray));
return formGroup;
}
buildForm(): FormGroup {
const formGroup = this.formBuilder.group({
label: [this.label]
});
const optionsFormArray = new Array<FormGroup>();
if (this.options) {
this.options.forEach(item => {
const form: FormGroup = item.buildForm();
optionsFormArray.push(form);
});
}
formGroup.addControl('options', this.formBuilder.array(optionsFormArray));
return formGroup;
}
fromJSONObject(item: any): RadioBoxData {
this.options = JsonSerializer.fromJSONArray(item.options, ListingItem);
this.label = item.label
return this;
}
fromJSONObject(item: any): RadioBoxData {
this.options = JsonSerializer.fromJSONArray(item.options, ListingItem);
this.label = item.label;
return this;
}
}

View File

@ -1,16 +1,16 @@
import { DataField } from './DataField';
import { FormGroup } from '@angular/forms';
export class TextArea extends DataField<TextArea>{
export class TextArea extends DataField<TextArea> {
buildForm(): FormGroup {
let formGroup = this.formBuilder.group({
label: this.label
});
return formGroup;
}
buildForm(): FormGroup {
const formGroup = this.formBuilder.group({
label: this.label
});
return formGroup;
}
fromJSONObject(item: any): TextArea {
this.label = item.label
return this;
}
fromJSONObject(item: any): TextArea {
this.label = item.label;
return this;
}
}

View File

@ -1,32 +1,32 @@
import { JsonSerializer } from '../../utilities/JsonSerializer';
import { ListingItem } from '../common/ListingItem';
import { DataField } from './DataField';
import { FormGroup } from '@angular/forms'
import { FormGroup } from '@angular/forms';
export class WordListData extends DataField<WordListData>{
public type: string;
public options: Array<ListingItem>;
buildForm(): FormGroup {
let formGroup = this.formBuilder.group({
type: [this.type],
label: [this.label]
});
let optionsFormArray = new Array<FormGroup>();
if (this.options) {
this.options.forEach(item => {
let form: FormGroup = item.buildForm();
optionsFormArray.push(form)
})
}
formGroup.addControl('options', this.formBuilder.array(optionsFormArray));
export class WordListData extends DataField<WordListData> {
public type: string;
public options: Array<ListingItem>;
buildForm(): FormGroup {
const formGroup = this.formBuilder.group({
type: [this.type],
label: [this.label]
});
const optionsFormArray = new Array<FormGroup>();
if (this.options) {
this.options.forEach(item => {
const form: FormGroup = item.buildForm();
optionsFormArray.push(form);
});
}
formGroup.addControl('options', this.formBuilder.array(optionsFormArray));
return formGroup;
}
return formGroup;
}
fromJSONObject(item: any): WordListData {
this.type = item.type;
this.options = JsonSerializer.fromJSONArray(item.options, ListingItem);
this.label = item.label;
return this;
}
fromJSONObject(item: any): WordListData {
this.type = item.type;
this.options = JsonSerializer.fromJSONArray(item.options, ListingItem);
this.label = item.label;
return this;
}
}

View File

@ -6,35 +6,35 @@ import { JsonSerializer } from '../utilities/JsonSerializer';
import { Section } from './Section';
import { Serializable } from './interfaces/Serializable';
import { Page } from '../models/Page';
export class DatasetProfileDefinitionModel extends BaseModel implements Serializable<DatasetProfileDefinitionModel>, FormGenerator<FormGroup>{
public status: number
public pages: Array<Page>;
public rules: Rule[];
//public sections:Array<Section>
fromJSONObject(item: any): DatasetProfileDefinitionModel {
this.status = item.status;
//this.sections = JsonSerializer.fromJSONArray(item.sections,Section);
this.rules = JsonSerializer.fromJSONArray(item.rules, Rule);
this.pages = JsonSerializer.fromJSONArray(item.pages, Page);
return this;
}
export class DatasetProfileDefinitionModel extends BaseModel implements Serializable<DatasetProfileDefinitionModel>, FormGenerator<FormGroup> {
public status: number;
public pages: Array<Page>;
public rules: Rule[];
//public sections:Array<Section>
fromJSONObject(item: any): DatasetProfileDefinitionModel {
this.status = item.status;
//this.sections = JsonSerializer.fromJSONArray(item.sections,Section);
this.rules = JsonSerializer.fromJSONArray(item.rules, Rule);
this.pages = JsonSerializer.fromJSONArray(item.pages, Page);
return this;
}
buildForm(): FormGroup {
let formGroup: FormGroup = new FormBuilder().group({});
let pagesFormArray = new Array<FormGroup>();
// let sectionsFormArray = new Array<FormGroup>();
// this.pages.forEach (page => {
// page.sections.forEach(item => {
// let form: FormGroup = item.buildForm();
// sectionsFormArray.push(form)
// })
// })
this.pages.forEach(item => {
let form: FormGroup = item.buildForm();
pagesFormArray.push(form)
})
formGroup.addControl('pages', this.formBuilder.array(pagesFormArray));
return formGroup;
}
buildForm(): FormGroup {
const formGroup: FormGroup = new FormBuilder().group({});
const pagesFormArray = new Array<FormGroup>();
// let sectionsFormArray = new Array<FormGroup>();
// this.pages.forEach (page => {
// page.sections.forEach(item => {
// let form: FormGroup = item.buildForm();
// sectionsFormArray.push(form)
// })
// })
this.pages.forEach(item => {
const form: FormGroup = item.buildForm();
pagesFormArray.push(form);
});
formGroup.addControl('pages', this.formBuilder.array(pagesFormArray));
return formGroup;
}
}

View File

@ -3,22 +3,22 @@ import { FormGroup } from '@angular/forms';
import { FormGenerator } from './interfaces/FormGenerator';
import { Serializable } from './interfaces/Serializable';
export class DefaultValue extends BaseModel implements Serializable<DefaultValue>, FormGenerator<FormGroup>{
public type: string;
public value: string;
export class DefaultValue extends BaseModel implements Serializable<DefaultValue>, FormGenerator<FormGroup> {
public type: string;
public value: string;
fromJSONObject(item: any): DefaultValue {
this.type = item.type;
this.value = item.value;
return this;
}
fromJSONObject(item: any): DefaultValue {
this.type = item.type;
this.value = item.value;
return this;
}
buildForm(): FormGroup {
let formGroup = this.formBuilder.group({
type: [this.type],
value: [this.value]
buildForm(): FormGroup {
const formGroup = this.formBuilder.group({
type: [this.type],
value: [this.value]
});
return formGroup;
}
});
return formGroup;
}
}

View File

@ -8,91 +8,92 @@ import { DefaultValue } from './DefaultValue';
import { ValidationTypes } from '../models/common/ValidationTypes';
import { ViewStyle } from './datasetProfileAdmin/ViewStyle';
export class Field extends BaseModel implements Serializable<Field>, FormGenerator<FormGroup>{
export class Field extends BaseModel implements Serializable<Field>, FormGenerator<FormGroup> {
public id: string;
public title: string;
public value: any;
public defaultValue: DefaultValue;
public description: string;
public extendedDescription: string;
public viewStyle: ViewStyle;
public defaultVisibility: boolean;
public page: number;
public multiplicity: Multiplicity;
public multiplicityItems: Array<Field> = new Array<Field>();
public data: any;
public validations: Array<any>;//Array<ValidationTypes>
public validationRequired = false;
public id: string;
public title: string;
public value: any;
public defaultValue: DefaultValue;
public description: string;
public extendedDescription: string;
public viewStyle: ViewStyle;
public defaultVisibility: boolean;
public page: number;
public multiplicity: Multiplicity;
public multiplicityItems: Array<Field> = new Array<Field>();
public data: any;
public validations: Array<any>; //Array<ValidationTypes>
public validationRequired = false;
fromJSONObject(item: any): Field {
this.id = item.id;
this.title = item.title;
//this.value = item.value;
this.description = item.description;
this.extendedDescription = item.extendedDescription;
this.viewStyle = item.viewStyle;
this.defaultVisibility = item.defaultVisibility;
this.page = item.page;
this.validations = item.validations;
this.multiplicity = JsonSerializer.fromJSONObject(item.multiplicity, Multiplicity);
this.defaultValue = JsonSerializer.fromJSONObject(item.defaultValue, DefaultValue);
this.value = this.defaultValue.value && !item.value ? this.defaultValue.value : item.value;
//this.multiplicity = new Multiplicity();
if (this.viewStyle.renderStyle === "checkBox") {
this.value = this.value === 'true';
}
//this.multiplicity.max = 2;
if (item.multiplicityItems) this.multiplicityItems = JsonSerializer.fromJSONArray(item.multiplicityItems, Field);
this.data = item.data;
return this;
}
fromJSONObject(item: any): Field {
this.id = item.id;
this.title = item.title;
//this.value = item.value;
this.description = item.description;
this.extendedDescription = item.extendedDescription;
this.viewStyle = item.viewStyle;
this.defaultVisibility = item.defaultVisibility;
this.page = item.page;
this.validations = item.validations;
this.multiplicity = JsonSerializer.fromJSONObject(item.multiplicity, Multiplicity);
this.defaultValue = JsonSerializer.fromJSONObject(item.defaultValue, DefaultValue);
this.value = this.defaultValue.value && !item.value ? this.defaultValue.value : item.value;
//this.multiplicity = new Multiplicity();
if (this.viewStyle.renderStyle === 'checkBox') {
this.value = this.value === 'true';
}
//this.multiplicity.max = 2;
if (item.multiplicityItems) { this.multiplicityItems = JsonSerializer.fromJSONArray(item.multiplicityItems, Field); }
this.data = item.data;
return this;
}
buildForm(): FormGroup {
if (this.validations)
this.validations.forEach(validation => {
if (validation == ValidationTypes.Required) this.validationRequired = true;
});
buildForm(): FormGroup {
if (this.validations) {
this.validations.forEach(validation => {
if (validation === ValidationTypes.Required) { this.validationRequired = true; }
});
}
let formGroup = this.formBuilder.group({
id: [this.id],
data: [this.data],
/* title: [this.title], */
value: [this.value, this.validationRequired == true ? Validators.required : null]/* ,
const formGroup = this.formBuilder.group({
id: [this.id],
data: [this.data],
/* title: [this.title], */
value: [this.value, this.validationRequired === true ? Validators.required : null]/* ,
description: [this.description],
extendedDescription:[this.extendedDescription],
viewStyle: [this.viewStyle],
defaultVisibility:[this.defaultVisibility],
page:[this.page],
data:[this.data] */
});
});
let multiplicityItemsFormArray = new Array<FormGroup>();
this.multiplicityItems.forEach(item => {
let form: FormGroup = item.buildForm();
multiplicityItemsFormArray.push(form)
})
formGroup.addControl('multiplicityItems', this.formBuilder.array(multiplicityItemsFormArray));
const multiplicityItemsFormArray = new Array<FormGroup>();
this.multiplicityItems.forEach(item => {
const form: FormGroup = item.buildForm();
multiplicityItemsFormArray.push(form);
});
formGroup.addControl('multiplicityItems', this.formBuilder.array(multiplicityItemsFormArray));
return formGroup;
}
return formGroup;
}
cloneForMultiplicity(index: number, idPath: string): Field {
let newItem: Field = new Field();
cloneForMultiplicity(index: number, idPath: string): Field {
const newItem: Field = new Field();
newItem.id = idPath ? idPath + index : 'multiple_' + this.id + '_' + index;
newItem.title = this.title;
newItem.description = this.description;
newItem.extendedDescription = this.extendedDescription;
newItem.viewStyle = this.viewStyle;
newItem.defaultVisibility = this.defaultVisibility;
newItem.page = this.page;
newItem.multiplicity = null;
newItem.data = this.data;
newItem.id = idPath ? idPath + index : 'multiple_' + this.id + '_' + index;
newItem.title = this.title;
newItem.description = this.description;
newItem.extendedDescription = this.extendedDescription;
newItem.viewStyle = this.viewStyle;
newItem.defaultVisibility = this.defaultVisibility;
newItem.page = this.page;
newItem.multiplicity = null;
newItem.data = this.data;
return newItem;
}
return newItem;
}
}

View File

@ -8,48 +8,48 @@ import { JsonSerializer } from '../utilities/JsonSerializer';
import { Serializable } from './interfaces/Serializable';
import { Field } from './Field';
export class FieldGroup extends BaseModel implements Serializable<FieldGroup>, FormGenerator<FormGroup>{
public id: string;
public title: string;
public section: string;
public value: string;
public description: string;
public extendedDescription: string;
public defaultVisibility: boolean;
public page: number;
public compositeFields: Array<CompositeField> = new Array<CompositeField>();
export class FieldGroup extends BaseModel implements Serializable<FieldGroup>, FormGenerator<FormGroup> {
public id: string;
public title: string;
public section: string;
public value: string;
public description: string;
public extendedDescription: string;
public defaultVisibility: boolean;
public page: number;
public compositeFields: Array<CompositeField> = new Array<CompositeField>();
fromJSONObject(item: any): FieldGroup {
this.id = item.id;
this.title = item.title;
this.value = item.value;
this.description = item.description;
this.extendedDescription = item.extendedDescription;
this.defaultVisibility = item.defaultVisibility;
this.page = item.page;
this.compositeFields = JsonSerializer.fromJSONArray(item.compositeFields, CompositeField);
return this;
}
fromJSONObject(item: any): FieldGroup {
this.id = item.id;
this.title = item.title;
this.value = item.value;
this.description = item.description;
this.extendedDescription = item.extendedDescription;
this.defaultVisibility = item.defaultVisibility;
this.page = item.page;
this.compositeFields = JsonSerializer.fromJSONArray(item.compositeFields, CompositeField);
return this;
}
buildForm(): FormGroup {
let formGroup: FormGroup = this.formBuilder.group({
/* id: [this.id],
buildForm(): FormGroup {
const formGroup: FormGroup = this.formBuilder.group({
/* id: [this.id],
title: [this.title],
value: [this.value],
description: [this.description],
extendedDescription: [this.extendedDescription],
defaultVisibility: [this.defaultVisibility],
page: [this.page] */
});
let compositeFieldsFormArray = new Array<FormGroup>();
if (this.compositeFields) {
this.compositeFields.forEach(item => {
let form: FormGroup = item.buildForm();
compositeFieldsFormArray.push(form)
})
}
formGroup.addControl('compositeFields', this.formBuilder.array(compositeFieldsFormArray));
});
const compositeFieldsFormArray = new Array<FormGroup>();
if (this.compositeFields) {
this.compositeFields.forEach(item => {
const form: FormGroup = item.buildForm();
compositeFieldsFormArray.push(form);
});
}
formGroup.addControl('compositeFields', this.formBuilder.array(compositeFieldsFormArray));
return formGroup;
}
return formGroup;
}
}

View File

@ -2,22 +2,22 @@ import { BaseModel } from './BaseModel';
import { FormGroup } from '@angular/forms';
import { FormGenerator } from './interfaces/FormGenerator';
import { Serializable } from './interfaces/Serializable';
export class Multiplicity extends BaseModel implements Serializable<Multiplicity>, FormGenerator<FormGroup>{
public min: number;
public max: number;
export class Multiplicity extends BaseModel implements Serializable<Multiplicity>, FormGenerator<FormGroup> {
public min: number;
public max: number;
fromJSONObject(item: any): Multiplicity {
this.min = item.min;
this.max = item.max;
return this;
}
fromJSONObject(item: any): Multiplicity {
this.min = item.min;
this.max = item.max;
return this;
}
buildForm(): FormGroup {
let formGroup = this.formBuilder.group({
min: [this.min],
max: [this.max]
buildForm(): FormGroup {
const formGroup = this.formBuilder.group({
min: [this.min],
max: [this.max]
});
return formGroup;
}
});
return formGroup;
}
}

View File

@ -1,4 +1,4 @@
import { Section } from "../models/Section";
import { Section } from '../models/Section';
import { BaseModel } from './BaseModel';
import { FormGenerator } from './interfaces/FormGenerator';
import { Serializable } from './interfaces/Serializable';
@ -6,25 +6,25 @@ import { JsonSerializer } from '../utilities/JsonSerializer';
import { FormBuilder, FormGroup } from '@angular/forms';
export class Page extends BaseModel implements Serializable<Page> {
public ordinal: number;
public title: string;
public sections: Array<Section>;
public ordinal: number;
public title: string;
public sections: Array<Section>;
fromJSONObject(item: any): Page {
this.ordinal = item.ordinal;
this.title = item.title;
this.sections = JsonSerializer.fromJSONArray(item.sections, Section);
return this;
}
fromJSONObject(item: any): Page {
this.ordinal = item.ordinal;
this.title = item.title;
this.sections = JsonSerializer.fromJSONArray(item.sections, Section);
return this;
}
buildForm(): FormGroup {
let formGroup: FormGroup = new FormBuilder().group({});
let sectionsFormArray = new Array<FormGroup>();
this.sections.forEach(item => {
let form: FormGroup = item.buildForm();
sectionsFormArray.push(form)
})
formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray));
return formGroup;
}
buildForm(): FormGroup {
const formGroup: FormGroup = new FormBuilder().group({});
const sectionsFormArray = new Array<FormGroup>();
this.sections.forEach(item => {
const form: FormGroup = item.buildForm();
sectionsFormArray.push(form);
});
formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray));
return formGroup;
}
}

View File

@ -2,17 +2,17 @@ import { BaseModel } from './BaseModel';
import { FormGroup } from '@angular/forms';
import { FormGenerator } from './interfaces/FormGenerator';
import { Serializable } from './interfaces/Serializable';
export class Rule extends BaseModel implements Serializable<Rule>{
public sourceField:string;
public targetField:string;
public requiredValue;
public type: string;
export class Rule extends BaseModel implements Serializable<Rule> {
public sourceField: string;
public targetField: string;
public requiredValue;
public type: string;
fromJSONObject(item:any):Rule{
this.sourceField = item.sourceField;
this.targetField = item.targetField;
this.requiredValue = item.requiredValue;
this.type = item.type;
return this;
}
fromJSONObject(item: any): Rule {
this.sourceField = item.sourceField;
this.targetField = item.targetField;
this.requiredValue = item.requiredValue;
this.type = item.type;
return this;
}
}

View File

@ -6,61 +6,61 @@ import { Serializable } from './interfaces/Serializable';
import { FieldGroup } from './FieldGroup';
import { CompositeField } from './CompositeField';
export class Section extends BaseModel implements Serializable<Section>, FormGenerator<FormGroup>{
public sections: Array<Section> = new Array<Section>();
//public fieldGroups: Array<FieldGroup>;
public defaultVisibility: boolean;
public page: number;
public ordinal: number;
public id: string
public title: string
public description: string;
public compositeFields: Array<CompositeField> = new Array<CompositeField>();
export class Section extends BaseModel implements Serializable<Section>, FormGenerator<FormGroup> {
public sections: Array<Section> = new Array<Section>();
//public fieldGroups: Array<FieldGroup>;
public defaultVisibility: boolean;
public page: number;
public ordinal: number;
public id: string;
public title: string;
public description: string;
public compositeFields: Array<CompositeField> = new Array<CompositeField>();
fromJSONObject(item: any): Section {
this.sections = JsonSerializer.fromJSONArray(item.sections, Section);
//this.fieldGroups = new JsonSerializer<FieldGroup>().fromJSONArray(item.fieldGroups, FieldGroup);
this.page = item.page;
this.defaultVisibility = item.defaultVisibility;
this.id = item.id;
this.title = item.title;
this.ordinal = item.ordinal;
this.description = item.description;
this.compositeFields = JsonSerializer.fromJSONArray(item.compositeFields, CompositeField);
return this;
}
fromJSONObject(item: any): Section {
this.sections = JsonSerializer.fromJSONArray(item.sections, Section);
//this.fieldGroups = new JsonSerializer<FieldGroup>().fromJSONArray(item.fieldGroups, FieldGroup);
this.page = item.page;
this.defaultVisibility = item.defaultVisibility;
this.id = item.id;
this.title = item.title;
this.ordinal = item.ordinal;
this.description = item.description;
this.compositeFields = JsonSerializer.fromJSONArray(item.compositeFields, CompositeField);
return this;
}
buildForm(): FormGroup {
let formGroup: FormGroup = new FormBuilder().group({});
let sectionsFormArray = new Array<FormGroup>();
if (this.sections) {
this.sections.forEach(item => {
let form: FormGroup = item.buildForm();
sectionsFormArray.push(form)
})
}
let fieldGroupsFormArray = new Array<FormGroup>();
// if (this.fieldGroups) {
// this.fieldGroups.forEach(item => {
// let form: FormGroup = item.buildForm();
// fieldGroupsFormArray.push(form)
// })
// }
let compositeFieldsFormArray = new Array<FormGroup>();
if (this.compositeFields) {
this.compositeFields.forEach(item => {
let form: FormGroup = item.buildForm();
compositeFieldsFormArray.push(form)
})
}
formGroup.addControl('compositeFields', this.formBuilder.array(compositeFieldsFormArray));
formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray));
// formGroup.addControl('fieldGroups', this.formBuilder.array(fieldGroupsFormArray));
/* formGroup.addControl('defaultVisibility', new FormControl(this.defaultVisibility))
formGroup.addControl('page', new FormControl(this.page))
formGroup.addControl('id', new FormControl(this.id))
formGroup.addControl('title', new FormControl(this.title))
formGroup.addControl('description', new FormControl(this.description)) */
return formGroup;
}
buildForm(): FormGroup {
const formGroup: FormGroup = new FormBuilder().group({});
const sectionsFormArray = new Array<FormGroup>();
if (this.sections) {
this.sections.forEach(item => {
const form: FormGroup = item.buildForm();
sectionsFormArray.push(form);
});
}
const fieldGroupsFormArray = new Array<FormGroup>();
// if (this.fieldGroups) {
// this.fieldGroups.forEach(item => {
// let form: FormGroup = item.buildForm();
// fieldGroupsFormArray.push(form)
// })
// }
const compositeFieldsFormArray = new Array<FormGroup>();
if (this.compositeFields) {
this.compositeFields.forEach(item => {
const form: FormGroup = item.buildForm();
compositeFieldsFormArray.push(form);
});
}
formGroup.addControl('compositeFields', this.formBuilder.array(compositeFieldsFormArray));
formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray));
// formGroup.addControl('fieldGroups', this.formBuilder.array(fieldGroupsFormArray));
/* formGroup.addControl('defaultVisibility', new FormControl(this.defaultVisibility))
formGroup.addControl('page', new FormControl(this.page))
formGroup.addControl('id', new FormControl(this.id))
formGroup.addControl('title', new FormControl(this.title))
formGroup.addControl('description', new FormControl(this.description)) */
return formGroup;
}
}

View File

@ -1,4 +1,4 @@
export enum Status {
Active = 0,
Inactive = 1
Active = 0,
Inactive = 1
}

View File

@ -2,20 +2,20 @@ import { BaseModel } from './BaseModel';
import { FormGroup } from '@angular/forms';
import { FormGenerator } from './interfaces/FormGenerator';
import { Serializable } from './interfaces/Serializable';
export class Validation extends BaseModel implements Serializable<Validation>,FormGenerator<FormGroup>{
public type:string;
public value:string;
export class Validation extends BaseModel implements Serializable<Validation>, FormGenerator<FormGroup> {
public type: string;
public value: string;
fromJSONObject(item:any):Validation{
this.type = item.type;
this.value = item.value;
return this;
}
fromJSONObject(item: any): Validation {
this.type = item.type;
this.value = item.value;
return this;
}
buildForm():FormGroup{
return this.formBuilder.group({
type: [this.type],
value: [this.value],
});
}
buildForm(): FormGroup {
return this.formBuilder.group({
type: [this.type],
value: [this.value],
});
}
}

View File

@ -1,4 +1,4 @@
import { BaseCriteria } from "../criteria/BaseCriteria";
import { BaseCriteria } from '../criteria/BaseCriteria';
export class AutocompleteLookupItem extends BaseCriteria {
public profileID: String;

Some files were not shown because too many files have changed in this diff Show More