Fixed Formatting in files
This commit is contained in:
parent
6ace88ecda
commit
510384cdb7
|
@ -1,51 +1,51 @@
|
||||||
import { BaseHttpService } from "../utilities/cite-http-service-module/base-http.service";
|
import { BaseHttpService } from '../utilities/cite-http-service-module/base-http.service';
|
||||||
import { HttpClient, HttpClientModule } from "@angular/common/http";
|
import { HttpClient, HttpClientModule } from '@angular/common/http';
|
||||||
import { TranslateLoader } from "@ngx-translate/core";
|
import { TranslateLoader } from '@ngx-translate/core';
|
||||||
import { TranslateModule } from "@ngx-translate/core";
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { SharedModule } from "../shared/shared.module";
|
import { SharedModule } from '../shared/shared.module';
|
||||||
import { FormsModule } from "@angular/forms";
|
import { FormsModule } from '@angular/forms';
|
||||||
import { CommonModule } from "@angular/common";
|
import { CommonModule } from '@angular/common';
|
||||||
import { NgModule } from "@angular/core";
|
import { NgModule } from '@angular/core';
|
||||||
import { TranslateService } from "@ngx-translate/core";
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { TranslateHttpLoader } from "@ngx-translate/http-loader";
|
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
|
||||||
import { AboutRoutes } from "./about.routes";
|
import { AboutRoutes } from './about.routes';
|
||||||
import { AboutComponent } from "./components/about.component";
|
import { AboutComponent } from './components/about.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
SharedModule,
|
SharedModule,
|
||||||
HttpClientModule,
|
HttpClientModule,
|
||||||
AboutRoutes,
|
AboutRoutes,
|
||||||
TranslateModule.forRoot({
|
TranslateModule.forRoot({
|
||||||
loader: {
|
loader: {
|
||||||
provide: TranslateLoader,
|
provide: TranslateLoader,
|
||||||
useFactory: HttpLoaderFactory,
|
useFactory: HttpLoaderFactory,
|
||||||
deps: [HttpClient]
|
deps: [HttpClient]
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|
||||||
declarations: [
|
declarations: [
|
||||||
AboutComponent
|
AboutComponent
|
||||||
],
|
],
|
||||||
|
|
||||||
exports: [
|
exports: [
|
||||||
AboutComponent
|
AboutComponent
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
BaseHttpService
|
BaseHttpService
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
export class AboutModule {
|
export class AboutModule {
|
||||||
constructor(private translate: TranslateService) {
|
constructor(private translate: TranslateService) {
|
||||||
translate.setDefaultLang('en');
|
translate.setDefaultLang('en');
|
||||||
translate.use('en');
|
translate.use('en');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function HttpLoaderFactory(httpClient: HttpClient) {
|
export function HttpLoaderFactory(httpClient: HttpClient) {
|
||||||
return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json');
|
return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { AboutComponent } from "./components/about.component";
|
import { AboutComponent } from './components/about.component';
|
||||||
import { Routes, RouterModule } from "@angular/router";
|
import { Routes, RouterModule } from '@angular/router';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: '', component: AboutComponent },
|
{ path: '', component: AboutComponent },
|
||||||
];
|
];
|
||||||
|
|
||||||
export const AboutRoutes = RouterModule.forChild(routes);
|
export const AboutRoutes = RouterModule.forChild(routes);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Component, ViewEncapsulation, OnInit } from "@angular/core";
|
import { Component, ViewEncapsulation, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from "@angular/router";
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { TranslateService } from "@ngx-translate/core";
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-about',
|
selector: 'app-about',
|
||||||
|
|
|
@ -31,7 +31,7 @@ const appRoutes: Routes = [
|
||||||
canActivate: [AuthGuard]
|
canActivate: [AuthGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "dmps",
|
path: 'dmps',
|
||||||
loadChildren: './dmps/dmps.module#DataManagementPlanModule',
|
loadChildren: './dmps/dmps.module#DataManagementPlanModule',
|
||||||
data: {
|
data: {
|
||||||
breadcrumb: true
|
breadcrumb: true
|
||||||
|
@ -39,7 +39,7 @@ const appRoutes: Routes = [
|
||||||
canActivate: [AuthGuard]
|
canActivate: [AuthGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "dmp-profiles",
|
path: 'dmp-profiles',
|
||||||
loadChildren: './dmp-profiles/dmp-profile.module#DataManagamentPlanProfileModule',
|
loadChildren: './dmp-profiles/dmp-profile.module#DataManagamentPlanProfileModule',
|
||||||
data: {
|
data: {
|
||||||
breadcrumb: true
|
breadcrumb: true
|
||||||
|
@ -71,32 +71,32 @@ const appRoutes: Routes = [
|
||||||
pathMatch: 'full'
|
pathMatch: 'full'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "unauthorized",
|
path: 'unauthorized',
|
||||||
loadChildren: './unauthorized/unauthorized.module#UnauthorizedModule',
|
loadChildren: './unauthorized/unauthorized.module#UnauthorizedModule',
|
||||||
data: {
|
data: {
|
||||||
breadcrumb: true
|
breadcrumb: true
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "users",
|
path: 'users',
|
||||||
loadChildren: './users/users.module#UsersModule'
|
loadChildren: './users/users.module#UsersModule'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "datasetsProfiles",
|
path: 'datasetsProfiles',
|
||||||
loadChildren: './datasets-admin-listing/dataset-admin.module#DatasetAdminModule',
|
loadChildren: './datasets-admin-listing/dataset-admin.module#DatasetAdminModule',
|
||||||
data: {
|
data: {
|
||||||
breadcrumb: true
|
breadcrumb: true
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "welcome",
|
path: 'welcome',
|
||||||
component: WelcomepageComponent,
|
component: WelcomepageComponent,
|
||||||
data: {
|
data: {
|
||||||
breadcrumb: false
|
breadcrumb: false
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "api/oauth/authorized/b2access",
|
path: 'api/oauth/authorized/b2access',
|
||||||
component: B2AccessLoginComponent,
|
component: B2AccessLoginComponent,
|
||||||
data: {
|
data: {
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
<app-navigation class="fixed"></app-navigation>
|
<app-navigation class="fixed"></app-navigation>
|
||||||
|
|
||||||
<div class="container-fluid main-container">
|
<div class="container-fluid main-container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<help-content position="top"></help-content>
|
<app-help-content position="top"></app-help-content>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-2">
|
<div class="col-md-2">
|
||||||
<help-content position="left"></help-content>
|
<app-help-content position="left"></app-help-content>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
<app-breadcrumb *ngIf="this.isAuthenticated() && (hasBreadCrumb | async)"></app-breadcrumb>
|
<app-breadcrumb *ngIf="this.isAuthenticated() && (hasBreadCrumb | async)"></app-breadcrumb>
|
||||||
<router-outlet (activate)='onActivate($event)' (deactivate)='onDeactivate($event)'></router-outlet>
|
<router-outlet (activate)='onActivate($event)' (deactivate)='onDeactivate($event)'></router-outlet>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2">
|
<div class="col-md-2">
|
||||||
<help-content position="right"></help-content>
|
<app-help-content position="right"></app-help-content>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<help-content position="bottom"></help-content>
|
<app-help-content position="bottom"></app-help-content>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -13,74 +13,74 @@ declare const gapi: any;
|
||||||
|
|
||||||
declare var $: any;
|
declare var $: any;
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
templateUrl: './app.component.html',
|
templateUrl: './app.component.html',
|
||||||
styleUrls: ['./app.component.scss'],
|
styleUrls: ['./app.component.scss'],
|
||||||
providers: [],
|
providers: [],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class AppComponent implements OnInit {
|
export class AppComponent implements OnInit {
|
||||||
|
|
||||||
hasBreadCrumb = Observable.of(false);
|
hasBreadCrumb = Observable.of(false);
|
||||||
sideNavOpen = false;
|
sideNavOpen = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private authentication: AuthService,
|
private authentication: AuthService,
|
||||||
private translate: TranslateService,
|
private translate: TranslateService,
|
||||||
private languageService: LanguageResolverService,
|
private languageService: LanguageResolverService,
|
||||||
private breadCrumbResolverService: BreadCrumbResolverService,
|
private breadCrumbResolverService: BreadCrumbResolverService,
|
||||||
private cultureService: CultureService
|
private cultureService: CultureService
|
||||||
) {
|
) {
|
||||||
this.initializeServices()
|
this.initializeServices();
|
||||||
}
|
}
|
||||||
|
|
||||||
onActivate(event: any) {
|
onActivate(event: any) {
|
||||||
this.breadCrumbResolverService.push(event)
|
this.breadCrumbResolverService.push(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
onDeactivate(event: any) {
|
onDeactivate(event: any) {
|
||||||
//this.breadCrumbResolverService.clear()
|
//this.breadCrumbResolverService.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.hasBreadCrumb = this.router.events
|
this.hasBreadCrumb = this.router.events
|
||||||
.filter(event => event instanceof NavigationEnd)
|
.filter(event => event instanceof NavigationEnd)
|
||||||
.map(() => this.route)
|
.map(() => this.route)
|
||||||
.map(route => route.firstChild)
|
.map(route => route.firstChild)
|
||||||
.switchMap(route => route.data)
|
.switchMap(route => route.data)
|
||||||
.map(data => data['breadcrumb'])
|
.map(data => data['breadcrumb']);
|
||||||
}
|
}
|
||||||
|
|
||||||
login() {
|
login() {
|
||||||
//redirect to login page
|
//redirect to login page
|
||||||
this.router.navigate(['/login'], { queryParams: { /*refresh : Math.random() ,returnUrl: this.state.url*/ } });
|
this.router.navigate(['/login'], { queryParams: { /*refresh : Math.random() ,returnUrl: this.state.url*/ } });
|
||||||
}
|
}
|
||||||
|
|
||||||
logout() {
|
logout() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public isAuthenticated(): boolean {
|
public isAuthenticated(): boolean {
|
||||||
return !(!this.authentication.current())
|
return !(!this.authentication.current());
|
||||||
}
|
}
|
||||||
|
|
||||||
goToDMPs() {
|
goToDMPs() {
|
||||||
this.router.navigate(['/dmps'], { queryParams: { /*refresh : Math.random() ,returnUrl: this.state.url*/ } });
|
this.router.navigate(['/dmps'], { queryParams: { /*refresh : Math.random() ,returnUrl: this.state.url*/ } });
|
||||||
}
|
}
|
||||||
|
|
||||||
goToProjects() {
|
goToProjects() {
|
||||||
this.router.navigate(['/projects'], { queryParams: { /*refresh : Math.random() ,returnUrl: this.state.url*/ } });
|
this.router.navigate(['/projects'], { queryParams: { /*refresh : Math.random() ,returnUrl: this.state.url*/ } });
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeServices() {
|
initializeServices() {
|
||||||
// this language will be used as a fallback when a translation isn't found in the current language
|
// this language will be used as a fallback when a translation isn't found in the current language
|
||||||
this.translate.setDefaultLang('en');
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,4 +4,4 @@ export const HostConfiguration = {
|
||||||
App: environment.App,
|
App: environment.App,
|
||||||
CacheLifeTimeMillis: 30000,
|
CacheLifeTimeMillis: 30000,
|
||||||
HelpServiceUrl: environment.HelpServiceUrl
|
HelpServiceUrl: environment.HelpServiceUrl
|
||||||
}
|
};
|
||||||
|
|
|
@ -106,18 +106,18 @@ import { CultureService } from './utilities/culture/culture-service';
|
||||||
HelpContentService,
|
HelpContentService,
|
||||||
LanguageService,
|
LanguageService,
|
||||||
LanguageResolverService,
|
LanguageResolverService,
|
||||||
BreadCrumbResolverService,
|
BreadCrumbResolverService,
|
||||||
CultureService,
|
CultureService,
|
||||||
{
|
{
|
||||||
provide: MAT_DATE_LOCALE,
|
provide: MAT_DATE_LOCALE,
|
||||||
deps: [CultureService],
|
deps: [CultureService],
|
||||||
useFactory: (cultureService) => cultureService.getCurrentCulture()
|
useFactory: (cultureService) => cultureService.getCurrentCulture()
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: LOCALE_ID,
|
provide: LOCALE_ID,
|
||||||
deps: [CultureService],
|
deps: [CultureService],
|
||||||
useFactory: (cultureService) => cultureService.getCurrentCulture()
|
useFactory: (cultureService) => cultureService.getCurrentCulture()
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
bootstrap: [AppComponent]
|
bootstrap: [AppComponent]
|
||||||
})
|
})
|
||||||
|
|
|
@ -57,8 +57,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<field-form *ngIf="!isComposite" [form]="form.get('fields').get(''+0)" [dataModel]="dataModel.fields[0]" [showMultiplicity]="false"
|
<app-field-form *ngIf="!isComposite" [form]="form.get('fields').get(''+0)" [dataModel]="dataModel.fields[0]" [showMultiplicity]="false"
|
||||||
[indexPath]="indexPath + 'f' + 0"></field-form>
|
[indexPath]="indexPath + 'f' + 0"></app-field-form>
|
||||||
|
|
||||||
<div *ngIf="isComposite">
|
<div *ngIf="isComposite">
|
||||||
<mat-expansion-panel *ngFor="let field of dataModel.fields let i=index;" #panel>
|
<mat-expansion-panel *ngFor="let field of dataModel.fields let i=index;" #panel>
|
||||||
|
@ -71,7 +71,7 @@
|
||||||
</div>
|
</div>
|
||||||
</mat-expansion-panel-header>
|
</mat-expansion-panel-header>
|
||||||
<div id="{{indexPath + 'f' + i}}" *ngIf="panel.expanded">
|
<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>
|
</div>
|
||||||
</mat-expansion-panel>
|
</mat-expansion-panel>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,57 +1,59 @@
|
||||||
import { Component, Input } from '@angular/core';
|
import { Component, Input, OnInit } from '@angular/core';
|
||||||
import { FormGroup } from '@angular/forms';
|
import { FormGroup } from '@angular/forms';
|
||||||
import { FormArray, FormControl } from '@angular/forms';
|
import { FormArray, FormControl } from '@angular/forms';
|
||||||
import { FieldSet } from '../../models/datasetProfileAdmin/FieldSet';
|
import { FieldSet } from '../../models/datasetProfileAdmin/FieldSet';
|
||||||
import { Field } from '../../models/datasetProfileAdmin/Field';
|
import { Field } from '../../models/datasetProfileAdmin/Field';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'compositefield-form',
|
selector: 'app-compositefield-form',
|
||||||
templateUrl: './compositefield-form.component.html',
|
templateUrl: './compositefield-form.component.html',
|
||||||
styleUrls: ['./compositefield-form.component.scss']
|
styleUrls: ['./compositefield-form.component.scss']
|
||||||
})
|
})
|
||||||
|
|
||||||
export class CompositeFieldFormComponent {
|
export class CompositeFieldFormComponent implements OnInit {
|
||||||
@Input() form: FormGroup;
|
@Input() form: FormGroup;
|
||||||
@Input() dataModel: FieldSet;
|
@Input() dataModel: FieldSet;
|
||||||
@Input() indexPath: string;
|
@Input() indexPath: string;
|
||||||
|
|
||||||
isComposite: boolean = false;
|
isComposite = false;
|
||||||
isMultiplicityEnabled: boolean = false;
|
isMultiplicityEnabled = false;
|
||||||
|
|
||||||
constructon() { }
|
constructon() { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
//this.addNewField();
|
//this.addNewField();
|
||||||
if (this.form.get("multiplicity"))
|
if (this.form.get('multiplicity')) {
|
||||||
if (this.form.get("multiplicity").value.min > 1 || this.form.get("multiplicity").value.max > 1)
|
if (this.form.get('multiplicity').value.min > 1 || this.form.get('multiplicity').value.max > 1) {
|
||||||
this.isMultiplicityEnabled = true;
|
this.isMultiplicityEnabled = true;
|
||||||
this.isComposite = this.dataModel.fields.length > 1;
|
}
|
||||||
}
|
}
|
||||||
|
this.isComposite = this.dataModel.fields.length > 1;
|
||||||
|
}
|
||||||
|
|
||||||
onIsCompositeChange(isComposite: boolean) {
|
onIsCompositeChange(isComposite: boolean) {
|
||||||
if (!isComposite && (<FormArray>this.form.get("fields")).length > 1) {
|
if (!isComposite && (<FormArray>this.form.get('fields')).length > 1) {
|
||||||
for (let i = 0; i < (<FormArray>this.form.get("fields")).length - 1; i++) {
|
for (let i = 0; i < (<FormArray>this.form.get('fields')).length - 1; i++) {
|
||||||
(<FormArray>this.form.get("fields")).removeAt(1);
|
(<FormArray>this.form.get('fields')).removeAt(1);
|
||||||
}
|
}
|
||||||
this.dataModel.fields.splice(1);
|
this.dataModel.fields.splice(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onIsMultiplicityEnabledChange(isMultiplicityEnabled: boolean) {
|
onIsMultiplicityEnabledChange(isMultiplicityEnabled: boolean) {
|
||||||
if (!isMultiplicityEnabled) {
|
if (!isMultiplicityEnabled) {
|
||||||
(<FormControl>this.form.get('multiplicity').get("min")).setValue(0);
|
(<FormControl>this.form.get('multiplicity').get('min')).setValue(0);
|
||||||
(<FormControl>this.form.get('multiplicity').get("max")).setValue(0);
|
(<FormControl>this.form.get('multiplicity').get('max')).setValue(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addNewField() {
|
addNewField() {
|
||||||
let field: Field = new Field();
|
const field: Field = new Field();
|
||||||
this.dataModel.fields.push(field);
|
this.dataModel.fields.push(field);
|
||||||
(<FormArray>this.form.get("fields")).push(field.buildForm());
|
(<FormArray>this.form.get('fields')).push(field.buildForm());
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteField(index) {
|
DeleteField(index) {
|
||||||
this.dataModel.fields.splice(index, 1);
|
this.dataModel.fields.splice(index, 1);
|
||||||
(<FormArray>this.form.get("fields")).removeAt(index);
|
(<FormArray>this.form.get('fields')).removeAt(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import { RouterModule, Routes } from '@angular/router';
|
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 = [
|
export const DatasetProfileRoutes: Routes = [
|
||||||
{
|
{
|
||||||
path: ':id',
|
path: ':id',
|
||||||
component: FormComponent
|
component: FormComponent
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
component: FormComponent
|
component: FormComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
|
@ -64,22 +64,22 @@
|
||||||
|
|
||||||
<div fxLayout="row" fxLayoutAlign="start center" [ngSwitch]="form.get('viewStyle').get('renderStyle').value">
|
<div fxLayout="row" fxLayoutAlign="start center" [ngSwitch]="form.get('viewStyle').get('renderStyle').value">
|
||||||
<div class="full-width" *ngSwitchCase="'combobox'">
|
<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>
|
||||||
<div class="full-width" *ngSwitchCase="'radiobox'">
|
<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>
|
||||||
<div class="full-width" *ngSwitchCase="'freetext'">
|
<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>
|
||||||
<div class="full-width" *ngSwitchCase="'textarea'">
|
<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>
|
||||||
<div class="full-width" *ngSwitchCase="'booleanDecision'">
|
<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>
|
||||||
<div class="full-width" *ngSwitchCase="'checkBox'">
|
<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>
|
||||||
</div>
|
</div>
|
||||||
<mat-checkbox *ngIf="showMultiplicity" [(ngModel)]="isFieldMultiplicityEnabled" (ngModelChange)="onIsFieldMultiplicityEnabledChange(isFieldMultiplicityEnabled)">Multiplicity</mat-checkbox>
|
<mat-checkbox *ngIf="showMultiplicity" [(ngModel)]="isFieldMultiplicityEnabled" (ngModelChange)="onIsFieldMultiplicityEnabledChange(isFieldMultiplicityEnabled)">Multiplicity</mat-checkbox>
|
||||||
|
@ -99,7 +99,7 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</mat-expansion-panel-header>
|
</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>
|
</mat-expansion-panel>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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 { FormGroup, FormControl, FormArray } from '@angular/forms';
|
||||||
import { ValidationTypes } from '../../models/common/ValidationTypes';
|
import { ValidationTypes } from '../../models/common/ValidationTypes';
|
||||||
import { Field } from '../../models/datasetProfileAdmin/Field';
|
import { Field } from '../../models/datasetProfileAdmin/Field';
|
||||||
import { Rule } from '../../models/datasetProfileAdmin/Rule';
|
import { Rule } from '../../models/datasetProfileAdmin/Rule';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'field-form',
|
selector: 'app-field-form',
|
||||||
templateUrl: './field-form.component.html',
|
templateUrl: './field-form.component.html',
|
||||||
styleUrls: ['./field-form.component.scss']
|
styleUrls: ['./field-form.component.scss']
|
||||||
})
|
})
|
||||||
|
|
||||||
export class FieldFormComponent {
|
export class FieldFormComponent implements OnInit {
|
||||||
@Input() form: FormGroup;
|
@Input() form: FormGroup;
|
||||||
@Input() dataModel: Field;
|
@Input() dataModel: Field;
|
||||||
@Input() showMultiplicity: boolean = true;
|
@Input() showMultiplicity = true;
|
||||||
@Input() indexPath: string;
|
@Input() indexPath: string;
|
||||||
validationsOptions: Array<any>;
|
validationsOptions: Array<any>;
|
||||||
isFieldMultiplicityEnabled: boolean = false;
|
isFieldMultiplicityEnabled = false;
|
||||||
|
|
||||||
constructon() {
|
constructon() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (this.form.get("multiplicity"))
|
if (this.form.get('multiplicity')) {
|
||||||
if (this.form.get("multiplicity").value.min > 1 || this.form.get("multiplicity").value.max > 1)
|
if (this.form.get('multiplicity').value.min > 1 || this.form.get('multiplicity').value.max > 1) {
|
||||||
this.isFieldMultiplicityEnabled = true;
|
this.isFieldMultiplicityEnabled = true;
|
||||||
this.validationsOptions = [{ key: 0, value: ValidationTypes[0] }, { key: 1, value: ValidationTypes[1] }]
|
}
|
||||||
// this.addNewRule();
|
}
|
||||||
}
|
this.validationsOptions = [{ key: 0, value: ValidationTypes[0] }, { key: 1, value: ValidationTypes[1] }];
|
||||||
|
// this.addNewRule();
|
||||||
|
}
|
||||||
|
|
||||||
onIsFieldMultiplicityEnabledChange(isFieldMultiplicityEnabled: boolean) {
|
onIsFieldMultiplicityEnabledChange(isFieldMultiplicityEnabled: boolean) {
|
||||||
if (!isFieldMultiplicityEnabled) {
|
if (!isFieldMultiplicityEnabled) {
|
||||||
(<FormControl>this.form.get('multiplicity').get("min")).setValue(0);
|
(<FormControl>this.form.get('multiplicity').get('min')).setValue(0);
|
||||||
(<FormControl>this.form.get('multiplicity').get("max")).setValue(0);
|
(<FormControl>this.form.get('multiplicity').get('max')).setValue(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addNewRule() {
|
addNewRule() {
|
||||||
let rule: Rule = new Rule();
|
const rule: Rule = new Rule();
|
||||||
this.dataModel.visible.rules.push(rule);
|
this.dataModel.visible.rules.push(rule);
|
||||||
(<FormArray>this.form.get("visible").get("rules")).push(rule.buildForm());
|
(<FormArray>this.form.get('visible').get('rules')).push(rule.buildForm());
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteRule(index) {
|
DeleteRule(index) {
|
||||||
this.dataModel.visible.rules.splice(index, 1);
|
this.dataModel.visible.rules.splice(index, 1);
|
||||||
(<FormArray>this.form.get("visible").get("rules")).removeAt(index);
|
(<FormArray>this.form.get('visible').get('rules')).removeAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
onchangeCombo() {
|
onchangeCombo() {
|
||||||
if (this.form.get("data")) this.form.removeControl("data");
|
if (this.form.get('data')) { this.form.removeControl('data'); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
</mat-expansion-panel-header>
|
</mat-expansion-panel-header>
|
||||||
<div id="{{'p' + i}}" *ngIf="panel.expanded">
|
<div id="{{'p' + i}}" *ngIf="panel.expanded">
|
||||||
<div>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
</mat-expansion-panel>
|
</mat-expansion-panel>
|
||||||
|
@ -56,7 +56,7 @@
|
||||||
</mat-expansion-panel-header>
|
</mat-expansion-panel-header>
|
||||||
<div id="{{'s' + i}}" *ngIf="panel.expanded">
|
<div id="{{'s' + i}}" *ngIf="panel.expanded">
|
||||||
<div>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
</mat-expansion-panel>
|
</mat-expansion-panel>
|
||||||
|
|
|
@ -4,108 +4,108 @@ import { DatasetProfileModelAdmin } from '../../models/datasetProfileAdmin/Datas
|
||||||
import { Page } from '../../models/datasetProfileAdmin/Page';
|
import { Page } from '../../models/datasetProfileAdmin/Page';
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { FormGroup, FormControl } from '@angular/forms';
|
import { FormGroup, FormControl } from '@angular/forms';
|
||||||
import { SectionFormComponent } from '../section-form/section-form.component';
|
|
||||||
import { FormArray } from '@angular/forms';
|
import { FormArray } from '@angular/forms';
|
||||||
import { Router, ActivatedRoute, ParamMap, Params } from '@angular/router';
|
import { Router, ActivatedRoute } from '@angular/router';
|
||||||
import { PageFormComponent } from '../page-form/page-component'
|
|
||||||
import { DatasetProfileAdmin } from '../../services/datasetProfileAdmin/datasetProfileAfmin.service';
|
import { DatasetProfileAdmin } from '../../services/datasetProfileAdmin/datasetProfileAfmin.service';
|
||||||
import { Section } from '../../models/datasetProfileAdmin/Section';
|
import { Section } from '../../models/datasetProfileAdmin/Section';
|
||||||
import { MatDialog } from '@angular/material';
|
import { MatDialog } from '@angular/material';
|
||||||
import { DatasetProfilePreviewerComponent } from '../previewer/dataset-profile-previewer.component';
|
import { DatasetProfilePreviewerComponent } from '../previewer/dataset-profile-previewer.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'form-comp',
|
selector: 'app-form-comp',
|
||||||
templateUrl: './form.component.html',
|
templateUrl: './form.component.html',
|
||||||
providers: [DatasetProfileAdmin, DatasetProfileService],
|
providers: [DatasetProfileAdmin, DatasetProfileService],
|
||||||
styleUrls: ['./form.component.scss']
|
styleUrls: ['./form.component.scss']
|
||||||
})
|
})
|
||||||
|
|
||||||
export class FormComponent {
|
export class FormComponent implements OnInit {
|
||||||
|
|
||||||
dataModel: DatasetProfileModelAdmin;
|
dataModel: DatasetProfileModelAdmin;
|
||||||
form: FormGroup;
|
form: FormGroup;
|
||||||
private profileID: string;
|
private profileID: string;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public datasetprofileAdmin: DatasetProfileAdmin,
|
public datasetprofileAdmin: DatasetProfileAdmin,
|
||||||
private datasetProfileService: DatasetProfileService,
|
private datasetProfileService: DatasetProfileService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
public dialog: MatDialog,
|
public dialog: MatDialog,
|
||||||
) {
|
) {
|
||||||
this.profileID = route.snapshot.params['id'];
|
this.profileID = route.snapshot.params['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
this.dataModel = JsonSerializer.fromJSONObject(new DatasetProfileModelAdmin(), DatasetProfileModelAdmin);
|
this.dataModel = JsonSerializer.fromJSONObject(new DatasetProfileModelAdmin(), DatasetProfileModelAdmin);
|
||||||
this.form = this.dataModel.buildForm();
|
this.form = this.dataModel.buildForm();
|
||||||
if (this.profileID) {
|
if (this.profileID) {
|
||||||
this.datasetProfileService.getDatasetProfileById(this.profileID).subscribe((data) => {
|
this.datasetProfileService.getDatasetProfileById(this.profileID).subscribe((data) => {
|
||||||
this.dataModel = JsonSerializer.fromJSONObject(data, DatasetProfileModelAdmin);
|
this.dataModel = JsonSerializer.fromJSONObject(data, DatasetProfileModelAdmin);
|
||||||
this.form = this.dataModel.buildForm();
|
this.form = this.dataModel.buildForm();
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
this.addSection();
|
||||||
this.addSection();
|
this.addPage();
|
||||||
this.addPage();
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
onIsMultiplicityEnabledChange(isMultiplicityEnabled: boolean) {
|
onIsMultiplicityEnabledChange(isMultiplicityEnabled: boolean) {
|
||||||
if (!isMultiplicityEnabled) {
|
if (!isMultiplicityEnabled) {
|
||||||
(<FormControl>this.form.get('multiplicity').get("min")).setValue(0);
|
(<FormControl>this.form.get('multiplicity').get('min')).setValue(0);
|
||||||
(<FormControl>this.form.get('multiplicity').get("max")).setValue(0);
|
(<FormControl>this.form.get('multiplicity').get('max')).setValue(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addSection() {
|
addSection() {
|
||||||
let section: Section = new Section();
|
const section: Section = new Section();
|
||||||
this.dataModel.sections.push(section);
|
this.dataModel.sections.push(section);
|
||||||
(<FormArray>this.form.get("sections")).push(section.buildForm());
|
(<FormArray>this.form.get('sections')).push(section.buildForm());
|
||||||
}
|
}
|
||||||
|
|
||||||
addPage() {
|
addPage() {
|
||||||
let page: Page = new Page(this.dataModel.pages.length);
|
const page: Page = new Page(this.dataModel.pages.length);
|
||||||
this.dataModel.pages.push(page);
|
this.dataModel.pages.push(page);
|
||||||
(<FormArray>this.form.get("pages")).push(page.buildForm());
|
(<FormArray>this.form.get('pages')).push(page.buildForm());
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteSection(index) {
|
DeleteSection(index) {
|
||||||
this.dataModel.sections.splice(index, 1);
|
this.dataModel.sections.splice(index, 1);
|
||||||
(<FormArray>this.form.get("sections")).removeAt(index)
|
(<FormArray>this.form.get('sections')).removeAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeletePage(index) {
|
DeletePage(index) {
|
||||||
this.dataModel.pages.splice(index, 1);
|
this.dataModel.pages.splice(index, 1);
|
||||||
(<FormArray>this.form.get("pages")).removeAt(index)
|
(<FormArray>this.form.get('pages')).removeAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
createForm(data) {
|
createForm(data) {
|
||||||
return this.datasetprofileAdmin.createForm(data);
|
return this.datasetprofileAdmin.createForm(data);
|
||||||
}
|
}
|
||||||
updateForm(id, data) {
|
updateForm(id, data) {
|
||||||
return this.datasetprofileAdmin.updateForm(id, data);
|
return this.datasetprofileAdmin.updateForm(id, data);
|
||||||
}
|
}
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
let data = this.form.value;
|
const data = this.form.value;
|
||||||
|
|
||||||
if (this.profileID) this.updateForm(this.profileID, data).subscribe(() => {
|
if (this.profileID) {
|
||||||
this.router.navigate(['/datasetsProfiles'])
|
this.updateForm(this.profileID, data).subscribe(() => {
|
||||||
});
|
this.router.navigate(['/datasetsProfiles']);
|
||||||
else this.createForm(data).subscribe(() => {
|
});
|
||||||
this.router.navigate(['/datasetsProfiles'])
|
} else {
|
||||||
});
|
this.createForm(data).subscribe(() => {
|
||||||
}
|
this.router.navigate(['/datasetsProfiles']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
preview() {
|
preview() {
|
||||||
let dialogRef = this.dialog.open(DatasetProfilePreviewerComponent, {
|
const dialogRef = this.dialog.open(DatasetProfilePreviewerComponent, {
|
||||||
height: '355px',
|
height: '355px',
|
||||||
width: '700px',
|
width: '700px',
|
||||||
data: {
|
data: {
|
||||||
model: this.dataModel
|
model: this.dataModel
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
||||||
import { FormGroup } from '@angular/forms'
|
import { FormGroup } from '@angular/forms';
|
||||||
import { Page } from '../../models/datasetProfileAdmin/Page';
|
import { Page } from '../../models/datasetProfileAdmin/Page';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'page-form',
|
selector: 'app-page-form',
|
||||||
templateUrl: './page-component.html',
|
templateUrl: './page-component.html',
|
||||||
styleUrls: ['./page-component.scss']
|
styleUrls: ['./page-component.scss']
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
<dynamic-form *ngIf="formGroup" [form]="this.formGroup"
|
<app-dynamic-form *ngIf="formGroup" [form]="this.formGroup"
|
||||||
[dataModel]="datasetWizardModel"></dynamic-form>
|
[dataModel]="datasetWizardModel"></app-dynamic-form>
|
||||||
|
|
|
@ -1,36 +1,36 @@
|
||||||
import { ViewEncapsulation, Component, Inject } from "@angular/core";
|
import { ViewEncapsulation, Component, Inject, OnInit } from '@angular/core';
|
||||||
import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material";
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
|
||||||
import { FormGroup } from "@angular/forms";
|
import { FormGroup } from '@angular/forms';
|
||||||
import { DatasetProfileDefinitionModel } from "../../models/DatasetProfileDefinitionModel";
|
import { DatasetProfileDefinitionModel } from '../../models/DatasetProfileDefinitionModel';
|
||||||
import { JsonSerializer } from "../../utilities/JsonSerializer";
|
import { JsonSerializer } from '../../utilities/JsonSerializer';
|
||||||
import { DatasetModel } from "../../models/datasets/DatasetModel";
|
import { DatasetModel } from '../../models/datasets/DatasetModel';
|
||||||
import { DatasetWizardModel } from "../../models/datasets/DatasetWizardModel";
|
import { DatasetWizardModel } from '../../models/datasets/DatasetWizardModel';
|
||||||
import { DatasetProfileService } from "../../services/dataset-profile.service";
|
import { DatasetProfileService } from '../../services/dataset-profile.service';
|
||||||
import { DatasetProfileAdmin } from "../../services/datasetProfileAdmin/datasetProfileAfmin.service";
|
import { DatasetProfileAdmin } from '../../services/datasetProfileAdmin/datasetProfileAfmin.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'dataset-profile-previewer',
|
selector: 'app-dataset-profile-previewer',
|
||||||
templateUrl: './dataset-profile-previewer.component.html',
|
templateUrl: './dataset-profile-previewer.component.html',
|
||||||
styleUrls: ['./dataset-profile-previewer.component.scss'],
|
styleUrls: ['./dataset-profile-previewer.component.scss'],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
|
|
||||||
export class DatasetProfilePreviewerComponent {
|
export class DatasetProfilePreviewerComponent implements OnInit {
|
||||||
formGroup: FormGroup
|
formGroup: FormGroup;
|
||||||
datasetWizardModel: DatasetWizardModel
|
datasetWizardModel: DatasetWizardModel;
|
||||||
constructor(
|
constructor(
|
||||||
private datasetProfileAdminService: DatasetProfileAdmin,
|
private datasetProfileAdminService: DatasetProfileAdmin,
|
||||||
public dialogRef: MatDialogRef<DatasetProfilePreviewerComponent>,
|
public dialogRef: MatDialogRef<DatasetProfilePreviewerComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: any
|
@Inject(MAT_DIALOG_DATA) public data: any
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|
||||||
this.datasetProfileAdminService.preview(this.data['model']).subscribe(x => {
|
this.datasetProfileAdminService.preview(this.data['model']).subscribe(x => {
|
||||||
this.datasetWizardModel = new DatasetWizardModel();
|
this.datasetWizardModel = new DatasetWizardModel();
|
||||||
this.datasetWizardModel.datasetProfileDefinition = JsonSerializer.fromJSONObject(x, DatasetProfileDefinitionModel)
|
this.datasetWizardModel.datasetProfileDefinition = JsonSerializer.fromJSONObject(x, DatasetProfileDefinitionModel);
|
||||||
this.formGroup = this.datasetWizardModel.buildForm();
|
this.formGroup = this.datasetWizardModel.buildForm();
|
||||||
})
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
</div>
|
</div>
|
||||||
</mat-expansion-panel-header>
|
</mat-expansion-panel-header>
|
||||||
<div id="{{indexPath + 's' + i}}" *ngIf="panel.expanded">
|
<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>
|
</div>
|
||||||
</mat-expansion-panel>
|
</mat-expansion-panel>
|
||||||
</div>
|
</div>
|
||||||
|
@ -92,7 +92,7 @@
|
||||||
</div>
|
</div>
|
||||||
</mat-expansion-panel-header>
|
</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>
|
</mat-expansion-panel>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -9,54 +9,56 @@ import { Page } from '../../models/datasetProfileAdmin/Page';
|
||||||
import { JsonSerializer } from '../../utilities/JsonSerializer';
|
import { JsonSerializer } from '../../utilities/JsonSerializer';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'section-form',
|
selector: 'app-section-form',
|
||||||
templateUrl: './section-form.component.html',
|
templateUrl: './section-form.component.html',
|
||||||
styleUrls: ['./section-form.component.scss'],
|
styleUrls: ['./section-form.component.scss'],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
|
|
||||||
export class SectionFormComponent {
|
export class SectionFormComponent implements OnInit {
|
||||||
@Input() form: FormGroup;
|
@Input() form: FormGroup;
|
||||||
@Input() dataModel: Section;
|
@Input() dataModel: Section;
|
||||||
@Input() indexPath: string;
|
@Input() indexPath: string;
|
||||||
|
|
||||||
constructor() { }
|
constructor() { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.form.root.get("pages").valueChanges.subscribe(x =>
|
this.form.root.get('pages').valueChanges.subscribe(x =>
|
||||||
this.keepPageSelectionValid(x)
|
this.keepPageSelectionValid(x)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
addField() {
|
addField() {
|
||||||
let fieldSet: FieldSet = new FieldSet();
|
const fieldSet: FieldSet = new FieldSet();
|
||||||
let field: Field = new Field();
|
const field: Field = new Field();
|
||||||
fieldSet.fields.push(field);
|
fieldSet.fields.push(field);
|
||||||
if (this.dataModel.fieldSets)
|
if (this.dataModel.fieldSets) {
|
||||||
this.dataModel.fieldSets.push(fieldSet);
|
this.dataModel.fieldSets.push(fieldSet);
|
||||||
(<FormArray>this.form.get("fieldSets")).push(fieldSet.buildForm());
|
}
|
||||||
}
|
(<FormArray>this.form.get('fieldSets')).push(fieldSet.buildForm());
|
||||||
|
}
|
||||||
|
|
||||||
addSectioninSection() {
|
addSectioninSection() {
|
||||||
let section: Section = new Section();
|
const section: Section = new Section();
|
||||||
this.dataModel.sections.push(section);
|
this.dataModel.sections.push(section);
|
||||||
(<FormArray>this.form.get("sections")).push(section.buildForm());
|
(<FormArray>this.form.get('sections')).push(section.buildForm());
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteSectionInSection(index) {
|
DeleteSectionInSection(index) {
|
||||||
this.dataModel.sections.splice(index);
|
this.dataModel.sections.splice(index);
|
||||||
(<FormArray>this.form.get("sections")).removeAt(index);
|
(<FormArray>this.form.get('sections')).removeAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteFieldSet(index) {
|
DeleteFieldSet(index) {
|
||||||
this.dataModel.fieldSets.splice(index, 1);
|
this.dataModel.fieldSets.splice(index, 1);
|
||||||
(<FormArray>this.form.get("fieldSets")).removeAt(index);
|
(<FormArray>this.form.get('fieldSets')).removeAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
keepPageSelectionValid(pagesJson: Array<any>) {
|
keepPageSelectionValid(pagesJson: Array<any>) {
|
||||||
let selectedPage = this.form.get("page").value as String;
|
const selectedPage = this.form.get('page').value as String;
|
||||||
let pages: Array<Page> = JsonSerializer.fromJSONArray(pagesJson, Page);
|
const pages: Array<Page> = JsonSerializer.fromJSONArray(pagesJson, Page);
|
||||||
if (pages.find(elem => elem.id === selectedPage) === undefined)
|
if (pages.find(elem => elem.id === selectedPage) === undefined) {
|
||||||
this.form.get("page").reset();
|
this.form.get('page').reset();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,156 +1,156 @@
|
||||||
import { DataTableRequest } from '../models/data-table/DataTableRequest';
|
import { DataTableRequest } from '../models/data-table/DataTableRequest';
|
||||||
import { DatasetListingModel } from '../models/datasets/DatasetListingModel';
|
import { DatasetListingModel } from '../models/datasets/DatasetListingModel';
|
||||||
import { DatasetCriteria } from '../models/criteria/dataset/DatasetCriteria';
|
import { DatasetCriteria } from '../models/criteria/dataset/DatasetCriteria';
|
||||||
import { Component, ViewChild, OnInit, AfterViewInit } from "@angular/core";
|
import { Component, ViewChild, OnInit, AfterViewInit } from '@angular/core';
|
||||||
import { MatPaginator, MatSort, MatSnackBar } from "@angular/material";
|
import { MatPaginator, MatSort, MatSnackBar } from '@angular/material';
|
||||||
import { Router, Params, ActivatedRoute } from "@angular/router";
|
import { Router, Params, ActivatedRoute } from '@angular/router';
|
||||||
import { TranslateService } from "@ngx-translate/core";
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { DataSource } from "@angular/cdk/table";
|
import { DataSource } from '@angular/cdk/table';
|
||||||
|
|
||||||
import { Observable } from "rxjs/Observable";
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { PageEvent } from '@angular/material';
|
import { PageEvent } from '@angular/material';
|
||||||
import { DataManagementPlanService } from "../services/data-management-plan/data-management-plan.service";
|
import { DataManagementPlanService } from '../services/data-management-plan/data-management-plan.service';
|
||||||
import { DataManagementPlanModel } from "../models/data-managemnt-plans/DataManagementPlanModel";
|
import { DataManagementPlanModel } from '../models/data-managemnt-plans/DataManagementPlanModel';
|
||||||
import { DatasetCriteriaComponent } from '../shared/components/criteria/datasets/datasets-criteria.component';
|
import { DatasetCriteriaComponent } from '../shared/components/criteria/datasets/datasets-criteria.component';
|
||||||
import { DatasetProfileAdmin } from '../services/datasetProfileAdmin/datasetProfileAfmin.service';
|
import { DatasetProfileAdmin } from '../services/datasetProfileAdmin/datasetProfileAfmin.service';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dataset-admin-listing-component',
|
selector: 'app-dataset-admin-listing-component',
|
||||||
templateUrl: 'dataset-admin-listing.component.html',
|
templateUrl: 'dataset-admin-listing.component.html',
|
||||||
styleUrls: ['./dataset-admin-listing.component.scss'],
|
styleUrls: ['./dataset-admin-listing.component.scss'],
|
||||||
providers: [DatasetProfileAdmin, DataManagementPlanService]
|
providers: [DatasetProfileAdmin, DataManagementPlanService]
|
||||||
})
|
})
|
||||||
export class DatasetAdminListingComponent implements OnInit {
|
export class DatasetAdminListingComponent implements OnInit {
|
||||||
|
|
||||||
@ViewChild(MatPaginator) _paginator: MatPaginator;
|
@ViewChild(MatPaginator) _paginator: MatPaginator;
|
||||||
@ViewChild(MatSort) sort: MatSort;
|
@ViewChild(MatSort) sort: MatSort;
|
||||||
@ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent;
|
@ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent;
|
||||||
|
|
||||||
|
|
||||||
dataSource: DatasetDataSource | null;
|
dataSource: DatasetDataSource | null;
|
||||||
displayedColumns: String[] = ['label', 'dmp', 'profile', 'dataRepositories', 'registries', 'services', 'description', 'created', 'actions'];
|
displayedColumns: String[] = ['label', 'dmp', 'profile', 'dataRepositories', 'registries', 'services', 'description', 'created', 'actions'];
|
||||||
pageEvent: PageEvent;
|
pageEvent: PageEvent;
|
||||||
titlePrefix: String;
|
titlePrefix: String;
|
||||||
dmpId: String;
|
dmpId: String;
|
||||||
|
|
||||||
statuses = [
|
statuses = [
|
||||||
{ value: '0', viewValue: 'Active' },
|
{ value: '0', viewValue: 'Active' },
|
||||||
{ value: '1', viewValue: 'Inactive' }
|
{ value: '1', viewValue: 'Inactive' }
|
||||||
];
|
];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private datasetService: DatasetProfileAdmin,
|
private datasetService: DatasetProfileAdmin,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private languageService: TranslateService,
|
private languageService: TranslateService,
|
||||||
public snackBar: MatSnackBar,
|
public snackBar: MatSnackBar,
|
||||||
public route: ActivatedRoute,
|
public route: ActivatedRoute,
|
||||||
public dataManagementPlanService: DataManagementPlanService
|
public dataManagementPlanService: DataManagementPlanService
|
||||||
) {
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.route.params.subscribe((params: Params) => {
|
this.route.params.subscribe((params: Params) => {
|
||||||
this.dmpId = params['dmpId'];
|
this.dmpId = params['dmpId'];
|
||||||
if (this.dmpId != null) this.setDmpTitle(this.dmpId);
|
if (this.dmpId != null) { this.setDmpTitle(this.dmpId); }
|
||||||
this.criteria.setCriteria(this.getDefaultCriteria(this.dmpId));
|
this.criteria.setCriteria(this.getDefaultCriteria(this.dmpId));
|
||||||
this.refresh();
|
this.refresh();
|
||||||
this.criteria.setRefreshCallback(() => this.refresh());
|
this.criteria.setRefreshCallback(() => this.refresh());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setDmpTitle(dmpId: String) {
|
setDmpTitle(dmpId: String) {
|
||||||
this.dataManagementPlanService.getSingle(dmpId).map(data => data as DataManagementPlanModel)
|
this.dataManagementPlanService.getSingle(dmpId).map(data => data as DataManagementPlanModel)
|
||||||
.subscribe(data => {
|
.subscribe(data => {
|
||||||
this.titlePrefix = data.label;
|
this.titlePrefix = data.label;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
this.dataSource = new DatasetDataSource(this.datasetService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria);
|
this.dataSource = new DatasetDataSource(this.datasetService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria);
|
||||||
}
|
}
|
||||||
|
|
||||||
rowClick(rowId: String) {
|
rowClick(rowId: String) {
|
||||||
this.router.navigate(['form/' + rowId]);
|
this.router.navigate(['form/' + rowId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
getDefaultCriteria(dmpId: String): DatasetCriteria {
|
getDefaultCriteria(dmpId: String): DatasetCriteria {
|
||||||
const defaultCriteria = new DatasetCriteria();
|
const defaultCriteria = new DatasetCriteria();
|
||||||
if (dmpId != null) {
|
if (dmpId != null) {
|
||||||
defaultCriteria.dmpIds.push(dmpId);
|
defaultCriteria.dmpIds.push(dmpId);
|
||||||
}
|
}
|
||||||
return defaultCriteria;
|
return defaultCriteria;
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeItPublic(id: String) {
|
// makeItPublic(id: String) {
|
||||||
// debugger;
|
// debugger;
|
||||||
// this.datasetService.makeDatasetPublic(id).subscribe();
|
// this.datasetService.makeDatasetPublic(id).subscribe();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DatasetDataSource extends DataSource<DatasetListingModel> {
|
export class DatasetDataSource extends DataSource<DatasetListingModel> {
|
||||||
|
|
||||||
totalCount = 0;
|
totalCount = 0;
|
||||||
isLoadingResults = false;
|
isLoadingResults = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _service: DatasetProfileAdmin,
|
private _service: DatasetProfileAdmin,
|
||||||
private _paginator: MatPaginator,
|
private _paginator: MatPaginator,
|
||||||
private _sort: MatSort,
|
private _sort: MatSort,
|
||||||
private _languageService: TranslateService,
|
private _languageService: TranslateService,
|
||||||
private _snackBar: MatSnackBar,
|
private _snackBar: MatSnackBar,
|
||||||
private _criteria: DatasetCriteriaComponent
|
private _criteria: DatasetCriteriaComponent
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(): Observable<DatasetListingModel[]> {
|
connect(): Observable<DatasetListingModel[]> {
|
||||||
const displayDataChanges = [
|
const displayDataChanges = [
|
||||||
this._paginator.page
|
this._paginator.page
|
||||||
//this._sort.matSortChange
|
//this._sort.matSortChange
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
return Observable.merge(...displayDataChanges)
|
return Observable.merge(...displayDataChanges)
|
||||||
.startWith(null)
|
.startWith(null)
|
||||||
.switchMap(() => {
|
.switchMap(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.isLoadingResults = true;
|
this.isLoadingResults = true;
|
||||||
});
|
});
|
||||||
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
|
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
|
||||||
let fields: Array<string> = new Array()
|
let fields: Array<string> = new Array();
|
||||||
if (this._sort.active) fields = this._sort.direction === "asc" ? ["+" + this._sort.active] : ["-" + this._sort.active];
|
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 });
|
const request = new DataTableRequest<DatasetCriteria>(startIndex, this._paginator.pageSize, { fields: fields });
|
||||||
request.criteria = this._criteria.criteria;
|
request.criteria = this._criteria.criteria;
|
||||||
return this._service.getPaged(request);
|
return this._service.getPaged(request);
|
||||||
})
|
})
|
||||||
/*.catch((error: any) => {
|
/*.catch((error: any) => {
|
||||||
this._snackBar.openFromComponent(SnackBarNotificationComponent, {
|
this._snackBar.openFromComponent(SnackBarNotificationComponent, {
|
||||||
data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService },
|
data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService },
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
extraClasses: ['snackbar-warning']
|
extraClasses: ['snackbar-warning']
|
||||||
});
|
});
|
||||||
//this._criteria.criteria.onCallbackError(error);
|
//this._criteria.criteria.onCallbackError(error);
|
||||||
return Observable.of(null);
|
return Observable.of(null);
|
||||||
})*/
|
})*/
|
||||||
.map(result => {
|
.map(result => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.isLoadingResults = false;
|
this.isLoadingResults = false;
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
})
|
})
|
||||||
.map(result => {
|
.map(result => {
|
||||||
if (!result) { return []; }
|
if (!result) { return []; }
|
||||||
if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; }
|
if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; }
|
||||||
return result.data;
|
return result.data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect() {
|
disconnect() {
|
||||||
// No-op
|
// No-op
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,45 +10,45 @@ import { HttpClient, HttpClientModule } from '@angular/common/http';
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||||
|
|
||||||
import { SharedModule } from '../shared/shared.module'
|
import { SharedModule } from '../shared/shared.module';
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
HttpClientModule,
|
HttpClientModule,
|
||||||
SharedModule,
|
SharedModule,
|
||||||
RouterModule.forChild(DatasetAdminRoutes),
|
RouterModule.forChild(DatasetAdminRoutes),
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
DynamicFormModule,
|
DynamicFormModule,
|
||||||
TranslateModule.forRoot({
|
TranslateModule.forRoot({
|
||||||
loader: {
|
loader: {
|
||||||
provide: TranslateLoader,
|
provide: TranslateLoader,
|
||||||
useFactory: HttpLoaderFactory,
|
useFactory: HttpLoaderFactory,
|
||||||
deps: [HttpClient]
|
deps: [HttpClient]
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|
||||||
declarations: [
|
declarations: [
|
||||||
DatasetAdminListingComponent,
|
DatasetAdminListingComponent,
|
||||||
],
|
],
|
||||||
|
|
||||||
exports: [
|
exports: [
|
||||||
DatasetAdminListingComponent,
|
DatasetAdminListingComponent,
|
||||||
RouterModule
|
RouterModule
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
DatasetService
|
DatasetService
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
export class DatasetAdminModule {
|
export class DatasetAdminModule {
|
||||||
constructor(private translate: TranslateService) {
|
constructor(private translate: TranslateService) {
|
||||||
translate.setDefaultLang('en');
|
translate.setDefaultLang('en');
|
||||||
translate.use('en');
|
translate.use('en');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function HttpLoaderFactory(httpClient: HttpClient) {
|
export function HttpLoaderFactory(httpClient: HttpClient) {
|
||||||
return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json');
|
return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json');
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,5 +3,5 @@ import { RouterModule, Routes } from '@angular/router';
|
||||||
import { AuthGuard } from '../shared/guards/auth.guard';
|
import { AuthGuard } from '../shared/guards/auth.guard';
|
||||||
|
|
||||||
export const DatasetAdminRoutes: Routes = [
|
export const DatasetAdminRoutes: Routes = [
|
||||||
{ path: '', component: DatasetAdminListingComponent, canActivate: [AuthGuard] },
|
{ path: '', component: DatasetAdminListingComponent, canActivate: [AuthGuard] },
|
||||||
];
|
];
|
||||||
|
|
|
@ -1,152 +1,153 @@
|
||||||
import { OnInit, Component, ViewChild } from "@angular/core";
|
import { OnInit, Component, ViewChild } from '@angular/core';
|
||||||
import { MatSort, MatPaginator, PageEvent, MatSnackBar } from "@angular/material";
|
import { MatSort, MatPaginator, PageEvent, MatSnackBar } from '@angular/material';
|
||||||
import { DatasetCriteriaComponent } from "../../shared/components/criteria/datasets/datasets-criteria.component";
|
import { DatasetCriteriaComponent } from '../../shared/components/criteria/datasets/datasets-criteria.component';
|
||||||
import { Observable } from "rxjs";
|
import { Observable } from 'rxjs';
|
||||||
import { BreadcrumbItem } from "../../shared/components/breadcrumb/definition/breadcrumb-item";
|
import { BreadcrumbItem } from '../../shared/components/breadcrumb/definition/breadcrumb-item';
|
||||||
import { DatasetService } from "../../services/dataset/dataset.service";
|
import { DatasetService } from '../../services/dataset/dataset.service';
|
||||||
import { Router, ActivatedRoute, Params } from "@angular/router";
|
import { Router, ActivatedRoute, Params } from '@angular/router';
|
||||||
import { TranslateService } from "@ngx-translate/core";
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { DataManagementPlanService } from "../../services/data-management-plan/data-management-plan.service";
|
import { DataManagementPlanService } from '../../services/data-management-plan/data-management-plan.service';
|
||||||
import { DatasetCriteria } from "../../models/criteria/dataset/DatasetCriteria";
|
import { DatasetCriteria } from '../../models/criteria/dataset/DatasetCriteria';
|
||||||
import { DataSource } from "@angular/cdk/table";
|
import { DataSource } from '@angular/cdk/table';
|
||||||
import { DatasetListingModel } from "../../models/datasets/DatasetListingModel";
|
import { DatasetListingModel } from '../../models/datasets/DatasetListingModel';
|
||||||
import { DataTableRequest } from "../../models/data-table/DataTableRequest";
|
import { DataTableRequest } from '../../models/data-table/DataTableRequest';
|
||||||
import { FacetSearchCriteriaModel } from "../../models/facet-search/FacetSearchCriteriaModel";
|
import { FacetSearchCriteriaModel } from '../../models/facet-search/FacetSearchCriteriaModel';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dataset-public-listing-component',
|
selector: 'app-dataset-public-listing-component',
|
||||||
templateUrl: 'dataset-public-listing.component.html',
|
templateUrl: 'dataset-public-listing.component.html',
|
||||||
styleUrls: ['./dataset-public-listing.component.scss'],
|
styleUrls: ['./dataset-public-listing.component.scss'],
|
||||||
})
|
})
|
||||||
export class DatasetPublicListingComponent implements OnInit {
|
export class DatasetPublicListingComponent implements OnInit {
|
||||||
|
|
||||||
|
|
||||||
@ViewChild(MatPaginator) _paginator: MatPaginator;
|
@ViewChild(MatPaginator) _paginator: MatPaginator;
|
||||||
@ViewChild(MatSort) sort: MatSort;
|
@ViewChild(MatSort) sort: MatSort;
|
||||||
@ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent;
|
@ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent;
|
||||||
|
|
||||||
dataSource: DatasetDataSource | null;
|
dataSource: DatasetDataSource | null;
|
||||||
displayedColumns: String[] = ['label', 'dmp', 'profile', 'status', 'description', 'created'];
|
displayedColumns: String[] = ['label', 'dmp', 'profile', 'status', 'description', 'created'];
|
||||||
pageEvent: PageEvent;
|
pageEvent: PageEvent;
|
||||||
titlePrefix: String;
|
titlePrefix: String;
|
||||||
dmpId: string;
|
dmpId: string;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private datasetService: DatasetService,
|
private datasetService: DatasetService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private languageService: TranslateService,
|
private languageService: TranslateService,
|
||||||
public snackBar: MatSnackBar,
|
public snackBar: MatSnackBar,
|
||||||
public route: ActivatedRoute,
|
public route: ActivatedRoute,
|
||||||
public dataManagementPlanService: DataManagementPlanService
|
public dataManagementPlanService: DataManagementPlanService
|
||||||
) {
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.route.params.subscribe(async (params: Params) => {
|
this.route.params.subscribe(async (params: Params) => {
|
||||||
this.dmpId = params['dmpId'];
|
this.dmpId = params['dmpId'];
|
||||||
this.criteria.setCriteria(this.getDefaultCriteria(this.dmpId));
|
this.criteria.setCriteria(this.getDefaultCriteria(this.dmpId));
|
||||||
this.refresh();
|
this.refresh();
|
||||||
this.criteria.setRefreshCallback(() => this.refresh());
|
this.criteria.setRefreshCallback(() => this.refresh());
|
||||||
if (this.dmpId != null) {
|
if (this.dmpId != null) {
|
||||||
let dmp = await this.dataManagementPlanService.getSingle(this.dmpId).toPromise()
|
const dmp = await this.dataManagementPlanService.getSingle(this.dmpId).toPromise();
|
||||||
if (params['dmpLabel'] != undefined)
|
if (params['dmpLabel'] !== undefined) {
|
||||||
this.titlePrefix = "for " + params['dmpLabel'];
|
this.titlePrefix = 'for ' + params['dmpLabel'];
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
onCriteriaChange(event){
|
onCriteriaChange(event) {
|
||||||
//console.log(event)
|
//console.log(event)
|
||||||
this.criteria.setCriteria(event);
|
this.criteria.setCriteria(event);
|
||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
this.dataSource = new DatasetDataSource(this.datasetService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria, this.dmpId);
|
this.dataSource = new DatasetDataSource(this.datasetService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria, this.dmpId);
|
||||||
}
|
}
|
||||||
|
|
||||||
rowClick(rowId: String) {
|
rowClick(rowId: String) {
|
||||||
this.router.navigate(['/datasets/publicEdit/' + rowId]);
|
this.router.navigate(['/datasets/publicEdit/' + rowId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
getDefaultCriteria(dmpId: String): DatasetCriteria {
|
getDefaultCriteria(dmpId: String): DatasetCriteria {
|
||||||
const defaultCriteria = new DatasetCriteria();
|
const defaultCriteria = new DatasetCriteria();
|
||||||
if (dmpId != null) {
|
if (dmpId != null) {
|
||||||
defaultCriteria.dmpIds.push(dmpId);
|
defaultCriteria.dmpIds.push(dmpId);
|
||||||
}
|
}
|
||||||
return defaultCriteria;
|
return defaultCriteria;
|
||||||
}
|
}
|
||||||
|
|
||||||
makeItPublic(id: String) {
|
makeItPublic(id: String) {
|
||||||
this.datasetService.makeDatasetPublic(id).subscribe();
|
this.datasetService.makeDatasetPublic(id).subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DatasetDataSource extends DataSource<DatasetListingModel> {
|
export class DatasetDataSource extends DataSource<DatasetListingModel> {
|
||||||
|
|
||||||
totalCount = 0;
|
totalCount = 0;
|
||||||
isLoadingResults = false;
|
isLoadingResults = false;
|
||||||
constructor(
|
constructor(
|
||||||
private _service: DatasetService,
|
private _service: DatasetService,
|
||||||
private _paginator: MatPaginator,
|
private _paginator: MatPaginator,
|
||||||
private _sort: MatSort,
|
private _sort: MatSort,
|
||||||
private _languageService: TranslateService,
|
private _languageService: TranslateService,
|
||||||
private _snackBar: MatSnackBar,
|
private _snackBar: MatSnackBar,
|
||||||
private _criteria: DatasetCriteriaComponent,
|
private _criteria: DatasetCriteriaComponent,
|
||||||
private dmpId: String
|
private dmpId: String
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(): Observable<DatasetListingModel[]> {
|
connect(): Observable<DatasetListingModel[]> {
|
||||||
const displayDataChanges = [
|
const displayDataChanges = [
|
||||||
this._paginator.page
|
this._paginator.page
|
||||||
//this._sort.matSortChange
|
//this._sort.matSortChange
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
return Observable.merge(...displayDataChanges)
|
return Observable.merge(...displayDataChanges)
|
||||||
.startWith(null)
|
.startWith(null)
|
||||||
.switchMap(() => {
|
.switchMap(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.isLoadingResults = true;
|
this.isLoadingResults = true;
|
||||||
});
|
});
|
||||||
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
|
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
|
||||||
let fields: Array<string> = new Array()
|
let fields: Array<string> = new Array();
|
||||||
if (this._sort.active) fields = this._sort.direction === "asc" ? ["+" + this._sort.active] : ["-" + this._sort.active];
|
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 });
|
const request = new DataTableRequest<FacetSearchCriteriaModel>(startIndex, this._paginator.pageSize, { fields: fields });
|
||||||
request.criteria = this._criteria.criteria;
|
request.criteria = this._criteria.criteria;
|
||||||
//if (this.dmpId) request.criteria.allVersions = true;
|
//if (this.dmpId) request.criteria.allVersions = true;
|
||||||
return this._service.getPublicPaged(request);
|
return this._service.getPublicPaged(request);
|
||||||
})
|
})
|
||||||
/*.catch((error: any) => {
|
/*.catch((error: any) => {
|
||||||
this._snackBar.openFromComponent(SnackBarNotificationComponent, {
|
this._snackBar.openFromComponent(SnackBarNotificationComponent, {
|
||||||
data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService },
|
data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService },
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
extraClasses: ['snackbar-warning']
|
extraClasses: ['snackbar-warning']
|
||||||
});
|
});
|
||||||
//this._criteria.criteria.onCallbackError(error);
|
//this._criteria.criteria.onCallbackError(error);
|
||||||
return Observable.of(null);
|
return Observable.of(null);
|
||||||
})*/
|
})*/
|
||||||
.map(result => {
|
.map(result => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.isLoadingResults = false;
|
this.isLoadingResults = false;
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
})
|
})
|
||||||
.map(result => {
|
.map(result => {
|
||||||
if (!result) { return []; }
|
if (!result) { return []; }
|
||||||
if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; }
|
if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; }
|
||||||
return result.data;
|
return result.data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect() {
|
disconnect() {
|
||||||
// No-op
|
// No-op
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +1,36 @@
|
||||||
import { Component, ViewEncapsulation, OnInit, Inject } from "@angular/core";
|
import { Component, ViewEncapsulation, OnInit, Inject } from '@angular/core';
|
||||||
import { FormGroup } from "@angular/forms";
|
import { FormGroup } from '@angular/forms';
|
||||||
import { DataRepositoryService } from "../../../services/datarepository/datarepository.service";
|
import { DataRepositoryService } from '../../../services/datarepository/datarepository.service';
|
||||||
import { Router, ActivatedRoute } from "@angular/router";
|
import { Router, ActivatedRoute } from '@angular/router';
|
||||||
import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material";
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
|
||||||
import { DataRepositoryModel } from "../../../models/dataRepositories/DataRepositoryModel";
|
import { DataRepositoryModel } from '../../../models/dataRepositories/DataRepositoryModel';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-datarepository-referenced-model-helper',
|
selector: 'app-datarepository-referenced-model-helper',
|
||||||
templateUrl: 'datarepository-referenced-model-helper.component.html',
|
templateUrl: 'datarepository-referenced-model-helper.component.html',
|
||||||
styleUrls: ['./datarepository-referenced-model-helper.component.scss'],
|
styleUrls: ['./datarepository-referenced-model-helper.component.scss'],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class DataRepositoryReferencedModelHelperComponent implements OnInit {
|
export class DataRepositoryReferencedModelHelperComponent implements OnInit {
|
||||||
public formGroup: FormGroup;
|
public formGroup: FormGroup;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private dataRepositoryService: DataRepositoryService,
|
private dataRepositoryService: DataRepositoryService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
public router: Router,
|
public router: Router,
|
||||||
public dialogRef: MatDialogRef<DataRepositoryReferencedModelHelperComponent>,
|
public dialogRef: MatDialogRef<DataRepositoryReferencedModelHelperComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: any
|
@Inject(MAT_DIALOG_DATA) public data: any
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
let datarepo = new DataRepositoryModel();
|
const datarepo = new DataRepositoryModel();
|
||||||
this.formGroup = datarepo.buildForm();
|
this.formGroup = datarepo.buildForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
send(value: any) {
|
send(value: any) {
|
||||||
this.dataRepositoryService.create(this.formGroup.value).subscribe(
|
this.dataRepositoryService.create(this.formGroup.value).subscribe(
|
||||||
(item)=> this.dialogRef.close(item)
|
(item) => this.dialogRef.close(item)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +1,36 @@
|
||||||
import { ExternalDatasetModel } from "../../../models/external-dataset/ExternalDatasetModel";
|
import { ExternalDatasetModel } from '../../../models/external-dataset/ExternalDatasetModel';
|
||||||
import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material";
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
|
||||||
import { Inject, ViewEncapsulation, Component, OnInit } from "@angular/core";
|
import { Inject, ViewEncapsulation, Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from "@angular/router";
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { ExternalDatasetService } from "../../../services/external-dataset/external-dataset.service";
|
import { ExternalDatasetService } from '../../../services/external-dataset/external-dataset.service';
|
||||||
import { FormGroup } from "@angular/forms";
|
import { FormGroup } from '@angular/forms';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-externaldataset-referenced-model-helper',
|
selector: 'app-externaldataset-referenced-model-helper',
|
||||||
templateUrl: 'externaldataset-referenced-model-helper.component.html',
|
templateUrl: 'externaldataset-referenced-model-helper.component.html',
|
||||||
styleUrls: ['./externaldataset-referenced-model-helper.component.scss'],
|
styleUrls: ['./externaldataset-referenced-model-helper.component.scss'],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class ExternalDatasetReferencedModelHelperComponent implements OnInit {
|
export class ExternalDatasetReferencedModelHelperComponent implements OnInit {
|
||||||
public formGroup: FormGroup;
|
public formGroup: FormGroup;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private externalDatasetService: ExternalDatasetService,
|
private externalDatasetService: ExternalDatasetService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
public router: Router,
|
public router: Router,
|
||||||
public dialogRef: MatDialogRef<ExternalDatasetReferencedModelHelperComponent>,
|
public dialogRef: MatDialogRef<ExternalDatasetReferencedModelHelperComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: any
|
@Inject(MAT_DIALOG_DATA) public data: any
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
let externalDatasetModel = new ExternalDatasetModel();
|
const externalDatasetModel = new ExternalDatasetModel();
|
||||||
this.formGroup = externalDatasetModel.buildForm();
|
this.formGroup = externalDatasetModel.buildForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
send(value: any) {
|
send(value: any) {
|
||||||
this.externalDatasetService.create(this.formGroup.value).subscribe(
|
this.externalDatasetService.create(this.formGroup.value).subscribe(
|
||||||
(item)=> this.dialogRef.close(item)
|
(item) => this.dialogRef.close(item)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +1,36 @@
|
||||||
import { Component, ViewEncapsulation, OnInit, Inject } from "@angular/core";
|
import { Component, ViewEncapsulation, OnInit, Inject } from '@angular/core';
|
||||||
import { FormGroup } from "@angular/forms";
|
import { FormGroup } from '@angular/forms';
|
||||||
import { ActivatedRoute, Router } from "@angular/router";
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material";
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
|
||||||
import { RegisterModel } from "../../../models/registers/RegisterModel";
|
import { RegisterModel } from '../../../models/registers/RegisterModel';
|
||||||
import { RegistryService } from "../../../services/registries/registry.service";
|
import { RegistryService } from '../../../services/registries/registry.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-registry-referenced-model-helper',
|
selector: 'app-registry-referenced-model-helper',
|
||||||
templateUrl: 'registry-referenced-model-helper.component.html',
|
templateUrl: 'registry-referenced-model-helper.component.html',
|
||||||
styleUrls: ['./registry-referenced-model-helper.component.scss'],
|
styleUrls: ['./registry-referenced-model-helper.component.scss'],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class RegistryReferencedModelHelperComponent implements OnInit {
|
export class RegistryReferencedModelHelperComponent implements OnInit {
|
||||||
public formGroup: FormGroup;
|
public formGroup: FormGroup;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private registryService: RegistryService,
|
private registryService: RegistryService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
public router: Router,
|
public router: Router,
|
||||||
public dialogRef: MatDialogRef<RegistryReferencedModelHelperComponent>,
|
public dialogRef: MatDialogRef<RegistryReferencedModelHelperComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: any
|
@Inject(MAT_DIALOG_DATA) public data: any
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
let registryModel = new RegisterModel();
|
const registryModel = new RegisterModel();
|
||||||
this.formGroup = registryModel.buildForm();
|
this.formGroup = registryModel.buildForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
send(value: any) {
|
send(value: any) {
|
||||||
this.registryService.create(this.formGroup.value).subscribe(
|
this.registryService.create(this.formGroup.value).subscribe(
|
||||||
(item)=> this.dialogRef.close(item)
|
(item) => this.dialogRef.close(item)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +1,36 @@
|
||||||
import { ViewEncapsulation, Component, OnInit, Inject } from "@angular/core";
|
import { ViewEncapsulation, Component, OnInit, Inject } from '@angular/core';
|
||||||
import { FormGroup } from "@angular/forms";
|
import { FormGroup } from '@angular/forms';
|
||||||
import { ActivatedRoute, Router } from "@angular/router";
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material";
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
|
||||||
import { ServiceModel } from "../../../models/services/ServiceModel";
|
import { ServiceModel } from '../../../models/services/ServiceModel';
|
||||||
import { ServicesDataService } from "../../../services/services/services-data.service";
|
import { ServicesDataService } from '../../../services/services/services-data.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-services-referenced-model-helper',
|
selector: 'app-services-referenced-model-helper',
|
||||||
templateUrl: 'services-referenced-model-helper.component.html',
|
templateUrl: 'services-referenced-model-helper.component.html',
|
||||||
styleUrls: ['./services-referenced-model-helper.component.scss'],
|
styleUrls: ['./services-referenced-model-helper.component.scss'],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class ServicesReferencedModelHelperComponent implements OnInit {
|
export class ServicesReferencedModelHelperComponent implements OnInit {
|
||||||
public formGroup: FormGroup;
|
public formGroup: FormGroup;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private registryService: ServicesDataService,
|
private registryService: ServicesDataService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
public router: Router,
|
public router: Router,
|
||||||
public dialogRef: MatDialogRef<ServicesReferencedModelHelperComponent>,
|
public dialogRef: MatDialogRef<ServicesReferencedModelHelperComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: any
|
@Inject(MAT_DIALOG_DATA) public data: any
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
let serviceModel = new ServiceModel();
|
const serviceModel = new ServiceModel();
|
||||||
this.formGroup = serviceModel.buildForm();
|
this.formGroup = serviceModel.buildForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
send() {
|
send() {
|
||||||
this.registryService.create(this.formGroup.value).subscribe(
|
this.registryService.create(this.formGroup.value).subscribe(
|
||||||
(item)=> this.dialogRef.close(item)
|
(item) => this.dialogRef.close(item)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,8 +225,8 @@
|
||||||
</mat-step>
|
</mat-step>
|
||||||
<mat-step>
|
<mat-step>
|
||||||
<ng-template matStepLabel>{{'DATASET-WIZARD.THIRD-STEP.TITLE' | translate}}</ng-template>
|
<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')"
|
<app-dynamic-form class="full-width" *ngIf="formGroup && datasetWizardModel && datasetWizardModel.datasetProfileDefinition" [form]="this.formGroup.get('datasetProfileDefinition')"
|
||||||
[dataModel]="datasetWizardModel"></dynamic-form>
|
[dataModel]="datasetWizardModel"></app-dynamic-form>
|
||||||
<div class="navigation-buttons-container">
|
<div class="navigation-buttons-container">
|
||||||
<button style="margin-top:10px;" matStepperPrevious mat-raised-button color="primary">{{'DATASET-WIZARD.ACTIONS.BACK'
|
<button style="margin-top:10px;" matStepperPrevious mat-raised-button color="primary">{{'DATASET-WIZARD.ACTIONS.BACK'
|
||||||
| translate}}</button>
|
| translate}}</button>
|
||||||
|
|
|
@ -15,10 +15,10 @@ import { ExternalSourcesService } from '../../services/external-sources/external
|
||||||
import { DatasetWizardService } from '../../services/dataset-wizard/dataset-wizard.service';
|
import { DatasetWizardService } from '../../services/dataset-wizard/dataset-wizard.service';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { ActivatedRoute, Router, Params } from '@angular/router';
|
import { ActivatedRoute, Router, Params } from '@angular/router';
|
||||||
import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation, TemplateRef, ChangeDetectionStrategy } from "@angular/core";
|
import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation, TemplateRef, ChangeDetectionStrategy } from '@angular/core';
|
||||||
import { FormGroup, Validators, FormBuilder, FormArray } from "@angular/forms";
|
import { FormGroup, Validators, FormBuilder, FormArray } from '@angular/forms';
|
||||||
import * as FileSaver from 'file-saver';
|
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 { ExternalDatasetCriteria } from '../../models/criteria/external-dataset/ExternalDatasetCriteria';
|
||||||
import { ExternalDatasetModel } from '../../models/external-dataset/ExternalDatasetModel';
|
import { ExternalDatasetModel } from '../../models/external-dataset/ExternalDatasetModel';
|
||||||
import { RegistryCriteria } from '../../models/criteria/registry/RegistryCriteria';
|
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';
|
import { ServicesReferencedModelHelperComponent } from '../dataset-referenced-models-helper/services/services-referenced-model-helper.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dataset-wizard-component',
|
selector: 'app-dataset-wizard-component',
|
||||||
templateUrl: 'dataset-wizard.component.html',
|
templateUrl: 'dataset-wizard.component.html',
|
||||||
styleUrls: ['./dataset-wizard.component.scss'],
|
styleUrls: ['./dataset-wizard.component.scss'],
|
||||||
encapsulation: ViewEncapsulation.None,
|
encapsulation: ViewEncapsulation.None,
|
||||||
})
|
})
|
||||||
export class DatasetWizardComponent implements OnInit, IBreadCrumbComponent {
|
export class DatasetWizardComponent implements OnInit, AfterViewInit, IBreadCrumbComponent {
|
||||||
breadCrumbs: Observable<BreadcrumbItem[]>;
|
breadCrumbs: Observable<BreadcrumbItem[]>;
|
||||||
viewOnly = false;
|
viewOnly = false;
|
||||||
@ViewChild('stepper') stepper: MatStepper;
|
@ViewChild('stepper') stepper: MatStepper;
|
||||||
//autocomplete Display Functions;
|
//autocomplete Display Functions;
|
||||||
externalDatasetDisplayFunc = (item) => item ? item.label : null;
|
//autocomplete Configurations;
|
||||||
registriesDisplayFunc = (item) => item ? item.label : null;
|
externalDatasetAutoCompleteConfiguration: AutoCompleteConfiguration;
|
||||||
dataRepositoryDisplayFunc = (item) => item ? item.name : null;
|
registriesAutoCompleteConfiguration: AutoCompleteConfiguration;
|
||||||
servicesDisplayFunc = (item) => item ? item.label : null;
|
dataRepositoriesAutoCompleteConfiguration: AutoCompleteConfiguration;
|
||||||
tagsDisplayFunc = (item) => item ? item.name : null;
|
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;
|
ngOnInit() {
|
||||||
externalDatasetDisplaySubtitleFunc = (item) => item ? item.tag : null;
|
this.route
|
||||||
registriesDisplaySubtitleFunc = (item) => item ? item.tag : null;
|
.data
|
||||||
dataRepositoryDisplaySubtitleFunc = (item) => item ? item.tag : null;
|
.subscribe(v => this.viewOnly = v['public']);
|
||||||
servicesDisplaySubtitleFunc = (item) => item ? item.tag : null;
|
|
||||||
tagsDisplaySubtitleFunc = (item) => item ? item.tag : null;
|
|
||||||
|
|
||||||
//autocomplete Configurations;
|
const dmpRequestItem: RequestItem<DataManagementPlanCriteria> = new RequestItem();
|
||||||
externalDatasetAutoCompleteConfiguration: AutoCompleteConfiguration;
|
dmpRequestItem.criteria = new DataManagementPlanCriteria();
|
||||||
registriesAutoCompleteConfiguration: AutoCompleteConfiguration;
|
|
||||||
dataRepositoriesAutoCompleteConfiguration: AutoCompleteConfiguration;
|
|
||||||
servicesAutoCompleteConfiguration: AutoCompleteConfiguration;
|
|
||||||
tagsAutoCompleteConfiguration: AutoCompleteConfiguration;
|
|
||||||
dmpAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
|
|
||||||
|
|
||||||
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;
|
const registriesRequestItem: RequestItem<RegistryCriteria> = new RequestItem();
|
||||||
isNew = true;
|
registriesRequestItem.criteria = new RegistryCriteria();
|
||||||
formGroup: FormGroup;
|
this.registriesAutoCompleteConfiguration = new AutoCompleteConfiguration(this.externalSourcesService.searchDatasetRegistry.bind(this.externalSourcesService), registriesRequestItem);
|
||||||
datasetProfileDefinitionModel: DatasetProfileDefinitionModel;
|
|
||||||
|
|
||||||
availableProfiles: DatasetProfileModel[] = [];
|
const dataRepositoriesRequestItem: RequestItem<DataRepositoryCriteria> = new RequestItem();
|
||||||
itemId: string
|
dataRepositoriesRequestItem.criteria = new DataRepositoryCriteria();
|
||||||
constructor(
|
this.dataRepositoriesAutoCompleteConfiguration = new AutoCompleteConfiguration(this.externalSourcesService.searchDatasetRepository.bind(this.externalSourcesService), dataRepositoriesRequestItem);
|
||||||
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 servicesRequestItem: RequestItem<ServicesCriteria> = new RequestItem();
|
||||||
|
servicesRequestItem.criteria = new ServicesCriteria();
|
||||||
|
this.servicesAutoCompleteConfiguration = new AutoCompleteConfiguration(this.externalSourcesService.searchDatasetService.bind(this.externalSourcesService), servicesRequestItem);
|
||||||
|
|
||||||
isLinear = false;
|
const tagsRequestItem: RequestItem<TagsCriteria> = new RequestItem();
|
||||||
firstStepFormGroup: FormGroup;
|
tagsRequestItem.criteria = new TagsCriteria();
|
||||||
secondFormGroup: FormGroup;
|
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
|
formSubmit(): void {
|
||||||
.data
|
if (!this.isFormValid()) { return; }
|
||||||
.subscribe(v => this.viewOnly = v["public"]);
|
this.onSubmit();
|
||||||
|
}
|
||||||
|
|
||||||
let dmpRequestItem: RequestItem<DataManagementPlanCriteria> = new RequestItem();
|
public isFormValid() {
|
||||||
dmpRequestItem.criteria = new DataManagementPlanCriteria();
|
return this.formGroup.valid;
|
||||||
|
}
|
||||||
|
|
||||||
let externalDatasetRequestItem: RequestItem<ExternalDatasetCriteria> = new RequestItem();
|
onSubmit(): void {
|
||||||
externalDatasetRequestItem.criteria = new ExternalDatasetCriteria();
|
this.datasetWizardService.createDataset(this.formGroup.value).subscribe(
|
||||||
this.externalDatasetAutoCompleteConfiguration = new AutoCompleteConfiguration(this.externalSourcesService.searchDatasetSExternalDatasetservice.bind(this.externalSourcesService), externalDatasetRequestItem)
|
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();
|
submit() {
|
||||||
registriesRequestItem.criteria = new RegistryCriteria();
|
this.datasetWizardService.createDataset(this.formGroup.value).subscribe(data => {
|
||||||
this.registriesAutoCompleteConfiguration = new AutoCompleteConfiguration(this.externalSourcesService.searchDatasetRegistry.bind(this.externalSourcesService), registriesRequestItem)
|
this.router.navigateByUrl('/datasets/dmp/' + this.formGroup.get('dmp').value.id);
|
||||||
|
});
|
||||||
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())
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
formSubmit(): void {
|
save() {
|
||||||
if (!this.isFormValid()) { return; }
|
if (!this.isFormValid()) { return; }
|
||||||
this.onSubmit();
|
this.formGroup.get('status').setValue('0');
|
||||||
}
|
this.submit();
|
||||||
|
}
|
||||||
|
|
||||||
public isFormValid() {
|
saveFinalize() {
|
||||||
return this.formGroup.valid;
|
if (!this.isFormValid()) { return; }
|
||||||
}
|
this.formGroup.get('status').setValue('1');
|
||||||
|
this.submit();
|
||||||
|
}
|
||||||
|
|
||||||
onSubmit(): void {
|
onCallbackSuccess(): void {
|
||||||
this.datasetWizardService.createDataset(this.formGroup.value).subscribe(
|
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
|
||||||
complete => {
|
data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
|
||||||
this.datasetWizardService.getSingle(complete.id).subscribe(
|
duration: 3000,
|
||||||
result => {
|
});
|
||||||
this.datasetWizardModel = JsonSerializer.fromJSONObject(result, DatasetWizardModel);
|
}
|
||||||
}
|
|
||||||
)
|
|
||||||
this.onCallbackSuccess()
|
|
||||||
},
|
|
||||||
error => this.onCallbackError(error)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
submit() {
|
onCallbackError(error: any) {
|
||||||
this.datasetWizardService.createDataset(this.formGroup.value).subscribe(data => {
|
this.setErrorModel(error.error);
|
||||||
this.router.navigateByUrl("/datasets/dmp/" + this.formGroup.get("dmp").value.id);
|
}
|
||||||
});
|
|
||||||
}
|
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() {
|
dataRepositoriesOnItemChange(event) {
|
||||||
if (!this.isFormValid()) { return; }
|
const dataRepositoryModel = new DataRepositoryModel(event.id, event.name, event.abbreviation, event.uri, event.pid);
|
||||||
this.formGroup.get("status").setValue("0");
|
(<FormArray>this.formGroup.get('dataRepositories')).push(dataRepositoryModel.buildForm());
|
||||||
this.submit();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
saveFinalize() {
|
addDataRepository() {
|
||||||
if (!this.isFormValid()) { return; }
|
const dialogRef = this.dialog.open(DataRepositoryReferencedModelHelperComponent, {
|
||||||
this.formGroup.get("status").setValue("1");
|
height: '255px',
|
||||||
this.submit();
|
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 },
|
dialogRef.afterClosed().subscribe(result => {
|
||||||
duration: 3000,
|
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) {
|
addRegistry() {
|
||||||
this.setErrorModel(error.error);
|
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 {
|
addExternalDataset() {
|
||||||
this.datasetWizardService.downloadPDF(this.itemId).subscribe(response => {
|
const dialogRef = this.dialog.open(ExternalDatasetReferencedModelHelperComponent, {
|
||||||
const blob = new Blob([response.body], { type: 'application/pdf' })
|
height: '255px',
|
||||||
const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
|
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 {
|
addService() {
|
||||||
this.datasetWizardService.downloadXML(this.itemId).subscribe(response => {
|
const dialogRef = this.dialog.open(ServicesReferencedModelHelperComponent, {
|
||||||
const blob = new Blob([response.body], { type: 'application/xml' })
|
height: '255px',
|
||||||
const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
|
width: '700px',
|
||||||
|
data: {
|
||||||
|
|
||||||
FileSaver.saveAs(blob, filename)
|
}
|
||||||
})
|
});
|
||||||
}
|
dialogRef.afterClosed().subscribe(result => {
|
||||||
|
if (!result) { return; }
|
||||||
getFilenameFromContentDispositionHeader(header: string): string {
|
const serviceModel = new ServiceModel(result.id, result.abbreviation, result.definition, result.uri, result.label, result.reference);
|
||||||
const regex: RegExp = new RegExp(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/g);
|
(<FormArray>this.formGroup.get('services')).push(serviceModel.buildForm());
|
||||||
|
});
|
||||||
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());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import { HttpClient, HttpClientModule } from '@angular/common/http';
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
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 { BaseHttpService } from '../utilities/cite-http-service-module/base-http.service';
|
||||||
import { BaseHttpModule } from '../utilities/cite-http-service-module/cite-http.module';
|
import { BaseHttpModule } from '../utilities/cite-http-service-module/cite-http.module';
|
||||||
import { MaterialModule } from '../shared/material/material.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 { DataRepositoryService } from '../services/datarepository/datarepository.service';
|
||||||
import { ExternalDatasetService } from '../services/external-dataset/external-dataset.service';
|
import { ExternalDatasetService } from '../services/external-dataset/external-dataset.service';
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
HttpClientModule,
|
HttpClientModule,
|
||||||
SharedModule,
|
SharedModule,
|
||||||
MaterialModule,
|
MaterialModule,
|
||||||
RouterModule.forChild(DatasetRoutes),
|
RouterModule.forChild(DatasetRoutes),
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
DynamicFormModule,
|
DynamicFormModule,
|
||||||
|
|
||||||
TranslateModule.forRoot({
|
TranslateModule.forRoot({
|
||||||
loader: {
|
loader: {
|
||||||
provide: TranslateLoader,
|
provide: TranslateLoader,
|
||||||
useFactory: HttpLoaderFactory,
|
useFactory: HttpLoaderFactory,
|
||||||
deps: [HttpClient]
|
deps: [HttpClient]
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|
||||||
declarations: [
|
declarations: [
|
||||||
DatasetListingComponent,
|
DatasetListingComponent,
|
||||||
DatasetEditorComponent,
|
DatasetEditorComponent,
|
||||||
DatasetWizardComponent,
|
DatasetWizardComponent,
|
||||||
DatasetPublicListingComponent,
|
DatasetPublicListingComponent,
|
||||||
DataRepositoryReferencedModelHelperComponent,
|
DataRepositoryReferencedModelHelperComponent,
|
||||||
ExternalDatasetReferencedModelHelperComponent,
|
ExternalDatasetReferencedModelHelperComponent,
|
||||||
ServicesReferencedModelHelperComponent,
|
ServicesReferencedModelHelperComponent,
|
||||||
RegistryReferencedModelHelperComponent,
|
RegistryReferencedModelHelperComponent,
|
||||||
],
|
],
|
||||||
|
|
||||||
exports: [
|
exports: [
|
||||||
DatasetListingComponent,
|
DatasetListingComponent,
|
||||||
DatasetEditorComponent,
|
DatasetEditorComponent,
|
||||||
DatasetWizardComponent,
|
DatasetWizardComponent,
|
||||||
DataRepositoryReferencedModelHelperComponent,
|
DataRepositoryReferencedModelHelperComponent,
|
||||||
ExternalDatasetReferencedModelHelperComponent,
|
ExternalDatasetReferencedModelHelperComponent,
|
||||||
ServicesReferencedModelHelperComponent,
|
ServicesReferencedModelHelperComponent,
|
||||||
RegistryReferencedModelHelperComponent,
|
RegistryReferencedModelHelperComponent,
|
||||||
DatasetPublicListingComponent,
|
DatasetPublicListingComponent,
|
||||||
RouterModule
|
RouterModule
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
DatasetWizardService,
|
DatasetWizardService,
|
||||||
ExternalSourcesService,
|
ExternalSourcesService,
|
||||||
ExternalSourcesConfigurationService,
|
ExternalSourcesConfigurationService,
|
||||||
DataManagementPlanService,
|
DataManagementPlanService,
|
||||||
DatasetService,
|
DatasetService,
|
||||||
DataRepositoryService,
|
DataRepositoryService,
|
||||||
ExternalDatasetService,
|
ExternalDatasetService,
|
||||||
ServicesDataService,
|
ServicesDataService,
|
||||||
RegistryService
|
RegistryService
|
||||||
],
|
],
|
||||||
entryComponents:[
|
entryComponents: [
|
||||||
DataRepositoryReferencedModelHelperComponent,
|
DataRepositoryReferencedModelHelperComponent,
|
||||||
ExternalDatasetReferencedModelHelperComponent,
|
ExternalDatasetReferencedModelHelperComponent,
|
||||||
ServicesReferencedModelHelperComponent,
|
ServicesReferencedModelHelperComponent,
|
||||||
RegistryReferencedModelHelperComponent
|
RegistryReferencedModelHelperComponent
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
export class DatasetModule {
|
export class DatasetModule {
|
||||||
constructor(private translate: TranslateService) {
|
constructor(private translate: TranslateService) {
|
||||||
translate.setDefaultLang('en');
|
translate.setDefaultLang('en');
|
||||||
translate.use('en');
|
translate.use('en');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function HttpLoaderFactory(httpClient: HttpClient) {
|
export function HttpLoaderFactory(httpClient: HttpClient) {
|
||||||
return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json');
|
return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json');
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,58 +5,58 @@ import { AuthGuard } from '../shared/guards/auth.guard';
|
||||||
import { DatasetPublicListingComponent } from './dataset-public/dataset-public-listing.component';
|
import { DatasetPublicListingComponent } from './dataset-public/dataset-public-listing.component';
|
||||||
|
|
||||||
export const DatasetRoutes: Routes = [
|
export const DatasetRoutes: Routes = [
|
||||||
{
|
{
|
||||||
path: "new/:dmpId",
|
path: 'new/:dmpId',
|
||||||
component: DatasetWizardComponent,
|
component: DatasetWizardComponent,
|
||||||
canActivate: [AuthGuard],
|
canActivate: [AuthGuard],
|
||||||
data: {
|
data: {
|
||||||
breadcrumb: true
|
breadcrumb: true
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "edit/:id",
|
path: 'edit/:id',
|
||||||
component: DatasetWizardComponent,
|
component: DatasetWizardComponent,
|
||||||
canActivate: [AuthGuard],
|
canActivate: [AuthGuard],
|
||||||
data: {
|
data: {
|
||||||
breadcrumb: true,
|
breadcrumb: true,
|
||||||
public: false
|
public: false
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "publicEdit/:id",
|
path: 'publicEdit/:id',
|
||||||
component: DatasetWizardComponent,
|
component: DatasetWizardComponent,
|
||||||
//canActivate: [AuthGuard],
|
//canActivate: [AuthGuard],
|
||||||
data: {
|
data: {
|
||||||
public: true
|
public: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "new",
|
path: 'new',
|
||||||
component: DatasetWizardComponent,
|
component: DatasetWizardComponent,
|
||||||
canActivate: [AuthGuard],
|
canActivate: [AuthGuard],
|
||||||
data: {
|
data: {
|
||||||
breadcrumb: true
|
breadcrumb: true
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
component: DatasetListingComponent,
|
component: DatasetListingComponent,
|
||||||
//canActivate: [AuthGuard],
|
//canActivate: [AuthGuard],
|
||||||
data: {
|
data: {
|
||||||
breadcrumb: true
|
breadcrumb: true
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'public',
|
path: 'public',
|
||||||
component: DatasetPublicListingComponent,
|
component: DatasetPublicListingComponent,
|
||||||
//canActivate: [AuthGuard],
|
//canActivate: [AuthGuard],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "dmp/:dmpId",
|
path: 'dmp/:dmpId',
|
||||||
component: DatasetListingComponent,
|
component: DatasetListingComponent,
|
||||||
//canActivate: [AuthGuard],
|
//canActivate: [AuthGuard],
|
||||||
data: {
|
data: {
|
||||||
breadcrumb: true
|
breadcrumb: true
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
@ -1,127 +1,127 @@
|
||||||
import { AfterViewInit, Component, Input, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
|
import { AfterViewInit, Component, Input, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
|
||||||
import { MatPaginator, MatSort, MatSnackBar } from "@angular/material";
|
import { MatPaginator, MatSort, MatSnackBar } from '@angular/material';
|
||||||
import { Router, ActivatedRoute, Params } from "@angular/router";
|
import { Router, ActivatedRoute, Params } from '@angular/router';
|
||||||
import { TranslateService } from "@ngx-translate/core";
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { DataSource } from "@angular/cdk/table";
|
import { DataSource } from '@angular/cdk/table';
|
||||||
import { Observable } from "rxjs/Observable";
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { JsonSerializer } from "../../utilities/JsonSerializer";
|
import { JsonSerializer } from '../../utilities/JsonSerializer';
|
||||||
import { FormGroup } from "@angular/forms";
|
import { FormGroup } from '@angular/forms';
|
||||||
import { SnackBarNotificationComponent } from "../../shared/components/notificaiton/snack-bar-notification.component";
|
import { SnackBarNotificationComponent } from '../../shared/components/notificaiton/snack-bar-notification.component';
|
||||||
import { BaseErrorModel } from "../../models/error/BaseErrorModel";
|
import { BaseErrorModel } from '../../models/error/BaseErrorModel';
|
||||||
import { DatasetService } from "../../services/dataset/dataset.service";
|
import { DatasetService } from '../../services/dataset/dataset.service';
|
||||||
import { DatasetModel } from "../../models/datasets/DatasetModel";
|
import { DatasetModel } from '../../models/datasets/DatasetModel';
|
||||||
import { ExternalSourcesService } from "../../services/external-sources/external-sources.service";
|
import { ExternalSourcesService } from '../../services/external-sources/external-sources.service';
|
||||||
import { ExternalSourcesItemModel } from "../../models/external-sources/ExternalSourcesItemModel";
|
import { ExternalSourcesItemModel } from '../../models/external-sources/ExternalSourcesItemModel';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dataset-editor-component',
|
selector: 'app-dataset-editor-component',
|
||||||
templateUrl: 'dataset-editor.component.html',
|
templateUrl: 'dataset-editor.component.html',
|
||||||
styleUrls: ['./dataset-editor.component.scss'],
|
styleUrls: ['./dataset-editor.component.scss'],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class DatasetEditorComponent implements AfterViewInit {
|
export class DatasetEditorComponent implements AfterViewInit {
|
||||||
|
|
||||||
isNew = true;
|
isNew = true;
|
||||||
dataset: DatasetModel;
|
dataset: DatasetModel;
|
||||||
@Input() formGroup: FormGroup = null;
|
@Input() formGroup: FormGroup = null;
|
||||||
|
|
||||||
// filtereddataRepositoriesAsync: boolean = false;
|
// filtereddataRepositoriesAsync: boolean = false;
|
||||||
// filteredRegistriesAsync: boolean = false;
|
// filteredRegistriesAsync: boolean = false;
|
||||||
// filteredServicesAsync: boolean = false;
|
// filteredServicesAsync: boolean = false;
|
||||||
|
|
||||||
// filtereddataRepositories: ExternalSourcesItemModel[];
|
// filtereddataRepositories: ExternalSourcesItemModel[];
|
||||||
// filteredRegistries: ExternalSourcesItemModel[];
|
// filteredRegistries: ExternalSourcesItemModel[];
|
||||||
// filteredServices: ExternalSourcesItemModel[];
|
// filteredServices: ExternalSourcesItemModel[];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private datasetService: DatasetService,
|
private datasetService: DatasetService,
|
||||||
private externalSourcesService: ExternalSourcesService,
|
private externalSourcesService: ExternalSourcesService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
public snackBar: MatSnackBar,
|
public snackBar: MatSnackBar,
|
||||||
public router: Router,
|
public router: Router,
|
||||||
public language: TranslateService,
|
public language: TranslateService,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
/* this.route.params.subscribe((params: Params) => {
|
/* this.route.params.subscribe((params: Params) => {
|
||||||
const itemId = params['id'];
|
const itemId = params['id'];
|
||||||
|
|
||||||
if (itemId != null) {
|
if (itemId != null) {
|
||||||
this.isNew = false;
|
this.isNew = false;
|
||||||
this.datasetService.getSingle(itemId).map(data => data as DatasetModel)
|
this.datasetService.getSingle(itemId).map(data => data as DatasetModel)
|
||||||
.subscribe(data => {
|
.subscribe(data => {
|
||||||
this.dataset = new JsonSerializer<DatasetModel>().fromJSONObject(data, DatasetModel);
|
this.dataset = new JsonSerializer<DatasetModel>().fromJSONObject(data, DatasetModel);
|
||||||
this.formGroup = this.dataset.buildForm();
|
this.formGroup = this.dataset.buildForm();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.dataset = new DatasetModel();
|
this.dataset = new DatasetModel();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.formGroup = this.dataset.buildForm();
|
this.formGroup = this.dataset.buildForm();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}); */
|
}); */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public cancel(): void {
|
public cancel(): void {
|
||||||
this.router.navigate(['/datasets']);
|
this.router.navigate(['/datasets']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// filterdataRepositories(value: string): void {
|
// filterdataRepositories(value: string): void {
|
||||||
|
|
||||||
// this.filtereddataRepositories = undefined;
|
// this.filtereddataRepositories = undefined;
|
||||||
// if (value) {
|
// if (value) {
|
||||||
// this.filtereddataRepositoriesAsync = true;
|
// this.filtereddataRepositoriesAsync = true;
|
||||||
|
|
||||||
// this.externalSourcesService.searchDMPOrganizations(value).subscribe(items => {
|
// this.externalSourcesService.searchDMPOrganizations(value).subscribe(items => {
|
||||||
// this.filtereddataRepositories = items;
|
// this.filtereddataRepositories = items;
|
||||||
// this.filtereddataRepositoriesAsync = false;
|
// this.filtereddataRepositoriesAsync = false;
|
||||||
|
|
||||||
// // this.filteredOrganisations = items.filter((filteredObj: any) => {
|
// // this.filteredOrganisations = items.filter((filteredObj: any) => {
|
||||||
// // return this.objectsModel ? this.objectsModel.indexOf(filteredObj) < 0 : true;
|
// // return this.objectsModel ? this.objectsModel.indexOf(filteredObj) < 0 : true;
|
||||||
// // });
|
// // });
|
||||||
|
|
||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// filterRegistries(value: string): void {
|
// filterRegistries(value: string): void {
|
||||||
|
|
||||||
// this.filteredRegistries = undefined;
|
// this.filteredRegistries = undefined;
|
||||||
// if (value) {
|
// if (value) {
|
||||||
// this.filteredRegistriesAsync = true;
|
// this.filteredRegistriesAsync = true;
|
||||||
|
|
||||||
// this.externalSourcesService.searchDMPResearchers(value).subscribe(items => {
|
// this.externalSourcesService.searchDMPResearchers(value).subscribe(items => {
|
||||||
// this.filteredRegistries = items;
|
// this.filteredRegistries = items;
|
||||||
// this.filteredRegistriesAsync = false;
|
// this.filteredRegistriesAsync = false;
|
||||||
|
|
||||||
// // this.filteredOrganisations = items.filter((filteredObj: any) => {
|
// // this.filteredOrganisations = items.filter((filteredObj: any) => {
|
||||||
// // return this.objectsModel ? this.objectsModel.indexOf(filteredObj) < 0 : true;
|
// // return this.objectsModel ? this.objectsModel.indexOf(filteredObj) < 0 : true;
|
||||||
// // });
|
// // });
|
||||||
|
|
||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// filterServices(value: string): void {
|
// filterServices(value: string): void {
|
||||||
|
|
||||||
// this.filteredServices = undefined;
|
// this.filteredServices = undefined;
|
||||||
// if (value) {
|
// if (value) {
|
||||||
// this.filteredServicesAsync = true;
|
// this.filteredServicesAsync = true;
|
||||||
|
|
||||||
// this.externalSourcesService.searchDatasetService(value).subscribe(items => {
|
// this.externalSourcesService.searchDatasetService(value).subscribe(items => {
|
||||||
// this.filteredServices = items;
|
// this.filteredServices = items;
|
||||||
// this.filteredServicesAsync = false;
|
// this.filteredServicesAsync = false;
|
||||||
|
|
||||||
// // this.filteredOrganisations = items.filter((filteredObj: any) => {
|
// // this.filteredOrganisations = items.filter((filteredObj: any) => {
|
||||||
// // return this.objectsModel ? this.objectsModel.indexOf(filteredObj) < 0 : true;
|
// // return this.objectsModel ? this.objectsModel.indexOf(filteredObj) < 0 : true;
|
||||||
// // });
|
// // });
|
||||||
|
|
||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,16 +3,16 @@ import { DataTableRequest } from '../../models/data-table/DataTableRequest';
|
||||||
import { DatasetListingModel } from '../../models/datasets/DatasetListingModel';
|
import { DatasetListingModel } from '../../models/datasets/DatasetListingModel';
|
||||||
import { DatasetCriteria } from '../../models/criteria/dataset/DatasetCriteria';
|
import { DatasetCriteria } from '../../models/criteria/dataset/DatasetCriteria';
|
||||||
import { DatasetService } from '../../services/dataset/dataset.service';
|
import { DatasetService } from '../../services/dataset/dataset.service';
|
||||||
import { Component, ViewChild, OnInit, AfterViewInit } from "@angular/core";
|
import { Component, ViewChild, OnInit, AfterViewInit } from '@angular/core';
|
||||||
import { MatPaginator, MatSort, MatSnackBar } from "@angular/material";
|
import { MatPaginator, MatSort, MatSnackBar } from '@angular/material';
|
||||||
import { Router, Params, ActivatedRoute } from "@angular/router";
|
import { Router, Params, ActivatedRoute } from '@angular/router';
|
||||||
import { TranslateService } from "@ngx-translate/core";
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { DataSource } from "@angular/cdk/table";
|
import { DataSource } from '@angular/cdk/table';
|
||||||
|
|
||||||
import { Observable } from "rxjs/Observable";
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { PageEvent } from '@angular/material';
|
import { PageEvent } from '@angular/material';
|
||||||
import { DataManagementPlanService } from "../../services/data-management-plan/data-management-plan.service";
|
import { DataManagementPlanService } from '../../services/data-management-plan/data-management-plan.service';
|
||||||
import { DataManagementPlanModel } from "../../models/data-managemnt-plans/DataManagementPlanModel";
|
import { DataManagementPlanModel } from '../../models/data-managemnt-plans/DataManagementPlanModel';
|
||||||
import { DatasetCriteriaComponent } from '../../shared/components/criteria/datasets/datasets-criteria.component';
|
import { DatasetCriteriaComponent } from '../../shared/components/criteria/datasets/datasets-criteria.component';
|
||||||
import { BreadcrumbItem } from '../../shared/components/breadcrumb/definition/breadcrumb-item';
|
import { BreadcrumbItem } from '../../shared/components/breadcrumb/definition/breadcrumb-item';
|
||||||
import { IBreadCrumbComponent } from '../../shared/components/breadcrumb/definition/IBreadCrumbComponent';
|
import { IBreadCrumbComponent } from '../../shared/components/breadcrumb/definition/IBreadCrumbComponent';
|
||||||
|
@ -21,148 +21,149 @@ import { JsonSerializer } from '../../utilities/JsonSerializer';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dataset-listing-component',
|
selector: 'app-dataset-listing-component',
|
||||||
templateUrl: 'dataset-listing.component.html',
|
templateUrl: 'dataset-listing.component.html',
|
||||||
styleUrls: ['./dataset-listing.component.scss'],
|
styleUrls: ['./dataset-listing.component.scss'],
|
||||||
providers:[Utilities]
|
providers: [Utilities]
|
||||||
})
|
})
|
||||||
export class DatasetListingComponent implements OnInit, IBreadCrumbComponent {
|
export class DatasetListingComponent implements OnInit, IBreadCrumbComponent {
|
||||||
|
|
||||||
@ViewChild(MatPaginator) _paginator: MatPaginator;
|
@ViewChild(MatPaginator) _paginator: MatPaginator;
|
||||||
@ViewChild(MatSort) sort: MatSort;
|
@ViewChild(MatSort) sort: MatSort;
|
||||||
@ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent;
|
@ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent;
|
||||||
|
|
||||||
breadCrumbs: Observable<BreadcrumbItem[]>;
|
breadCrumbs: Observable<BreadcrumbItem[]>;
|
||||||
|
|
||||||
dataSource: DatasetDataSource | null;
|
dataSource: DatasetDataSource | null;
|
||||||
displayedColumns: String[] = ['label', 'dmp', 'profile', 'status', 'description', 'created', 'actions'];
|
displayedColumns: String[] = ['label', 'dmp', 'profile', 'status', 'description', 'created', 'actions'];
|
||||||
pageEvent: PageEvent;
|
pageEvent: PageEvent;
|
||||||
titlePrefix: String;
|
titlePrefix: String;
|
||||||
dmpId: string;
|
dmpId: string;
|
||||||
|
|
||||||
statuses = [
|
statuses = [
|
||||||
{ value: '0', viewValue: 'Active' },
|
{ value: '0', viewValue: 'Active' },
|
||||||
{ value: '1', viewValue: 'Inactive' }
|
{ value: '1', viewValue: 'Inactive' }
|
||||||
];
|
];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private datasetService: DatasetService,
|
private datasetService: DatasetService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private languageService: TranslateService,
|
private languageService: TranslateService,
|
||||||
public snackBar: MatSnackBar,
|
public snackBar: MatSnackBar,
|
||||||
public route: ActivatedRoute,
|
public route: ActivatedRoute,
|
||||||
public dataManagementPlanService: DataManagementPlanService,
|
public dataManagementPlanService: DataManagementPlanService,
|
||||||
public utilities: Utilities
|
public utilities: Utilities
|
||||||
) {
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
this.route.params.subscribe(async (params: Params) => {
|
this.route.params.subscribe(async (params: Params) => {
|
||||||
this.dmpId = params['dmpId'];
|
this.dmpId = params['dmpId'];
|
||||||
this.criteria.setCriteria(this.getDefaultCriteria(this.dmpId));
|
this.criteria.setCriteria(this.getDefaultCriteria(this.dmpId));
|
||||||
this.refresh();
|
this.refresh();
|
||||||
this.criteria.setRefreshCallback(() => this.refresh());
|
this.criteria.setRefreshCallback(() => this.refresh());
|
||||||
if (this.dmpId != null) {
|
if (this.dmpId != null) {
|
||||||
let dmp = await this.dataManagementPlanService.getSingle(this.dmpId).toPromise()
|
const dmp = await this.dataManagementPlanService.getSingle(this.dmpId).toPromise();
|
||||||
this.breadCrumbs = Observable.of([{ parentComponentName: "DataManagementPlanEditorComponent", label: dmp.label, url: "dmps/edit/" + this.dmpId }])
|
this.breadCrumbs = Observable.of([{ parentComponentName: 'DataManagementPlanEditorComponent', label: dmp.label, url: 'dmps/edit/' + this.dmpId }]);
|
||||||
if (params['dmpLabel'] != undefined)
|
if (params['dmpLabel'] !== undefined) {
|
||||||
this.titlePrefix = "for " + params['dmpLabel'];
|
this.titlePrefix = 'for ' + params['dmpLabel'];
|
||||||
} else {
|
}
|
||||||
this.breadCrumbs = Observable.of([])
|
} else {
|
||||||
}
|
this.breadCrumbs = Observable.of([]);
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
this.dataSource = new DatasetDataSource(this.datasetService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria, this.dmpId);
|
this.dataSource = new DatasetDataSource(this.datasetService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria, this.dmpId);
|
||||||
}
|
}
|
||||||
|
|
||||||
rowClick(rowId: String) {
|
rowClick(rowId: String) {
|
||||||
this.router.navigate(['/datasets/edit/' + rowId]);
|
this.router.navigate(['/datasets/edit/' + rowId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
getDefaultCriteria(dmpId: String): DatasetCriteria {
|
getDefaultCriteria(dmpId: String): DatasetCriteria {
|
||||||
const defaultCriteria = new DatasetCriteria();
|
const defaultCriteria = new DatasetCriteria();
|
||||||
if (dmpId != null) {
|
if (dmpId != null) {
|
||||||
defaultCriteria.dmpIds.push(dmpId);
|
defaultCriteria.dmpIds.push(dmpId);
|
||||||
}
|
}
|
||||||
return defaultCriteria;
|
return defaultCriteria;
|
||||||
}
|
}
|
||||||
|
|
||||||
makeItPublic(id: String) {
|
makeItPublic(id: String) {
|
||||||
this.datasetService.makeDatasetPublic(id).subscribe();
|
this.datasetService.makeDatasetPublic(id).subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DatasetDataSource extends DataSource<DatasetListingModel> {
|
export class DatasetDataSource extends DataSource<DatasetListingModel> {
|
||||||
|
|
||||||
totalCount = 0;
|
totalCount = 0;
|
||||||
isLoadingResults = false;
|
isLoadingResults = false;
|
||||||
constructor(
|
constructor(
|
||||||
private _service: DatasetService,
|
private _service: DatasetService,
|
||||||
private _paginator: MatPaginator,
|
private _paginator: MatPaginator,
|
||||||
private _sort: MatSort,
|
private _sort: MatSort,
|
||||||
private _languageService: TranslateService,
|
private _languageService: TranslateService,
|
||||||
private _snackBar: MatSnackBar,
|
private _snackBar: MatSnackBar,
|
||||||
private _criteria: DatasetCriteriaComponent,
|
private _criteria: DatasetCriteriaComponent,
|
||||||
private dmpId: String
|
private dmpId: String
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(): Observable<DatasetListingModel[]> {
|
connect(): Observable<DatasetListingModel[]> {
|
||||||
const displayDataChanges = [
|
const displayDataChanges = [
|
||||||
this._paginator.page
|
this._paginator.page
|
||||||
//this._sort.matSortChange
|
//this._sort.matSortChange
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
return Observable.merge(...displayDataChanges)
|
return Observable.merge(...displayDataChanges)
|
||||||
.startWith(null)
|
.startWith(null)
|
||||||
.switchMap(() => {
|
.switchMap(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.isLoadingResults = true;
|
this.isLoadingResults = true;
|
||||||
});
|
});
|
||||||
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
|
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
|
||||||
let fields: Array<string> = new Array()
|
let fields: Array<string> = new Array();
|
||||||
if (this._sort.active) fields = this._sort.direction === "asc" ? ["+" + this._sort.active] : ["-" + this._sort.active];
|
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 });
|
const request = new DataTableRequest<DatasetCriteria>(startIndex, this._paginator.pageSize, { fields: fields });
|
||||||
request.criteria = this._criteria.criteria;
|
request.criteria = this._criteria.criteria;
|
||||||
if (this.dmpId) request.criteria.allVersions = true;
|
if (this.dmpId) { request.criteria.allVersions = true; }
|
||||||
return this._service.getPaged(request);
|
return this._service.getPaged(request);
|
||||||
})
|
})
|
||||||
/*.catch((error: any) => {
|
/*.catch((error: any) => {
|
||||||
this._snackBar.openFromComponent(SnackBarNotificationComponent, {
|
this._snackBar.openFromComponent(SnackBarNotificationComponent, {
|
||||||
data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService },
|
data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService },
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
extraClasses: ['snackbar-warning']
|
extraClasses: ['snackbar-warning']
|
||||||
});
|
});
|
||||||
//this._criteria.criteria.onCallbackError(error);
|
//this._criteria.criteria.onCallbackError(error);
|
||||||
return Observable.of(null);
|
return Observable.of(null);
|
||||||
})*/
|
})*/
|
||||||
.map(result => {
|
.map(result => {
|
||||||
result.data = JsonSerializer.fromJSONArray(result.data, DatasetListingModel)
|
result.data = JsonSerializer.fromJSONArray(result.data, DatasetListingModel);
|
||||||
return result;
|
return result;
|
||||||
})
|
})
|
||||||
.map(result => {
|
.map(result => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.isLoadingResults = false;
|
this.isLoadingResults = false;
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
})
|
})
|
||||||
.map(result => {
|
.map(result => {
|
||||||
if (!result) { return []; }
|
if (!result) { return []; }
|
||||||
if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; }
|
if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; }
|
||||||
return result.data;
|
return result.data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect() {
|
disconnect() {
|
||||||
// No-op
|
// No-op
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,63 +1,68 @@
|
||||||
|
|
||||||
|
|
||||||
<div class="dmp-profile-editor">
|
<div class="dmp-profile-editor">
|
||||||
<form *ngIf="formGroup" (ngSubmit)="formSubmit()" [formGroup]="formGroup">
|
<form *ngIf="formGroup" (ngSubmit)="formSubmit()" [formGroup]="formGroup">
|
||||||
<mat-card>
|
<mat-card>
|
||||||
<mat-card-header>
|
<mat-card-header>
|
||||||
<mat-card-title *ngIf="isNew">{{'DMP-PROFILE-EDITOR.TITLE.NEW' | translate}}</mat-card-title>
|
<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-title *ngIf="!isNew">{{formGroup.get('label').value}}</mat-card-title>
|
||||||
|
|
||||||
</mat-card-header>
|
</mat-card-header>
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
|
|
||||||
<mat-form-field class="full-width">
|
<mat-form-field class="full-width">
|
||||||
<input matInput placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.LABEL' | translate}}" type="text" name="label" formControlName="label"
|
<input matInput placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.LABEL' | translate}}" type="text" name="label"
|
||||||
required>
|
formControlName="label" required>
|
||||||
<mat-error *ngIf="formGroup.get('label').errors?.backendError">{{baseErrorModel.label}}</mat-error>
|
<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-error *ngIf="formGroup.get('label').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<div formGroupName="definition">
|
<div formGroupName="definition">
|
||||||
<mat-list formArrayName="fields">
|
<mat-list formArrayName="fields">
|
||||||
<mat-list-item *ngFor="let field of formGroup.controls.definition.controls.fields.controls;let i=index">
|
<mat-list-item *ngFor="let field of formGroup.controls.definition.controls.fields.controls;let i=index">
|
||||||
<div [formGroupName]="i">
|
<div [formGroupName]="i">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<input matInput placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.LABEL' | translate}}" type="text" name="label" formControlName="label"
|
<input matInput placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.LABEL' | translate}}" type="text" name="label"
|
||||||
required>
|
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?.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-error *ngIf="formGroup.get('definition').get('fields').get(''+i).get('label').errors?.backendError">{{'GENERAL.VALIDATION.REQUIRED'
|
||||||
</mat-form-field>
|
| translate}}</mat-error>
|
||||||
<mat-form-field>
|
</mat-form-field>
|
||||||
<mat-select placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.TYPE' | translate}}" formControlName="type">
|
<mat-form-field>
|
||||||
<mat-option *ngFor="let fieldType of getDMPProfileFieldTypeValues()" [value]="fieldType">{{ getDMPProfileFieldTypeWithLanguage(fieldType) | translate}}</mat-option>
|
<mat-select placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.TYPE' | translate}}" formControlName="type">
|
||||||
</mat-select>
|
<mat-option *ngFor="let fieldType of getDMPProfileFieldTypeValues()" [value]="fieldType">{{
|
||||||
<mat-error *ngIf="formGroup.get('definition').get('fields').get(''+i).get('type').errors?.required">{{baseErrorModel.type}}</mat-error>
|
getDMPProfileFieldTypeWithLanguage(fieldType) | translate}}</mat-option>
|
||||||
<mat-error *ngIf="formGroup.get('definition').get('fields').get(''+i).get('type').errors?.backendError">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
</mat-select>
|
||||||
</mat-form-field>
|
<mat-error *ngIf="formGroup.get('definition').get('fields').get(''+i).get('type').errors?.required">{{baseErrorModel.type}}</mat-error>
|
||||||
<mat-form-field>
|
<mat-error *ngIf="formGroup.get('definition').get('fields').get(''+i).get('type').errors?.backendError">{{'GENERAL.VALIDATION.REQUIRED'
|
||||||
<mat-select placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.DATATYPE' | translate}}" formControlName="dataType">
|
| translate}}</mat-error>
|
||||||
<mat-option *ngFor="let fieldDataType of getDMPProfileFieldDataTypeValues()" [value]="fieldDataType">{{ getDMPProfileFieldDataTypeWithLanguage(fieldDataType) | translate}}</mat-option>
|
</mat-form-field>
|
||||||
</mat-select>
|
<mat-form-field>
|
||||||
<mat-error *ngIf="formGroup.get('definition').get('fields').get(''+i).get('dataType').errors?.required">{{baseErrorModel.dataType}}</mat-error>
|
<mat-select placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.DATATYPE' | translate}}" formControlName="dataType">
|
||||||
<mat-error *ngIf="formGroup.get('definition').get('fields').get(''+i).get('dataType').errors?.backendError">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-option *ngFor="let fieldDataType of getDMPProfileFieldDataTypeValues()" [value]="fieldDataType">{{
|
||||||
</mat-form-field>
|
getDMPProfileFieldDataTypeWithLanguage(fieldDataType) | translate}}</mat-option>
|
||||||
<mat-checkbox formControlName="required">
|
</mat-select>
|
||||||
{{'DMP-PROFILE-EDITOR.FIELDS.REQUIRED' | translate}}
|
<mat-error *ngIf="formGroup.get('definition').get('fields').get(''+i).get('dataType').errors?.required">{{baseErrorModel.dataType}}</mat-error>
|
||||||
</mat-checkbox>
|
<mat-error *ngIf="formGroup.get('definition').get('fields').get(''+i).get('dataType').errors?.backendError">{{'GENERAL.VALIDATION.REQUIRED'
|
||||||
</div>
|
| translate}}</mat-error>
|
||||||
</mat-list-item>
|
</mat-form-field>
|
||||||
<button mat-fab class="mat-fab-bottom-right" color="primary" type="button" (click)="addField()">
|
<mat-checkbox formControlName="required">
|
||||||
<mat-icon class="mat-24">add</mat-icon>
|
{{'DMP-PROFILE-EDITOR.FIELDS.REQUIRED' | translate}}
|
||||||
</button>
|
</mat-checkbox>
|
||||||
</mat-list>
|
</div>
|
||||||
</div>
|
</mat-list-item>
|
||||||
<div layout="row" class="full-width text-right" align="end">
|
<button mat-fab class="mat-fab-bottom-right" color="primary" type="button" (click)="addField()">
|
||||||
<button mat-raised-button color="primary" (click)="cancel()" type="button">{{'DMP-PROFILE-EDITOR.ACTIONS.CANCEL' | translate}}</button>
|
<mat-icon class="mat-24">add</mat-icon>
|
||||||
<button mat-raised-button color="primary" type="submit">{{'DMP-PROFILE-EDITOR.ACTIONS.SAVE' | translate}}</button>
|
</button>
|
||||||
<button *ngIf="!isNew" mat-raised-button color="primary" type="button" (click)="delete()">{{'DMP-PROFILE-EDITOR.ACTIONS.DELETE' | translate}}</button>
|
</mat-list>
|
||||||
</div>
|
</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-content>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,177 +1,175 @@
|
||||||
import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from "@angular/core";
|
import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from '@angular/core';
|
||||||
import { MatPaginator, MatSort, MatSnackBar } from "@angular/material";
|
import { MatPaginator, MatSort, MatSnackBar } from '@angular/material';
|
||||||
import { Router, ActivatedRoute, Params } from "@angular/router";
|
import { Router, ActivatedRoute, Params } from '@angular/router';
|
||||||
import { TranslateService } from "@ngx-translate/core";
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { DataSource } from "@angular/cdk/table";
|
import { DataSource } from '@angular/cdk/table';
|
||||||
import { Observable } from "rxjs/Observable";
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { DataManagementPlanService } from "../../services/data-management-plan/data-management-plan.service";
|
import { DataManagementPlanService } from '../../services/data-management-plan/data-management-plan.service';
|
||||||
import { ProjectModel } from "../../models/projects/ProjectModel";
|
import { ProjectModel } from '../../models/projects/ProjectModel';
|
||||||
import { JsonSerializer } from "../../utilities/JsonSerializer";
|
import { JsonSerializer } from '../../utilities/JsonSerializer';
|
||||||
import { FormGroup, AbstractControl, FormControl, FormArray } from "@angular/forms";
|
import { FormGroup, AbstractControl, FormControl, FormArray } from '@angular/forms';
|
||||||
import { SnackBarNotificationComponent } from "../../shared/components/notificaiton/snack-bar-notification.component";
|
import { SnackBarNotificationComponent } from '../../shared/components/notificaiton/snack-bar-notification.component';
|
||||||
import { BaseErrorModel } from "../../models/error/BaseErrorModel";
|
import { BaseErrorModel } from '../../models/error/BaseErrorModel';
|
||||||
import { TdDialogService } from "@covalent/core";
|
import { TdDialogService } from '@covalent/core';
|
||||||
import { HostConfiguration } from "../../app.constants";
|
import { HostConfiguration } from '../../app.constants';
|
||||||
import { DataManagementPlanProfileService } from "../../services/data-management-plan-profile/datamanagement-profile.service";
|
import { DataManagementPlanProfileService } from '../../services/data-management-plan-profile/datamanagement-profile.service';
|
||||||
import { DataManagementPlanProfileModel } from "../../models/data-management-plan-profile/DataManagementPlanProfileModel";
|
import { DataManagementPlanProfileModel } from '../../models/data-management-plan-profile/DataManagementPlanProfileModel';
|
||||||
import { DMPProfileFieldDataType, DMPProfileType, DataManagementProfileField } from "../../models/data-management-plan-profile/DataManagementProfileField";
|
import { DMPProfileFieldDataType, DMPProfileType, DataManagementProfileField } from '../../models/data-management-plan-profile/DataManagementProfileField';
|
||||||
import { Utilities } from "../../utilities/utilities";
|
import { Utilities } from '../../utilities/utilities';
|
||||||
import { DataManagementPlanProfileListingModel } from "../../models/data-management-plan-profile/DataManagementPlanProfileListingModel";
|
import { DataManagementPlanProfileListingModel } from '../../models/data-management-plan-profile/DataManagementPlanProfileListingModel';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dmp-profile-editor-component',
|
selector: 'app-dmp-profile-editor-component',
|
||||||
templateUrl: 'dmp-profile-editor.component.html',
|
templateUrl: 'dmp-profile-editor.component.html',
|
||||||
styleUrls: ['./dmp-profile-editor.component.scss'],
|
styleUrls: ['./dmp-profile-editor.component.scss'],
|
||||||
providers: [DataManagementPlanProfileService],
|
providers: [DataManagementPlanProfileService, Utilities],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class DataManagementPlanProfileEditorComponent implements AfterViewInit {
|
export class DataManagementPlanProfileEditorComponent implements AfterViewInit {
|
||||||
|
|
||||||
isNew = true;
|
isNew = true;
|
||||||
dataManagementPlanProfileModel: DataManagementPlanProfileModel;
|
dataManagementPlanProfileModel: DataManagementPlanProfileModel;
|
||||||
formGroup: FormGroup = null;
|
formGroup: FormGroup = null;
|
||||||
host = HostConfiguration.Server;
|
host = HostConfiguration.Server;
|
||||||
baseErrorModel: BaseErrorModel;
|
baseErrorModel: BaseErrorModel;
|
||||||
constructor(
|
constructor(
|
||||||
private dmpProfileService: DataManagementPlanProfileService,
|
private dmpProfileService: DataManagementPlanProfileService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
public snackBar: MatSnackBar,
|
public snackBar: MatSnackBar,
|
||||||
public router: Router,
|
public router: Router,
|
||||||
public language: TranslateService,
|
public language: TranslateService,
|
||||||
private dialogService: TdDialogService,
|
private dialogService: TdDialogService,
|
||||||
private utilities: Utilities
|
private utilities: Utilities
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
this.route.params.subscribe((params: Params) => {
|
this.route.params.subscribe((params: Params) => {
|
||||||
const itemId = params['id'];
|
const itemId = params['id'];
|
||||||
|
|
||||||
if (itemId != null) {
|
if (itemId != null) {
|
||||||
this.isNew = false;
|
this.isNew = false;
|
||||||
this.dmpProfileService.getSingle(itemId).map(data => data as DataManagementPlanProfileModel)
|
this.dmpProfileService.getSingle(itemId).map(data => data as DataManagementPlanProfileModel)
|
||||||
.subscribe(data => {
|
.subscribe(data => {
|
||||||
this.dataManagementPlanProfileModel = JsonSerializer.fromJSONObject(data, DataManagementPlanProfileModel);
|
this.dataManagementPlanProfileModel = JsonSerializer.fromJSONObject(data, DataManagementPlanProfileModel);
|
||||||
this.baseErrorModel = this.dataManagementPlanProfileModel.errorModel;
|
this.baseErrorModel = this.dataManagementPlanProfileModel.errorModel;
|
||||||
this.formGroup = this.dataManagementPlanProfileModel.buildForm();
|
this.formGroup = this.dataManagementPlanProfileModel.buildForm();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.dataManagementPlanProfileModel = new DataManagementPlanProfileModel();
|
this.dataManagementPlanProfileModel = new DataManagementPlanProfileModel();
|
||||||
this.baseErrorModel = this.dataManagementPlanProfileModel.errorModel;
|
this.baseErrorModel = this.dataManagementPlanProfileModel.errorModel;
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.formGroup = this.dataManagementPlanProfileModel.buildForm();
|
this.formGroup = this.dataManagementPlanProfileModel.buildForm();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
formSubmit(): void {
|
formSubmit(): void {
|
||||||
this.touchAllFormFields(this.formGroup);
|
this.touchAllFormFields(this.formGroup);
|
||||||
if (!this.isFormValid()) { return; }
|
if (!this.isFormValid()) { return; }
|
||||||
this.onSubmit();
|
this.onSubmit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public isFormValid() {
|
public isFormValid() {
|
||||||
return this.formGroup.valid;
|
return this.formGroup.valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit(): void {
|
onSubmit(): void {
|
||||||
this.dmpProfileService.createDataManagementPlan(this.formGroup.value).subscribe(
|
this.dmpProfileService.createDataManagementPlan(this.formGroup.value).subscribe(
|
||||||
complete => this.onCallbackSuccess(),
|
complete => this.onCallbackSuccess(),
|
||||||
error => this.onCallbackError(error)
|
error => this.onCallbackError(error)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onCallbackSuccess(): void {
|
onCallbackSuccess(): void {
|
||||||
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
|
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
|
||||||
data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
|
data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
})
|
});
|
||||||
this.router.navigate(['/dmp-profiles']);
|
this.router.navigate(['/dmp-profiles']);
|
||||||
}
|
}
|
||||||
|
|
||||||
onCallbackError(errorResponse: any) {
|
onCallbackError(errorResponse: any) {
|
||||||
this.setErrorModel(errorResponse.error);
|
this.setErrorModel(errorResponse.error);
|
||||||
this.validateAllFormFields(this.formGroup);
|
this.validateAllFormFields(this.formGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
public setErrorModel(errorModel: BaseErrorModel) {
|
public setErrorModel(errorModel: BaseErrorModel) {
|
||||||
Object.keys(errorModel).forEach(item => {
|
Object.keys(errorModel).forEach(item => {
|
||||||
(<any>this.dataManagementPlanProfileModel.errorModel)[item] = (<any>errorModel)[item];
|
(<any>this.dataManagementPlanProfileModel.errorModel)[item] = (<any>errorModel)[item];
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public cancel(): void {
|
public cancel(): void {
|
||||||
this.router.navigate(['/dmp-profiles']);
|
this.router.navigate(['/dmp-profiles']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public touchAllFormFields(formControl: AbstractControl) {
|
public touchAllFormFields(formControl: AbstractControl) {
|
||||||
if (formControl instanceof FormControl) {
|
if (formControl instanceof FormControl) {
|
||||||
formControl.markAsTouched();
|
formControl.markAsTouched();
|
||||||
} else if (formControl instanceof FormGroup) {
|
} else if (formControl instanceof FormGroup) {
|
||||||
Object.keys(formControl.controls).forEach(item => {
|
Object.keys(formControl.controls).forEach(item => {
|
||||||
const control = formControl.get(item);
|
const control = formControl.get(item);
|
||||||
this.touchAllFormFields(control);
|
this.touchAllFormFields(control);
|
||||||
})
|
});
|
||||||
}
|
} else if (formControl instanceof FormArray) {
|
||||||
else if (formControl instanceof FormArray) {
|
formControl.controls.forEach(item => {
|
||||||
formControl.controls.forEach(item => {
|
this.touchAllFormFields(item);
|
||||||
this.touchAllFormFields(item);
|
});
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public validateAllFormFields(formControl: AbstractControl) {
|
public validateAllFormFields(formControl: AbstractControl) {
|
||||||
if (formControl instanceof FormControl) {
|
if (formControl instanceof FormControl) {
|
||||||
formControl.updateValueAndValidity({ emitEvent: false })
|
formControl.updateValueAndValidity({ emitEvent: false });
|
||||||
} else if (formControl instanceof FormGroup) {
|
} else if (formControl instanceof FormGroup) {
|
||||||
Object.keys(formControl.controls).forEach(item => {
|
Object.keys(formControl.controls).forEach(item => {
|
||||||
const control = formControl.get(item);
|
const control = formControl.get(item);
|
||||||
this.validateAllFormFields(control);
|
this.validateAllFormFields(control);
|
||||||
})
|
});
|
||||||
}
|
} else if (formControl instanceof FormArray) {
|
||||||
else if (formControl instanceof FormArray) {
|
formControl.controls.forEach(item => {
|
||||||
formControl.controls.forEach(item => {
|
this.validateAllFormFields(item);
|
||||||
this.validateAllFormFields(item);
|
});
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
addField() {
|
addField() {
|
||||||
(<FormArray>this.formGroup.get("definition").get("fields")).push(new DataManagementProfileField().buildForm())
|
(<FormArray>this.formGroup.get('definition').get('fields')).push(new DataManagementProfileField().buildForm());
|
||||||
}
|
}
|
||||||
|
|
||||||
getDMPProfileFieldDataTypeValues(): Number[] {
|
getDMPProfileFieldDataTypeValues(): Number[] {
|
||||||
let keys: string[] = Object.keys(DMPProfileFieldDataType);
|
let keys: string[] = Object.keys(DMPProfileFieldDataType);
|
||||||
keys = keys.slice(0, keys.length / 2);
|
keys = keys.slice(0, keys.length / 2);
|
||||||
const values: Number[] = keys.map(Number);
|
const values: Number[] = keys.map(Number);
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
getDMPProfileFieldDataTypeWithLanguage(role: DMPProfileFieldDataType): string {
|
getDMPProfileFieldDataTypeWithLanguage(role: DMPProfileFieldDataType): string {
|
||||||
let result = '';
|
let result = '';
|
||||||
this.language.get(this.utilities.convertFromDMPProfileDataType(role)).subscribe((value: string) => {
|
this.language.get(this.utilities.convertFromDMPProfileDataType(role)).subscribe((value: string) => {
|
||||||
result = value;
|
result = value;
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
getDMPProfileFieldTypeValues(): Number[] {
|
getDMPProfileFieldTypeValues(): Number[] {
|
||||||
let keys: string[] = Object.keys(DMPProfileType);
|
let keys: string[] = Object.keys(DMPProfileType);
|
||||||
keys = keys.slice(0, keys.length / 2);
|
keys = keys.slice(0, keys.length / 2);
|
||||||
const values: Number[] = keys.map(Number);
|
const values: Number[] = keys.map(Number);
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
getDMPProfileFieldTypeWithLanguage(role: DMPProfileType): string {
|
getDMPProfileFieldTypeWithLanguage(role: DMPProfileType): string {
|
||||||
let result = '';
|
let result = '';
|
||||||
this.language.get(this.utilities.convertFromDMPProfileType(role)).subscribe((value: string) => {
|
this.language.get(this.utilities.convertFromDMPProfileType(role)).subscribe((value: string) => {
|
||||||
result = value;
|
result = value;
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,117 +1,117 @@
|
||||||
import { Component, ViewChild, OnInit } from "@angular/core";
|
import { Component, ViewChild, OnInit } from '@angular/core';
|
||||||
import { MatPaginator, MatSort, PageEvent, MatSnackBar } from "@angular/material";
|
import { MatPaginator, MatSort, PageEvent, MatSnackBar } from '@angular/material';
|
||||||
import { DataManagementPlanProfileCriteriaComponent } from "../../shared/components/criteria/datamanagementplanprofile/dmp-profile-criteria.component";
|
import { DataManagementPlanProfileCriteriaComponent } from '../../shared/components/criteria/datamanagementplanprofile/dmp-profile-criteria.component';
|
||||||
import { ActivatedRoute, Router, Params } from "@angular/router";
|
import { ActivatedRoute, Router, Params } from '@angular/router';
|
||||||
import { TranslateService } from "@ngx-translate/core";
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { DataSource } from "@angular/cdk/table";
|
import { DataSource } from '@angular/cdk/table';
|
||||||
import { DataManagementPlanProfileCriteria } from "../../models/criteria/dmp-profile/DataManagementPlanProfileCriteria";
|
import { DataManagementPlanProfileCriteria } from '../../models/criteria/dmp-profile/DataManagementPlanProfileCriteria';
|
||||||
import { Observable } from "rxjs";
|
import { Observable } from 'rxjs';
|
||||||
import { DataTableRequest } from "../../models/data-table/DataTableRequest";
|
import { DataTableRequest } from '../../models/data-table/DataTableRequest';
|
||||||
import { DataManagementPlanProfileListingModel } from "../../models/data-management-plan-profile/DataManagementPlanProfileListingModel";
|
import { DataManagementPlanProfileListingModel } from '../../models/data-management-plan-profile/DataManagementPlanProfileListingModel';
|
||||||
import { DataManagementPlanProfileService } from "../../services/data-management-plan-profile/datamanagement-profile.service";
|
import { DataManagementPlanProfileService } from '../../services/data-management-plan-profile/datamanagement-profile.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dmp-profile-listing-component',
|
selector: 'app-dmp-profile-listing-component',
|
||||||
templateUrl: 'dmp-profile-listing.component.html',
|
templateUrl: 'dmp-profile-listing.component.html',
|
||||||
styleUrls: ['./dmp-profile-listing.component.scss'],
|
styleUrls: ['./dmp-profile-listing.component.scss'],
|
||||||
providers: [DataManagementPlanProfileService]
|
providers: [DataManagementPlanProfileService]
|
||||||
})
|
})
|
||||||
export class DataManagementPlanProfileListingComponent implements OnInit {
|
export class DataManagementPlanProfileListingComponent implements OnInit {
|
||||||
|
|
||||||
@ViewChild(MatPaginator) _paginator: MatPaginator;
|
@ViewChild(MatPaginator) _paginator: MatPaginator;
|
||||||
@ViewChild(MatSort) sort: MatSort;
|
@ViewChild(MatSort) sort: MatSort;
|
||||||
@ViewChild(DataManagementPlanProfileCriteriaComponent) criteria: DataManagementPlanProfileCriteriaComponent;
|
@ViewChild(DataManagementPlanProfileCriteriaComponent) criteria: DataManagementPlanProfileCriteriaComponent;
|
||||||
|
|
||||||
|
|
||||||
dataSource: DatasetDataSource | null;
|
dataSource: DatasetDataSource | null;
|
||||||
displayedColumns: String[] = ['label', 'status', 'created'];
|
displayedColumns: String[] = ['label', 'status', 'created'];
|
||||||
pageEvent: PageEvent;
|
pageEvent: PageEvent;
|
||||||
titlePrefix: String;
|
titlePrefix: String;
|
||||||
dmpId: String;
|
dmpId: String;
|
||||||
|
|
||||||
statuses = [
|
statuses = [
|
||||||
{ value: '0', viewValue: 'Active' },
|
{ value: '0', viewValue: 'Active' },
|
||||||
{ value: '1', viewValue: 'Inactive' }
|
{ value: '1', viewValue: 'Inactive' }
|
||||||
];
|
];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private languageService: TranslateService,
|
private languageService: TranslateService,
|
||||||
public snackBar: MatSnackBar,
|
public snackBar: MatSnackBar,
|
||||||
public route: ActivatedRoute,
|
public route: ActivatedRoute,
|
||||||
public dataManagementPlanService: DataManagementPlanProfileService
|
public dataManagementPlanService: DataManagementPlanProfileService
|
||||||
) {
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.route.params.subscribe((params: Params) => {
|
this.route.params.subscribe((params: Params) => {
|
||||||
this.dmpId = params['dmpId'];
|
this.dmpId = params['dmpId'];
|
||||||
this.criteria.setCriteria(this.getDefaultCriteria());
|
this.criteria.setCriteria(this.getDefaultCriteria());
|
||||||
this.refresh();
|
this.refresh();
|
||||||
this.criteria.setRefreshCallback(() => this.refresh());
|
this.criteria.setRefreshCallback(() => this.refresh());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
this.dataSource = new DatasetDataSource(this.dataManagementPlanService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria);
|
this.dataSource = new DatasetDataSource(this.dataManagementPlanService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria);
|
||||||
}
|
}
|
||||||
|
|
||||||
rowClick(rowId: String) {
|
rowClick(rowId: String) {
|
||||||
this.router.navigate(['dmp-profiles/' + rowId]);
|
this.router.navigate(['dmp-profiles/' + rowId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
getDefaultCriteria(): DataManagementPlanProfileCriteria {
|
getDefaultCriteria(): DataManagementPlanProfileCriteria {
|
||||||
const defaultCriteria = new DataManagementPlanProfileCriteria();
|
const defaultCriteria = new DataManagementPlanProfileCriteria();
|
||||||
return defaultCriteria;
|
return defaultCriteria;
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeItPublic(id: String) {
|
// makeItPublic(id: String) {
|
||||||
// debugger;
|
// debugger;
|
||||||
// this.datasetService.makeDatasetPublic(id).subscribe();
|
// this.datasetService.makeDatasetPublic(id).subscribe();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DatasetDataSource extends DataSource<DataManagementPlanProfileListingModel> {
|
export class DatasetDataSource extends DataSource<DataManagementPlanProfileListingModel> {
|
||||||
|
|
||||||
totalCount = 0;
|
totalCount = 0;
|
||||||
isLoadingResults = false;
|
isLoadingResults = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _service: DataManagementPlanProfileService,
|
private _service: DataManagementPlanProfileService,
|
||||||
private _paginator: MatPaginator,
|
private _paginator: MatPaginator,
|
||||||
private _sort: MatSort,
|
private _sort: MatSort,
|
||||||
private _languageService: TranslateService,
|
private _languageService: TranslateService,
|
||||||
private _snackBar: MatSnackBar,
|
private _snackBar: MatSnackBar,
|
||||||
private _criteria: DataManagementPlanProfileCriteriaComponent
|
private _criteria: DataManagementPlanProfileCriteriaComponent
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(): Observable<DataManagementPlanProfileListingModel[]> {
|
connect(): Observable<DataManagementPlanProfileListingModel[]> {
|
||||||
const displayDataChanges = [
|
const displayDataChanges = [
|
||||||
this._paginator.page
|
this._paginator.page
|
||||||
//this._sort.matSortChange
|
//this._sort.matSortChange
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
return Observable.merge(...displayDataChanges)
|
return Observable.merge(...displayDataChanges)
|
||||||
.startWith(null)
|
.startWith(null)
|
||||||
.switchMap(() => {
|
.switchMap(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.isLoadingResults = true;
|
this.isLoadingResults = true;
|
||||||
});
|
});
|
||||||
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
|
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
|
||||||
let fields: Array<string> = new Array()
|
let fields: Array<string> = new Array();
|
||||||
if (this._sort.active) fields = this._sort.direction === "asc" ? ["+" + this._sort.active] : ["-" + this._sort.active];
|
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 });
|
const request = new DataTableRequest<DataManagementPlanProfileCriteria>(startIndex, this._paginator.pageSize, { fields: fields });
|
||||||
request.criteria = this._criteria.criteria;
|
request.criteria = this._criteria.criteria;
|
||||||
return this._service.getPaged(request);
|
return this._service.getPaged(request);
|
||||||
})
|
})
|
||||||
/*.catch((error: any) => {
|
/*.catch((error: any) => {
|
||||||
this._snackBar.openFromComponent(SnackBarNotificationComponent, {
|
this._snackBar.openFromComponent(SnackBarNotificationComponent, {
|
||||||
data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService },
|
data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService },
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
|
@ -120,20 +120,20 @@ export class DatasetDataSource extends DataSource<DataManagementPlanProfileListi
|
||||||
//this._criteria.criteria.onCallbackError(error);
|
//this._criteria.criteria.onCallbackError(error);
|
||||||
return Observable.of(null);
|
return Observable.of(null);
|
||||||
})*/
|
})*/
|
||||||
.map(result => {
|
.map(result => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.isLoadingResults = false;
|
this.isLoadingResults = false;
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
})
|
})
|
||||||
.map(result => {
|
.map(result => {
|
||||||
if (!result) { return []; }
|
if (!result) { return []; }
|
||||||
if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; }
|
if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; }
|
||||||
return result.data;
|
return result.data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect() {
|
disconnect() {
|
||||||
// No-op
|
// No-op
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,50 +8,50 @@ import { HttpClient, HttpClientModule } from '@angular/common/http';
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
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 { DataManagementPlanProfileRoutes } from './dmp-profile.routes';
|
||||||
import { DataManagementPlanProfileEditorComponent } from './dmp-profile-editor/dmp-profile-editor.component';
|
import { DataManagementPlanProfileEditorComponent } from './dmp-profile-editor/dmp-profile-editor.component';
|
||||||
import { DataManagementPlanProfileListingComponent } from './dmp-profile-listing/dmp-profile-listing.component';
|
import { DataManagementPlanProfileListingComponent } from './dmp-profile-listing/dmp-profile-listing.component';
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
HttpClientModule,
|
HttpClientModule,
|
||||||
SharedModule,
|
SharedModule,
|
||||||
RouterModule.forChild(DataManagementPlanProfileRoutes),
|
RouterModule.forChild(DataManagementPlanProfileRoutes),
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
DynamicFormModule,
|
DynamicFormModule,
|
||||||
TranslateModule.forRoot({
|
TranslateModule.forRoot({
|
||||||
loader: {
|
loader: {
|
||||||
provide: TranslateLoader,
|
provide: TranslateLoader,
|
||||||
useFactory: HttpLoaderFactory,
|
useFactory: HttpLoaderFactory,
|
||||||
deps: [HttpClient]
|
deps: [HttpClient]
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|
||||||
declarations: [
|
declarations: [
|
||||||
DataManagementPlanProfileEditorComponent,
|
DataManagementPlanProfileEditorComponent,
|
||||||
DataManagementPlanProfileListingComponent
|
DataManagementPlanProfileListingComponent
|
||||||
],
|
],
|
||||||
|
|
||||||
exports: [
|
exports: [
|
||||||
DataManagementPlanProfileEditorComponent,
|
DataManagementPlanProfileEditorComponent,
|
||||||
DataManagementPlanProfileListingComponent,
|
DataManagementPlanProfileListingComponent,
|
||||||
RouterModule
|
RouterModule
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
DatasetService
|
DatasetService
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
export class DataManagamentPlanProfileModule {
|
export class DataManagamentPlanProfileModule {
|
||||||
constructor(private translate: TranslateService) {
|
constructor(private translate: TranslateService) {
|
||||||
translate.setDefaultLang('en');
|
translate.setDefaultLang('en');
|
||||||
translate.use('en');
|
translate.use('en');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function HttpLoaderFactory(httpClient: HttpClient) {
|
export function HttpLoaderFactory(httpClient: HttpClient) {
|
||||||
return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json');
|
return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json');
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { DataManagementPlanProfileEditorComponent } from './dmp-profile-editor/d
|
||||||
import { AuthGuard } from '../shared/guards/auth.guard';
|
import { AuthGuard } from '../shared/guards/auth.guard';
|
||||||
|
|
||||||
export const DataManagementPlanProfileRoutes: Routes = [
|
export const DataManagementPlanProfileRoutes: Routes = [
|
||||||
{ path: '', component: DataManagementPlanProfileListingComponent, canActivate: [AuthGuard] },
|
{ path: '', component: DataManagementPlanProfileListingComponent, canActivate: [AuthGuard] },
|
||||||
{ path: 'new', component: DataManagementPlanProfileEditorComponent, canActivate: [AuthGuard] },
|
{ path: 'new', component: DataManagementPlanProfileEditorComponent, canActivate: [AuthGuard] },
|
||||||
{ path: ':id', component: DataManagementPlanProfileEditorComponent, canActivate: [AuthGuard] },
|
{ path: ':id', component: DataManagementPlanProfileEditorComponent, canActivate: [AuthGuard] },
|
||||||
];
|
];
|
||||||
|
|
|
@ -15,10 +15,10 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { CovalentDialogsModule } from '@covalent/core';
|
import { CovalentDialogsModule } from '@covalent/core';
|
||||||
|
|
||||||
import { SharedModule } from '../shared/shared.module'
|
import { SharedModule } from '../shared/shared.module';
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { AvailableProfilesComponent } from '../shared/components/available-profiles/available-profiles.component';
|
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 { 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 { DynamicFieldProjectComponent } from './editor/dynamic-fields-project/dynamic-field-project/dynamic-field-project.component';
|
||||||
import { BaseHttpModule } from '../utilities/cite-http-service-module/cite-http.module';
|
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';
|
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
HttpClientModule,
|
HttpClientModule,
|
||||||
SharedModule,
|
SharedModule,
|
||||||
MaterialModule,
|
MaterialModule,
|
||||||
RouterModule.forChild(DataManagementPlanRoutes),
|
RouterModule.forChild(DataManagementPlanRoutes),
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
TranslateModule.forRoot({
|
TranslateModule.forRoot({
|
||||||
loader: {
|
loader: {
|
||||||
provide: TranslateLoader,
|
provide: TranslateLoader,
|
||||||
useFactory: HttpLoaderFactory,
|
useFactory: HttpLoaderFactory,
|
||||||
deps: [HttpClient]
|
deps: [HttpClient]
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
CovalentDialogsModule
|
CovalentDialogsModule
|
||||||
],
|
],
|
||||||
|
|
||||||
declarations: [
|
declarations: [
|
||||||
DataManagementPlanListingComponent,
|
DataManagementPlanListingComponent,
|
||||||
DataManagementPlanEditorComponent,
|
DataManagementPlanEditorComponent,
|
||||||
InvitationComponent,
|
InvitationComponent,
|
||||||
InvitationAcceptedComponent,
|
InvitationAcceptedComponent,
|
||||||
DataManagementPlanWizardComponent,
|
DataManagementPlanWizardComponent,
|
||||||
DataManagementPlanWizardEditorComponent,
|
DataManagementPlanWizardEditorComponent,
|
||||||
DatasetWizardListingComponent,
|
DatasetWizardListingComponent,
|
||||||
AddResearchersComponent,
|
AddResearchersComponent,
|
||||||
AvailableProfilesComponent,
|
AvailableProfilesComponent,
|
||||||
DynamicDmpFieldResolver,
|
DynamicDmpFieldResolverComponent,
|
||||||
DynamicFieldsProjectComponent,
|
DynamicFieldsProjectComponent,
|
||||||
DynamicFieldProjectComponent
|
DynamicFieldProjectComponent
|
||||||
],
|
],
|
||||||
|
|
||||||
exports: [
|
exports: [
|
||||||
DataManagementPlanListingComponent,
|
DataManagementPlanListingComponent,
|
||||||
DataManagementPlanEditorComponent,
|
DataManagementPlanEditorComponent,
|
||||||
InvitationComponent,
|
InvitationComponent,
|
||||||
InvitationAcceptedComponent,
|
InvitationAcceptedComponent,
|
||||||
DataManagementPlanWizardComponent,
|
DataManagementPlanWizardComponent,
|
||||||
DataManagementPlanWizardEditorComponent,
|
DataManagementPlanWizardEditorComponent,
|
||||||
DatasetWizardListingComponent,
|
DatasetWizardListingComponent,
|
||||||
AddResearchersComponent,
|
AddResearchersComponent,
|
||||||
AvailableProfilesComponent,
|
AvailableProfilesComponent,
|
||||||
DynamicFieldsProjectComponent,
|
DynamicFieldsProjectComponent,
|
||||||
DynamicFieldProjectComponent,
|
DynamicFieldProjectComponent,
|
||||||
RouterModule
|
RouterModule
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
InvitationComponent,
|
InvitationComponent,
|
||||||
AddResearchersComponent,
|
AddResearchersComponent,
|
||||||
AvailableProfilesComponent
|
AvailableProfilesComponent
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
ProjectService,
|
ProjectService,
|
||||||
ResearcherService,
|
ResearcherService,
|
||||||
DatasetService,
|
DatasetService,
|
||||||
InvitationService,
|
InvitationService,
|
||||||
DataManagementPlanService,
|
DataManagementPlanService,
|
||||||
ExternalSourcesService,
|
ExternalSourcesService,
|
||||||
DataManagementPlanProfileService
|
DataManagementPlanProfileService
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
export class DataManagementPlanModule {
|
export class DataManagementPlanModule {
|
||||||
constructor(private translate: TranslateService) {
|
constructor(private translate: TranslateService) {
|
||||||
translate.setDefaultLang('en');
|
translate.setDefaultLang('en');
|
||||||
translate.use('en');
|
translate.use('en');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function HttpLoaderFactory(httpClient: HttpClient) {
|
export function HttpLoaderFactory(httpClient: HttpClient) {
|
||||||
return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json');
|
return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json');
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,62 +6,62 @@ import { RouterModule, Routes } from '@angular/router';
|
||||||
import { InvitationAcceptedComponent } from '../shared/components/invitation-accepted/invitation-accepted.component';
|
import { InvitationAcceptedComponent } from '../shared/components/invitation-accepted/invitation-accepted.component';
|
||||||
|
|
||||||
export const DataManagementPlanRoutes: Routes = [
|
export const DataManagementPlanRoutes: Routes = [
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
component: DataManagementPlanListingComponent,
|
component: DataManagementPlanListingComponent,
|
||||||
data: {
|
data: {
|
||||||
breadcrumb: true
|
breadcrumb: true
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'viewversions/:groupId',
|
path: 'viewversions/:groupId',
|
||||||
component: DataManagementPlanListingComponent,
|
component: DataManagementPlanListingComponent,
|
||||||
data: {
|
data: {
|
||||||
breadcrumb: true
|
breadcrumb: true
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'project/:projectId',
|
path: 'project/:projectId',
|
||||||
component: DataManagementPlanListingComponent,
|
component: DataManagementPlanListingComponent,
|
||||||
data: {
|
data: {
|
||||||
breadcrumb: true
|
breadcrumb: true
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'edit/:id',
|
path: 'edit/:id',
|
||||||
component: DataManagementPlanEditorComponent,
|
component: DataManagementPlanEditorComponent,
|
||||||
data: {
|
data: {
|
||||||
breadcrumb: true
|
breadcrumb: true
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'new',
|
path: 'new',
|
||||||
component: DataManagementPlanEditorComponent,
|
component: DataManagementPlanEditorComponent,
|
||||||
data: {
|
data: {
|
||||||
breadcrumbs: 'new'
|
breadcrumbs: 'new'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'new_version/:id',
|
path: 'new_version/:id',
|
||||||
component: DataManagementPlanWizardComponent,
|
component: DataManagementPlanWizardComponent,
|
||||||
data: {
|
data: {
|
||||||
clone: false,
|
clone: false,
|
||||||
breadcrumb: true
|
breadcrumb: true
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'clone/:id',
|
path: 'clone/:id',
|
||||||
component: DataManagementPlanWizardComponent,
|
component: DataManagementPlanWizardComponent,
|
||||||
data: {
|
data: {
|
||||||
clone: false,
|
clone: false,
|
||||||
breadcrumb: true
|
breadcrumb: true
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "invitation/:id",
|
path: 'invitation/:id',
|
||||||
component: InvitationAcceptedComponent,
|
component: InvitationAcceptedComponent,
|
||||||
data: {
|
data: {
|
||||||
breadcrumb: true
|
breadcrumb: true
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
@ -1,129 +1,138 @@
|
||||||
<div class="data-management-plan-editor">
|
<div class="data-management-plan-editor">
|
||||||
<mat-card-title *ngIf="isNew">{{'DMP-EDITOR.TITLE.NEW' | translate}}</mat-card-title>
|
<mat-card-title *ngIf="isNew">{{'DMP-EDITOR.TITLE.NEW' | translate}}</mat-card-title>
|
||||||
<mat-card-title *ngIf="!isNew">
|
<mat-card-title *ngIf="!isNew">
|
||||||
<h3>{{formGroup?.get('label')?.value}} </h3>
|
<h3>{{formGroup?.get('label')?.value}} </h3>
|
||||||
</mat-card-title>
|
</mat-card-title>
|
||||||
<form *ngIf="formGroup" (ngSubmit)="formSubmit()" [formGroup]="formGroup">
|
<form *ngIf="formGroup" (ngSubmit)="formSubmit()" [formGroup]="formGroup">
|
||||||
<mat-card>
|
<mat-card>
|
||||||
<mat-card-header>
|
<mat-card-header>
|
||||||
<div class="fill-space"></div>
|
<div class="fill-space"></div>
|
||||||
<div *ngIf="!isNew">
|
<div *ngIf="!isNew">
|
||||||
<!-- <div fxFlex>
|
<!-- <div fxFlex>
|
||||||
<button mat-button type="button" (click)="redirectToProject()">
|
<button mat-button type="button" (click)="redirectToProject()">
|
||||||
<mat-icon>arrow_right_alt</mat-icon>{{'DMP-EDITOR.ACTIONS.GO-TO-PROJECT' | translate}}</button>
|
<mat-icon>arrow_right_alt</mat-icon>{{'DMP-EDITOR.ACTIONS.GO-TO-PROJECT' | translate}}</button>
|
||||||
</div> -->
|
</div> -->
|
||||||
<div>
|
<div>
|
||||||
<button mat-button type="button" (click)="redirectToDatasets()">
|
<button mat-button type="button" (click)="redirectToDatasets()">
|
||||||
<mat-icon>arrow_right_alt</mat-icon>{{'DMP-EDITOR.ACTIONS.GO-TO-DATASETS' | translate}}</button>
|
<mat-icon>arrow_right_alt</mat-icon>{{'DMP-EDITOR.ACTIONS.GO-TO-DATASETS' | translate}}
|
||||||
</div>
|
</button>
|
||||||
<mat-menu #actionsMenu="matMenu">
|
</div>
|
||||||
<button mat-menu-item (click)="newVersion(this.dataManagementPlan.id, this.dataManagementPlan.label)">
|
<mat-menu #actionsMenu="matMenu">
|
||||||
<mat-icon>queue</mat-icon>{{'DMP-LISTING.ACTIONS.NEW-VERSION' | translate}}</button>
|
<button mat-menu-item (click)="newVersion(this.dataManagementPlan.id, this.dataManagementPlan.label)">
|
||||||
<button mat-menu-item (click)="clone(this.dataManagementPlan.id)">
|
<mat-icon>queue</mat-icon>{{'DMP-LISTING.ACTIONS.NEW-VERSION' | translate}}
|
||||||
<mat-icon>filter_none</mat-icon>{{'DMP-LISTING.ACTIONS.CLONE' | translate}}</button>
|
</button>
|
||||||
<button mat-menu-item (click)="viewVersions(this.dataManagementPlan.groupId, this.dataManagementPlan.label)">
|
<button mat-menu-item (click)="clone(this.dataManagementPlan.id)">
|
||||||
<mat-icon>library_books</mat-icon>{{'DMP-LISTING.ACTIONS.VIEW-VERSION' | translate}}</button>
|
<mat-icon>filter_none</mat-icon>{{'DMP-LISTING.ACTIONS.CLONE' | translate}}
|
||||||
</mat-menu>
|
</button>
|
||||||
<div>
|
<button mat-menu-item (click)="viewVersions(this.dataManagementPlan.groupId, this.dataManagementPlan.label)">
|
||||||
<button mat-icon-button type="button" [matMenuTriggerFor]="actionsMenu">
|
<mat-icon>library_books</mat-icon>{{'DMP-LISTING.ACTIONS.VIEW-VERSION' | translate}}
|
||||||
<mat-icon>more_vert</mat-icon>
|
</button>
|
||||||
</button>
|
</mat-menu>
|
||||||
</div>
|
<div>
|
||||||
</div>
|
<button mat-icon-button type="button" [matMenuTriggerFor]="actionsMenu">
|
||||||
</mat-card-header>
|
<mat-icon>more_vert</mat-icon>
|
||||||
<mat-card-content>
|
</button>
|
||||||
<div class="row">
|
</div>
|
||||||
<mat-form-field class="col-md-12">
|
</div>
|
||||||
<input matInput placeholder="{{'DMP-EDITOR.FIELDS.NAME' | translate}}" type="text" name="label" formControlName="label" required>
|
</mat-card-header>
|
||||||
<mat-error *ngIf="formGroup.get('label').errors?.backendError">{{baseErrorModel.label}}</mat-error>
|
<mat-card-content>
|
||||||
<mat-error *ngIf="formGroup.get('label').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<div class="row">
|
||||||
</mat-form-field>
|
<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">
|
<mat-form-field class="col-md-12">
|
||||||
<textarea matInput class="description-area" placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION' | translate}}" formControlName="description"
|
<textarea matInput class="description-area" placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION' | translate}}"
|
||||||
required></textarea>
|
formControlName="description" required></textarea>
|
||||||
<mat-error *ngIf="formGroup.get('description').errors?.backendError">{{errorModel.description}}</mat-error>
|
<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-error *ngIf="formGroup.get('description').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<app-single-auto-complete required='true' [reactiveFormControl]="formGroup.get('project')" placeholder="{{this.languageResolverService.getBy('dmpEditor') | translate}}"
|
<app-single-auto-complete required='true' [reactiveFormControl]="formGroup.get('project')" placeholder="{{this.languageResolverService.getBy('dmpEditor') | translate}}"
|
||||||
[configuration]="projectAutoCompleteConfiguration">
|
[configuration]="projectAutoCompleteConfiguration">
|
||||||
</app-single-auto-complete>
|
</app-single-auto-complete>
|
||||||
</div>
|
</div>
|
||||||
<!-- <app-dynamic-fields-project [formGroup]="formGroup"></app-dynamic-fields-project> -->
|
<!-- <app-dynamic-fields-project [formGroup]="formGroup"></app-dynamic-fields-project> -->
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<app-multiple-auto-complete required='true' class="col-md-10" [reactiveFormControl]="formGroup.get('profiles')" placeholder="{{'DMP-EDITOR.FIELDS.PROFILES' | translate}}"
|
<app-multiple-auto-complete required='true' class="col-md-10" [reactiveFormControl]="formGroup.get('profiles')"
|
||||||
[configuration]="profilesAutoCompleteConfiguration">
|
placeholder="{{'DMP-EDITOR.FIELDS.PROFILES' | translate}}" [configuration]="profilesAutoCompleteConfiguration">
|
||||||
</app-multiple-auto-complete>
|
</app-multiple-auto-complete>
|
||||||
<div class="col-md-2">
|
<div class="col-md-2">
|
||||||
<button mat-icon-button type="button" (click)="availableProfiles()">
|
<button mat-icon-button type="button" (click)="availableProfiles()">
|
||||||
<mat-icon>view_list</mat-icon>
|
<mat-icon>view_list</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- <button mat-button (click)="availableProfiles()">View All</button> -->
|
<!-- <button mat-button (click)="availableProfiles()">View All</button> -->
|
||||||
|
|
||||||
|
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<app-multiple-auto-complete [reactiveFormControl]="formGroup.get('organisations')" placeholder="{{'DMP-EDITOR.FIELDS.ORGANISATIONS' | translate}}"
|
<app-multiple-auto-complete [reactiveFormControl]="formGroup.get('organisations')" placeholder="{{'DMP-EDITOR.FIELDS.ORGANISATIONS' | translate}}"
|
||||||
[configuration]="organisationsAutoCompleteConfiguration">
|
[configuration]="organisationsAutoCompleteConfiguration">
|
||||||
</app-multiple-auto-complete>
|
</app-multiple-auto-complete>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-10">
|
<div class="col-md-10">
|
||||||
<app-multiple-auto-complete [reactiveFormControl]="formGroup.get('researchers')" placeholder="{{'DMP-EDITOR.FIELDS.RESEARCHERS' | translate}}"
|
<app-multiple-auto-complete [reactiveFormControl]="formGroup.get('researchers')" placeholder="{{'DMP-EDITOR.FIELDS.RESEARCHERS' | translate}}"
|
||||||
[configuration]="researchersAutoCompleteConfiguration">
|
[configuration]="researchersAutoCompleteConfiguration">
|
||||||
</app-multiple-auto-complete>
|
</app-multiple-auto-complete>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2">
|
<div class="col-md-2">
|
||||||
<button mat-icon-button type="button" (click)="addResearcher()">
|
<button mat-icon-button type="button" (click)="addResearcher()">
|
||||||
<mat-icon>add_circle</mat-icon>
|
<mat-icon>add_circle</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</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">
|
<mat-form-field class="col-md-6">
|
||||||
<input type="text" placeholder="{{'DMP-EDITOR.FIELDS.PROFILE' | translate}}" [formControl]="textCtrl" matInput [matAutocomplete]="auto">
|
<input type="text" placeholder="{{'DMP-EDITOR.FIELDS.PROFILE' | translate}}" [formControl]="textCtrl" matInput
|
||||||
<mat-autocomplete #auto="matAutocomplete" [displayWith]="displayWith">
|
[matAutocomplete]="auto">
|
||||||
<mat-option *ngFor="let option of filteredOptions | async" [value]="option" (click)="selectOption(option)">
|
<mat-autocomplete #auto="matAutocomplete" [displayWith]="displayWith">
|
||||||
{{ option.label }}
|
<mat-option *ngFor="let option of filteredOptions | async" [value]="option" (click)="selectOption(option)">
|
||||||
</mat-option>
|
{{ option.label }}
|
||||||
</mat-autocomplete>
|
</mat-option>
|
||||||
</mat-form-field>
|
</mat-autocomplete>
|
||||||
<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>
|
||||||
|
<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">
|
<mat-form-field class="col-md-6">
|
||||||
<input matInput placeholder="Version" disabled [value]="formGroup.get('version').value== undefined ?0 :formGroup.get('version').value">
|
<input matInput placeholder="Version" disabled [value]="formGroup.get('version').value== undefined ?0 :formGroup.get('version').value">
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<mat-list *ngIf="associatedUsers?.length" role="list" class="col-md-12">
|
<mat-list *ngIf="associatedUsers?.length" role="list" class="col-md-12">
|
||||||
<h3 mat-subheader>Associated Users</h3>
|
<h3 mat-subheader>Associated Users</h3>
|
||||||
<mat-list-item role="listitem" *ngFor="let user of associatedUsers">
|
<mat-list-item role="listitem" *ngFor="let user of associatedUsers">
|
||||||
<mat-icon mat-list-icon>person</mat-icon>
|
<mat-icon mat-list-icon>person</mat-icon>
|
||||||
<div>{{user.name}}</div>
|
<div>{{user.name}}</div>
|
||||||
</mat-list-item>
|
</mat-list-item>
|
||||||
</mat-list>
|
</mat-list>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="right-button">
|
<div class="right-button">
|
||||||
<button mat-raised-button color="primary" (click)="cancel()" type="button">{{'DMP-EDITOR.ACTIONS.CANCEL' | translate}}</button>
|
<button mat-raised-button color="primary" (click)="cancel()" type="button">{{'DMP-EDITOR.ACTIONS.CANCEL' |
|
||||||
<!-- <button *ngIf="!isNew" mat-raised-button color="primary" (click)="invite()" type="button">{{'DMP-EDITOR.ACTIONS.INVITE' | translate}}</button> -->
|
translate}}</button>
|
||||||
<button mat-raised-button color="primary" type="submit">{{'DMP-EDITOR.ACTIONS.SAVE' | translate}}</button>
|
<!-- <button *ngIf="!isNew" mat-raised-button color="primary" (click)="invite()" type="button">{{'DMP-EDITOR.ACTIONS.INVITE' | 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>
|
<button mat-raised-button color="primary" type="submit">{{'DMP-EDITOR.ACTIONS.SAVE' | translate}}</button>
|
||||||
</div>
|
<button *ngIf="!isNew" mat-raised-button color="primary" type="button" (click)="openConfirm(formGroup.get('label').value, formGroup.get('id').value)">{{'DMP-EDITOR.ACTIONS.DELETE'
|
||||||
</div>
|
| translate}}</button>
|
||||||
</div>
|
</div>
|
||||||
</mat-card-content>
|
</div>
|
||||||
</mat-card>
|
</div>
|
||||||
</form>
|
</mat-card-content>
|
||||||
<!-- <div *ngIf="formGroup"> {{ formGroup.value | json }}</div> -->
|
</mat-card>
|
||||||
|
</form>
|
||||||
|
<!-- <div *ngIf="formGroup"> {{ formGroup.value | json }}</div> -->
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,331 +1,331 @@
|
||||||
import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from "@angular/core";
|
import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from '@angular/core';
|
||||||
import { MatPaginator, MatSort, MatSnackBar, MatDialog, MatChipList, MatChip } from "@angular/material";
|
import { MatPaginator, MatSort, MatSnackBar, MatDialog, MatChipList, MatChip } from '@angular/material';
|
||||||
import { Router, ActivatedRoute, Params } from "@angular/router";
|
import { Router, ActivatedRoute, Params } from '@angular/router';
|
||||||
import { TranslateService } from "@ngx-translate/core";
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { DataSource } from "@angular/cdk/table";
|
import { DataSource } from '@angular/cdk/table';
|
||||||
import { Observable } from "rxjs/Observable";
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { JsonSerializer } from "../../utilities/JsonSerializer";
|
import { JsonSerializer } from '../../utilities/JsonSerializer';
|
||||||
import { FormGroup, FormControl } from "@angular/forms";
|
import { FormGroup, FormControl } from '@angular/forms';
|
||||||
import { SnackBarNotificationComponent } from "../../shared/components/notificaiton/snack-bar-notification.component";
|
import { SnackBarNotificationComponent } from '../../shared/components/notificaiton/snack-bar-notification.component';
|
||||||
import { BaseErrorModel } from "../../models/error/BaseErrorModel";
|
import { BaseErrorModel } from '../../models/error/BaseErrorModel';
|
||||||
import { DataManagementPlanService } from "../../services/data-management-plan/data-management-plan.service";
|
import { DataManagementPlanService } from '../../services/data-management-plan/data-management-plan.service';
|
||||||
import { DataManagementPlanModel } from "../../models/data-managemnt-plans/DataManagementPlanModel";
|
import { DataManagementPlanModel } from '../../models/data-managemnt-plans/DataManagementPlanModel';
|
||||||
import { ExternalSourcesService } from "../../services/external-sources/external-sources.service";
|
import { ExternalSourcesService } from '../../services/external-sources/external-sources.service';
|
||||||
import { ExternalSourcesItemModel } from "../../models/external-sources/ExternalSourcesItemModel";
|
import { ExternalSourcesItemModel } from '../../models/external-sources/ExternalSourcesItemModel';
|
||||||
import { RequestItem } from "../../models/criteria/RequestItem";
|
import { RequestItem } from '../../models/criteria/RequestItem';
|
||||||
import { DatasetProfileCriteria } from "../../models/criteria/dataset/DatasetProfileCriteria";
|
import { DatasetProfileCriteria } from '../../models/criteria/dataset/DatasetProfileCriteria';
|
||||||
import { DataManagementPlanCriteriaComponent } from "../../shared/components/criteria/data-management-plan/dmp-criteria.component";
|
import { DataManagementPlanCriteriaComponent } from '../../shared/components/criteria/data-management-plan/dmp-criteria.component';
|
||||||
import { DatasetProfileModel } from "../../models/datasets/DatasetProfileModel";
|
import { DatasetProfileModel } from '../../models/datasets/DatasetProfileModel';
|
||||||
import { ProjectCriteria } from "../../models/criteria/project/ProjectCriteria";
|
import { ProjectCriteria } from '../../models/criteria/project/ProjectCriteria';
|
||||||
import { ProjectService } from "../../services/project/project.service";
|
import { ProjectService } from '../../services/project/project.service';
|
||||||
import { DmpUsersModel } from "../../models/dmpUsers/DmpUsersModel";
|
import { DmpUsersModel } from '../../models/dmpUsers/DmpUsersModel';
|
||||||
import { AddResearchersComponent } from "../../shared/components/add-researchers/add-researchers.component";
|
import { AddResearchersComponent } from '../../shared/components/add-researchers/add-researchers.component';
|
||||||
import { ViewContainerRef } from '@angular/core';
|
import { ViewContainerRef } from '@angular/core';
|
||||||
import { TdDialogService } from '@covalent/core';
|
import { TdDialogService } from '@covalent/core';
|
||||||
import { AvailableProfilesComponent } from "../../shared/components/available-profiles/available-profiles.component";
|
import { AvailableProfilesComponent } from '../../shared/components/available-profiles/available-profiles.component';
|
||||||
import { BaseCriteria } from "../../models/criteria/BaseCriteria";
|
import { BaseCriteria } from '../../models/criteria/BaseCriteria';
|
||||||
import { DataManagementPlanProfileService } from "../../services/data-management-plan-profile/datamanagement-profile.service";
|
import { DataManagementPlanProfileService } from '../../services/data-management-plan-profile/datamanagement-profile.service';
|
||||||
import { DataManagementPlanProfileListingModel } from "../../models/data-management-plan-profile/DataManagementPlanProfileListingModel";
|
import { DataManagementPlanProfileListingModel } from '../../models/data-management-plan-profile/DataManagementPlanProfileListingModel';
|
||||||
import { DataManagementPlanProfileCriteria } from "../../models/criteria/dmp-profile/DataManagementPlanProfileCriteria";
|
import { DataManagementPlanProfileCriteria } from '../../models/criteria/dmp-profile/DataManagementPlanProfileCriteria';
|
||||||
import { DataManagementPlanProfile } from "../../models/data-management-plan-profile/DataManagementPlanProfile";
|
import { DataManagementPlanProfile } from '../../models/data-management-plan-profile/DataManagementPlanProfile';
|
||||||
import { LanguageResolverService } from "../../services/language-resolver/language-resolver.service";
|
import { LanguageResolverService } from '../../services/language-resolver/language-resolver.service';
|
||||||
import { IBreadCrumbComponent } from "../../shared/components/breadcrumb/definition/IBreadCrumbComponent";
|
import { IBreadCrumbComponent } from '../../shared/components/breadcrumb/definition/IBreadCrumbComponent';
|
||||||
import { BreadcrumbItem } from "../../shared/components/breadcrumb/definition/breadcrumb-item";
|
import { BreadcrumbItem } from '../../shared/components/breadcrumb/definition/breadcrumb-item';
|
||||||
import { SingleAutoCompleteConfiguration } from "../../shared/components/autocompletes/single/single-auto-complete-configuration";
|
import { SingleAutoCompleteConfiguration } from '../../shared/components/autocompletes/single/single-auto-complete-configuration';
|
||||||
import { MultipleAutoCompleteConfiguration } from "../../shared/components/autocompletes/multiple/multiple-auto-complete-configuration";
|
import { MultipleAutoCompleteConfiguration } from '../../shared/components/autocompletes/multiple/multiple-auto-complete-configuration';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dmp-editor-component',
|
selector: 'app-dmp-editor-component',
|
||||||
templateUrl: 'dmp-editor.component.html',
|
templateUrl: 'dmp-editor.component.html',
|
||||||
styleUrls: ['./dmp-editor.component.scss'],
|
styleUrls: ['./dmp-editor.component.scss'],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class DataManagementPlanEditorComponent implements AfterViewInit, IBreadCrumbComponent {
|
export class DataManagementPlanEditorComponent implements AfterViewInit, IBreadCrumbComponent {
|
||||||
|
|
||||||
|
|
||||||
breadCrumbs: Observable<BreadcrumbItem[]>;
|
breadCrumbs: Observable<BreadcrumbItem[]>;
|
||||||
isNew = true;
|
isNew = true;
|
||||||
textCtrl = new FormControl();
|
textCtrl = new FormControl();
|
||||||
dataManagementPlan: DataManagementPlanModel;
|
dataManagementPlan: DataManagementPlanModel;
|
||||||
formGroup: FormGroup = null;
|
formGroup: FormGroup = null;
|
||||||
|
|
||||||
filteringOrganisationsAsync: boolean = false;
|
filteringOrganisationsAsync = false;
|
||||||
filteringResearchersAsync: boolean = false;
|
filteringResearchersAsync = false;
|
||||||
filteredProfilesAsync: boolean = false;
|
filteredProfilesAsync = false;
|
||||||
filteredOrganisations: ExternalSourcesItemModel[];
|
filteredOrganisations: ExternalSourcesItemModel[];
|
||||||
filteredResearchers: ExternalSourcesItemModel[];
|
filteredResearchers: ExternalSourcesItemModel[];
|
||||||
filteredProfiles: DatasetProfileModel[];
|
filteredProfiles: DatasetProfileModel[];
|
||||||
|
|
||||||
projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
|
projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
|
||||||
profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
|
profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
|
||||||
organisationsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
|
organisationsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
|
||||||
researchersAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
|
researchersAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
|
||||||
|
|
||||||
createNewVersion;
|
createNewVersion;
|
||||||
associatedUsers: Array<DmpUsersModel>
|
associatedUsers: Array<DmpUsersModel>;
|
||||||
filteredOptions: Observable<DataManagementPlanProfileListingModel>
|
filteredOptions: Observable<DataManagementPlanProfileListingModel>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private dmpProfileService: DataManagementPlanProfileService,
|
private dmpProfileService: DataManagementPlanProfileService,
|
||||||
private dataManagementPlanService: DataManagementPlanService,
|
private dataManagementPlanService: DataManagementPlanService,
|
||||||
private projectService: ProjectService,
|
private projectService: ProjectService,
|
||||||
private externalSourcesService: ExternalSourcesService,
|
private externalSourcesService: ExternalSourcesService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
public snackBar: MatSnackBar,
|
public snackBar: MatSnackBar,
|
||||||
public router: Router,
|
public router: Router,
|
||||||
public language: TranslateService,
|
public language: TranslateService,
|
||||||
private _service: DataManagementPlanService,
|
private _service: DataManagementPlanService,
|
||||||
public dialog: MatDialog,
|
public dialog: MatDialog,
|
||||||
private _dialogService: TdDialogService,
|
private _dialogService: TdDialogService,
|
||||||
private _viewContainerRef: ViewContainerRef,
|
private _viewContainerRef: ViewContainerRef,
|
||||||
private languageResolverService: LanguageResolverService
|
private languageResolverService: LanguageResolverService
|
||||||
) {
|
) {
|
||||||
this.filteredOptions = dmpProfileService.getAll({ criteria: new DataManagementPlanProfileCriteria() });
|
this.filteredOptions = dmpProfileService.getAll({ criteria: new DataManagementPlanProfileCriteria() });
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
this.route.params.subscribe((params: Params) => {
|
this.route.params.subscribe((params: Params) => {
|
||||||
const itemId = params['id'];
|
const itemId = params['id'];
|
||||||
|
|
||||||
let projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
|
const projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
|
||||||
projectRequestItem.criteria = new ProjectCriteria();
|
projectRequestItem.criteria = new ProjectCriteria();
|
||||||
let organisationRequestItem: RequestItem<BaseCriteria> = new RequestItem();
|
const organisationRequestItem: RequestItem<BaseCriteria> = new RequestItem();
|
||||||
organisationRequestItem.criteria = new BaseCriteria();
|
organisationRequestItem.criteria = new BaseCriteria();
|
||||||
//this.projectAutoCompleteConfiguration = new AutoCompleteConfiguration(this.projectService.getWithExternal.bind(this.projectService), projectRequestItem);
|
//this.projectAutoCompleteConfiguration = new AutoCompleteConfiguration(this.projectService.getWithExternal.bind(this.projectService), projectRequestItem);
|
||||||
|
|
||||||
|
|
||||||
this.projectAutoCompleteConfiguration = {
|
this.projectAutoCompleteConfiguration = {
|
||||||
filterFn: this.searchProject.bind(this),
|
filterFn: this.searchProject.bind(this),
|
||||||
items: this.searchProject(''),
|
items: this.searchProject(''),
|
||||||
displayFn: (item) => item["label"],
|
displayFn: (item) => item['label'],
|
||||||
titleFn: (item) => item["label"],
|
titleFn: (item) => item['label'],
|
||||||
//mapFn: (item) => new JsonSerializer<ProjectReference>().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()),
|
//mapFn: (item) => new JsonSerializer<ProjectReference>().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()),
|
||||||
loadDataOnStart: true
|
loadDataOnStart: true
|
||||||
};
|
};
|
||||||
|
|
||||||
this.profilesAutoCompleteConfiguration = {
|
this.profilesAutoCompleteConfiguration = {
|
||||||
filterFn: this.filterProfiles.bind(this),
|
filterFn: this.filterProfiles.bind(this),
|
||||||
initialItems: (excludedItems: any[]) => this.filterProfiles('').map(result => result.filter(x => excludedItems.map(x => x.id).indexOf(x.id) == -1)),
|
initialItems: (excludedItems: any[]) => this.filterProfiles('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)),
|
||||||
displayFn: (item) => item["label"],
|
displayFn: (item) => item['label'],
|
||||||
titleFn: (item) => item["label"],
|
titleFn: (item) => item['label'],
|
||||||
//mapFn: (item) => new JsonSerializer<ProjectReference>().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()),
|
//mapFn: (item) => new JsonSerializer<ProjectReference>().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()),
|
||||||
loadDataOnStart: true
|
loadDataOnStart: true
|
||||||
};
|
};
|
||||||
|
|
||||||
this.organisationsAutoCompleteConfiguration = {
|
this.organisationsAutoCompleteConfiguration = {
|
||||||
filterFn: this.filterOrganisations.bind(this),
|
filterFn: this.filterOrganisations.bind(this),
|
||||||
initialItems: (excludedItems: any[]) => this.filterOrganisations('').map(result => result.filter(x => excludedItems.map(x => x.id).indexOf(x.id) == -1)),
|
initialItems: (excludedItems: any[]) => this.filterOrganisations('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)),
|
||||||
displayFn: (item) => item["name"],
|
displayFn: (item) => item['name'],
|
||||||
titleFn: (item) => item["name"],
|
titleFn: (item) => item['name'],
|
||||||
loadDataOnStart: true
|
loadDataOnStart: true
|
||||||
};
|
};
|
||||||
|
|
||||||
this.researchersAutoCompleteConfiguration = {
|
this.researchersAutoCompleteConfiguration = {
|
||||||
filterFn: this.filterResearchers.bind(this),
|
filterFn: this.filterResearchers.bind(this),
|
||||||
initialItems: (excludedItems: any[]) => this.filterResearchers('').map(result => result.filter(x => excludedItems.map(x => x.id).indexOf(x.id) == -1)),
|
initialItems: (excludedItems: any[]) => this.filterResearchers('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)),
|
||||||
displayFn: (item) => item["name"],
|
displayFn: (item) => item['name'],
|
||||||
titleFn: (item) => item["name"],
|
titleFn: (item) => item['name'],
|
||||||
loadDataOnStart: true
|
loadDataOnStart: true
|
||||||
};
|
};
|
||||||
|
|
||||||
if (itemId != null) {
|
if (itemId != null) {
|
||||||
this.isNew = false;
|
this.isNew = false;
|
||||||
this.dataManagementPlanService.getSingle(itemId).map(data => data as DataManagementPlanModel)
|
this.dataManagementPlanService.getSingle(itemId).map(data => data as DataManagementPlanModel)
|
||||||
.subscribe(async data => {
|
.subscribe(async data => {
|
||||||
this.dataManagementPlan = JsonSerializer.fromJSONObject(data, DataManagementPlanModel);
|
this.dataManagementPlan = JsonSerializer.fromJSONObject(data, DataManagementPlanModel);
|
||||||
this.formGroup = this.dataManagementPlan.buildForm();
|
this.formGroup = this.dataManagementPlan.buildForm();
|
||||||
if (this.formGroup.get("profile") && this.formGroup.get("profile").value) {
|
if (this.formGroup.get('profile') && this.formGroup.get('profile').value) {
|
||||||
this.textCtrl.patchValue(this.formGroup.get("profile").value);
|
this.textCtrl.patchValue(this.formGroup.get('profile').value);
|
||||||
}
|
}
|
||||||
this.breadCrumbs = Observable.of([
|
this.breadCrumbs = Observable.of([
|
||||||
{
|
{
|
||||||
parentComponentName: "DataManagementPlanListingComponent",
|
parentComponentName: 'DataManagementPlanListingComponent',
|
||||||
label: 'DMPs',
|
label: 'DMPs',
|
||||||
url: "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()]
|
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;
|
this.associatedUsers = data.associatedUsers;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.dataManagementPlan = new DataManagementPlanModel();
|
this.dataManagementPlan = new DataManagementPlanModel();
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
this.formGroup = this.dataManagementPlan.buildForm();
|
this.formGroup = this.dataManagementPlan.buildForm();
|
||||||
if (this.formGroup.get("profile") && this.formGroup.get("profile").value) {
|
if (this.formGroup.get('profile') && this.formGroup.get('profile').value) {
|
||||||
this.textCtrl.patchValue(this.formGroup.get("profile").value);
|
this.textCtrl.patchValue(this.formGroup.get('profile').value);
|
||||||
}
|
}
|
||||||
this.breadCrumbs = Observable.of([
|
this.breadCrumbs = Observable.of([
|
||||||
{
|
{
|
||||||
parentComponentName: "DataManagementPlanListingComponent",
|
parentComponentName: 'DataManagementPlanListingComponent',
|
||||||
label: 'DMPs',
|
label: 'DMPs',
|
||||||
url: "dmps",
|
url: 'dmps',
|
||||||
}
|
}
|
||||||
])
|
]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
this.route
|
this.route
|
||||||
.queryParams
|
.queryParams
|
||||||
.subscribe(params => {
|
.subscribe(params => {
|
||||||
this.createNewVersion = params["clone"];
|
this.createNewVersion = params['clone'];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
searchProject(query: string) {
|
searchProject(query: string) {
|
||||||
let projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
|
const projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
|
||||||
projectRequestItem.criteria = new ProjectCriteria();
|
projectRequestItem.criteria = new ProjectCriteria();
|
||||||
projectRequestItem.criteria.like = query;
|
projectRequestItem.criteria.like = query;
|
||||||
return this.projectService.getWithExternal(projectRequestItem);
|
return this.projectService.getWithExternal(projectRequestItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
formSubmit(): void {
|
formSubmit(): void {
|
||||||
//this.touchAllFormFields(this.formGroup);
|
//this.touchAllFormFields(this.formGroup);
|
||||||
if (!this.isFormValid()) { return; }
|
if (!this.isFormValid()) { return; }
|
||||||
this.onSubmit();
|
this.onSubmit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public isFormValid() {
|
public isFormValid() {
|
||||||
return this.formGroup.valid;
|
return this.formGroup.valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit(): void {
|
onSubmit(): void {
|
||||||
this.dataManagementPlanService.createDataManagementPlan(this.formGroup.value).subscribe(
|
this.dataManagementPlanService.createDataManagementPlan(this.formGroup.value).subscribe(
|
||||||
complete => this.onCallbackSuccess(),
|
complete => this.onCallbackSuccess(),
|
||||||
error => this.onCallbackError(error)
|
error => this.onCallbackError(error)
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onCallbackSuccess(): void {
|
onCallbackSuccess(): void {
|
||||||
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
|
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
|
||||||
data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
|
data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
})
|
});
|
||||||
this.router.navigate(['/dmps']);
|
this.router.navigate(['/dmps']);
|
||||||
}
|
}
|
||||||
|
|
||||||
onCallbackError(error: any) {
|
onCallbackError(error: any) {
|
||||||
this.setErrorModel(error.error);
|
this.setErrorModel(error.error);
|
||||||
//this.validateAllFormFields(this.formGroup);
|
//this.validateAllFormFields(this.formGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
public setErrorModel(errorModel: BaseErrorModel) {
|
public setErrorModel(errorModel: BaseErrorModel) {
|
||||||
Object.keys(errorModel).forEach(item => {
|
Object.keys(errorModel).forEach(item => {
|
||||||
(<any>this.dataManagementPlan.errorModel)[item] = (<any>errorModel)[item];
|
(<any>this.dataManagementPlan.errorModel)[item] = (<any>errorModel)[item];
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public cancel(): void {
|
public cancel(): void {
|
||||||
this.router.navigate(['/dmps']);
|
this.router.navigate(['/dmps']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public invite(): void {
|
public invite(): void {
|
||||||
this.router.navigate(['/invite/' + this.dataManagementPlan.id]);
|
this.router.navigate(['/invite/' + this.dataManagementPlan.id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
filterOrganisations(value: string): Observable<ExternalSourcesItemModel[]> {
|
filterOrganisations(value: string): Observable<ExternalSourcesItemModel[]> {
|
||||||
|
|
||||||
this.filteredOrganisations = undefined;
|
this.filteredOrganisations = undefined;
|
||||||
this.filteringOrganisationsAsync = true;
|
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.filteredResearchers = undefined;
|
||||||
this.filteringResearchersAsync = true;
|
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.filteredProfiles = undefined;
|
||||||
this.filteredProfilesAsync = true;
|
this.filteredProfilesAsync = true;
|
||||||
|
|
||||||
const request = new RequestItem<DatasetProfileCriteria>();
|
const request = new RequestItem<DatasetProfileCriteria>();
|
||||||
let criteria = new DatasetProfileCriteria();
|
const criteria = new DatasetProfileCriteria();
|
||||||
criteria.like = value;
|
criteria.like = value;
|
||||||
request.criteria = criteria;
|
request.criteria = criteria;
|
||||||
return this._service.searchDMPProfiles(request)
|
return this._service.searchDMPProfiles(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
addResearcher(rowId: any, rowName: any) {
|
addResearcher(rowId: any, rowName: any) {
|
||||||
let dialogRef = this.dialog.open(AddResearchersComponent, {
|
const dialogRef = this.dialog.open(AddResearchersComponent, {
|
||||||
height: '255px',
|
height: '255px',
|
||||||
width: '700px',
|
width: '700px',
|
||||||
data: {
|
data: {
|
||||||
dmpId: rowId,
|
dmpId: rowId,
|
||||||
dmpName: rowName
|
dmpName: rowName
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
availableProfiles() {
|
availableProfiles() {
|
||||||
let dialogRef = this.dialog.open(AvailableProfilesComponent, {
|
const dialogRef = this.dialog.open(AvailableProfilesComponent, {
|
||||||
height: '355px',
|
height: '355px',
|
||||||
width: '700px',
|
width: '700px',
|
||||||
data: {
|
data: {
|
||||||
profiles: this.formGroup.get("profiles")
|
profiles: this.formGroup.get('profiles')
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
openConfirm(dmpLabel, id): void {
|
openConfirm(dmpLabel, id): void {
|
||||||
this._dialogService.openConfirm({
|
this._dialogService.openConfirm({
|
||||||
message: 'Are you sure you want to delete the "' + dmpLabel + '"',
|
message: 'Are you sure you want to delete the "' + dmpLabel + '"',
|
||||||
disableClose: true || false, // defaults to false
|
disableClose: true || false, // defaults to false
|
||||||
viewContainerRef: this._viewContainerRef, //OPTIONAL
|
viewContainerRef: this._viewContainerRef, //OPTIONAL
|
||||||
title: 'Confirm', //OPTIONAL, hides if not provided
|
title: 'Confirm', //OPTIONAL, hides if not provided
|
||||||
cancelButton: 'No', //OPTIONAL, defaults to 'CANCEL'
|
cancelButton: 'No', //OPTIONAL, defaults to 'CANCEL'
|
||||||
acceptButton: 'Yes' //OPTIONAL, defaults to 'ACCEPT'
|
acceptButton: 'Yes' //OPTIONAL, defaults to 'ACCEPT'
|
||||||
// width: '500px', //OPTIONAL, defaults to 400px
|
// width: '500px', //OPTIONAL, defaults to 400px
|
||||||
}).afterClosed().subscribe((accept: boolean) => {
|
}).afterClosed().subscribe((accept: boolean) => {
|
||||||
if (accept) {
|
if (accept) {
|
||||||
this.dataManagementPlanService.delete(id).subscribe(() => {
|
this.dataManagementPlanService.delete(id).subscribe(() => {
|
||||||
this.router.navigate(['/dmps'])
|
this.router.navigate(['/dmps']);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// DO SOMETHING ELSE
|
// DO SOMETHING ELSE
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
selectOption(option: any) {
|
selectOption(option: any) {
|
||||||
this.dataManagementPlan.definition = null;
|
this.dataManagementPlan.definition = null;
|
||||||
this.formGroup.get("profile").patchValue(option, { emitEvent: false })
|
this.formGroup.get('profile').patchValue(option, { emitEvent: false });
|
||||||
this.dmpProfileService.getSingle(option.id).subscribe(result => {
|
this.dmpProfileService.getSingle(option.id).subscribe(result => {
|
||||||
this.dataManagementPlan.definition = result.definition;
|
this.dataManagementPlan.definition = result.definition;
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
displayWith(item: any) {
|
displayWith(item: any) {
|
||||||
if (!item) return null;
|
if (!item) { return null; }
|
||||||
return item["label"];
|
return item['label'];
|
||||||
}
|
}
|
||||||
|
|
||||||
redirectToProject() {
|
redirectToProject() {
|
||||||
this.router.navigate(["projects/edit/" + this.dataManagementPlan.project.id])
|
this.router.navigate(['projects/edit/' + this.dataManagementPlan.project.id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
redirectToDatasets() {
|
redirectToDatasets() {
|
||||||
this.router.navigate(["datasets/dmp/" + this.dataManagementPlan.id])
|
this.router.navigate(['datasets/dmp/' + this.dataManagementPlan.id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
newVersion(id: String, label: String) {
|
newVersion(id: String, label: String) {
|
||||||
this.router.navigate(['/dmps/new_version/' + id, { dmpLabel: label }]);
|
this.router.navigate(['/dmps/new_version/' + id, { dmpLabel: label }]);
|
||||||
}
|
}
|
||||||
|
|
||||||
clone(id: String) {
|
clone(id: String) {
|
||||||
this.router.navigate(['/dmps/clone/' + id]);
|
this.router.navigate(['/dmps/clone/' + id]);
|
||||||
}
|
}
|
||||||
viewVersions(rowId: String, rowLabel: String) {
|
viewVersions(rowId: String, rowLabel: String) {
|
||||||
this.router.navigate(['/dmps/viewversions/' + rowId], { queryParams: { groupLabel: rowLabel } });
|
this.router.navigate(['/dmps/viewversions/' + rowId], { queryParams: { groupLabel: rowLabel } });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,40 +1,40 @@
|
||||||
import { Component, ViewEncapsulation, AfterViewInit, Input, OnInit, OnDestroy } from "@angular/core";
|
import { Component, ViewEncapsulation, AfterViewInit, Input, OnInit, OnDestroy } from '@angular/core';
|
||||||
import { DataManagementPlanProfile } from "../../../models/data-management-plan-profile/DataManagementPlanProfile";
|
import { DataManagementPlanProfile } from '../../../models/data-management-plan-profile/DataManagementPlanProfile';
|
||||||
import { DMPProfileFieldDataType, DMPProfileType } from "../../../models/data-management-plan-profile/DataManagementProfileField";
|
import { DMPProfileFieldDataType, DMPProfileType } from '../../../models/data-management-plan-profile/DataManagementProfileField';
|
||||||
import { FormGroup, FormBuilder, FormArray } from "@angular/forms";
|
import { FormGroup, FormBuilder, FormArray } from '@angular/forms';
|
||||||
import { LanguageResolverService } from "../../../services/language-resolver/language-resolver.service";
|
import { LanguageResolverService } from '../../../services/language-resolver/language-resolver.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dynamic-dmp-field-resolver',
|
selector: 'app-dynamic-dmp-field-resolver',
|
||||||
templateUrl: 'dynamic-dmp-field-resolver.component.html',
|
templateUrl: 'dynamic-dmp-field-resolver.component.html',
|
||||||
styleUrls: ['./dynamic-dmp-field-resolver.component.scss'],
|
styleUrls: ['./dynamic-dmp-field-resolver.component.scss'],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class DynamicDmpFieldResolver implements OnInit, OnDestroy {
|
export class DynamicDmpFieldResolverComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
|
|
||||||
DMPProfileFieldDataType = DMPProfileFieldDataType;
|
DMPProfileFieldDataType = DMPProfileFieldDataType;
|
||||||
DMPProfileType = DMPProfileType;
|
DMPProfileType = DMPProfileType;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
dataManagementPlanProfile: DataManagementPlanProfile;
|
dataManagementPlanProfile: DataManagementPlanProfile;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
formGroup: FormGroup
|
formGroup: FormGroup;
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.formGroup.addControl("properties", new FormBuilder().group([]));
|
this.formGroup.addControl('properties', new FormBuilder().group([]));
|
||||||
(<FormGroup>this.formGroup.get("properties")).addControl("fields", new FormBuilder().array([]))
|
(<FormGroup>this.formGroup.get('properties')).addControl('fields', new FormBuilder().array([]));
|
||||||
|
|
||||||
this.dataManagementPlanProfile.fields.forEach(item => {
|
this.dataManagementPlanProfile.fields.forEach(item => {
|
||||||
(<FormArray>this.formGroup.get("properties").get("fields")).push(new FormBuilder().group({
|
(<FormArray>this.formGroup.get('properties').get('fields')).push(new FormBuilder().group({
|
||||||
id: [item.id],
|
id: [item.id],
|
||||||
value: [item.value]
|
value: [item.value]
|
||||||
}))
|
}));
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
this.formGroup.removeControl("properties")
|
this.formGroup.removeControl('properties');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,84 +1,84 @@
|
||||||
import { Component, ViewEncapsulation, OnInit, Input, ViewChild } from "@angular/core";
|
import { Component, ViewEncapsulation, OnInit, Input, ViewChild } from '@angular/core';
|
||||||
import { FormGroup } from "@angular/forms";
|
import { FormGroup } from '@angular/forms';
|
||||||
import { DataManagementPlanService } from "../../../../services/data-management-plan/data-management-plan.service";
|
import { DataManagementPlanService } from '../../../../services/data-management-plan/data-management-plan.service';
|
||||||
import { RequestItem } from "../../../../models/criteria/RequestItem";
|
import { RequestItem } from '../../../../models/criteria/RequestItem';
|
||||||
import { DynamicFieldProjectCriteria, DynamicFieldProjectCriteriaDependencies } from "../../../../models/dynamic-field-project/DynamicFieldProjectCriteria";
|
import { DynamicFieldProjectCriteria, DynamicFieldProjectCriteriaDependencies } from '../../../../models/dynamic-field-project/DynamicFieldProjectCriteria';
|
||||||
import { AutoCompleteComponent } from "../../../../shared/components/auto-complete/auto-complete.component";
|
import { AutoCompleteComponent } from '../../../../shared/components/auto-complete/auto-complete.component';
|
||||||
import { DynamicFieldDependency } from "../../../../models/data-managemnt-plans/DynamicFieldDependency";
|
import { DynamicFieldDependency } from '../../../../models/data-managemnt-plans/DynamicFieldDependency';
|
||||||
import { LanguageResolverService } from "../../../../services/language-resolver/language-resolver.service";
|
import { LanguageResolverService } from '../../../../services/language-resolver/language-resolver.service';
|
||||||
import { AutoCompleteConfiguration } from "../../../../shared/components/auto-complete/AutoCompleteConfiguration";
|
import { AutoCompleteConfiguration } from '../../../../shared/components/auto-complete/AutoCompleteConfiguration';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dynamic-field-project',
|
selector: 'app-dynamic-field-project',
|
||||||
templateUrl: 'dynamic-field-project.component.html',
|
templateUrl: 'dynamic-field-project.component.html',
|
||||||
styleUrls: ['./dynamic-field-project.component.scss'],
|
styleUrls: ['./dynamic-field-project.component.scss'],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class DynamicFieldProjectComponent implements OnInit {
|
export class DynamicFieldProjectComponent implements OnInit {
|
||||||
|
|
||||||
constructor(private languageResolverService: LanguageResolverService, private dmpService: DataManagementPlanService) { }
|
constructor(private languageResolverService: LanguageResolverService, private dmpService: DataManagementPlanService) { }
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
dependencies: Array<FormGroup>
|
dependencies: Array<FormGroup>;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
formGroup: FormGroup;
|
formGroup: FormGroup;
|
||||||
|
|
||||||
@ViewChild(AutoCompleteComponent)
|
@ViewChild(AutoCompleteComponent)
|
||||||
autocomplete: AutoCompleteComponent
|
autocomplete: AutoCompleteComponent;
|
||||||
|
|
||||||
autoCompleteConfiguration: AutoCompleteConfiguration
|
autoCompleteConfiguration: AutoCompleteConfiguration;
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
let requestItem = new RequestItem<DynamicFieldProjectCriteria>()
|
const requestItem = new RequestItem<DynamicFieldProjectCriteria>();
|
||||||
requestItem.criteria = { id: this.formGroup.get("id").value, dynamicFields: this.buildDependencies() }
|
requestItem.criteria = { id: this.formGroup.get('id').value, dynamicFields: this.buildDependencies() };
|
||||||
this.autoCompleteConfiguration = new AutoCompleteConfiguration(this.dmpService.getDynamicField.bind(this.dmpService), requestItem);
|
this.autoCompleteConfiguration = new AutoCompleteConfiguration(this.dmpService.getDynamicField.bind(this.dmpService), requestItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
hasUnResolvedDependencies() {
|
hasUnResolvedDependencies() {
|
||||||
if (this.dependencies == null || this.dependencies.length == 0) {
|
if (this.dependencies == null || this.dependencies.length === 0) {
|
||||||
if (this.formGroup.get("value").disabled) {
|
if (this.formGroup.get('value').disabled) {
|
||||||
this.updateConfiguration();
|
this.updateConfiguration();
|
||||||
this.formGroup.get("value").enable({ onlySelf: true, emitEvent: false })
|
this.formGroup.get('value').enable({ onlySelf: true, emitEvent: false });
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (let i = 0; i < this.dependencies.length; i++) {
|
for (let i = 0; i < this.dependencies.length; i++) {
|
||||||
if (!this.dependencies[i].get("value").value) {
|
if (!this.dependencies[i].get('value').value) {
|
||||||
this.formGroup.get("value").disable({ onlySelf: true, emitEvent: false })
|
this.formGroup.get('value').disable({ onlySelf: true, emitEvent: false });
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.formGroup.get("value").disabled) {
|
if (this.formGroup.get('value').disabled) {
|
||||||
this.updateConfiguration();
|
this.updateConfiguration();
|
||||||
this.formGroup.get("value").enable({ onlySelf: true, emitEvent: false })
|
this.formGroup.get('value').enable({ onlySelf: true, emitEvent: false });
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateConfiguration() {
|
updateConfiguration() {
|
||||||
let requestItem = new RequestItem<DynamicFieldProjectCriteria>()
|
const requestItem = new RequestItem<DynamicFieldProjectCriteria>();
|
||||||
requestItem.criteria = { id: this.formGroup.get("id").value, dynamicFields: this.buildDependencies() }
|
requestItem.criteria = { id: this.formGroup.get('id').value, dynamicFields: this.buildDependencies() };
|
||||||
this.autoCompleteConfiguration = new AutoCompleteConfiguration(this.dmpService.getDynamicField.bind(this.dmpService), requestItem);
|
this.autoCompleteConfiguration = new AutoCompleteConfiguration(this.dmpService.getDynamicField.bind(this.dmpService), requestItem);
|
||||||
this.autocomplete.inputData = this.autoCompleteConfiguration;
|
this.autocomplete.inputData = this.autoCompleteConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
buildDependencies(): Array<DynamicFieldProjectCriteriaDependencies> {
|
buildDependencies(): Array<DynamicFieldProjectCriteriaDependencies> {
|
||||||
if (!this.dependencies || this.dependencies.length == 0) return []
|
if (!this.dependencies || this.dependencies.length === 0) { return []; }
|
||||||
let dependencies = new Array<DynamicFieldProjectCriteriaDependencies>();
|
const dependencies = new Array<DynamicFieldProjectCriteriaDependencies>();
|
||||||
for (let i = 0; i < this.dependencies.length; i++) {
|
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) })
|
dependencies.push({ property: this.dependencies[i].get('id').value, value: this.assignFunction(this.dependencies[i].get('value').value) });
|
||||||
}
|
}
|
||||||
return dependencies;
|
return dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
displayFunction(item: any): any {
|
displayFunction(item: any): any {
|
||||||
if (!item) return null;
|
if (!item) { return null; }
|
||||||
return item["label"];
|
return item['label'];
|
||||||
}
|
}
|
||||||
|
|
||||||
assignFunction(item: any): any {
|
assignFunction(item: any): any {
|
||||||
if (!item) return null;
|
if (!item) { return null; }
|
||||||
return item["id"];
|
return item['id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,33 +1,33 @@
|
||||||
import { Component, ViewEncapsulation, OnInit, OnDestroy, Input } from "@angular/core";
|
import { Component, ViewEncapsulation, OnInit, OnDestroy, Input } from '@angular/core';
|
||||||
import { FormGroup, FormArray } from "@angular/forms";
|
import { FormGroup, FormArray } from '@angular/forms';
|
||||||
import { DynamicFieldDependency } from "../../../models/data-managemnt-plans/DynamicFieldDependency";
|
import { DynamicFieldDependency } from '../../../models/data-managemnt-plans/DynamicFieldDependency';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dynamic-fields-project',
|
selector: 'app-dynamic-fields-project',
|
||||||
templateUrl: 'dynamic-fields-project.component.html',
|
templateUrl: 'dynamic-fields-project.component.html',
|
||||||
styleUrls: ['./dynamic-fields-project.component.scss'],
|
styleUrls: ['./dynamic-fields-project.component.scss'],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class DynamicFieldsProjectComponent implements OnInit {
|
export class DynamicFieldsProjectComponent implements OnInit {
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
formGroup: FormGroup;
|
formGroup: FormGroup;
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
findDependencies(id: number) {
|
findDependencies(id: number) {
|
||||||
let formGroupDependencies: Array<FormGroup> = new Array<FormGroup>();
|
const formGroupDependencies: Array<FormGroup> = new Array<FormGroup>();
|
||||||
let dynamicFieldDependency: DynamicFieldDependency[] = (<FormArray>this.formGroup.get("dynamicFields")).at(id).get("dependencies").value
|
const dynamicFieldDependency: DynamicFieldDependency[] = (<FormArray>this.formGroup.get('dynamicFields')).at(id).get('dependencies').value;
|
||||||
if (dynamicFieldDependency.length > 0) {
|
if (dynamicFieldDependency.length > 0) {
|
||||||
dynamicFieldDependency.forEach(item => {
|
dynamicFieldDependency.forEach(item => {
|
||||||
let length = (<FormArray>this.formGroup.get("dynamicFields")).length;
|
const length = (<FormArray>this.formGroup.get('dynamicFields')).length;
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
let formGroup = (<FormArray>this.formGroup.get("dynamicFields")).at(i);
|
const formGroup = (<FormArray>this.formGroup.get('dynamicFields')).at(i);
|
||||||
if (formGroup.get("id").value === item.id) formGroupDependencies.push(<FormGroup>formGroup);
|
if (formGroup.get('id').value === item.id) { formGroupDependencies.push(<FormGroup>formGroup); }
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
return formGroupDependencies;
|
return formGroupDependencies;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,15 +3,15 @@ import { DataManagementPlanListingModel } from '../../models/data-managemnt-plan
|
||||||
import { InvitationComponent } from '../../shared/components/invitation/invitation.component';
|
import { InvitationComponent } from '../../shared/components/invitation/invitation.component';
|
||||||
import { DataManagementPlanCriteria } from '../../models/criteria/data-management-plan/DataManagementPlanCriteria';
|
import { DataManagementPlanCriteria } from '../../models/criteria/data-management-plan/DataManagementPlanCriteria';
|
||||||
import {
|
import {
|
||||||
DataManagementPlanCriteriaComponent,
|
DataManagementPlanCriteriaComponent,
|
||||||
} from '../../shared/components/criteria/data-management-plan/dmp-criteria.component';
|
} from '../../shared/components/criteria/data-management-plan/dmp-criteria.component';
|
||||||
import { DataManagementPlanService } from '../../services/data-management-plan/data-management-plan.service';
|
import { DataManagementPlanService } from '../../services/data-management-plan/data-management-plan.service';
|
||||||
import { Component, ViewChild, OnInit, AfterViewInit } from "@angular/core";
|
import { Component, ViewChild, OnInit, AfterViewInit } from '@angular/core';
|
||||||
import { MatPaginator, MatSort, MatSnackBar, MatDialog } from "@angular/material";
|
import { MatPaginator, MatSort, MatSnackBar, MatDialog } from '@angular/material';
|
||||||
import { Router, ActivatedRoute, ActivatedRouteSnapshot } from "@angular/router";
|
import { Router, ActivatedRoute, ActivatedRouteSnapshot } from '@angular/router';
|
||||||
import { TranslateService } from "@ngx-translate/core";
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { DataSource } from "@angular/cdk/table";
|
import { DataSource } from '@angular/cdk/table';
|
||||||
import { Observable } from "rxjs/Observable";
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { DataManagementPlanRoutes } from '../../dmps/dmps.routes';
|
import { DataManagementPlanRoutes } from '../../dmps/dmps.routes';
|
||||||
import { DatasetRoutes } from '../../datasets/dataset.routes';
|
import { DatasetRoutes } from '../../datasets/dataset.routes';
|
||||||
import { ProjectModel } from '../../models/projects/ProjectModel';
|
import { ProjectModel } from '../../models/projects/ProjectModel';
|
||||||
|
@ -22,182 +22,184 @@ import { JsonSerializer } from '../../utilities/JsonSerializer';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dmp-listing-component',
|
selector: 'app-dmp-listing-component',
|
||||||
templateUrl: 'dmp-listing.component.html',
|
templateUrl: 'dmp-listing.component.html',
|
||||||
styleUrls: ['./dmp-listing.component.scss'],
|
styleUrls: ['./dmp-listing.component.scss'],
|
||||||
})
|
})
|
||||||
export class DataManagementPlanListingComponent implements OnInit, IBreadCrumbComponent {
|
export class DataManagementPlanListingComponent implements OnInit, IBreadCrumbComponent {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ViewChild(MatPaginator) _paginator: MatPaginator;
|
@ViewChild(MatPaginator) _paginator: MatPaginator;
|
||||||
@ViewChild(MatSort) sort: MatSort;
|
@ViewChild(MatSort) sort: MatSort;
|
||||||
@ViewChild(DataManagementPlanCriteriaComponent) criteria: DataManagementPlanCriteriaComponent;
|
@ViewChild(DataManagementPlanCriteriaComponent) criteria: DataManagementPlanCriteriaComponent;
|
||||||
|
|
||||||
breadCrumbs: Observable<BreadcrumbItem[]> = Observable.of([]);
|
breadCrumbs: Observable<BreadcrumbItem[]> = Observable.of([]);
|
||||||
dataSource: DataManagementPlanDataSource | null;
|
dataSource: DataManagementPlanDataSource | null;
|
||||||
displayedColumns: String[] = ['name', 'project', 'creationTime', 'organisations', 'version', 'datasets', 'actions'];
|
displayedColumns: String[] = ['name', 'project', 'creationTime', 'organisations', 'version', 'datasets', 'actions'];
|
||||||
itemId: string;
|
itemId: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
showProject: boolean;
|
showProject: boolean;
|
||||||
titlePrefix: string;
|
titlePrefix: string;
|
||||||
constructor(
|
constructor(
|
||||||
private dataManagementPlanService: DataManagementPlanService,
|
private dataManagementPlanService: DataManagementPlanService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private languageService: TranslateService,
|
private languageService: TranslateService,
|
||||||
public snackBar: MatSnackBar,
|
public snackBar: MatSnackBar,
|
||||||
public dialog: MatDialog
|
public dialog: MatDialog
|
||||||
) {
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.route.params.subscribe(async params => {
|
this.route.params.subscribe(async params => {
|
||||||
let projectLabel;
|
let projectLabel;
|
||||||
if (params["projectId"]) {
|
if (params['projectId']) {
|
||||||
this.projectId = params["projectId"];
|
this.projectId = params['projectId'];
|
||||||
this.showProject = false;
|
this.showProject = false;
|
||||||
let project = new ProjectModel();
|
const project = new ProjectModel();
|
||||||
project.id = this.projectId;
|
project.id = this.projectId;
|
||||||
this.criteria.setCriteria({ like: null, projects: [project], groupIds: null, allVersions: false })
|
this.criteria.setCriteria({ like: null, projects: [project], groupIds: null, allVersions: false });
|
||||||
this.refresh();
|
this.refresh();
|
||||||
projectLabel = this.route.snapshot.queryParams.projectLabel
|
projectLabel = this.route.snapshot.queryParams.projectLabel;
|
||||||
this.breadCrumbs = Observable.of([{ parentComponentName: "ProjectEditorComponent", label: projectLabel, url: "/projects/edit/" + this.projectId }])
|
this.breadCrumbs = Observable.of([{ parentComponentName: 'ProjectEditorComponent', label: projectLabel, url: '/projects/edit/' + this.projectId }]);
|
||||||
this.criteria.setRefreshCallback(() => this.refresh());
|
this.criteria.setRefreshCallback(() => this.refresh());
|
||||||
} else {
|
} else {
|
||||||
this.itemId = params['groupId'];
|
this.itemId = params['groupId'];
|
||||||
this.showProject = true;
|
this.showProject = true;
|
||||||
let breadCrumbs = [];
|
const breadCrumbs = [];
|
||||||
|
|
||||||
if (this.itemId) {
|
if (this.itemId) {
|
||||||
let dmplabel = this.route.snapshot.queryParams.groupLabel
|
const dmplabel = this.route.snapshot.queryParams.groupLabel;
|
||||||
breadCrumbs.push(
|
breadCrumbs.push(
|
||||||
{ parentComponentName: null, label: 'DMPs', url: "/dmps" },
|
{ parentComponentName: null, label: 'DMPs', url: '/dmps' },
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
//else breadCrumbs.push({ parentComponentName: null, label: 'DMPs', url: "/dmps" })
|
//else breadCrumbs.push({ parentComponentName: null, label: 'DMPs', url: "/dmps" })
|
||||||
this.breadCrumbs = Observable.of(breadCrumbs)
|
this.breadCrumbs = Observable.of(breadCrumbs);
|
||||||
|
|
||||||
this.criteria.setCriteria(this.getDefaultCriteria());
|
this.criteria.setCriteria(this.getDefaultCriteria());
|
||||||
this.refresh();
|
this.refresh();
|
||||||
this.criteria.setRefreshCallback(() => this.refresh());
|
this.criteria.setRefreshCallback(() => this.refresh());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.projectId != null)
|
if (this.projectId != null) {
|
||||||
if (projectLabel != undefined)
|
if (projectLabel !== undefined) {
|
||||||
this.titlePrefix = "for " + projectLabel;
|
this.titlePrefix = 'for ' + projectLabel;
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
this.dataSource = new DataManagementPlanDataSource(this.dataManagementPlanService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria, this.itemId);
|
this.dataSource = new DataManagementPlanDataSource(this.dataManagementPlanService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria, this.itemId);
|
||||||
}
|
}
|
||||||
|
|
||||||
rowClick(rowId: String) {
|
rowClick(rowId: String) {
|
||||||
this.router.navigate(['/dmps/edit/' + rowId]);
|
this.router.navigate(['/dmps/edit/' + rowId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
addDataset(rowId: String) {
|
addDataset(rowId: String) {
|
||||||
this.router.navigate(['/datasets/new/' + rowId]);
|
this.router.navigate(['/datasets/new/' + rowId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
showDatasets(rowId: String, rowLabel: String) {
|
showDatasets(rowId: String, rowLabel: String) {
|
||||||
this.router.navigate(['/datasets/dmp/' + rowId, { dmpLabel: rowLabel }]);
|
this.router.navigate(['/datasets/dmp/' + rowId, { dmpLabel: rowLabel }]);
|
||||||
}
|
}
|
||||||
|
|
||||||
viewVersions(rowId: String, rowLabel: String) {
|
viewVersions(rowId: String, rowLabel: String) {
|
||||||
this.router.navigate(['/dmps/viewversions/' + rowId], { queryParams: { groupLabel: rowLabel } });
|
this.router.navigate(['/dmps/viewversions/' + rowId], { queryParams: { groupLabel: rowLabel } });
|
||||||
}
|
}
|
||||||
|
|
||||||
getDefaultCriteria(): DataManagementPlanCriteria {
|
getDefaultCriteria(): DataManagementPlanCriteria {
|
||||||
const defaultCriteria = new DataManagementPlanCriteria();
|
const defaultCriteria = new DataManagementPlanCriteria();
|
||||||
return defaultCriteria;
|
return defaultCriteria;
|
||||||
}
|
}
|
||||||
|
|
||||||
openShareDialog(rowId: any, rowName: any) {
|
openShareDialog(rowId: any, rowName: any) {
|
||||||
let dialogRef = this.dialog.open(InvitationComponent, {
|
const dialogRef = this.dialog.open(InvitationComponent, {
|
||||||
height: '200px',
|
height: '200px',
|
||||||
width: '700px',
|
width: '700px',
|
||||||
data: {
|
data: {
|
||||||
dmpId: rowId,
|
dmpId: rowId,
|
||||||
dmpName: rowName
|
dmpName: rowName
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DataManagementPlanDataSource extends DataSource<DataManagementPlanListingModel> {
|
export class DataManagementPlanDataSource extends DataSource<DataManagementPlanListingModel> {
|
||||||
|
|
||||||
totalCount = 0;
|
totalCount = 0;
|
||||||
isLoadingResults = false;
|
isLoadingResults = false;
|
||||||
constructor(
|
constructor(
|
||||||
private _service: DataManagementPlanService,
|
private _service: DataManagementPlanService,
|
||||||
private _paginator: MatPaginator,
|
private _paginator: MatPaginator,
|
||||||
private _sort: MatSort,
|
private _sort: MatSort,
|
||||||
private _languageService: TranslateService,
|
private _languageService: TranslateService,
|
||||||
private _snackBar: MatSnackBar,
|
private _snackBar: MatSnackBar,
|
||||||
private _criteria: DataManagementPlanCriteriaComponent,
|
private _criteria: DataManagementPlanCriteriaComponent,
|
||||||
private itemId
|
private itemId
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(): Observable<DataManagementPlanListingModel[]> {
|
connect(): Observable<DataManagementPlanListingModel[]> {
|
||||||
const displayDataChanges = [
|
const displayDataChanges = [
|
||||||
this._paginator.page
|
this._paginator.page
|
||||||
];
|
];
|
||||||
|
|
||||||
return Observable.merge(...displayDataChanges)
|
return Observable.merge(...displayDataChanges)
|
||||||
.startWith(null)
|
.startWith(null)
|
||||||
.switchMap(() => {
|
.switchMap(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.isLoadingResults = true;
|
this.isLoadingResults = true;
|
||||||
});
|
});
|
||||||
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
|
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
|
||||||
let fields: Array<string> = new Array()
|
let fields: Array<string> = new Array();
|
||||||
if (this._sort.active) fields = this._sort.direction === "asc" ? ["+" + this._sort.active] : ["-" + this._sort.active];
|
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 });
|
const request = new DataTableRequest<DataManagementPlanCriteria>(startIndex, this._paginator.pageSize, { fields: fields });
|
||||||
request.criteria = this._criteria.formGroup.value;
|
request.criteria = this._criteria.formGroup.value;
|
||||||
if (this.itemId) {
|
if (this.itemId) {
|
||||||
request.criteria.groupIds = [this.itemId];
|
request.criteria.groupIds = [this.itemId];
|
||||||
request.criteria.allVersions = true;
|
request.criteria.allVersions = true;
|
||||||
}
|
}
|
||||||
return this._service.getPaged(request);
|
return this._service.getPaged(request);
|
||||||
})
|
})
|
||||||
/*.catch((error: any) => {
|
/*.catch((error: any) => {
|
||||||
this._snackBar.openFromComponent(SnackBarNotificationComponent, {
|
this._snackBar.openFromComponent(SnackBarNotificationComponent, {
|
||||||
data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService },
|
data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService },
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
extraClasses: ['snackbar-warning']
|
extraClasses: ['snackbar-warning']
|
||||||
});
|
});
|
||||||
return Observable.of(null);
|
return Observable.of(null);
|
||||||
})*/
|
})*/
|
||||||
.map(result => {
|
.map(result => {
|
||||||
result.data = JsonSerializer.fromJSONArray(result.data, DataManagementPlanListingModel)
|
result.data = JsonSerializer.fromJSONArray(result.data, DataManagementPlanListingModel);
|
||||||
return result;
|
return result;
|
||||||
})
|
})
|
||||||
.map(result => {
|
.map(result => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.isLoadingResults = false;
|
this.isLoadingResults = false;
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
})
|
})
|
||||||
.map(result => {
|
.map(result => {
|
||||||
if (!result) { return []; }
|
if (!result) { return []; }
|
||||||
if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; }
|
if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; }
|
||||||
return result.data.map(item => {
|
return result.data.map(item => {
|
||||||
item["datasets"].map(dmp => {
|
item['datasets'].map(dmp => {
|
||||||
dmp.url = "datasets/edit/" + dmp.url;
|
dmp.url = 'datasets/edit/' + dmp.url;
|
||||||
dmp.all = "datasets/dmp/" + item.id
|
dmp.all = 'datasets/dmp/' + item.id;
|
||||||
return dmp;
|
return dmp;
|
||||||
})
|
});
|
||||||
return item;
|
return item;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect() {
|
disconnect() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,73 +12,72 @@ import { IBreadCrumbComponent } from '../../shared/components/breadcrumb/definit
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { BreadcrumbItem } from '../../shared/components/breadcrumb/definition/breadcrumb-item';
|
import { BreadcrumbItem } from '../../shared/components/breadcrumb/definition/breadcrumb-item';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dmp-wizard-component',
|
selector: 'app-dmp-wizard-component',
|
||||||
templateUrl: 'dmp-wizard.component.html',
|
templateUrl: 'dmp-wizard.component.html',
|
||||||
styleUrls: ['./dmp-wizard.component.scss'],
|
styleUrls: ['./dmp-wizard.component.scss'],
|
||||||
})
|
})
|
||||||
export class DataManagementPlanWizardComponent implements OnInit, IBreadCrumbComponent {
|
export class DataManagementPlanWizardComponent implements OnInit, IBreadCrumbComponent {
|
||||||
breadCrumbs: Observable<BreadcrumbItem[]>;
|
breadCrumbs: Observable<BreadcrumbItem[]>;
|
||||||
constructor(
|
constructor(
|
||||||
private dataManagementPlanService: DataManagementPlanService,
|
private dataManagementPlanService: DataManagementPlanService,
|
||||||
private language: TranslateService,
|
private language: TranslateService,
|
||||||
public snackBar: MatSnackBar,
|
public snackBar: MatSnackBar,
|
||||||
public route: ActivatedRoute,
|
public route: ActivatedRoute,
|
||||||
private router: Router
|
private router: Router
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
public itemId: string
|
public itemId: string;
|
||||||
public dataManagementPlan: DataManagementPlanModel;
|
public dataManagementPlan: DataManagementPlanModel;
|
||||||
public formGroup: FormGroup
|
public formGroup: FormGroup;
|
||||||
public isClone: boolean
|
public isClone: boolean;
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|
||||||
this.route.params.subscribe((params: Params) => {
|
this.route.params.subscribe((params: Params) => {
|
||||||
this.itemId = params['id'];
|
this.itemId = params['id'];
|
||||||
this.dataManagementPlanService.getSingle(this.itemId).map(data => data as DataManagementPlanModel)
|
this.dataManagementPlanService.getSingle(this.itemId).map(data => data as DataManagementPlanModel)
|
||||||
.subscribe(data => {
|
.subscribe(data => {
|
||||||
this.dataManagementPlan = JsonSerializer.fromJSONObject(data, DataManagementPlanModel);
|
this.dataManagementPlan = JsonSerializer.fromJSONObject(data, DataManagementPlanModel);
|
||||||
this.isClone = this.route.snapshot.data.clone;
|
this.isClone = this.route.snapshot.data.clone;
|
||||||
if (this.isClone == false) this.dataManagementPlan.version = this.dataManagementPlan.version + 1;
|
if (this.isClone === false) { this.dataManagementPlan.version = this.dataManagementPlan.version + 1; }
|
||||||
this.formGroup = this.dataManagementPlan.buildForm();
|
this.formGroup = this.dataManagementPlan.buildForm();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
})
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
submit() {
|
submit() {
|
||||||
if (this.isClone) {
|
if (this.isClone) {
|
||||||
this.dataManagementPlanService.clone(this.formGroup.getRawValue(), this.itemId).subscribe(
|
this.dataManagementPlanService.clone(this.formGroup.getRawValue(), this.itemId).subscribe(
|
||||||
complete => this.onCallbackSuccess(),
|
complete => this.onCallbackSuccess(),
|
||||||
error => this.onCallbackError(error)
|
error => this.onCallbackError(error)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
this.dataManagementPlanService.newVersion(this.formGroup.getRawValue(), this.itemId).subscribe(
|
this.dataManagementPlanService.newVersion(this.formGroup.getRawValue(), this.itemId).subscribe(
|
||||||
complete => this.onCallbackSuccess(),
|
complete => this.onCallbackSuccess(),
|
||||||
error => this.onCallbackError(error)
|
error => this.onCallbackError(error)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onCallbackSuccess(): void {
|
onCallbackSuccess(): void {
|
||||||
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
|
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
|
||||||
data: { message: 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
|
data: { message: 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
})
|
});
|
||||||
this.router.navigate(['/dmps']);
|
this.router.navigate(['/dmps']);
|
||||||
}
|
}
|
||||||
|
|
||||||
onCallbackError(error: any) {
|
onCallbackError(error: any) {
|
||||||
this.setErrorModel(error.error);
|
this.setErrorModel(error.error);
|
||||||
//this.validateAllFormFields(this.formGroup);
|
//this.validateAllFormFields(this.formGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
public setErrorModel(errorModel: BaseErrorModel) {
|
public setErrorModel(errorModel: BaseErrorModel) {
|
||||||
Object.keys(errorModel).forEach(item => {
|
Object.keys(errorModel).forEach(item => {
|
||||||
// (<any>this.dataManagementPlan.errorModel)[item] = (<any>errorModel)[item];
|
// (<any>this.dataManagementPlan.errorModel)[item] = (<any>errorModel)[item];
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,79 +1,79 @@
|
||||||
<div class="data-management-plan-wizard-editor">
|
<div class="data-management-plan-wizard-editor">
|
||||||
<form *ngIf="formGroup" (ngSubmit)="formSubmit()" [formGroup]="formGroup">
|
<form *ngIf="formGroup" (ngSubmit)="formSubmit()" [formGroup]="formGroup">
|
||||||
<mat-card>
|
<mat-card>
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<mat-form-field class="full-width">
|
<mat-form-field class="full-width">
|
||||||
<input matInput placeholder="{{'DMP-EDITOR.FIELDS.NAME' | translate}}" type="text" name="label" formControlName="label" required
|
<input matInput placeholder="{{'DMP-EDITOR.FIELDS.NAME' | translate}}" type="text" name="label" formControlName="label"
|
||||||
[attr.disabled]="labelDisabled">
|
required [attr.disabled]="labelDisabled">
|
||||||
<mat-error *ngIf="formGroup.get('label').errors?.backendError">{{baseErrorModel.label}}</mat-error>
|
<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-error *ngIf="formGroup.get('label').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field class="full-width">
|
<mat-form-field class="full-width">
|
||||||
<textarea matInput class="description-area" placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION' | translate}}" formControlName="description"
|
<textarea matInput class="description-area" placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION' | translate}}"
|
||||||
required></textarea>
|
formControlName="description" required></textarea>
|
||||||
<mat-error *ngIf="formGroup.get('description').errors?.backendError">{{errorModel.description}}</mat-error>
|
<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-error *ngIf="formGroup.get('description').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<app-single-auto-complete [reactiveFormControl]="formGroup.get('project')" placeholder="{{this.languageResolverService.getBy('dmpEditor') | translate}}"
|
<app-single-auto-complete [reactiveFormControl]="formGroup.get('project')" placeholder="{{this.languageResolverService.getBy('dmpEditor') | translate}}"
|
||||||
[configuration]="projectAutoCompleteConfiguration">
|
[configuration]="projectAutoCompleteConfiguration">
|
||||||
</app-single-auto-complete>
|
</app-single-auto-complete>
|
||||||
</div>
|
</div>
|
||||||
<!-- <app-dynamic-fields-project [formGroup]="formGroup"></app-dynamic-fields-project> -->
|
<!-- <app-dynamic-fields-project [formGroup]="formGroup"></app-dynamic-fields-project> -->
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<app-multiple-auto-complete class="col-md-10" [reactiveFormControl]="formGroup.get('profiles')" placeholder="{{'DMP-EDITOR.FIELDS.PROFILES' | translate}}"
|
<app-multiple-auto-complete class="col-md-10" [reactiveFormControl]="formGroup.get('profiles')" placeholder="{{'DMP-EDITOR.FIELDS.PROFILES' | translate}}"
|
||||||
[configuration]="profilesAutoCompleteConfiguration">
|
[configuration]="profilesAutoCompleteConfiguration">
|
||||||
</app-multiple-auto-complete>
|
</app-multiple-auto-complete>
|
||||||
<div class="col-md-2">
|
<div class="col-md-2">
|
||||||
<button mat-icon-button type="button" (click)="availableProfiles()">
|
<button mat-icon-button type="button" (click)="availableProfiles()">
|
||||||
<mat-icon>view_list</mat-icon>
|
<mat-icon>view_list</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- <button mat-button (click)="availableProfiles()">View All</button> -->
|
<!-- <button mat-button (click)="availableProfiles()">View All</button> -->
|
||||||
|
|
||||||
|
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<app-multiple-auto-complete [reactiveFormControl]="formGroup.get('organisations')" placeholder="{{'DMP-EDITOR.FIELDS.ORGANISATIONS' | translate}}"
|
<app-multiple-auto-complete [reactiveFormControl]="formGroup.get('organisations')" placeholder="{{'DMP-EDITOR.FIELDS.ORGANISATIONS' | translate}}"
|
||||||
[configuration]="organisationsAutoCompleteConfiguration">
|
[configuration]="organisationsAutoCompleteConfiguration">
|
||||||
</app-multiple-auto-complete>
|
</app-multiple-auto-complete>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-10">
|
<div class="col-md-10">
|
||||||
<app-multiple-auto-complete [reactiveFormControl]="formGroup.get('researchers')" placeholder="{{'DMP-EDITOR.FIELDS.RESEARCHERS' | translate}}"
|
<app-multiple-auto-complete [reactiveFormControl]="formGroup.get('researchers')" placeholder="{{'DMP-EDITOR.FIELDS.RESEARCHERS' | translate}}"
|
||||||
[configuration]="researchersAutoCompleteConfiguration">
|
[configuration]="researchersAutoCompleteConfiguration">
|
||||||
</app-multiple-auto-complete>
|
</app-multiple-auto-complete>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2">
|
<div class="col-md-2">
|
||||||
<button mat-icon-button type="button" (click)="addResearcher()">
|
<button mat-icon-button type="button" (click)="addResearcher()">
|
||||||
<mat-icon>add_circle</mat-icon>
|
<mat-icon>add_circle</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<mat-form-field class="full-width">
|
<mat-form-field class="full-width">
|
||||||
<input matInput placeholder="Version" formControlName="version">
|
<input matInput placeholder="Version" formControlName="version">
|
||||||
<!--disabled doesn't work -->
|
<!--disabled doesn't work -->
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-list *ngIf="associatedUsers?.length" role="list">
|
<mat-list *ngIf="associatedUsers?.length" role="list">
|
||||||
<h3 mat-subheader>Associated Users</h3>
|
<h3 mat-subheader>Associated Users</h3>
|
||||||
<mat-list-item role="listitem" *ngFor="let user of associatedUsers">
|
<mat-list-item role="listitem" *ngFor="let user of associatedUsers">
|
||||||
<mat-icon mat-list-icon>person</mat-icon>
|
<mat-icon mat-list-icon>person</mat-icon>
|
||||||
<div>{{user.name}}</div>
|
<div>{{user.name}}</div>
|
||||||
</mat-list-item>
|
</mat-list-item>
|
||||||
</mat-list>
|
</mat-list>
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
</form>
|
</form>
|
||||||
<!-- <div *ngIf="formGroup"> {{ formGroup.value | json }}</div> -->
|
<!-- <div *ngIf="formGroup"> {{ formGroup.value | json }}</div> -->
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -11,12 +11,12 @@ import { DataManagementPlanModel } from '../../../models/data-managemnt-plans/Da
|
||||||
import { ProjectService } from '../../../services/project/project.service';
|
import { ProjectService } from '../../../services/project/project.service';
|
||||||
import { ExternalSourcesService } from '../../../services/external-sources/external-sources.service';
|
import { ExternalSourcesService } from '../../../services/external-sources/external-sources.service';
|
||||||
import { DataManagementPlanService } from '../../../services/data-management-plan/data-management-plan.service';
|
import { DataManagementPlanService } from '../../../services/data-management-plan/data-management-plan.service';
|
||||||
import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation, Input } from "@angular/core";
|
import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation, Input } from '@angular/core';
|
||||||
import { MatPaginator, MatSort, MatSnackBar } from "@angular/material";
|
import { MatPaginator, MatSort, MatSnackBar } from '@angular/material';
|
||||||
import { Router, ActivatedRoute, Params } from "@angular/router";
|
import { Router, ActivatedRoute, Params } from '@angular/router';
|
||||||
import { TranslateService } from "@ngx-translate/core";
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { DataSource } from "@angular/cdk/table";
|
import { DataSource } from '@angular/cdk/table';
|
||||||
import { Observable } from "rxjs/Observable";
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { FormGroup } from '@angular/forms';
|
import { FormGroup } from '@angular/forms';
|
||||||
import { BaseCriteria } from '../../../models/criteria/BaseCriteria';
|
import { BaseCriteria } from '../../../models/criteria/BaseCriteria';
|
||||||
import { SingleAutoCompleteConfiguration } from '../../../shared/components/autocompletes/single/single-auto-complete-configuration';
|
import { SingleAutoCompleteConfiguration } from '../../../shared/components/autocompletes/single/single-auto-complete-configuration';
|
||||||
|
@ -25,168 +25,168 @@ import { MultipleAutoCompleteConfiguration } from '../../../shared/components/au
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dmp-wizard-editor-component',
|
selector: 'app-dmp-wizard-editor-component',
|
||||||
templateUrl: 'dmp-wizard-editor.component.html',
|
templateUrl: 'dmp-wizard-editor.component.html',
|
||||||
styleUrls: ['./dmp-wizard-editor.component.scss'],
|
styleUrls: ['./dmp-wizard-editor.component.scss'],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class DataManagementPlanWizardEditorComponent implements OnInit {
|
export class DataManagementPlanWizardEditorComponent implements OnInit {
|
||||||
|
|
||||||
|
|
||||||
isNew = true;
|
isNew = true;
|
||||||
@Input() formGroup: FormGroup = null;
|
@Input() formGroup: FormGroup = null;
|
||||||
|
|
||||||
filteringOrganisationsAsync: boolean = false;
|
filteringOrganisationsAsync = false;
|
||||||
filteringResearchersAsync: boolean = false;
|
filteringResearchersAsync = false;
|
||||||
filteredProfilesAsync: boolean = false;
|
filteredProfilesAsync = false;
|
||||||
filteredOrganisations: ExternalSourcesItemModel[];
|
filteredOrganisations: ExternalSourcesItemModel[];
|
||||||
filteredResearchers: ExternalSourcesItemModel[];
|
filteredResearchers: ExternalSourcesItemModel[];
|
||||||
filteredProfiles: DatasetProfileModel[];
|
filteredProfiles: DatasetProfileModel[];
|
||||||
|
|
||||||
projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
|
projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
|
||||||
profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
|
profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
|
||||||
organisationsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
|
organisationsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
|
||||||
researchersAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
|
researchersAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
|
||||||
createNewVersion;
|
createNewVersion;
|
||||||
associatedUsers: Array<DmpUsersModel>
|
associatedUsers: Array<DmpUsersModel>;
|
||||||
labelDisabled: boolean = false;
|
labelDisabled = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private dataManagementPlanService: DataManagementPlanService,
|
private dataManagementPlanService: DataManagementPlanService,
|
||||||
private projectService: ProjectService,
|
private projectService: ProjectService,
|
||||||
private externalSourcesService: ExternalSourcesService,
|
private externalSourcesService: ExternalSourcesService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
public snackBar: MatSnackBar,
|
public snackBar: MatSnackBar,
|
||||||
public router: Router,
|
public router: Router,
|
||||||
public language: TranslateService,
|
public language: TranslateService,
|
||||||
private _service: DataManagementPlanService,
|
private _service: DataManagementPlanService,
|
||||||
private languageResolverService: LanguageResolverService
|
private languageResolverService: LanguageResolverService
|
||||||
) {
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
let projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
|
const projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
|
||||||
projectRequestItem.criteria = new ProjectCriteria();
|
projectRequestItem.criteria = new ProjectCriteria();
|
||||||
this.projectAutoCompleteConfiguration = {
|
this.projectAutoCompleteConfiguration = {
|
||||||
filterFn: this.searchProject.bind(this.projectService),
|
filterFn: this.searchProject.bind(this.projectService),
|
||||||
items: this.searchProject(''),
|
items: this.searchProject(''),
|
||||||
displayFn: (item) => item["label"],
|
displayFn: (item) => item['label'],
|
||||||
titleFn: (item) => item["label"],
|
titleFn: (item) => item['label'],
|
||||||
//mapFn: (item) => new JsonSerializer<ProjectReference>().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()),
|
//mapFn: (item) => new JsonSerializer<ProjectReference>().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()),
|
||||||
loadDataOnStart: true
|
loadDataOnStart: true
|
||||||
};
|
};
|
||||||
|
|
||||||
this.profilesAutoCompleteConfiguration = {
|
this.profilesAutoCompleteConfiguration = {
|
||||||
filterFn: this.filterProfiles.bind(this),
|
filterFn: this.filterProfiles.bind(this),
|
||||||
initialItems: (excludedItems: any[]) => this.filterProfiles('').map(result => result.filter(x => excludedItems.map(x => x.id).indexOf(x.id) == -1)),
|
initialItems: (excludedItems: any[]) => this.filterProfiles('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)),
|
||||||
displayFn: (item) => item["label"],
|
displayFn: (item) => item['label'],
|
||||||
titleFn: (item) => item["label"],
|
titleFn: (item) => item['label'],
|
||||||
//mapFn: (item) => new JsonSerializer<ProjectReference>().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()),
|
//mapFn: (item) => new JsonSerializer<ProjectReference>().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()),
|
||||||
loadDataOnStart: true
|
loadDataOnStart: true
|
||||||
};
|
};
|
||||||
|
|
||||||
this.organisationsAutoCompleteConfiguration = {
|
this.organisationsAutoCompleteConfiguration = {
|
||||||
filterFn: this.filterOrganisations.bind(this),
|
filterFn: this.filterOrganisations.bind(this),
|
||||||
initialItems: (excludedItems: any[]) => this.filterOrganisations('').map(result => result.filter(x => excludedItems.map(x => x.id).indexOf(x.id) == -1)),
|
initialItems: (excludedItems: any[]) => this.filterOrganisations('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)),
|
||||||
displayFn: (item) => item["name"],
|
displayFn: (item) => item['name'],
|
||||||
titleFn: (item) => item["name"],
|
titleFn: (item) => item['name'],
|
||||||
loadDataOnStart: true
|
loadDataOnStart: true
|
||||||
};
|
};
|
||||||
|
|
||||||
this.researchersAutoCompleteConfiguration = {
|
this.researchersAutoCompleteConfiguration = {
|
||||||
filterFn: this.filterResearchers.bind(this),
|
filterFn: this.filterResearchers.bind(this),
|
||||||
initialItems: (excludedItems: any[]) => this.filterResearchers('').map(result => result.filter(x => excludedItems.map(x => x.id).indexOf(x.id) == -1)),
|
initialItems: (excludedItems: any[]) => this.filterResearchers('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)),
|
||||||
displayFn: (item) => item["name"],
|
displayFn: (item) => item['name'],
|
||||||
titleFn: (item) => item["name"],
|
titleFn: (item) => item['name'],
|
||||||
loadDataOnStart: true
|
loadDataOnStart: true
|
||||||
};
|
};
|
||||||
|
|
||||||
let organisationRequestItem: RequestItem<BaseCriteria> = new RequestItem();
|
const organisationRequestItem: RequestItem<BaseCriteria> = new RequestItem();
|
||||||
organisationRequestItem.criteria = new BaseCriteria();
|
organisationRequestItem.criteria = new BaseCriteria();
|
||||||
|
|
||||||
this.route.data.subscribe(value => {
|
this.route.data.subscribe(value => {
|
||||||
if (value.clone == false && this.formGroup.get("label").value) {
|
if (value.clone === false && this.formGroup.get('label').value) {
|
||||||
this.labelDisabled = true;
|
this.labelDisabled = true;
|
||||||
}
|
}
|
||||||
this.formGroup.controls["version"].disable();
|
this.formGroup.controls['version'].disable();
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
searchProject(query: string) {
|
searchProject(query: string) {
|
||||||
let projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
|
const projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
|
||||||
projectRequestItem.criteria = new ProjectCriteria();
|
projectRequestItem.criteria = new ProjectCriteria();
|
||||||
projectRequestItem.criteria.like = query;
|
projectRequestItem.criteria.like = query;
|
||||||
return this.projectService.getWithExternal(projectRequestItem);
|
return this.projectService.getWithExternal(projectRequestItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
formSubmit(): void {
|
formSubmit(): void {
|
||||||
//this.touchAllFormFields(this.formGroup);
|
//this.touchAllFormFields(this.formGroup);
|
||||||
if (!this.isFormValid()) { return; }
|
if (!this.isFormValid()) { return; }
|
||||||
this.onSubmit();
|
this.onSubmit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public isFormValid() {
|
public isFormValid() {
|
||||||
return this.formGroup.valid;
|
return this.formGroup.valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit(): void {
|
onSubmit(): void {
|
||||||
this.dataManagementPlanService.createDataManagementPlan(this.formGroup.getRawValue()).subscribe(
|
this.dataManagementPlanService.createDataManagementPlan(this.formGroup.getRawValue()).subscribe(
|
||||||
complete => this.onCallbackSuccess(),
|
complete => this.onCallbackSuccess(),
|
||||||
error => this.onCallbackError(error)
|
error => this.onCallbackError(error)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onCallbackSuccess(): void {
|
onCallbackSuccess(): void {
|
||||||
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
|
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
|
||||||
data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
|
data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
})
|
});
|
||||||
this.router.navigate(['/dmps']);
|
this.router.navigate(['/dmps']);
|
||||||
}
|
}
|
||||||
|
|
||||||
onCallbackError(error: any) {
|
onCallbackError(error: any) {
|
||||||
this.setErrorModel(error.error);
|
this.setErrorModel(error.error);
|
||||||
//this.validateAllFormFields(this.formGroup);
|
//this.validateAllFormFields(this.formGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
public setErrorModel(errorModel: BaseErrorModel) {
|
public setErrorModel(errorModel: BaseErrorModel) {
|
||||||
Object.keys(errorModel).forEach(item => {
|
Object.keys(errorModel).forEach(item => {
|
||||||
// (<any>this.dataManagementPlan.errorModel)[item] = (<any>errorModel)[item];
|
// (<any>this.dataManagementPlan.errorModel)[item] = (<any>errorModel)[item];
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public cancel(): void {
|
public cancel(): void {
|
||||||
this.router.navigate(['/dmps']);
|
this.router.navigate(['/dmps']);
|
||||||
}
|
}
|
||||||
|
|
||||||
filterOrganisations(value: string): Observable<ExternalSourcesItemModel[]> {
|
filterOrganisations(value: string): Observable<ExternalSourcesItemModel[]> {
|
||||||
|
|
||||||
this.filteredOrganisations = undefined;
|
this.filteredOrganisations = undefined;
|
||||||
this.filteringOrganisationsAsync = true;
|
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.filteredResearchers = undefined;
|
||||||
this.filteringResearchersAsync = true;
|
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.filteredProfiles = undefined;
|
||||||
this.filteredProfilesAsync = true;
|
this.filteredProfilesAsync = true;
|
||||||
|
|
||||||
const request = new RequestItem<DatasetProfileCriteria>();
|
const request = new RequestItem<DatasetProfileCriteria>();
|
||||||
let criteria = new DatasetProfileCriteria();
|
const criteria = new DatasetProfileCriteria();
|
||||||
criteria.like = value;
|
criteria.like = value;
|
||||||
request.criteria = criteria;
|
request.criteria = criteria;
|
||||||
return this._service.searchDMPProfiles(request)
|
return this._service.searchDMPProfiles(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,74 +7,76 @@ import { DataManagementPlanModel } from '../../../models/data-managemnt-plans/Da
|
||||||
import { DatasetCriteriaComponent } from '../../../shared/components/criteria/datasets/datasets-criteria.component';
|
import { DatasetCriteriaComponent } from '../../../shared/components/criteria/datasets/datasets-criteria.component';
|
||||||
import { DataManagementPlanService } from '../../../services/data-management-plan/data-management-plan.service';
|
import { DataManagementPlanService } from '../../../services/data-management-plan/data-management-plan.service';
|
||||||
import { DatasetService } from '../../../services/dataset/dataset.service';
|
import { DatasetService } from '../../../services/dataset/dataset.service';
|
||||||
import { Component, ViewChild, OnInit, AfterViewInit, Input } from "@angular/core";
|
import { Component, ViewChild, OnInit, AfterViewInit, Input } from '@angular/core';
|
||||||
import { MatPaginator, MatSort, MatSnackBar } from "@angular/material";
|
import { MatPaginator, MatSort, MatSnackBar } from '@angular/material';
|
||||||
import { Router, Params, ActivatedRoute } from "@angular/router";
|
import { Router, Params, ActivatedRoute } from '@angular/router';
|
||||||
import { TranslateService } from "@ngx-translate/core";
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { DataSource } from "@angular/cdk/table";
|
import { DataSource } from '@angular/cdk/table';
|
||||||
import { FormGroup, FormBuilder, FormControl, FormArray } from "@angular/forms"
|
import { FormGroup, FormBuilder, FormControl, FormArray } from '@angular/forms';
|
||||||
import { Observable } from "rxjs/Observable";
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { PageEvent } from '@angular/material';
|
import { PageEvent } from '@angular/material';
|
||||||
import { SelectionModel } from '@angular/cdk/collections';
|
import { SelectionModel } from '@angular/cdk/collections';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dataset-wizard-listing-component',
|
selector: 'app-dataset-wizard-listing-component',
|
||||||
templateUrl: 'dataset-wizard-listing.component.html',
|
templateUrl: 'dataset-wizard-listing.component.html',
|
||||||
styleUrls: ['./dataset-wizard-listing.component.scss'],
|
styleUrls: ['./dataset-wizard-listing.component.scss'],
|
||||||
})
|
})
|
||||||
export class DatasetWizardListingComponent implements OnInit {
|
export class DatasetWizardListingComponent implements OnInit {
|
||||||
|
|
||||||
@ViewChild(MatPaginator) _paginator: MatPaginator;
|
@ViewChild(MatPaginator) _paginator: MatPaginator;
|
||||||
@ViewChild(MatSort) sort: MatSort;
|
@ViewChild(MatSort) sort: MatSort;
|
||||||
@ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent;
|
@ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent;
|
||||||
|
|
||||||
|
|
||||||
titlePrefix: String;
|
titlePrefix: String;
|
||||||
datasets: DatasetListingModel[] = []
|
datasets: DatasetListingModel[] = [];
|
||||||
|
|
||||||
@Input() dmpId: String;
|
@Input() dmpId: String;
|
||||||
@Input() formGroup: FormGroup
|
@Input() formGroup: FormGroup;
|
||||||
selection = new SelectionModel<Element>(true, []);
|
selection = new SelectionModel<Element>(true, []);
|
||||||
|
|
||||||
statuses = [
|
statuses = [
|
||||||
{ value: '0', viewValue: 'Active' },
|
{ value: '0', viewValue: 'Active' },
|
||||||
{ value: '1', viewValue: 'Inactive' }
|
{ value: '1', viewValue: 'Inactive' }
|
||||||
];
|
];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private datasetService: DatasetService,
|
private datasetService: DatasetService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private languageService: TranslateService,
|
private languageService: TranslateService,
|
||||||
public snackBar: MatSnackBar,
|
public snackBar: MatSnackBar,
|
||||||
public route: ActivatedRoute,
|
public route: ActivatedRoute,
|
||||||
public dataManagementPlanService: DataManagementPlanService
|
public dataManagementPlanService: DataManagementPlanService
|
||||||
) {
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.route.params.subscribe((params: Params) => {
|
this.route.params.subscribe((params: Params) => {
|
||||||
if (this.dmpId != null)
|
if (this.dmpId != null) {
|
||||||
if (params['dmpLabel'] != undefined)
|
if (params['dmpLabel'] !== undefined) {
|
||||||
this.titlePrefix = "for " + params['dmpLabel'];
|
this.titlePrefix = 'for ' + params['dmpLabel'];
|
||||||
});
|
}
|
||||||
let request: DataTableRequest<DatasetCriteria> = new DataTableRequest<DatasetCriteria>(null, null, null);
|
}
|
||||||
request.criteria = new DatasetCriteria();
|
});
|
||||||
request.criteria.dmpIds = [this.dmpId];
|
const request: DataTableRequest<DatasetCriteria> = new DataTableRequest<DatasetCriteria>(null, null, null);
|
||||||
this.datasetService.getPaged(request).subscribe(items => {
|
request.criteria = new DatasetCriteria();
|
||||||
this.datasets = JsonSerializer.fromJSONArray(items.data, DatasetListingModel)
|
request.criteria.dmpIds = [this.dmpId];
|
||||||
})
|
this.datasetService.getPaged(request).subscribe(items => {
|
||||||
this.formGroup.addControl("datasets", new FormBuilder().array(new Array<FormControl>()))
|
this.datasets = JsonSerializer.fromJSONArray(items.data, DatasetListingModel);
|
||||||
}
|
});
|
||||||
|
this.formGroup.addControl('datasets', new FormBuilder().array(new Array<FormControl>()));
|
||||||
|
}
|
||||||
|
|
||||||
selectionChanged(event, selectedItems) {
|
selectionChanged(event, selectedItems) {
|
||||||
this.formGroup.removeControl("datasets");
|
this.formGroup.removeControl('datasets');
|
||||||
this.formGroup.addControl("datasets", new FormBuilder().array(new Array<FormControl>()))
|
this.formGroup.addControl('datasets', new FormBuilder().array(new Array<FormControl>()));
|
||||||
selectedItems.selectedOptions.selected.forEach(element => {
|
selectedItems.selectedOptions.selected.forEach(element => {
|
||||||
(<FormArray>this.formGroup.get("datasets")).push(new FormBuilder().group({ id: element.value }))
|
(<FormArray>this.formGroup.get('datasets')).push(new FormBuilder().group({ id: element.value }));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,52 +11,51 @@ declare var $: any;
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'df-autocomplete',
|
selector: 'app-df-autocomplete',
|
||||||
templateUrl: './autocomplete-remote.component.html',
|
templateUrl: './autocomplete-remote.component.html',
|
||||||
styleUrls: ['./autocomplete-remote.component.css'],
|
styleUrls: ['./autocomplete-remote.component.css'],
|
||||||
encapsulation: ViewEncapsulation.None,
|
encapsulation: ViewEncapsulation.None,
|
||||||
})
|
})
|
||||||
export class AutocompleteRemoteComponent implements OnInit/* , ControlValueAccessor */ {
|
export class AutocompleteRemoteComponent implements OnInit/* , ControlValueAccessor */ {
|
||||||
|
|
||||||
|
|
||||||
@Input() field: Field;
|
@Input() field: Field;
|
||||||
@Input() disabled = false
|
@Input() disabled = false;
|
||||||
@Input() form: FormGroup;
|
@Input() form: FormGroup;
|
||||||
|
|
||||||
public autoCompleteConfiguration: AutoCompleteConfiguration;
|
public autoCompleteConfiguration: AutoCompleteConfiguration;
|
||||||
public loading: boolean;
|
public loading: boolean;
|
||||||
public datasetId;
|
public datasetId;
|
||||||
public values: any[] = new Array();
|
public values: any[] = new Array();
|
||||||
public typeaheadMS: number = 1400;
|
public typeaheadMS = 1400;
|
||||||
|
|
||||||
constructor(private datasetProfileService: DatasetProfileService, route: ActivatedRoute) {
|
constructor(private datasetProfileService: DatasetProfileService, route: ActivatedRoute) {
|
||||||
this.datasetId = route.snapshot.params['id'];
|
this.datasetId = route.snapshot.params['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
let autocompleteRequestItem: RequestItem<AutocompleteLookupItem> = new RequestItem();
|
const autocompleteRequestItem: RequestItem<AutocompleteLookupItem> = new RequestItem();
|
||||||
autocompleteRequestItem.criteria = new AutocompleteLookupItem();
|
autocompleteRequestItem.criteria = new AutocompleteLookupItem();
|
||||||
autocompleteRequestItem.criteria.fieldID = this.field.id;
|
autocompleteRequestItem.criteria.fieldID = this.field.id;
|
||||||
autocompleteRequestItem.criteria.profileID = this.datasetId;
|
autocompleteRequestItem.criteria.profileID = this.datasetId;
|
||||||
this.autoCompleteConfiguration = new AutoCompleteConfiguration(this.datasetProfileService.queryAutocomplete.bind(this.datasetProfileService), autocompleteRequestItem);
|
this.autoCompleteConfiguration = new AutoCompleteConfiguration(this.datasetProfileService.queryAutocomplete.bind(this.datasetProfileService), autocompleteRequestItem);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
displayWith(item: any) {
|
displayWith(item: any) {
|
||||||
if (!item) return null;
|
if (!item) { return null; }
|
||||||
if (typeof item === 'string') item = this.transform(item);
|
if (typeof item === 'string') { item = this.transform(item); }
|
||||||
return item["label"];
|
return item['label'];
|
||||||
}
|
}
|
||||||
|
|
||||||
assign(item: any) {
|
assign(item: any) {
|
||||||
if (!item) return null;
|
if (!item) { return null; }
|
||||||
return this.transform(item);
|
return this.transform(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
transform(item: any) {
|
transform(item: any) {
|
||||||
if (typeof item === 'string') return JSON.parse(item)
|
if (typeof item === 'string') { return JSON.parse(item); } else { return JSON.stringify(item); }
|
||||||
else return JSON.stringify(item);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,18 +3,18 @@ import { Field } from '../../../models/Field';
|
||||||
import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core';
|
import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'df-booleanDecision',
|
selector: 'app-df-boolean-decision',
|
||||||
templateUrl: './dynamic-field-boolean-decision.component.html',
|
templateUrl: './dynamic-field-boolean-decision.component.html',
|
||||||
styleUrls: [
|
styleUrls: [
|
||||||
'./dynamic-field-boolean-decision.component.css'
|
'./dynamic-field-boolean-decision.component.css'
|
||||||
],
|
],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class DynamicFieldBooleanDecisionComponent implements OnInit {
|
export class DynamicFieldBooleanDecisionComponent implements OnInit {
|
||||||
@Input() field: Field;
|
@Input() field: Field;
|
||||||
@Input() form: FormGroup;
|
@Input() form: FormGroup;
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,15 +3,15 @@ import { FormGroup } from '@angular/forms';
|
||||||
import { Component, Input, ViewEncapsulation, OnInit } from '@angular/core';
|
import { Component, Input, ViewEncapsulation, OnInit } from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'df-checkbox',
|
selector: 'app-df-checkbox',
|
||||||
templateUrl: './dynamic-field-checkbox.html',
|
templateUrl: './dynamic-field-checkbox.html',
|
||||||
styleUrls: [
|
styleUrls: [
|
||||||
'./dynamic-field-checkbox.css'
|
'./dynamic-field-checkbox.css'
|
||||||
],
|
],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class DynamicFieldCheckBoxComponent {
|
export class DynamicFieldCheckBoxComponent {
|
||||||
@Input() field: Field;
|
@Input() field: Field;
|
||||||
@Input() form: FormGroup;
|
@Input() form: FormGroup;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,18 +3,18 @@ import { Field } from '../../../models/Field';
|
||||||
import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core';
|
import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'df-dropdown',
|
selector: 'app-df-dropdown',
|
||||||
templateUrl: './dynamic-field-dropdown.html',
|
templateUrl: './dynamic-field-dropdown.html',
|
||||||
styleUrls: [
|
styleUrls: [
|
||||||
'./dynamic-field-dropdown.css'
|
'./dynamic-field-dropdown.css'
|
||||||
],
|
],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class DynamicFieldDropdownComponent implements OnInit {
|
export class DynamicFieldDropdownComponent implements OnInit {
|
||||||
@Input() field: Field;
|
@Input() field: Field;
|
||||||
@Input() form: FormGroup;
|
@Input() form: FormGroup;
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,18 +4,18 @@ import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'df-radiobox',
|
selector: 'app-df-radiobox',
|
||||||
templateUrl: './dynamic-field-radiobox.component.html',
|
templateUrl: './dynamic-field-radiobox.component.html',
|
||||||
styleUrls: [
|
styleUrls: [
|
||||||
'./dynamic-field-radiobox.component.css'
|
'./dynamic-field-radiobox.component.css'
|
||||||
],
|
],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class DynamicFieldRadioBoxComponent implements OnInit {
|
export class DynamicFieldRadioBoxComponent implements OnInit {
|
||||||
@Input() field: Field;
|
@Input() field: Field;
|
||||||
@Input() form: FormGroup;
|
@Input() form: FormGroup;
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,16 +19,16 @@
|
||||||
<div *ngSwitchCase="'combobox'">
|
<div *ngSwitchCase="'combobox'">
|
||||||
<!--TODO-->
|
<!--TODO-->
|
||||||
<div *ngIf="this.field.data.type === 'autocomplete'">
|
<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>
|
||||||
<div *ngIf="this.field.data.type === 'wordlist'">
|
<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>
|
</div>
|
||||||
|
|
||||||
<div *ngSwitchCase="'checkBox'" class="checkbox">
|
<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>
|
||||||
|
|
||||||
<div *ngSwitchCase="'textarea'">
|
<div *ngSwitchCase="'textarea'">
|
||||||
|
@ -44,11 +44,11 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div *ngSwitchCase="'booleanDecision'">
|
<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>
|
||||||
|
|
||||||
<div *ngSwitchCase="'radiobox'">
|
<div *ngSwitchCase="'radiobox'">
|
||||||
<df-radiobox [form]="form" [field]="field"></df-radiobox>
|
<app-df-radiobox [form]="form" [field]="field"></app-df-radiobox>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div *ngSwitchCase="'label'"> </div>
|
<div *ngSwitchCase="'label'"> </div>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Field } from '../../models/Field';
|
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 { FormGroup, ValidatorFn, AbstractControl, Validators } from '@angular/forms';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { VisibilityRulesService } from '../../utilities/visibility-rules/visibility-rules.service';
|
import { VisibilityRulesService } from '../../utilities/visibility-rules/visibility-rules.service';
|
||||||
|
@ -7,60 +7,58 @@ import { Subscription } from 'rxjs';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'df-field',
|
selector: 'app-df-field',
|
||||||
templateUrl: './dynamic-form-field.component.html',
|
templateUrl: './dynamic-form-field.component.html',
|
||||||
// styles: ['.checkBoxLabelCustom {font-weight: 700;}']
|
// styles: ['.checkBoxLabelCustom {font-weight: 700;}']
|
||||||
styleUrls: [
|
styleUrls: [
|
||||||
'./dynamic-form-field.component.css'
|
'./dynamic-form-field.component.css'
|
||||||
],
|
],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
|
|
||||||
export class DynamicFormFieldComponent implements OnInit {
|
export class DynamicFormFieldComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
@Input() field: Field;
|
@Input() field: Field;
|
||||||
form: FormGroup;
|
form: FormGroup;
|
||||||
@Input() pathName: string;
|
@Input() pathName: string;
|
||||||
@Input() path: string;
|
@Input() path: string;
|
||||||
change: Subscription;
|
change: Subscription;
|
||||||
trackByFn = (index, item) => item ? item["id"] : null
|
trackByFn = (index, item) => item ? item['id'] : null;
|
||||||
constructor(private route: ActivatedRoute, public visibilityRulesService: VisibilityRulesService) {
|
constructor(private route: ActivatedRoute, public visibilityRulesService: VisibilityRulesService) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (this.field) {
|
if (this.field) {
|
||||||
this.form = this.visibilityRulesService.getFormGroup(this.field.id)
|
this.form = this.visibilityRulesService.getFormGroup(this.field.id);
|
||||||
if (!this.form) debugger;
|
this.change = this.form.get('value').valueChanges.subscribe(item => {
|
||||||
if (!this.form.get('value')) debugger;
|
this.visibilityRulesService.updateValueAndVisibility(this.field.id);
|
||||||
this.change = this.form.get('value').valueChanges.subscribe(item => {
|
});
|
||||||
this.visibilityRulesService.updateValueAndVisibility(this.field.id)
|
}
|
||||||
})
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnChanges(changeRecord) {
|
ngOnChanges(changeRecord) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
//Called once, before the instance is destroyed.
|
//Called once, before the instance is destroyed.
|
||||||
//Add 'implements OnDestroy' to the class.
|
//Add 'implements OnDestroy' to the class.
|
||||||
if(this.change) this.change.unsubscribe()
|
if (this.change) { this.change.unsubscribe(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
clearInput() {
|
clearInput() {
|
||||||
}
|
}
|
||||||
|
|
||||||
get isValid() {
|
get isValid() {
|
||||||
return this.form.get("value").valid;
|
return this.form.get('value').valid;
|
||||||
}
|
}
|
||||||
get isValidRequired() {
|
get isValidRequired() {
|
||||||
return this.form.get("value").hasError("required");
|
return this.form.get('value').hasError('required');
|
||||||
}
|
}
|
||||||
get isValidPattern() {
|
get isValidPattern() {
|
||||||
return this.form.get("value").hasError("pattern");
|
return this.form.get('value').hasError('pattern');
|
||||||
}
|
}
|
||||||
get isValidCustom() {
|
get isValidCustom() {
|
||||||
return this.form.get("value").hasError("forbiddenName");
|
return this.form.get('value').hasError('forbiddenName');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,40 +1,40 @@
|
||||||
<div *ngIf="form" [id]="compositeField.id" [formGroup]="form">
|
<div *ngIf="form" [id]="compositeField.id" [formGroup]="form">
|
||||||
|
|
||||||
<div *ngIf="compositeField.fields.length == 1" class="fieldset-component">
|
<div *ngIf="compositeField.fields.length == 1" class="fieldset-component">
|
||||||
<h5 *ngIf="compositeField.title" style="font-weight:bold; color: #3a3737;">{{compositeField.title}}</h5>
|
<h5 *ngIf="compositeField.title" style="font-weight:bold; color: #3a3737;">{{compositeField.title}}</h5>
|
||||||
<div class="content-left-margin">
|
<div class="content-left-margin">
|
||||||
<h5 *ngIf="compositeField.description">{{compositeField.description}}</h5>
|
<h5 *ngIf="compositeField.description">{{compositeField.description}}</h5>
|
||||||
<h5 *ngIf="compositeField.extendedDescription" class="fieldset-extended-desc">
|
<h5 *ngIf="compositeField.extendedDescription" class="fieldset-extended-desc">
|
||||||
<i>{{compositeField.extendedDescription}}</i>
|
<i>{{compositeField.extendedDescription}}</i>
|
||||||
</h5>
|
</h5>
|
||||||
<df-field *ngIf="compositeField.fields.length == 1" [field]="compositeField.fields[0]" [pathName]="pathName+'.fields.'+0"></df-field>
|
<app-df-field *ngIf="compositeField.fields.length == 1" [field]="compositeField.fields[0]" [pathName]="pathName+'.fields.'+0"></app-df-field>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div *ngIf="compositeField.fields.length > 1" class="fieldset-component">
|
<div *ngIf="compositeField.fields.length > 1" class="fieldset-component">
|
||||||
<h5 *ngIf="compositeField.title" style="font-weight:bold; color: #3a3737;">{{compositeField.title}}</h5>
|
<h5 *ngIf="compositeField.title" style="font-weight:bold; color: #3a3737;">{{compositeField.title}}</h5>
|
||||||
<div class="content-left-margin">
|
<div class="content-left-margin">
|
||||||
<h5 *ngIf="compositeField.description">{{compositeField.description}}</h5>
|
<h5 *ngIf="compositeField.description">{{compositeField.description}}</h5>
|
||||||
<h5 *ngIf="compositeField.extendedDescription" class="fieldset-extended-desc">
|
<h5 *ngIf="compositeField.extendedDescription" class="fieldset-extended-desc">
|
||||||
<i>{{compositeField.extendedDescription}}</i>
|
<i>{{compositeField.extendedDescription}}</i>
|
||||||
</h5>
|
</h5>
|
||||||
<div *ngFor="let field of compositeField.fields; let i = index; trackBy: trackByFn ">
|
<div *ngFor="let field of compositeField.fields; let i = index; trackBy: trackByFn ">
|
||||||
<div>
|
<div>
|
||||||
<div *ngIf="(field?.multiplicity?.max - 1) > (field?.multiplicityItems?.length)">
|
<div *ngIf="(field?.multiplicity?.max - 1) > (field?.multiplicityItems?.length)">
|
||||||
<a (click)="addMultipleField(i)" style="cursor: pointer">
|
<a (click)="addMultipleField(i)" style="cursor: pointer">
|
||||||
Add one more field +
|
Add one more field +
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<df-field [field]="field" [pathName]="pathName+'.fields.'+i"></df-field>
|
<app-df-field [field]="field" [pathName]="pathName+'.fields.'+i"></app-df-field>
|
||||||
<div *ngIf="field">
|
<div *ngIf="field">
|
||||||
<div *ngFor="let multipleField of field.multiplicityItems; let j = index; trackBy: trackByFn">
|
<div *ngFor="let multipleField of field.multiplicityItems; let j = index; trackBy: trackByFn">
|
||||||
<df-field [field]="multipleField" [pathName]="pathName+'.fields.'+i+'.multiplicityItems.'+j"></df-field>
|
<app-df-field [field]="multipleField" [pathName]="pathName+'.fields.'+i+'.multiplicityItems.'+j"></app-df-field>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -4,34 +4,34 @@ import { FormGroup, FormArray } from '@angular/forms';
|
||||||
import { Component, Input, OnInit, ViewEncapsulation, ChangeDetectionStrategy } from '@angular/core';
|
import { Component, Input, OnInit, ViewEncapsulation, ChangeDetectionStrategy } from '@angular/core';
|
||||||
import { Field } from '../../models/Field';
|
import { Field } from '../../models/Field';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'df-composite-field',
|
selector: 'app-df-composite-field',
|
||||||
templateUrl: './dynamic-form-composite-field.html',
|
templateUrl: './dynamic-form-composite-field.html',
|
||||||
styleUrls: [
|
styleUrls: [
|
||||||
'./dynamic-form-composite-field.css'
|
'./dynamic-form-composite-field.css'
|
||||||
],
|
],
|
||||||
encapsulation: ViewEncapsulation.None,
|
encapsulation: ViewEncapsulation.None,
|
||||||
})
|
})
|
||||||
export class DynamicFormCompositeFieldComponent implements OnInit {
|
export class DynamicFormCompositeFieldComponent implements OnInit {
|
||||||
|
|
||||||
@Input() compositeField: CompositeField
|
@Input() compositeField: CompositeField;
|
||||||
form: FormGroup;
|
form: FormGroup;
|
||||||
@Input() pathName: string;
|
@Input() pathName: string;
|
||||||
@Input() path: string;
|
@Input() path: string;
|
||||||
trackByFn = (index, item) => item ? item["id"] : null
|
trackByFn = (index, item) => item ? item['id'] : null;
|
||||||
|
|
||||||
constructor(private visibilityRulesService: VisibilityRulesService) {
|
constructor(private visibilityRulesService: VisibilityRulesService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (this.compositeField) {
|
if (this.compositeField) {
|
||||||
this.form = this.visibilityRulesService.getFormGroup(this.compositeField.id)
|
this.form = this.visibilityRulesService.getFormGroup(this.compositeField.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
addMultipleField(fieldIndex: number) {
|
addMultipleField(fieldIndex: number) {
|
||||||
let field: Field = this.compositeField.fields[fieldIndex].cloneForMultiplicity(fieldIndex, "");
|
const field: Field = this.compositeField.fields[fieldIndex].cloneForMultiplicity(fieldIndex, '');
|
||||||
this.compositeField.fields[fieldIndex].multiplicityItems.push(field);
|
this.compositeField.fields[fieldIndex].multiplicityItems.push(field);
|
||||||
(<FormArray>(this.form.get("fields").get('' + fieldIndex).get('multiplicityItems'))).push(field.buildForm());
|
(<FormArray>(this.form.get('fields').get('' + fieldIndex).get('multiplicityItems'))).push(field.buildForm());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,10 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</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 *ngIf="compositeField">
|
||||||
<div *ngFor="let multipleCompositeField of compositeField.multiplicityItems; let j = index; trackBy: trackByFn">
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -8,36 +8,36 @@ import { CompositeField } from '../../models/CompositeField';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'df-group',
|
selector: 'app-df-group',
|
||||||
templateUrl: './dynamic-form-group.component.html',
|
templateUrl: './dynamic-form-group.component.html',
|
||||||
styleUrls: ['./dynamic-form-group.component.css'],
|
styleUrls: ['./dynamic-form-group.component.css'],
|
||||||
encapsulation: ViewEncapsulation.None,
|
encapsulation: ViewEncapsulation.None,
|
||||||
})
|
})
|
||||||
export class DynamicFormGroupComponent implements OnInit {
|
export class DynamicFormGroupComponent implements OnInit {
|
||||||
@Input() group: FieldGroup
|
@Input() group: FieldGroup;
|
||||||
form: FormGroup;
|
form: FormGroup;
|
||||||
@Input() pathName: string;
|
@Input() pathName: string;
|
||||||
|
|
||||||
@Input() path: string;
|
@Input() path: string;
|
||||||
trackByFn = (index, item) => item ? item["id"] : null
|
trackByFn = (index, item) => item ? item['id'] : null;
|
||||||
constructor(public visibilityRulesService: VisibilityRulesService) {
|
constructor(public visibilityRulesService: VisibilityRulesService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (this.group) {
|
if (this.group) {
|
||||||
this.form = this.visibilityRulesService.getFormGroup(this.group.id)
|
this.form = this.visibilityRulesService.getFormGroup(this.group.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
addMultipleField(fieldsetIndex: number) {
|
addMultipleField(fieldsetIndex: number) {
|
||||||
let compositeField: CompositeField = this.group.compositeFields[fieldsetIndex].cloneForMultiplicity(fieldsetIndex);
|
const compositeField: CompositeField = this.group.compositeFields[fieldsetIndex].cloneForMultiplicity(fieldsetIndex);
|
||||||
this.group.compositeFields[fieldsetIndex].multiplicityItems.push(compositeField);
|
this.group.compositeFields[fieldsetIndex].multiplicityItems.push(compositeField);
|
||||||
(<FormArray>(this.form.get("compositeFields").get('' + fieldsetIndex).get('multiplicityItems'))).push(compositeField.buildForm());
|
(<FormArray>(this.form.get('compositeFields').get('' + fieldsetIndex).get('multiplicityItems'))).push(compositeField.buildForm());
|
||||||
}
|
}
|
||||||
|
|
||||||
addFieldSet() {
|
addFieldSet() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,10 @@
|
||||||
Add one more fieldset +
|
Add one more fieldset +
|
||||||
</a>
|
</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 *ngIf="compositeField">
|
||||||
<div *ngFor="let multipleCompositeField of compositeField.multiplicityItems; let j = index; trackBy: trackByFn">
|
<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 *ngIf="compositeField.hasCommentField" [formGroup]="form.get('compositeFields').get(''+i)">
|
<div *ngIf="compositeField.hasCommentField" [formGroup]="form.get('compositeFields').get(''+i)">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
<div *ngIf="section?.sections">
|
<div *ngIf="section?.sections">
|
||||||
<div *ngFor="let itemsection of section.sections; let j = index;">
|
<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>
|
||||||
</div>
|
</div>
|
||||||
</mat-expansion-panel>
|
</mat-expansion-panel>
|
||||||
|
|
|
@ -1,49 +1,50 @@
|
||||||
import { VisibilityRulesService } from '../../utilities/visibility-rules/visibility-rules.service';
|
import { VisibilityRulesService } from '../../utilities/visibility-rules/visibility-rules.service';
|
||||||
import { FormGroup, Form, FormArray } from '@angular/forms';
|
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 { CompositeField } from '../../models/CompositeField';
|
||||||
import { Section } from '../../models/Section';
|
import { Section } from '../../models/Section';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'df-section',
|
selector: 'app-df-section',
|
||||||
templateUrl: './dynamic-form-section.html',
|
templateUrl: './dynamic-form-section.html',
|
||||||
styleUrls: [
|
styleUrls: [
|
||||||
'./dynamic-form-section.css'
|
'./dynamic-form-section.css'
|
||||||
],
|
],
|
||||||
encapsulation: ViewEncapsulation.None,
|
encapsulation: ViewEncapsulation.None,
|
||||||
})
|
})
|
||||||
export class DynamicFormSectionComponent implements OnInit {
|
export class DynamicFormSectionComponent implements OnInit, AfterViewInit {
|
||||||
|
|
||||||
@Input() section: Section
|
@Input() section: Section;
|
||||||
form: FormGroup;
|
form: FormGroup;
|
||||||
@Input() pathName: string;
|
@Input() pathName: string;
|
||||||
@Input() path: string;
|
@Input() path: string;
|
||||||
trackByFn = (index, item) => item ? item["id"] : null
|
trackByFn = (index, item) => item ? item['id'] : null;
|
||||||
constructor(public visibilityRulesService: VisibilityRulesService) { }
|
constructor(public visibilityRulesService: VisibilityRulesService) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (this.section) {
|
if (this.section) {
|
||||||
this.form = this.visibilityRulesService.getFormGroup(this.section.id)
|
this.form = this.visibilityRulesService.getFormGroup(this.section.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
this.visibilityRulesService.triggerVisibilityEvaluation()
|
this.visibilityRulesService.triggerVisibilityEvaluation();
|
||||||
}
|
}
|
||||||
|
|
||||||
addMultipleField(fieldsetIndex: number) {
|
addMultipleField(fieldsetIndex: number) {
|
||||||
let compositeField: CompositeField = this.section.compositeFields[fieldsetIndex].cloneForMultiplicity(fieldsetIndex);
|
const compositeField: CompositeField = this.section.compositeFields[fieldsetIndex].cloneForMultiplicity(fieldsetIndex);
|
||||||
this.section.compositeFields[fieldsetIndex].multiplicityItems.push(compositeField);
|
this.section.compositeFields[fieldsetIndex].multiplicityItems.push(compositeField);
|
||||||
(<FormArray>(this.form.get("compositeFields").get('' + fieldsetIndex).get('multiplicityItems'))).push(compositeField.buildForm());
|
(<FormArray>(this.form.get('compositeFields').get('' + fieldsetIndex).get('multiplicityItems'))).push(compositeField.buildForm());
|
||||||
}
|
}
|
||||||
|
|
||||||
isElementVisible(fieldSet: CompositeField): boolean {
|
isElementVisible(fieldSet: CompositeField): boolean {
|
||||||
if (!fieldSet) return false;
|
if (!fieldSet) { return false; }
|
||||||
for (var i = 0; i < fieldSet.fields.length; i++) {
|
for (let i = 0; i < fieldSet.fields.length; i++) {
|
||||||
if (fieldSet.fields[i])
|
if (fieldSet.fields[i]) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
}
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,16 +8,16 @@ import { DynamicFormSectionComponent } from './dynamic-form-section/dynamic-form
|
||||||
import { DynamicFieldDropdownComponent } from './dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown';
|
import { DynamicFieldDropdownComponent } from './dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown';
|
||||||
import { AutocompleteRemoteComponent } from './dynamic-fields/dynamic-field-autocomplete/autocomplete-remote.component';
|
import { AutocompleteRemoteComponent } from './dynamic-fields/dynamic-field-autocomplete/autocomplete-remote.component';
|
||||||
import {
|
import {
|
||||||
TableOfContentsSectionComponent,
|
TableOfContentsSectionComponent,
|
||||||
} from './tableOfContents/table-of-content-section/table-of-content-section.component';
|
} 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 { TableOfContentsGroupComponent } from './tableOfContents/table-of-content-group/table-of-content-group.component';
|
||||||
import {
|
import {
|
||||||
TableOfContentsFieldSetComponent,
|
TableOfContentsFieldSetComponent,
|
||||||
} from './tableOfContents/table-of-content-fieldset/table-of-content-fieldset.component';
|
} from './tableOfContents/table-of-content-fieldset/table-of-content-fieldset.component';
|
||||||
import { DynamicFieldRadioBoxComponent } from './dynamic-fields/dynamic-field-radiobox/dynamic-field-radiobox.component';
|
import { DynamicFieldRadioBoxComponent } from './dynamic-fields/dynamic-field-radiobox/dynamic-field-radiobox.component';
|
||||||
import { TableOfContentsComponent } from './tableOfContents/table-of-contents.component';
|
import { TableOfContentsComponent } from './tableOfContents/table-of-contents.component';
|
||||||
import {
|
import {
|
||||||
DynamicFieldBooleanDecisionComponent,
|
DynamicFieldBooleanDecisionComponent,
|
||||||
} from './dynamic-fields/dynamic-field-boolean-decision/dynamic-field-boolean-decision.component';
|
} from './dynamic-fields/dynamic-field-boolean-decision/dynamic-field-boolean-decision.component';
|
||||||
import { DynamicFormGroupComponent } from './dynamic-form-group/dynamic-form-group.component';
|
import { DynamicFormGroupComponent } from './dynamic-form-group/dynamic-form-group.component';
|
||||||
import { DynamicFormCompositeFieldComponent } from './dynamic-form-composite-field/dynamic-form-composite-field';
|
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 { HttpClient, HttpClientModule } from '@angular/common/http';
|
||||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { NgModule } from "@angular/core";
|
import { NgModule } from '@angular/core';
|
||||||
import { DatasetProfileAdmin } from '../services/datasetProfileAdmin/datasetProfileAfmin.service';
|
import { DatasetProfileAdmin } from '../services/datasetProfileAdmin/datasetProfileAfmin.service';
|
||||||
import { DatasetProfileService } from '../services/dataset-profile.service';
|
import { DatasetProfileService } from '../services/dataset-profile.service';
|
||||||
import { DatasetWizardService } from '../services/dataset-wizard/dataset-wizard.service';
|
import { DatasetWizardService } from '../services/dataset-wizard/dataset-wizard.service';
|
||||||
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
HttpClientModule,
|
HttpClientModule,
|
||||||
SharedModule,
|
SharedModule,
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
TranslateModule.forRoot({
|
TranslateModule.forRoot({
|
||||||
loader: {
|
loader: {
|
||||||
provide: TranslateLoader,
|
provide: TranslateLoader,
|
||||||
useFactory: HttpLoaderFactory,
|
useFactory: HttpLoaderFactory,
|
||||||
deps: [HttpClient]
|
deps: [HttpClient]
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|
||||||
declarations: [
|
declarations: [
|
||||||
DynamicFormComponent,
|
DynamicFormComponent,
|
||||||
DynamicFormFieldComponent,
|
DynamicFormFieldComponent,
|
||||||
DynamicFormGroupComponent,
|
DynamicFormGroupComponent,
|
||||||
DynamicFormCompositeFieldComponent,
|
DynamicFormCompositeFieldComponent,
|
||||||
DynamicFieldBooleanDecisionComponent,
|
DynamicFieldBooleanDecisionComponent,
|
||||||
DynamicFieldRadioBoxComponent,
|
DynamicFieldRadioBoxComponent,
|
||||||
TableOfContentsComponent,
|
TableOfContentsComponent,
|
||||||
TableOfContentsFieldSetComponent,
|
TableOfContentsFieldSetComponent,
|
||||||
TableOfContentsGroupComponent,
|
TableOfContentsGroupComponent,
|
||||||
TableOfContentsSectionComponent,
|
TableOfContentsSectionComponent,
|
||||||
AutocompleteRemoteComponent,
|
AutocompleteRemoteComponent,
|
||||||
DynamicFieldDropdownComponent,
|
DynamicFieldDropdownComponent,
|
||||||
DynamicFormSectionComponent,
|
DynamicFormSectionComponent,
|
||||||
TableOfContentsFieldComponent,
|
TableOfContentsFieldComponent,
|
||||||
ProgressBarComponent,
|
ProgressBarComponent,
|
||||||
DynamicFieldCheckBoxComponent,
|
DynamicFieldCheckBoxComponent,
|
||||||
],
|
],
|
||||||
|
|
||||||
exports: [
|
exports: [
|
||||||
DynamicFormComponent,
|
DynamicFormComponent,
|
||||||
DynamicFormFieldComponent,
|
DynamicFormFieldComponent,
|
||||||
DynamicFormGroupComponent,
|
DynamicFormGroupComponent,
|
||||||
DynamicFormCompositeFieldComponent,
|
DynamicFormCompositeFieldComponent,
|
||||||
DynamicFieldBooleanDecisionComponent,
|
DynamicFieldBooleanDecisionComponent,
|
||||||
DynamicFieldRadioBoxComponent,
|
DynamicFieldRadioBoxComponent,
|
||||||
TableOfContentsComponent,
|
TableOfContentsComponent,
|
||||||
TableOfContentsFieldSetComponent,
|
TableOfContentsFieldSetComponent,
|
||||||
TableOfContentsGroupComponent,
|
TableOfContentsGroupComponent,
|
||||||
TableOfContentsSectionComponent,
|
TableOfContentsSectionComponent,
|
||||||
AutocompleteRemoteComponent,
|
AutocompleteRemoteComponent,
|
||||||
DynamicFieldDropdownComponent,
|
DynamicFieldDropdownComponent,
|
||||||
DynamicFormSectionComponent,
|
DynamicFormSectionComponent,
|
||||||
TableOfContentsFieldComponent,
|
TableOfContentsFieldComponent,
|
||||||
ProgressBarComponent,
|
ProgressBarComponent,
|
||||||
DynamicFieldCheckBoxComponent,
|
DynamicFieldCheckBoxComponent,
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
VisibilityRulesService,
|
VisibilityRulesService,
|
||||||
PaginationService,
|
PaginationService,
|
||||||
DatasetProfileService,
|
DatasetProfileService,
|
||||||
DatasetProfileAdmin,
|
DatasetProfileAdmin,
|
||||||
DatasetWizardService
|
DatasetWizardService
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
export class DynamicFormModule { }
|
export class DynamicFormModule { }
|
||||||
|
|
||||||
export function HttpLoaderFactory(httpClient: HttpClient) {
|
export function HttpLoaderFactory(httpClient: HttpClient) {
|
||||||
return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json');
|
return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,44 +1,44 @@
|
||||||
<div class="dynamic-form-editor">
|
<div class="dynamic-form-editor">
|
||||||
<!-- <mat-sidenav-container class="ng-sidebar-container"> -->
|
<!-- <mat-sidenav-container class="ng-sidebar-container"> -->
|
||||||
<!-- <mat-sidenav mode="push" position="right" [(opened)]="visibleSidebar">
|
<!-- <mat-sidenav mode="push" position="right" [(opened)]="visibleSidebar">
|
||||||
<table-of-content class="toc-container full-height" [model]="datasetProfileDefinitionModel"></table-of-content>
|
<table-of-content class="toc-container full-height" [model]="datasetProfileDefinitionModel"></table-of-content>
|
||||||
</mat-sidenav> -->
|
</mat-sidenav> -->
|
||||||
|
|
||||||
<!-- <mat-sidenav-content> -->
|
<!-- <mat-sidenav-content> -->
|
||||||
<!-- <button mat-raised-button color="primary" style="margin: 15px;" (click)="toggleSidebar()" icon="fa-arrow-left">Table Of Contents</button> -->
|
<!-- <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">
|
<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;"
|
<!-- <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>
|
(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;"
|
<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> -->
|
(click)="saveFinalize();" type="button">Save and Finalize</button> -->
|
||||||
<div>
|
<div>
|
||||||
<div class="alignment-center">
|
<div class="alignment-center">
|
||||||
<!-- <ngb-pagination *ngIf="pages" [collectionSize]="pages.length*10" [page]="currentPageIndex" (pageChange)="changePageIndex($event)" aria-label="Default pagination"></ngb-pagination> -->
|
<!-- <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>
|
<app-progress-bar *ngIf="form" [formGroup]="form"></app-progress-bar>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div *ngIf='datasetProfileDefinitionModel' class="col-md-12" id="form-container">
|
<div *ngIf='datasetProfileDefinitionModel' class="col-md-12" id="form-container">
|
||||||
<!-- <form *ngIf="form" novalidate [formGroup]="form" (ngSubmit)="onSubmit()"> -->
|
<!-- <form *ngIf="form" novalidate [formGroup]="form" (ngSubmit)="onSubmit()"> -->
|
||||||
<mat-vertical-stepper #stepper [linear]="false">
|
<mat-vertical-stepper #stepper [linear]="false">
|
||||||
<div *ngFor="let page of datasetProfileDefinitionModel.pages; let z=index; trackBy: pageTrackByFn">
|
<div *ngFor="let page of datasetProfileDefinitionModel.pages; let z=index; trackBy: pageTrackByFn">
|
||||||
<div *ngFor="let section of page.sections; let i = index; trackBy: trackByFn">
|
<div *ngFor="let section of page.sections; let i = index; trackBy: trackByFn">
|
||||||
<mat-step [stepControl]="section">
|
<mat-step [stepControl]="section">
|
||||||
<ng-template matStepLabel>{{page.title}}</ng-template>
|
<ng-template matStepLabel>{{page.title}}</ng-template>
|
||||||
<div *ngIf="stepper.selectedIndex == z">
|
<div *ngIf="stepper.selectedIndex == z">
|
||||||
<df-section [section]="section" [path]="z+1" [pathName]="'pages.'+z+'.sections.'+i"></df-section>
|
<app-df-section [section]="section" [path]="z+1" [pathName]="'pages.'+z+'.sections.'+i"></app-df-section>
|
||||||
</div>
|
</div>
|
||||||
</mat-step>
|
</mat-step>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</mat-vertical-stepper>
|
</mat-vertical-stepper>
|
||||||
<!-- <div *ngFor="let section of datasetProfileDefinitionModel.sections; let i = index;">
|
<!-- <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"
|
<df-section *ngIf='this.shouldDisplaySection(section)' [section]="section" [form]="form.get('sections').get(''+i)" [path]="i+1"
|
||||||
[pathName]="'sections.'+i"></df-section>
|
[pathName]="'sections.'+i"></df-section>
|
||||||
</div> -->
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<!-- </mat-sidenav-content>
|
<!-- </mat-sidenav-content>
|
||||||
</mat-sidenav-container> -->
|
</mat-sidenav-container> -->
|
||||||
</div>
|
</div>
|
||||||
<!-- <p>Form value: {{ form.value | json }}</p> -->
|
<!-- <p>Form value: {{ form.value | json }}</p> -->
|
||||||
|
|
|
@ -17,122 +17,123 @@ import { MatSidenavModule } from '@angular/material/sidenav';
|
||||||
declare function simple_notifier(type: string, title: string, message: string): any;
|
declare function simple_notifier(type: string, title: string, message: string): any;
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'dynamic-form',
|
selector: 'app-dynamic-form',
|
||||||
templateUrl: './dynamic-form.component.html',
|
templateUrl: './dynamic-form.component.html',
|
||||||
styleUrls: [
|
styleUrls: [
|
||||||
'./dynamic-form.component.scss'
|
'./dynamic-form.component.scss'
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
],
|
],
|
||||||
encapsulation: ViewEncapsulation.None,
|
encapsulation: ViewEncapsulation.None,
|
||||||
})
|
})
|
||||||
export class DynamicFormComponent implements OnInit, AfterViewInit {
|
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();
|
private fragment: string;
|
||||||
@Input() path: string;
|
@Input() dataModel: DatasetWizardModel = new DatasetWizardModel();
|
||||||
@Input() form: FormGroup;
|
@Input() path: string;
|
||||||
id: string;
|
@Input() form: FormGroup;
|
||||||
trackByFn = (index, item) => item ? item["id"] : null
|
id: string;
|
||||||
pageTrackByFn = (index, item) => item["id"]
|
trackByFn = (index, item) => item ? item['id'] : null;
|
||||||
|
pageTrackByFn = (index, item) => item['id'];
|
||||||
|
|
||||||
// @Input() datasetId: string;
|
// @Input() datasetId: string;
|
||||||
pathName: string;
|
|
||||||
pages: Array<number>;
|
|
||||||
activeStepperIndex: number = 1;
|
|
||||||
visibleSidebar: boolean = false;
|
|
||||||
datasetProfileDefinitionModel: DatasetProfileDefinitionModel
|
|
||||||
private progressbar: boolean = false;
|
|
||||||
private currentPageIndex: number = 0;
|
|
||||||
|
|
||||||
private fragment: string;
|
constructor(private router: Router,
|
||||||
constructor(private router: Router,
|
private _location: Location,
|
||||||
private _location: Location,
|
private route: ActivatedRoute,
|
||||||
private route: ActivatedRoute,
|
private visibilityRulesService: VisibilityRulesService,
|
||||||
private visibilityRulesService: VisibilityRulesService,
|
private http: BaseHttpService,
|
||||||
private http: BaseHttpService,
|
private datasetWizardService: DatasetWizardService,
|
||||||
private datasetWizardService: DatasetWizardService,
|
) {
|
||||||
) {
|
//this.datasetId = route.snapshot.params['id'];
|
||||||
//this.datasetId = route.snapshot.params['id'];
|
}
|
||||||
}
|
|
||||||
|
|
||||||
getSubForm(subformName) {
|
getSubForm(subformName) {
|
||||||
return this.form.controls[subformName];
|
return this.form.controls[subformName];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
let rules: Rule[] = JsonSerializer.fromJSONArray(this.dataModel.datasetProfileDefinition.rules, Rule);
|
const rules: Rule[] = JsonSerializer.fromJSONArray(this.dataModel.datasetProfileDefinition.rules, Rule);
|
||||||
this.visibilityRulesService.formGroup = this.form;
|
this.visibilityRulesService.formGroup = this.form;
|
||||||
this.visibilityRulesService.buildVisibilityRules(rules)
|
this.visibilityRulesService.buildVisibilityRules(rules);
|
||||||
this.datasetProfileDefinitionModel = this.dataModel.datasetProfileDefinition
|
this.datasetProfileDefinitionModel = this.dataModel.datasetProfileDefinition;
|
||||||
this.visibilityRulesService.setModel(this.datasetProfileDefinitionModel)
|
this.visibilityRulesService.setModel(this.datasetProfileDefinitionModel);
|
||||||
this.createPagination();
|
this.createPagination();
|
||||||
this.progressbar = true;
|
this.progressbar = true;
|
||||||
|
|
||||||
this.route.fragment.subscribe((fragment: string) => {
|
this.route.fragment.subscribe((fragment: string) => {
|
||||||
var self = this;
|
const self = this;
|
||||||
setTimeout(function () { self.scrollTo(fragment) });
|
setTimeout(function () { self.scrollTo(fragment); });
|
||||||
});
|
});
|
||||||
|
|
||||||
this.route.queryParams.subscribe((params) => {
|
this.route.queryParams.subscribe((params) => {
|
||||||
if (params && "page" in params)
|
if (params && 'page' in params) {
|
||||||
this.changeCurrentPage(params["page"]);
|
this.changeCurrentPage(params['page']);
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
this.visibilityRulesService.triggerVisibilityEvaluation()
|
this.visibilityRulesService.triggerVisibilityEvaluation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
toggleSidebar() {
|
toggleSidebar() {
|
||||||
this.visibleSidebar = !this.visibleSidebar;
|
this.visibleSidebar = !this.visibleSidebar;
|
||||||
}
|
}
|
||||||
|
|
||||||
// getPages(model: DatasetProfileDefinitionModel): Array<number> {
|
// getPages(model: DatasetProfileDefinitionModel): Array<number> {
|
||||||
// let pageSet = new Set<number>();
|
// let pageSet = new Set<number>();
|
||||||
|
|
||||||
// model.sections.forEach(section => {
|
// model.sections.forEach(section => {
|
||||||
// pageSet.add(section.page);
|
// 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 {
|
shouldDisplaySection(section: Section): Boolean {
|
||||||
return (section.page) == this.currentPageIndex;
|
return (section.page) === this.currentPageIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
createPagination() {
|
createPagination() {
|
||||||
/*this.pages.forEach(item => {
|
/*this.pages.forEach(item => {
|
||||||
this.stepperItems.push({
|
this.stepperItems.push({
|
||||||
label: '',
|
label: '',
|
||||||
})
|
})
|
||||||
});*/
|
});*/
|
||||||
}
|
}
|
||||||
|
|
||||||
changePageIndex(index: any) {
|
changePageIndex(index: any) {
|
||||||
this.router.navigate([this.route.snapshot.url[0] + "/" + this.route.snapshot.url[1]], { queryParams: { page: this.pages[index - 1] } });
|
this.router.navigate([this.route.snapshot.url[0] + '/' + this.route.snapshot.url[1]], { queryParams: { page: this.pages[index - 1] } });
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollTo(sectionID: string) {
|
scrollTo(sectionID: string) {
|
||||||
if (!sectionID) return;
|
if (!sectionID) { return; }
|
||||||
var element = document.querySelector('#' + sectionID);
|
const element = document.querySelector('#' + sectionID);
|
||||||
if (!element) return;
|
if (!element) { return; }
|
||||||
element.scrollIntoView();
|
element.scrollIntoView();
|
||||||
this.visibleSidebar = true;
|
this.visibleSidebar = true;
|
||||||
var scrollElement = document.querySelector('.scrollableContent');
|
const scrollElement = document.querySelector('.scrollableContent');
|
||||||
//scrollElement.scrollTop = topElement.offsetTop;
|
//scrollElement.scrollTop = topElement.offsetTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
changeCurrentPage(pageString: string) {
|
changeCurrentPage(pageString: string) {
|
||||||
if (!pageString) return;
|
if (!pageString) { return; }
|
||||||
var page = parseInt(pageString);
|
const page = parseInt(pageString);
|
||||||
if (isNaN(page)) return;
|
if (isNaN(page)) { return; }
|
||||||
var pageIndex = this.pages.indexOf(page);
|
const pageIndex = this.pages.indexOf(page);
|
||||||
if (pageIndex === -1) return;
|
if (pageIndex === -1) { return; }
|
||||||
this.currentPageIndex = page;
|
this.currentPageIndex = page;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
|
|
||||||
export class DropdownField {
|
export class DropdownField {
|
||||||
controlType = 'dropdown';
|
controlType = 'dropdown';
|
||||||
options: {key: string, value: string}[] =[];
|
options: { key: string, value: string }[] = [];
|
||||||
|
|
||||||
constructor(options: {} = {}){
|
constructor(options: {} = {}) {
|
||||||
this.options = options['options'] || [];
|
this.options = options['options'] || [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core';
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class PaginationService {
|
export class PaginationService {
|
||||||
|
|
||||||
private currentPageIndex: number;
|
private currentPageIndex: number;
|
||||||
|
|
||||||
public setCurrentIndex(currentPageIndex: number): void {
|
public setCurrentIndex(currentPageIndex: number): void {
|
||||||
this.currentPageIndex = currentPageIndex;
|
this.currentPageIndex = currentPageIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getCurrentIndex():number{
|
public getCurrentIndex(): number {
|
||||||
return this.currentPageIndex;
|
return this.currentPageIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public isElementVisible(elementPage: number):boolean {
|
public isElementVisible(elementPage: number): boolean {
|
||||||
return elementPage == this.currentPageIndex ; //TODO
|
return elementPage === this.currentPageIndex; //TODO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,68 +2,65 @@
|
||||||
import { ViewEncapsulation } from '@angular/core';
|
import { ViewEncapsulation } from '@angular/core';
|
||||||
|
|
||||||
import { Component, Input, OnInit } 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({
|
@Component({
|
||||||
selector: 'progress-bar',
|
selector: 'app-progress-bar',
|
||||||
templateUrl: './progress-bar.component.html',
|
templateUrl: './progress-bar.component.html',
|
||||||
styles: ['.alwaysVisible .ui-progressbar-label { display:block!important; }'],
|
styles: ['.alwaysVisible .ui-progressbar-label { display:block!important; }'],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class ProgressBarComponent implements OnInit {
|
export class ProgressBarComponent implements OnInit {
|
||||||
@Input() formGroup: FormGroup
|
@Input() formGroup: FormGroup;
|
||||||
@Input("progressValueAccuracy") public accuracy: number = 1;
|
@Input() public progressValueAccuracy = 1;
|
||||||
determinateProgressValue: number;
|
determinateProgressValue: number;
|
||||||
|
|
||||||
constructor(private visibilityRulesService: VisibilityRulesService) { }
|
constructor(private visibilityRulesService: VisibilityRulesService) { }
|
||||||
|
|
||||||
public value: number = 0;
|
public value = 0;
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.calculateValueForProgressbar()
|
this.calculateValueForProgressbar();
|
||||||
this.formGroup
|
this.formGroup
|
||||||
.valueChanges
|
.valueChanges
|
||||||
.subscribe(control => {
|
.subscribe(control => {
|
||||||
this.calculateValueForProgressbar();
|
this.calculateValueForProgressbar();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateValueForProgressbar() {
|
calculateValueForProgressbar() {
|
||||||
var progressSoFar = this.countFormControlsWithValue(this.formGroup);
|
const progressSoFar = this.countFormControlsWithValue(this.formGroup);
|
||||||
var total = this.getFormControlDepthLength(this.formGroup);
|
const total = this.getFormControlDepthLength(this.formGroup);
|
||||||
var perc = (progressSoFar / total) * 100;
|
const perc = (progressSoFar / total) * 100;
|
||||||
this.value = Number.parseFloat(perc.toPrecision(this.accuracy));
|
this.value = Number.parseFloat(perc.toPrecision(this.progressValueAccuracy));
|
||||||
}
|
}
|
||||||
|
|
||||||
countFormControlsWithValue(form: FormGroup): number {
|
countFormControlsWithValue(form: FormGroup): number {
|
||||||
let value = 0;
|
let value = 0;
|
||||||
Object.keys(form.controls).forEach(key => {
|
Object.keys(form.controls).forEach(key => {
|
||||||
let control = form.controls[key]
|
const control = form.controls[key];
|
||||||
if (control instanceof FormGroup) value += this.countFormControlsWithValue(control);
|
if (control instanceof FormGroup) { value += this.countFormControlsWithValue(control); } else if (control instanceof FormArray) {
|
||||||
else if (control instanceof FormArray) {
|
const formArray = (<FormArray>control);
|
||||||
let formArray = (<FormArray>control);
|
for (let i = 0; i < formArray.length; i++) {
|
||||||
for (let i = 0; i < formArray.length; i++) {
|
value += this.countFormControlsWithValue(<FormGroup>formArray.get('' + i));
|
||||||
value += this.countFormControlsWithValue(<FormGroup>formArray.get("" + i))
|
}
|
||||||
}
|
} else if (key === 'value' && control.value != null && control.value !== '') { value++; }
|
||||||
}
|
});
|
||||||
else if (key === "value" && control.value != null && control.value != "") value++;
|
return value;
|
||||||
});
|
}
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
getFormControlDepthLength(form: FormGroup): number {
|
getFormControlDepthLength(form: FormGroup): number {
|
||||||
let value = 0;
|
let value = 0;
|
||||||
Object.keys(form.controls).forEach(key => {
|
Object.keys(form.controls).forEach(key => {
|
||||||
let control = form.controls[key];
|
const control = form.controls[key];
|
||||||
if (control instanceof FormGroup) { value += this.getFormControlDepthLength(control); }
|
if (control instanceof FormGroup) { value += this.getFormControlDepthLength(control); } else if (control instanceof FormArray) {
|
||||||
else if (control instanceof FormArray) {
|
const formArray = (<FormArray>control);
|
||||||
let formArray = (<FormArray>control);
|
for (let i = 0; i < formArray.length; i++) {
|
||||||
for (let i = 0; i < formArray.length; i++) {
|
//if (<FormGroup>formArray.get("" + i).value && this.visibilityRulesService.isElementVisible(null, formArray.get("" + i).value.id))
|
||||||
//if (<FormGroup>formArray.get("" + i).value && this.visibilityRulesService.isElementVisible(null, formArray.get("" + i).value.id))
|
//value += this.getFormControlDepthLength(<FormGroup>formArray.get("" + i))
|
||||||
//value += this.getFormControlDepthLength(<FormGroup>formArray.get("" + i))
|
}
|
||||||
}
|
}
|
||||||
}
|
//else if (key === "value" && this.visibilityRulesService.isElementVisible(null, form.controls["id"].value))
|
||||||
//else if (key === "value" && this.visibilityRulesService.isElementVisible(null, form.controls["id"].value))
|
//value++;
|
||||||
//value++;
|
});
|
||||||
});
|
return value;
|
||||||
return value;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { ActivatedRouteSnapshot, Router, ActivatedRoute } from '@angular/router';
|
import { ActivatedRouteSnapshot, Router, ActivatedRoute } from '@angular/router';
|
||||||
|
|
||||||
export class BaseTableOfContent {
|
export class BaseTableOfContent {
|
||||||
constructor(public router: Router, public route: ActivatedRoute) { }
|
constructor(public router: Router, public route: ActivatedRoute) { }
|
||||||
|
|
||||||
scrollToId(elementId, page: number) {
|
scrollToId(elementId, page: number) {
|
||||||
//this.paginationService.setCurrentIndex(page-1);
|
//this.paginationService.setCurrentIndex(page-1);
|
||||||
this.router.navigate([this.route.snapshot.url[0] + "/" + this.route.snapshot.url[1]], { fragment: elementId, queryParams: { page: page } });
|
this.router.navigate([this.route.snapshot.url[0] + '/' + this.route.snapshot.url[1]], { fragment: elementId, queryParams: { page: page } });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,20 +4,20 @@ import { CompositeField } from '../../../models/CompositeField';
|
||||||
import { Field } from '../../../models/Field';
|
import { Field } from '../../../models/Field';
|
||||||
import { Section } from '../../../models/Section';
|
import { Section } from '../../../models/Section';
|
||||||
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
||||||
import { Router, ActivatedRoute } from '@angular/router'
|
import { Router, ActivatedRoute } from '@angular/router';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'table-of-contents-field',
|
selector: 'app-table-of-contents-field',
|
||||||
templateUrl: './table-of-content-field.component.html',
|
templateUrl: './table-of-content-field.component.html',
|
||||||
providers: []
|
providers: []
|
||||||
})
|
})
|
||||||
export class TableOfContentsFieldComponent extends BaseTableOfContent {
|
export class TableOfContentsFieldComponent extends BaseTableOfContent {
|
||||||
@Input() model: Field;
|
@Input() model: Field;
|
||||||
@Input() index: number;
|
@Input() index: number;
|
||||||
@Input() public path: string;
|
@Input() public path: string;
|
||||||
@Input() public page: number;
|
@Input() public page: number;
|
||||||
constructor(public router: Router, public route: ActivatedRoute, private visibilityRulesService: VisibilityRulesService) {
|
constructor(public router: Router, public route: ActivatedRoute, private visibilityRulesService: VisibilityRulesService) {
|
||||||
super(router, route)
|
super(router, route);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,23 +4,23 @@ import { CompositeField } from '../../../models/CompositeField';
|
||||||
import { FieldGroup } from '../../../models/FieldGroup';
|
import { FieldGroup } from '../../../models/FieldGroup';
|
||||||
import { Section } from '../../../models/Section';
|
import { Section } from '../../../models/Section';
|
||||||
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
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'
|
//import * as $ from '../../../../node_modules/jquery/dist/jquery'
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'table-of-contents-fieldset',
|
selector: 'app-table-of-contents-fieldset',
|
||||||
templateUrl: './table-of-content-fieldset.component.html',
|
templateUrl: './table-of-content-fieldset.component.html',
|
||||||
providers: []
|
providers: []
|
||||||
})
|
})
|
||||||
export class TableOfContentsFieldSetComponent extends BaseTableOfContent {
|
export class TableOfContentsFieldSetComponent extends BaseTableOfContent {
|
||||||
|
|
||||||
@Input() model: CompositeField;
|
@Input() model: CompositeField;
|
||||||
@Input() index: number;
|
@Input() index: number;
|
||||||
@Input() public path: string;
|
@Input() public path: string;
|
||||||
@Input() public page: number;
|
@Input() public page: number;
|
||||||
constructor(public router: Router, public route: ActivatedRoute, private visibilityRulesService: VisibilityRulesService) {
|
constructor(public router: Router, public route: ActivatedRoute, private visibilityRulesService: VisibilityRulesService) {
|
||||||
super(router, route)
|
super(router, route);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,28 +3,28 @@ import { BaseTableOfContent } from '../base-table-of-content.component';
|
||||||
import { FieldGroup } from '../../../models/FieldGroup';
|
import { FieldGroup } from '../../../models/FieldGroup';
|
||||||
import { Section } from '../../../models/Section';
|
import { Section } from '../../../models/Section';
|
||||||
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
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'
|
//import * as $ from '../../../../node_modules/jquery/dist/jquery'
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'table-of-contents-group',
|
selector: 'app-table-of-contents-group',
|
||||||
templateUrl: './table-of-content-group.component.html',
|
templateUrl: './table-of-content-group.component.html',
|
||||||
providers: []
|
providers: []
|
||||||
})
|
})
|
||||||
export class TableOfContentsGroupComponent extends BaseTableOfContent {
|
export class TableOfContentsGroupComponent extends BaseTableOfContent {
|
||||||
|
|
||||||
@Input() model: FieldGroup;
|
@Input() model: FieldGroup;
|
||||||
@Input() index: number;
|
@Input() index: number;
|
||||||
@Input() public path: string;
|
@Input() public path: string;
|
||||||
@Input() public page: number;
|
@Input() public page: number;
|
||||||
/* @Output()
|
/* @Output()
|
||||||
setPage:EventEmitter<number> = new EventEmitter<number>();
|
setPage:EventEmitter<number> = new EventEmitter<number>();
|
||||||
|
|
||||||
*/
|
*/
|
||||||
constructor(public router: Router, public route: ActivatedRoute, private visibilityRulesService: VisibilityRulesService) {
|
constructor(public router: Router, public route: ActivatedRoute, private visibilityRulesService: VisibilityRulesService) {
|
||||||
super(router, route)
|
super(router, route);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
<!-- All contents in the first page -->
|
<!-- All contents in the first page -->
|
||||||
<ul>
|
<ul>
|
||||||
<li *ngFor="let sectionModel of model.sections let i = index">
|
<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>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -8,21 +8,21 @@ import { ActivatedRouteSnapshot, Router, ActivatedRoute } from '@angular/router'
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'table-of-contents-section',
|
selector: 'app-table-of-contents-section',
|
||||||
templateUrl: './table-of-content-section.component.html',
|
templateUrl: './table-of-content-section.component.html',
|
||||||
providers: []
|
providers: []
|
||||||
})
|
})
|
||||||
export class TableOfContentsSectionComponent extends BaseTableOfContent implements OnInit {
|
export class TableOfContentsSectionComponent extends BaseTableOfContent implements OnInit {
|
||||||
|
|
||||||
@Input() model: Section;
|
@Input() model: Section;
|
||||||
@Input() index: number;
|
@Input() index: number;
|
||||||
@Input() public path: string;
|
@Input() public path: string;
|
||||||
@Input() public page: number;
|
@Input() public page: number;
|
||||||
constructor(public router: Router, public route: ActivatedRoute, private visibilityRulesService: VisibilityRulesService) {
|
constructor(public router: Router, public route: ActivatedRoute, private visibilityRulesService: VisibilityRulesService) {
|
||||||
super(router, route)
|
super(router, route);
|
||||||
}
|
}
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
<ul>
|
<ul>
|
||||||
<li *ngFor="let section of model['sections'] let i = index">
|
<li *ngFor="let section of model['sections'] let i = index">
|
||||||
<!-- && field.label for sections without field label as data summery -->
|
<!-- && 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>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -6,21 +6,21 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
||||||
//import * as scroll from '../../../assets/jquery.scrollTo.min.js';
|
//import * as scroll from '../../../assets/jquery.scrollTo.min.js';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'table-of-content',
|
selector: 'app-table-of-content',
|
||||||
templateUrl: './table-of-contents.component.html',
|
templateUrl: './table-of-contents.component.html',
|
||||||
styleUrls: ['./toc.component.css'],
|
styleUrls: ['./toc.component.css'],
|
||||||
providers: []
|
providers: []
|
||||||
})
|
})
|
||||||
export class TableOfContentsComponent implements OnInit {
|
export class TableOfContentsComponent implements OnInit {
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
public model: DatasetProfileDefinitionModel;
|
public model: DatasetProfileDefinitionModel;
|
||||||
public path: string = "";
|
public path = '';
|
||||||
/* @Output()
|
/* @Output()
|
||||||
setPage:EventEmitter<number> = new EventEmitter<number>();
|
setPage:EventEmitter<number> = new EventEmitter<number>();
|
||||||
|
|
||||||
*/ ngOnInit() {
|
*/ ngOnInit() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,110 +16,110 @@ import { SearchBarItem } from '../models/dashboard/SearchBarItem';
|
||||||
import { SearchBarType } from '../shared/components/search-bar/types/search-bar-type';
|
import { SearchBarType } from '../shared/components/search-bar/types/search-bar-type';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'homepage',
|
selector: 'app-homepage',
|
||||||
templateUrl: './homepage.component.html',
|
templateUrl: './homepage.component.html',
|
||||||
styleUrls: ['./homepage.component.scss'],
|
styleUrls: ['./homepage.component.scss'],
|
||||||
providers: [ProjectService, UserReferenceService]
|
providers: [ProjectService, UserReferenceService]
|
||||||
})
|
})
|
||||||
export class HomepageComponent implements OnInit {
|
export class HomepageComponent implements OnInit {
|
||||||
|
|
||||||
public userInfo: any;
|
public userInfo: any;
|
||||||
datasetActivities: any[];
|
datasetActivities: any[];
|
||||||
projectActivities: any[];
|
projectActivities: any[];
|
||||||
dmpActivities: any[];
|
dmpActivities: any[];
|
||||||
public dashboardStatisticsData: DashboardStatisticsModel = new DashboardStatisticsModel();
|
public dashboardStatisticsData: DashboardStatisticsModel = new DashboardStatisticsModel();
|
||||||
public formControl = new FormControl();
|
public formControl = new FormControl();
|
||||||
projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
|
projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
|
||||||
public searchControl = new FormControl();
|
public searchControl = new FormControl();
|
||||||
filteredOptions: Observable<SearchBarItem[]>;
|
filteredOptions: Observable<SearchBarItem[]>;
|
||||||
RecentActivityTypes = RecentActivityTypes
|
RecentActivityTypes = RecentActivityTypes;
|
||||||
public search = false;
|
public search = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private projectService: ProjectService,
|
private projectService: ProjectService,
|
||||||
private dashBoardService: DashboardService,
|
private dashBoardService: DashboardService,
|
||||||
private authentication: AuthService,
|
private authentication: AuthService,
|
||||||
private userReferenceService: UserReferenceService
|
private userReferenceService: UserReferenceService
|
||||||
|
|
||||||
) {
|
) {
|
||||||
this.dashboardStatisticsData.totalDataManagementPlanCount = 0;
|
this.dashboardStatisticsData.totalDataManagementPlanCount = 0;
|
||||||
this.dashboardStatisticsData.totalDataSetCount = 0;
|
this.dashboardStatisticsData.totalDataSetCount = 0;
|
||||||
this.dashboardStatisticsData.totalProjectCount = 0;
|
this.dashboardStatisticsData.totalProjectCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
if (this.isAuthenticated()) {
|
if (this.isAuthenticated()) {
|
||||||
this.userReferenceService.getRecentActivity().subscribe(response => {
|
this.userReferenceService.getRecentActivity().subscribe(response => {
|
||||||
this.datasetActivities = response["recentDatasetActivities"];
|
this.datasetActivities = response['recentDatasetActivities'];
|
||||||
this.dmpActivities = response["recentDmpActivities"];
|
this.dmpActivities = response['recentDmpActivities'];
|
||||||
this.projectActivities = response["recentProjectActivities"];
|
this.projectActivities = response['recentProjectActivities'];
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.projectAutoCompleteConfiguration = {
|
this.projectAutoCompleteConfiguration = {
|
||||||
filterFn: this.searchProject.bind(this),
|
filterFn: this.searchProject.bind(this),
|
||||||
items: this.searchProject(''),
|
items: this.searchProject(''),
|
||||||
displayFn: (item) => item["label"],
|
displayFn: (item) => item['label'],
|
||||||
titleFn: (item) => item["label"],
|
titleFn: (item) => item['label'],
|
||||||
//mapFn: (item) => new JsonSerializer<ProjectReference>().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()),
|
//mapFn: (item) => new JsonSerializer<ProjectReference>().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()),
|
||||||
loadDataOnStart: true
|
loadDataOnStart: true
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!this.isAuthenticated()) {
|
if (!this.isAuthenticated()) {
|
||||||
this.dashBoardService.getStatistics().subscribe(results => {
|
this.dashBoardService.getStatistics().subscribe(results => {
|
||||||
//let data = results['payload'];
|
//let data = results['payload'];
|
||||||
this.dashboardStatisticsData = JsonSerializer.fromJSONObject(results, DashboardStatisticsModel);
|
this.dashboardStatisticsData = JsonSerializer.fromJSONObject(results, DashboardStatisticsModel);
|
||||||
})
|
});
|
||||||
} else {
|
} else {
|
||||||
this.dashBoardService.getStatisticsSpecificuser().subscribe(results => {
|
this.dashBoardService.getStatisticsSpecificuser().subscribe(results => {
|
||||||
this.dashboardStatisticsData = JsonSerializer.fromJSONObject(results, DashboardStatisticsModel);
|
this.dashboardStatisticsData = JsonSerializer.fromJSONObject(results, DashboardStatisticsModel);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.filteredOptions = this.searchControl.valueChanges.flatMap(x => {
|
this.filteredOptions = this.searchControl.valueChanges.flatMap(x => {
|
||||||
return this.dashBoardService.searchUserItems(x);
|
return this.dashBoardService.searchUserItems(x);
|
||||||
})
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public isAuthenticated(): boolean {
|
public isAuthenticated(): boolean {
|
||||||
return !(!this.authentication.current())
|
return !(!this.authentication.current());
|
||||||
}
|
}
|
||||||
|
|
||||||
searchProject(query: string) {
|
searchProject(query: string) {
|
||||||
let projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
|
const projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
|
||||||
projectRequestItem.criteria = new ProjectCriteria();
|
projectRequestItem.criteria = new ProjectCriteria();
|
||||||
projectRequestItem.criteria.like = query;
|
projectRequestItem.criteria.like = query;
|
||||||
return this.projectService.getWithExternal(projectRequestItem);
|
return this.projectService.getWithExternal(projectRequestItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
redirect(id: string, type: RecentActivityTypes) {
|
redirect(id: string, type: RecentActivityTypes) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case RecentActivityTypes.PROJECT: {
|
case RecentActivityTypes.PROJECT: {
|
||||||
this.router.navigate(["projects/edit/" + id]);
|
this.router.navigate(['projects/edit/' + id]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case RecentActivityTypes.DATASET: {
|
case RecentActivityTypes.DATASET: {
|
||||||
this.router.navigate(["datasets/edit/" + id]);
|
this.router.navigate(['datasets/edit/' + id]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case RecentActivityTypes.DMP: {
|
case RecentActivityTypes.DMP: {
|
||||||
this.router.navigate(["dmps/edit/" + id]);
|
this.router.navigate(['dmps/edit/' + id]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
default: throw new Error("Unsupported Activity Type ")
|
default: throw new Error('Unsupported Activity Type ');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onOptionSelected(event: any) {
|
onOptionSelected(event: any) {
|
||||||
let selectedSearchBarItem = event.option.value;
|
const selectedSearchBarItem = event.option.value;
|
||||||
if (selectedSearchBarItem.type == SearchBarType.DATASET) this.router.navigate(["datasets/edit/" + selectedSearchBarItem.id])
|
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.PROJECT) { this.router.navigate(['projects/edit/' + selectedSearchBarItem.id]); }
|
||||||
if (selectedSearchBarItem.type == SearchBarType.DATAMANAGEMENTPLAN) this.router.navigate(["dmps/edit/" + selectedSearchBarItem.id])
|
if (selectedSearchBarItem.type === SearchBarType.DATAMANAGEMENTPLAN) { this.router.navigate(['dmps/edit/' + selectedSearchBarItem.id]); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { FormBuilder } from '@angular/forms';
|
import { FormBuilder } from '@angular/forms';
|
||||||
export abstract class BaseModel{
|
export abstract class BaseModel {
|
||||||
public formBuilder:FormBuilder = new FormBuilder();
|
public formBuilder: FormBuilder = new FormBuilder();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,73 +2,73 @@ import { FormGroup } from '@angular/forms';
|
||||||
import { JsonSerializer } from '../utilities/JsonSerializer';
|
import { JsonSerializer } from '../utilities/JsonSerializer';
|
||||||
import { Serializable } from './interfaces/Serializable';
|
import { Serializable } from './interfaces/Serializable';
|
||||||
import { BaseModel } from './BaseModel';
|
import { BaseModel } from './BaseModel';
|
||||||
import { Field } from './Field'
|
import { Field } from './Field';
|
||||||
import { Multiplicity } from './Multiplicity';
|
import { Multiplicity } from './Multiplicity';
|
||||||
export class CompositeField extends BaseModel implements Serializable<CompositeField> {
|
export class CompositeField extends BaseModel implements Serializable<CompositeField> {
|
||||||
public fields: Array<Field> = new Array<Field>();
|
public fields: Array<Field> = new Array<Field>();
|
||||||
public ordinal: number
|
public ordinal: number;
|
||||||
public id: string
|
public id: string;
|
||||||
public multiplicity: Multiplicity;
|
public multiplicity: Multiplicity;
|
||||||
public multiplicityItems: Array<CompositeField> = new Array<CompositeField>();
|
public multiplicityItems: Array<CompositeField> = new Array<CompositeField>();
|
||||||
public title: string
|
public title: string;
|
||||||
public description: string
|
public description: string;
|
||||||
public extendedDescription: string
|
public extendedDescription: string;
|
||||||
public hasCommentField: boolean;
|
public hasCommentField: boolean;
|
||||||
public commentFieldValue: string;
|
public commentFieldValue: string;
|
||||||
|
|
||||||
fromJSONObject(item: any): CompositeField {
|
fromJSONObject(item: any): CompositeField {
|
||||||
|
|
||||||
this.fields = JsonSerializer.fromJSONArray(item.fields, Field);
|
this.fields = JsonSerializer.fromJSONArray(item.fields, Field);
|
||||||
this.ordinal = item.ordinal;
|
this.ordinal = item.ordinal;
|
||||||
this.id = item.id;
|
this.id = item.id;
|
||||||
this.title = item.title;
|
this.title = item.title;
|
||||||
this.description = item.description;
|
this.description = item.description;
|
||||||
this.extendedDescription = item.extendedDescription;
|
this.extendedDescription = item.extendedDescription;
|
||||||
this.hasCommentField = item.hasCommentField;
|
this.hasCommentField = item.hasCommentField;
|
||||||
this.commentFieldValue = item.commentFieldValue;
|
this.commentFieldValue = item.commentFieldValue;
|
||||||
this.multiplicity = JsonSerializer.fromJSONObject(item.multiplicity, Multiplicity);
|
this.multiplicity = JsonSerializer.fromJSONObject(item.multiplicity, Multiplicity);
|
||||||
//this.multiplicity = new Multiplicity();
|
//this.multiplicity = new Multiplicity();
|
||||||
//this.multiplicity.max = 2;
|
//this.multiplicity.max = 2;
|
||||||
if(item.multiplicityItems)this.multiplicityItems = JsonSerializer.fromJSONArray(item.multiplicityItems, CompositeField);
|
if (item.multiplicityItems) {this.multiplicityItems = JsonSerializer.fromJSONArray(item.multiplicityItems, CompositeField); }
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
buildForm(): FormGroup {
|
buildForm(): FormGroup {
|
||||||
let formGroup = this.formBuilder.group({
|
const formGroup = this.formBuilder.group({
|
||||||
id: this.id,
|
id: this.id,
|
||||||
ordinal: this.ordinal,
|
ordinal: this.ordinal,
|
||||||
title: this.title,
|
title: this.title,
|
||||||
description: this.description,
|
description: this.description,
|
||||||
extendedDescription: this.extendedDescription,
|
extendedDescription: this.extendedDescription,
|
||||||
hasCommentField: this.hasCommentField,
|
hasCommentField: this.hasCommentField,
|
||||||
commentFieldValue: this.commentFieldValue
|
commentFieldValue: this.commentFieldValue
|
||||||
});
|
});
|
||||||
|
|
||||||
let fieldsFormArray = new Array<FormGroup>();
|
const fieldsFormArray = new Array<FormGroup>();
|
||||||
this.fields.forEach(item => {
|
this.fields.forEach(item => {
|
||||||
let form: FormGroup = item.buildForm();
|
const form: FormGroup = item.buildForm();
|
||||||
fieldsFormArray.push(form)
|
fieldsFormArray.push(form);
|
||||||
})
|
});
|
||||||
formGroup.addControl('fields', this.formBuilder.array(fieldsFormArray));
|
formGroup.addControl('fields', this.formBuilder.array(fieldsFormArray));
|
||||||
|
|
||||||
let multiplicityItemsFormArray = new Array<FormGroup>();
|
const multiplicityItemsFormArray = new Array<FormGroup>();
|
||||||
this.multiplicityItems.forEach(item => {
|
this.multiplicityItems.forEach(item => {
|
||||||
let form: FormGroup = item.buildForm();
|
const form: FormGroup = item.buildForm();
|
||||||
multiplicityItemsFormArray.push(form)
|
multiplicityItemsFormArray.push(form);
|
||||||
})
|
});
|
||||||
formGroup.addControl('multiplicityItems', this.formBuilder.array(multiplicityItemsFormArray));
|
formGroup.addControl('multiplicityItems', this.formBuilder.array(multiplicityItemsFormArray));
|
||||||
|
|
||||||
return formGroup;
|
return formGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
cloneForMultiplicity(index: number): CompositeField {
|
cloneForMultiplicity(index: number): CompositeField {
|
||||||
let newItem: CompositeField = new CompositeField();
|
const newItem: CompositeField = new CompositeField();
|
||||||
newItem.id = 'multiple_' + this.id + '_' + index;
|
newItem.id = 'multiple_' + this.id + '_' + index;
|
||||||
this.fields.forEach(field => {
|
this.fields.forEach(field => {
|
||||||
newItem.fields.push(field.cloneForMultiplicity(this.fields.indexOf(field), newItem.id + "_"));
|
newItem.fields.push(field.cloneForMultiplicity(this.fields.indexOf(field), newItem.id + '_'));
|
||||||
});
|
});
|
||||||
newItem.ordinal = this.ordinal;
|
newItem.ordinal = this.ordinal;
|
||||||
|
|
||||||
return newItem;
|
return newItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,32 +1,32 @@
|
||||||
import { DataField } from './DataField';
|
import { DataField } from './DataField';
|
||||||
import { FormGroup } from '@angular/forms'
|
import { FormGroup } from '@angular/forms';
|
||||||
import { ListingItem } from '../common/ListingItem';
|
import { ListingItem } from '../common/ListingItem';
|
||||||
import { JsonSerializer } from '../../utilities/JsonSerializer';
|
import { JsonSerializer } from '../../utilities/JsonSerializer';
|
||||||
|
|
||||||
export class AutocompleteData extends DataField<AutocompleteData>{
|
export class AutocompleteData extends DataField<AutocompleteData> {
|
||||||
|
|
||||||
public type: string;
|
public type: string;
|
||||||
public url: string;
|
public url: string;
|
||||||
public optionsRoot: string;
|
public optionsRoot: string;
|
||||||
public autoCompleteOptions: ListingItem = new ListingItem();
|
public autoCompleteOptions: ListingItem = new ListingItem();
|
||||||
|
|
||||||
buildForm(): FormGroup {
|
buildForm(): FormGroup {
|
||||||
let formGroup = this.formBuilder.group({
|
const formGroup = this.formBuilder.group({
|
||||||
label: [this.label],
|
label: [this.label],
|
||||||
type: [this.type],
|
type: [this.type],
|
||||||
url: [this.url],
|
url: [this.url],
|
||||||
optionsRoot: [this.optionsRoot]
|
optionsRoot: [this.optionsRoot]
|
||||||
})
|
});
|
||||||
formGroup.addControl("autoCompleteOptions", this.autoCompleteOptions.buildForm());
|
formGroup.addControl('autoCompleteOptions', this.autoCompleteOptions.buildForm());
|
||||||
return formGroup;
|
return formGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
fromJSONObject(item: any): AutocompleteData {
|
fromJSONObject(item: any): AutocompleteData {
|
||||||
this.type = item.type;
|
this.type = item.type;
|
||||||
this.url = item.url;
|
this.url = item.url;
|
||||||
this.label = item.label;
|
this.label = item.label;
|
||||||
this.optionsRoot = item.optionsRoot;
|
this.optionsRoot = item.optionsRoot;
|
||||||
this.autoCompleteOptions = JsonSerializer.fromJSONObject(item.autoCompleteOptions, ListingItem);
|
this.autoCompleteOptions = JsonSerializer.fromJSONObject(item.autoCompleteOptions, ListingItem);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import { DataField } from './DataField';
|
import { DataField } from './DataField';
|
||||||
import { FormGroup } from '@angular/forms';
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
fromJSONObject(item:any):BooleanDecisionData{
|
buildForm(): FormGroup {
|
||||||
this.label = item.label
|
const formGroup = this.formBuilder.group({
|
||||||
return this;
|
label: this.label
|
||||||
}
|
});
|
||||||
}
|
return formGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
fromJSONObject(item: any): BooleanDecisionData {
|
||||||
|
this.label = item.label;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import { DataField } from './DataField';
|
import { DataField } from './DataField';
|
||||||
import { FormGroup } from '@angular/forms';
|
import { FormGroup } from '@angular/forms';
|
||||||
export class CheckBoxData extends DataField<CheckBoxData>{
|
export class CheckBoxData extends DataField<CheckBoxData> {
|
||||||
|
|
||||||
buildForm():FormGroup{
|
buildForm(): FormGroup {
|
||||||
let formGroup = this.formBuilder.group({
|
const formGroup = this.formBuilder.group({
|
||||||
label:this.label
|
label: this.label
|
||||||
});
|
});
|
||||||
return formGroup;
|
return formGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
fromJSONObject(item:any):CheckBoxData{
|
fromJSONObject(item: any): CheckBoxData {
|
||||||
this.label = item.label
|
this.label = item.label;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import { BaseModel } from '../BaseModel';
|
import { BaseModel } from '../BaseModel';
|
||||||
import { FormGenerator } from '../interfaces/FormGenerator';
|
import { FormGenerator } from '../interfaces/FormGenerator';
|
||||||
import { Serializable } from '../interfaces/Serializable';
|
import { Serializable } from '../interfaces/Serializable';
|
||||||
import { FormGroup } from '@angular/forms'
|
import { FormGroup } from '@angular/forms';
|
||||||
export abstract class DataField<T> extends BaseModel implements Serializable<T>,FormGenerator<FormGroup>{
|
export abstract class DataField<T> extends BaseModel implements Serializable<T>, FormGenerator<FormGroup> {
|
||||||
public label:string;
|
public label: string;
|
||||||
|
|
||||||
buildForm():FormGroup{
|
|
||||||
throw new Error("Build Form Is not not correctly overriden");
|
|
||||||
}
|
|
||||||
|
|
||||||
fromJSONObject(item:any):T{
|
buildForm(): FormGroup {
|
||||||
throw new Error("From Json Object is not correctly overriden")
|
throw new Error('Build Form Is not not correctly overriden');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
fromJSONObject(item: any): T {
|
||||||
|
throw new Error('From Json Object is not correctly overriden');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import { DataField } from './DataField';
|
import { DataField } from './DataField';
|
||||||
import { FormGroup } from '@angular/forms';
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
fromJSONObject(item:any):FreeTextData{
|
buildForm(): FormGroup {
|
||||||
this.label = item.label
|
const formGroup = this.formBuilder.group({
|
||||||
return this;
|
label: this.label
|
||||||
}
|
});
|
||||||
}
|
return formGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
fromJSONObject(item: any): FreeTextData {
|
||||||
|
this.label = item.label;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,29 +1,29 @@
|
||||||
import { JsonSerializer } from '../../utilities/JsonSerializer';
|
import { JsonSerializer } from '../../utilities/JsonSerializer';
|
||||||
import { DataField } from './DataField';
|
import { DataField } from './DataField';
|
||||||
import { ListingItem } from '../common/ListingItem';
|
import { ListingItem } from '../common/ListingItem';
|
||||||
import { FormGroup } from '@angular/forms'
|
import { FormGroup } from '@angular/forms';
|
||||||
|
|
||||||
export class RadioBoxData extends DataField<RadioBoxData>{
|
export class RadioBoxData extends DataField<RadioBoxData> {
|
||||||
public options: Array<ListingItem>;
|
public options: Array<ListingItem>;
|
||||||
|
|
||||||
buildForm(): FormGroup {
|
buildForm(): FormGroup {
|
||||||
let formGroup = this.formBuilder.group({
|
const formGroup = this.formBuilder.group({
|
||||||
label: [this.label]
|
label: [this.label]
|
||||||
});
|
});
|
||||||
let optionsFormArray = new Array<FormGroup>();
|
const optionsFormArray = new Array<FormGroup>();
|
||||||
if (this.options) {
|
if (this.options) {
|
||||||
this.options.forEach(item => {
|
this.options.forEach(item => {
|
||||||
let form: FormGroup = item.buildForm();
|
const form: FormGroup = item.buildForm();
|
||||||
optionsFormArray.push(form)
|
optionsFormArray.push(form);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
formGroup.addControl('options', this.formBuilder.array(optionsFormArray));
|
formGroup.addControl('options', this.formBuilder.array(optionsFormArray));
|
||||||
return formGroup;
|
return formGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
fromJSONObject(item: any): RadioBoxData {
|
fromJSONObject(item: any): RadioBoxData {
|
||||||
this.options = JsonSerializer.fromJSONArray(item.options, ListingItem);
|
this.options = JsonSerializer.fromJSONArray(item.options, ListingItem);
|
||||||
this.label = item.label
|
this.label = item.label;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import { DataField } from './DataField';
|
import { DataField } from './DataField';
|
||||||
import { FormGroup } from '@angular/forms';
|
import { FormGroup } from '@angular/forms';
|
||||||
export class TextArea extends DataField<TextArea>{
|
export class TextArea extends DataField<TextArea> {
|
||||||
|
|
||||||
buildForm(): FormGroup {
|
buildForm(): FormGroup {
|
||||||
let formGroup = this.formBuilder.group({
|
const formGroup = this.formBuilder.group({
|
||||||
label: this.label
|
label: this.label
|
||||||
});
|
});
|
||||||
return formGroup;
|
return formGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
fromJSONObject(item: any): TextArea {
|
fromJSONObject(item: any): TextArea {
|
||||||
this.label = item.label
|
this.label = item.label;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,32 +1,32 @@
|
||||||
import { JsonSerializer } from '../../utilities/JsonSerializer';
|
import { JsonSerializer } from '../../utilities/JsonSerializer';
|
||||||
import { ListingItem } from '../common/ListingItem';
|
import { ListingItem } from '../common/ListingItem';
|
||||||
import { DataField } from './DataField';
|
import { DataField } from './DataField';
|
||||||
import { FormGroup } from '@angular/forms'
|
import { FormGroup } from '@angular/forms';
|
||||||
|
|
||||||
export class WordListData extends DataField<WordListData>{
|
export class WordListData extends DataField<WordListData> {
|
||||||
public type: string;
|
public type: string;
|
||||||
public options: Array<ListingItem>;
|
public options: Array<ListingItem>;
|
||||||
buildForm(): FormGroup {
|
buildForm(): FormGroup {
|
||||||
let formGroup = this.formBuilder.group({
|
const formGroup = this.formBuilder.group({
|
||||||
type: [this.type],
|
type: [this.type],
|
||||||
label: [this.label]
|
label: [this.label]
|
||||||
});
|
});
|
||||||
let optionsFormArray = new Array<FormGroup>();
|
const optionsFormArray = new Array<FormGroup>();
|
||||||
if (this.options) {
|
if (this.options) {
|
||||||
this.options.forEach(item => {
|
this.options.forEach(item => {
|
||||||
let form: FormGroup = item.buildForm();
|
const form: FormGroup = item.buildForm();
|
||||||
optionsFormArray.push(form)
|
optionsFormArray.push(form);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
formGroup.addControl('options', this.formBuilder.array(optionsFormArray));
|
formGroup.addControl('options', this.formBuilder.array(optionsFormArray));
|
||||||
|
|
||||||
return formGroup;
|
return formGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
fromJSONObject(item: any): WordListData {
|
fromJSONObject(item: any): WordListData {
|
||||||
this.type = item.type;
|
this.type = item.type;
|
||||||
this.options = JsonSerializer.fromJSONArray(item.options, ListingItem);
|
this.options = JsonSerializer.fromJSONArray(item.options, ListingItem);
|
||||||
this.label = item.label;
|
this.label = item.label;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,35 +6,35 @@ import { JsonSerializer } from '../utilities/JsonSerializer';
|
||||||
import { Section } from './Section';
|
import { Section } from './Section';
|
||||||
import { Serializable } from './interfaces/Serializable';
|
import { Serializable } from './interfaces/Serializable';
|
||||||
import { Page } from '../models/Page';
|
import { Page } from '../models/Page';
|
||||||
export class DatasetProfileDefinitionModel extends BaseModel implements Serializable<DatasetProfileDefinitionModel>, FormGenerator<FormGroup>{
|
export class DatasetProfileDefinitionModel extends BaseModel implements Serializable<DatasetProfileDefinitionModel>, FormGenerator<FormGroup> {
|
||||||
public status: number
|
public status: number;
|
||||||
public pages: Array<Page>;
|
public pages: Array<Page>;
|
||||||
public rules: Rule[];
|
public rules: Rule[];
|
||||||
//public sections:Array<Section>
|
//public sections:Array<Section>
|
||||||
fromJSONObject(item: any): DatasetProfileDefinitionModel {
|
fromJSONObject(item: any): DatasetProfileDefinitionModel {
|
||||||
this.status = item.status;
|
this.status = item.status;
|
||||||
//this.sections = JsonSerializer.fromJSONArray(item.sections,Section);
|
//this.sections = JsonSerializer.fromJSONArray(item.sections,Section);
|
||||||
this.rules = JsonSerializer.fromJSONArray(item.rules, Rule);
|
this.rules = JsonSerializer.fromJSONArray(item.rules, Rule);
|
||||||
this.pages = JsonSerializer.fromJSONArray(item.pages, Page);
|
this.pages = JsonSerializer.fromJSONArray(item.pages, Page);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
buildForm(): FormGroup {
|
buildForm(): FormGroup {
|
||||||
let formGroup: FormGroup = new FormBuilder().group({});
|
const formGroup: FormGroup = new FormBuilder().group({});
|
||||||
let pagesFormArray = new Array<FormGroup>();
|
const pagesFormArray = new Array<FormGroup>();
|
||||||
// let sectionsFormArray = new Array<FormGroup>();
|
// let sectionsFormArray = new Array<FormGroup>();
|
||||||
// this.pages.forEach (page => {
|
// this.pages.forEach (page => {
|
||||||
// page.sections.forEach(item => {
|
// page.sections.forEach(item => {
|
||||||
// let form: FormGroup = item.buildForm();
|
// let form: FormGroup = item.buildForm();
|
||||||
// sectionsFormArray.push(form)
|
// sectionsFormArray.push(form)
|
||||||
// })
|
// })
|
||||||
// })
|
// })
|
||||||
this.pages.forEach(item => {
|
this.pages.forEach(item => {
|
||||||
let form: FormGroup = item.buildForm();
|
const form: FormGroup = item.buildForm();
|
||||||
pagesFormArray.push(form)
|
pagesFormArray.push(form);
|
||||||
})
|
});
|
||||||
formGroup.addControl('pages', this.formBuilder.array(pagesFormArray));
|
formGroup.addControl('pages', this.formBuilder.array(pagesFormArray));
|
||||||
return formGroup;
|
return formGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,22 +3,22 @@ import { FormGroup } from '@angular/forms';
|
||||||
import { FormGenerator } from './interfaces/FormGenerator';
|
import { FormGenerator } from './interfaces/FormGenerator';
|
||||||
import { Serializable } from './interfaces/Serializable';
|
import { Serializable } from './interfaces/Serializable';
|
||||||
|
|
||||||
export class DefaultValue extends BaseModel implements Serializable<DefaultValue>, FormGenerator<FormGroup>{
|
export class DefaultValue extends BaseModel implements Serializable<DefaultValue>, FormGenerator<FormGroup> {
|
||||||
public type: string;
|
public type: string;
|
||||||
public value: string;
|
public value: string;
|
||||||
|
|
||||||
fromJSONObject(item: any): DefaultValue {
|
fromJSONObject(item: any): DefaultValue {
|
||||||
this.type = item.type;
|
this.type = item.type;
|
||||||
this.value = item.value;
|
this.value = item.value;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
buildForm(): FormGroup {
|
buildForm(): FormGroup {
|
||||||
let formGroup = this.formBuilder.group({
|
const formGroup = this.formBuilder.group({
|
||||||
type: [this.type],
|
type: [this.type],
|
||||||
value: [this.value]
|
value: [this.value]
|
||||||
|
|
||||||
});
|
});
|
||||||
return formGroup;
|
return formGroup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,91 +8,92 @@ import { DefaultValue } from './DefaultValue';
|
||||||
import { ValidationTypes } from '../models/common/ValidationTypes';
|
import { ValidationTypes } from '../models/common/ValidationTypes';
|
||||||
import { ViewStyle } from './datasetProfileAdmin/ViewStyle';
|
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 id: string;
|
||||||
public title: string;
|
public title: string;
|
||||||
public value: any;
|
public value: any;
|
||||||
public defaultValue: DefaultValue;
|
public defaultValue: DefaultValue;
|
||||||
public description: string;
|
public description: string;
|
||||||
public extendedDescription: string;
|
public extendedDescription: string;
|
||||||
public viewStyle: ViewStyle;
|
public viewStyle: ViewStyle;
|
||||||
public defaultVisibility: boolean;
|
public defaultVisibility: boolean;
|
||||||
public page: number;
|
public page: number;
|
||||||
public multiplicity: Multiplicity;
|
public multiplicity: Multiplicity;
|
||||||
public multiplicityItems: Array<Field> = new Array<Field>();
|
public multiplicityItems: Array<Field> = new Array<Field>();
|
||||||
public data: any;
|
public data: any;
|
||||||
public validations: Array<any>;//Array<ValidationTypes>
|
public validations: Array<any>; //Array<ValidationTypes>
|
||||||
public validationRequired = false;
|
public validationRequired = false;
|
||||||
|
|
||||||
fromJSONObject(item: any): Field {
|
fromJSONObject(item: any): Field {
|
||||||
this.id = item.id;
|
this.id = item.id;
|
||||||
this.title = item.title;
|
this.title = item.title;
|
||||||
//this.value = item.value;
|
//this.value = item.value;
|
||||||
this.description = item.description;
|
this.description = item.description;
|
||||||
this.extendedDescription = item.extendedDescription;
|
this.extendedDescription = item.extendedDescription;
|
||||||
this.viewStyle = item.viewStyle;
|
this.viewStyle = item.viewStyle;
|
||||||
this.defaultVisibility = item.defaultVisibility;
|
this.defaultVisibility = item.defaultVisibility;
|
||||||
this.page = item.page;
|
this.page = item.page;
|
||||||
this.validations = item.validations;
|
this.validations = item.validations;
|
||||||
this.multiplicity = JsonSerializer.fromJSONObject(item.multiplicity, Multiplicity);
|
this.multiplicity = JsonSerializer.fromJSONObject(item.multiplicity, Multiplicity);
|
||||||
this.defaultValue = JsonSerializer.fromJSONObject(item.defaultValue, DefaultValue);
|
this.defaultValue = JsonSerializer.fromJSONObject(item.defaultValue, DefaultValue);
|
||||||
this.value = this.defaultValue.value && !item.value ? this.defaultValue.value : item.value;
|
this.value = this.defaultValue.value && !item.value ? this.defaultValue.value : item.value;
|
||||||
//this.multiplicity = new Multiplicity();
|
//this.multiplicity = new Multiplicity();
|
||||||
if (this.viewStyle.renderStyle === "checkBox") {
|
if (this.viewStyle.renderStyle === 'checkBox') {
|
||||||
this.value = this.value === 'true';
|
this.value = this.value === 'true';
|
||||||
}
|
}
|
||||||
//this.multiplicity.max = 2;
|
//this.multiplicity.max = 2;
|
||||||
if (item.multiplicityItems) this.multiplicityItems = JsonSerializer.fromJSONArray(item.multiplicityItems, Field);
|
if (item.multiplicityItems) { this.multiplicityItems = JsonSerializer.fromJSONArray(item.multiplicityItems, Field); }
|
||||||
this.data = item.data;
|
this.data = item.data;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
buildForm(): FormGroup {
|
buildForm(): FormGroup {
|
||||||
if (this.validations)
|
if (this.validations) {
|
||||||
this.validations.forEach(validation => {
|
this.validations.forEach(validation => {
|
||||||
if (validation == ValidationTypes.Required) this.validationRequired = true;
|
if (validation === ValidationTypes.Required) { this.validationRequired = true; }
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
let formGroup = this.formBuilder.group({
|
const formGroup = this.formBuilder.group({
|
||||||
id: [this.id],
|
id: [this.id],
|
||||||
data: [this.data],
|
data: [this.data],
|
||||||
/* title: [this.title], */
|
/* title: [this.title], */
|
||||||
value: [this.value, this.validationRequired == true ? Validators.required : null]/* ,
|
value: [this.value, this.validationRequired === true ? Validators.required : null]/* ,
|
||||||
description: [this.description],
|
description: [this.description],
|
||||||
extendedDescription:[this.extendedDescription],
|
extendedDescription:[this.extendedDescription],
|
||||||
viewStyle: [this.viewStyle],
|
viewStyle: [this.viewStyle],
|
||||||
defaultVisibility:[this.defaultVisibility],
|
defaultVisibility:[this.defaultVisibility],
|
||||||
page:[this.page],
|
page:[this.page],
|
||||||
data:[this.data] */
|
data:[this.data] */
|
||||||
});
|
});
|
||||||
|
|
||||||
let multiplicityItemsFormArray = new Array<FormGroup>();
|
const multiplicityItemsFormArray = new Array<FormGroup>();
|
||||||
this.multiplicityItems.forEach(item => {
|
this.multiplicityItems.forEach(item => {
|
||||||
let form: FormGroup = item.buildForm();
|
const form: FormGroup = item.buildForm();
|
||||||
multiplicityItemsFormArray.push(form)
|
multiplicityItemsFormArray.push(form);
|
||||||
})
|
});
|
||||||
formGroup.addControl('multiplicityItems', this.formBuilder.array(multiplicityItemsFormArray));
|
formGroup.addControl('multiplicityItems', this.formBuilder.array(multiplicityItemsFormArray));
|
||||||
|
|
||||||
return formGroup;
|
return formGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
cloneForMultiplicity(index: number, idPath: string): Field {
|
cloneForMultiplicity(index: number, idPath: string): Field {
|
||||||
let newItem: Field = new Field();
|
const newItem: Field = new Field();
|
||||||
|
|
||||||
newItem.id = idPath ? idPath + index : 'multiple_' + this.id + '_' + index;
|
newItem.id = idPath ? idPath + index : 'multiple_' + this.id + '_' + index;
|
||||||
newItem.title = this.title;
|
newItem.title = this.title;
|
||||||
newItem.description = this.description;
|
newItem.description = this.description;
|
||||||
newItem.extendedDescription = this.extendedDescription;
|
newItem.extendedDescription = this.extendedDescription;
|
||||||
newItem.viewStyle = this.viewStyle;
|
newItem.viewStyle = this.viewStyle;
|
||||||
newItem.defaultVisibility = this.defaultVisibility;
|
newItem.defaultVisibility = this.defaultVisibility;
|
||||||
newItem.page = this.page;
|
newItem.page = this.page;
|
||||||
newItem.multiplicity = null;
|
newItem.multiplicity = null;
|
||||||
newItem.data = this.data;
|
newItem.data = this.data;
|
||||||
|
|
||||||
return newItem;
|
return newItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,48 +8,48 @@ import { JsonSerializer } from '../utilities/JsonSerializer';
|
||||||
import { Serializable } from './interfaces/Serializable';
|
import { Serializable } from './interfaces/Serializable';
|
||||||
import { Field } from './Field';
|
import { Field } from './Field';
|
||||||
|
|
||||||
export class FieldGroup extends BaseModel implements Serializable<FieldGroup>, FormGenerator<FormGroup>{
|
export class FieldGroup extends BaseModel implements Serializable<FieldGroup>, FormGenerator<FormGroup> {
|
||||||
public id: string;
|
public id: string;
|
||||||
public title: string;
|
public title: string;
|
||||||
public section: string;
|
public section: string;
|
||||||
public value: string;
|
public value: string;
|
||||||
public description: string;
|
public description: string;
|
||||||
public extendedDescription: string;
|
public extendedDescription: string;
|
||||||
public defaultVisibility: boolean;
|
public defaultVisibility: boolean;
|
||||||
public page: number;
|
public page: number;
|
||||||
public compositeFields: Array<CompositeField> = new Array<CompositeField>();
|
public compositeFields: Array<CompositeField> = new Array<CompositeField>();
|
||||||
|
|
||||||
fromJSONObject(item: any): FieldGroup {
|
fromJSONObject(item: any): FieldGroup {
|
||||||
this.id = item.id;
|
this.id = item.id;
|
||||||
this.title = item.title;
|
this.title = item.title;
|
||||||
this.value = item.value;
|
this.value = item.value;
|
||||||
this.description = item.description;
|
this.description = item.description;
|
||||||
this.extendedDescription = item.extendedDescription;
|
this.extendedDescription = item.extendedDescription;
|
||||||
this.defaultVisibility = item.defaultVisibility;
|
this.defaultVisibility = item.defaultVisibility;
|
||||||
this.page = item.page;
|
this.page = item.page;
|
||||||
this.compositeFields = JsonSerializer.fromJSONArray(item.compositeFields, CompositeField);
|
this.compositeFields = JsonSerializer.fromJSONArray(item.compositeFields, CompositeField);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
buildForm(): FormGroup {
|
buildForm(): FormGroup {
|
||||||
let formGroup: FormGroup = this.formBuilder.group({
|
const formGroup: FormGroup = this.formBuilder.group({
|
||||||
/* id: [this.id],
|
/* id: [this.id],
|
||||||
title: [this.title],
|
title: [this.title],
|
||||||
value: [this.value],
|
value: [this.value],
|
||||||
description: [this.description],
|
description: [this.description],
|
||||||
extendedDescription: [this.extendedDescription],
|
extendedDescription: [this.extendedDescription],
|
||||||
defaultVisibility: [this.defaultVisibility],
|
defaultVisibility: [this.defaultVisibility],
|
||||||
page: [this.page] */
|
page: [this.page] */
|
||||||
});
|
});
|
||||||
let compositeFieldsFormArray = new Array<FormGroup>();
|
const compositeFieldsFormArray = new Array<FormGroup>();
|
||||||
if (this.compositeFields) {
|
if (this.compositeFields) {
|
||||||
this.compositeFields.forEach(item => {
|
this.compositeFields.forEach(item => {
|
||||||
let form: FormGroup = item.buildForm();
|
const form: FormGroup = item.buildForm();
|
||||||
compositeFieldsFormArray.push(form)
|
compositeFieldsFormArray.push(form);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
formGroup.addControl('compositeFields', this.formBuilder.array(compositeFieldsFormArray));
|
formGroup.addControl('compositeFields', this.formBuilder.array(compositeFieldsFormArray));
|
||||||
|
|
||||||
return formGroup;
|
return formGroup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,22 +2,22 @@ import { BaseModel } from './BaseModel';
|
||||||
import { FormGroup } from '@angular/forms';
|
import { FormGroup } from '@angular/forms';
|
||||||
import { FormGenerator } from './interfaces/FormGenerator';
|
import { FormGenerator } from './interfaces/FormGenerator';
|
||||||
import { Serializable } from './interfaces/Serializable';
|
import { Serializable } from './interfaces/Serializable';
|
||||||
export class Multiplicity extends BaseModel implements Serializable<Multiplicity>, FormGenerator<FormGroup>{
|
export class Multiplicity extends BaseModel implements Serializable<Multiplicity>, FormGenerator<FormGroup> {
|
||||||
public min: number;
|
public min: number;
|
||||||
public max: number;
|
public max: number;
|
||||||
|
|
||||||
fromJSONObject(item: any): Multiplicity {
|
fromJSONObject(item: any): Multiplicity {
|
||||||
this.min = item.min;
|
this.min = item.min;
|
||||||
this.max = item.max;
|
this.max = item.max;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
buildForm(): FormGroup {
|
buildForm(): FormGroup {
|
||||||
let formGroup = this.formBuilder.group({
|
const formGroup = this.formBuilder.group({
|
||||||
min: [this.min],
|
min: [this.min],
|
||||||
max: [this.max]
|
max: [this.max]
|
||||||
|
|
||||||
});
|
});
|
||||||
return formGroup;
|
return formGroup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Section } from "../models/Section";
|
import { Section } from '../models/Section';
|
||||||
import { BaseModel } from './BaseModel';
|
import { BaseModel } from './BaseModel';
|
||||||
import { FormGenerator } from './interfaces/FormGenerator';
|
import { FormGenerator } from './interfaces/FormGenerator';
|
||||||
import { Serializable } from './interfaces/Serializable';
|
import { Serializable } from './interfaces/Serializable';
|
||||||
|
@ -6,25 +6,25 @@ import { JsonSerializer } from '../utilities/JsonSerializer';
|
||||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||||
|
|
||||||
export class Page extends BaseModel implements Serializable<Page> {
|
export class Page extends BaseModel implements Serializable<Page> {
|
||||||
public ordinal: number;
|
public ordinal: number;
|
||||||
public title: string;
|
public title: string;
|
||||||
public sections: Array<Section>;
|
public sections: Array<Section>;
|
||||||
|
|
||||||
fromJSONObject(item: any): Page {
|
fromJSONObject(item: any): Page {
|
||||||
this.ordinal = item.ordinal;
|
this.ordinal = item.ordinal;
|
||||||
this.title = item.title;
|
this.title = item.title;
|
||||||
this.sections = JsonSerializer.fromJSONArray(item.sections, Section);
|
this.sections = JsonSerializer.fromJSONArray(item.sections, Section);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
buildForm(): FormGroup {
|
buildForm(): FormGroup {
|
||||||
let formGroup: FormGroup = new FormBuilder().group({});
|
const formGroup: FormGroup = new FormBuilder().group({});
|
||||||
let sectionsFormArray = new Array<FormGroup>();
|
const sectionsFormArray = new Array<FormGroup>();
|
||||||
this.sections.forEach(item => {
|
this.sections.forEach(item => {
|
||||||
let form: FormGroup = item.buildForm();
|
const form: FormGroup = item.buildForm();
|
||||||
sectionsFormArray.push(form)
|
sectionsFormArray.push(form);
|
||||||
})
|
});
|
||||||
formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray));
|
formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray));
|
||||||
return formGroup;
|
return formGroup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,17 +2,17 @@ import { BaseModel } from './BaseModel';
|
||||||
import { FormGroup } from '@angular/forms';
|
import { FormGroup } from '@angular/forms';
|
||||||
import { FormGenerator } from './interfaces/FormGenerator';
|
import { FormGenerator } from './interfaces/FormGenerator';
|
||||||
import { Serializable } from './interfaces/Serializable';
|
import { Serializable } from './interfaces/Serializable';
|
||||||
export class Rule extends BaseModel implements Serializable<Rule>{
|
export class Rule extends BaseModel implements Serializable<Rule> {
|
||||||
public sourceField:string;
|
public sourceField: string;
|
||||||
public targetField:string;
|
public targetField: string;
|
||||||
public requiredValue;
|
public requiredValue;
|
||||||
public type: string;
|
public type: string;
|
||||||
|
|
||||||
fromJSONObject(item:any):Rule{
|
fromJSONObject(item: any): Rule {
|
||||||
this.sourceField = item.sourceField;
|
this.sourceField = item.sourceField;
|
||||||
this.targetField = item.targetField;
|
this.targetField = item.targetField;
|
||||||
this.requiredValue = item.requiredValue;
|
this.requiredValue = item.requiredValue;
|
||||||
this.type = item.type;
|
this.type = item.type;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,61 +6,61 @@ import { Serializable } from './interfaces/Serializable';
|
||||||
import { FieldGroup } from './FieldGroup';
|
import { FieldGroup } from './FieldGroup';
|
||||||
import { CompositeField } from './CompositeField';
|
import { CompositeField } from './CompositeField';
|
||||||
|
|
||||||
export class Section extends BaseModel implements Serializable<Section>, FormGenerator<FormGroup>{
|
export class Section extends BaseModel implements Serializable<Section>, FormGenerator<FormGroup> {
|
||||||
public sections: Array<Section> = new Array<Section>();
|
public sections: Array<Section> = new Array<Section>();
|
||||||
//public fieldGroups: Array<FieldGroup>;
|
//public fieldGroups: Array<FieldGroup>;
|
||||||
public defaultVisibility: boolean;
|
public defaultVisibility: boolean;
|
||||||
public page: number;
|
public page: number;
|
||||||
public ordinal: number;
|
public ordinal: number;
|
||||||
public id: string
|
public id: string;
|
||||||
public title: string
|
public title: string;
|
||||||
public description: string;
|
public description: string;
|
||||||
public compositeFields: Array<CompositeField> = new Array<CompositeField>();
|
public compositeFields: Array<CompositeField> = new Array<CompositeField>();
|
||||||
|
|
||||||
fromJSONObject(item: any): Section {
|
fromJSONObject(item: any): Section {
|
||||||
this.sections = JsonSerializer.fromJSONArray(item.sections, Section);
|
this.sections = JsonSerializer.fromJSONArray(item.sections, Section);
|
||||||
//this.fieldGroups = new JsonSerializer<FieldGroup>().fromJSONArray(item.fieldGroups, FieldGroup);
|
//this.fieldGroups = new JsonSerializer<FieldGroup>().fromJSONArray(item.fieldGroups, FieldGroup);
|
||||||
this.page = item.page;
|
this.page = item.page;
|
||||||
this.defaultVisibility = item.defaultVisibility;
|
this.defaultVisibility = item.defaultVisibility;
|
||||||
this.id = item.id;
|
this.id = item.id;
|
||||||
this.title = item.title;
|
this.title = item.title;
|
||||||
this.ordinal = item.ordinal;
|
this.ordinal = item.ordinal;
|
||||||
this.description = item.description;
|
this.description = item.description;
|
||||||
this.compositeFields = JsonSerializer.fromJSONArray(item.compositeFields, CompositeField);
|
this.compositeFields = JsonSerializer.fromJSONArray(item.compositeFields, CompositeField);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
buildForm(): FormGroup {
|
buildForm(): FormGroup {
|
||||||
let formGroup: FormGroup = new FormBuilder().group({});
|
const formGroup: FormGroup = new FormBuilder().group({});
|
||||||
let sectionsFormArray = new Array<FormGroup>();
|
const sectionsFormArray = new Array<FormGroup>();
|
||||||
if (this.sections) {
|
if (this.sections) {
|
||||||
this.sections.forEach(item => {
|
this.sections.forEach(item => {
|
||||||
let form: FormGroup = item.buildForm();
|
const form: FormGroup = item.buildForm();
|
||||||
sectionsFormArray.push(form)
|
sectionsFormArray.push(form);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
let fieldGroupsFormArray = new Array<FormGroup>();
|
const fieldGroupsFormArray = new Array<FormGroup>();
|
||||||
// if (this.fieldGroups) {
|
// if (this.fieldGroups) {
|
||||||
// this.fieldGroups.forEach(item => {
|
// this.fieldGroups.forEach(item => {
|
||||||
// let form: FormGroup = item.buildForm();
|
// let form: FormGroup = item.buildForm();
|
||||||
// fieldGroupsFormArray.push(form)
|
// fieldGroupsFormArray.push(form)
|
||||||
// })
|
// })
|
||||||
// }
|
// }
|
||||||
let compositeFieldsFormArray = new Array<FormGroup>();
|
const compositeFieldsFormArray = new Array<FormGroup>();
|
||||||
if (this.compositeFields) {
|
if (this.compositeFields) {
|
||||||
this.compositeFields.forEach(item => {
|
this.compositeFields.forEach(item => {
|
||||||
let form: FormGroup = item.buildForm();
|
const form: FormGroup = item.buildForm();
|
||||||
compositeFieldsFormArray.push(form)
|
compositeFieldsFormArray.push(form);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
formGroup.addControl('compositeFields', this.formBuilder.array(compositeFieldsFormArray));
|
formGroup.addControl('compositeFields', this.formBuilder.array(compositeFieldsFormArray));
|
||||||
formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray));
|
formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray));
|
||||||
// formGroup.addControl('fieldGroups', this.formBuilder.array(fieldGroupsFormArray));
|
// formGroup.addControl('fieldGroups', this.formBuilder.array(fieldGroupsFormArray));
|
||||||
/* formGroup.addControl('defaultVisibility', new FormControl(this.defaultVisibility))
|
/* formGroup.addControl('defaultVisibility', new FormControl(this.defaultVisibility))
|
||||||
formGroup.addControl('page', new FormControl(this.page))
|
formGroup.addControl('page', new FormControl(this.page))
|
||||||
formGroup.addControl('id', new FormControl(this.id))
|
formGroup.addControl('id', new FormControl(this.id))
|
||||||
formGroup.addControl('title', new FormControl(this.title))
|
formGroup.addControl('title', new FormControl(this.title))
|
||||||
formGroup.addControl('description', new FormControl(this.description)) */
|
formGroup.addControl('description', new FormControl(this.description)) */
|
||||||
return formGroup;
|
return formGroup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
export enum Status {
|
export enum Status {
|
||||||
Active = 0,
|
Active = 0,
|
||||||
Inactive = 1
|
Inactive = 1
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,20 +2,20 @@ import { BaseModel } from './BaseModel';
|
||||||
import { FormGroup } from '@angular/forms';
|
import { FormGroup } from '@angular/forms';
|
||||||
import { FormGenerator } from './interfaces/FormGenerator';
|
import { FormGenerator } from './interfaces/FormGenerator';
|
||||||
import { Serializable } from './interfaces/Serializable';
|
import { Serializable } from './interfaces/Serializable';
|
||||||
export class Validation extends BaseModel implements Serializable<Validation>,FormGenerator<FormGroup>{
|
export class Validation extends BaseModel implements Serializable<Validation>, FormGenerator<FormGroup> {
|
||||||
public type:string;
|
public type: string;
|
||||||
public value:string;
|
public value: string;
|
||||||
|
|
||||||
fromJSONObject(item:any):Validation{
|
fromJSONObject(item: any): Validation {
|
||||||
this.type = item.type;
|
this.type = item.type;
|
||||||
this.value = item.value;
|
this.value = item.value;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
buildForm():FormGroup{
|
buildForm(): FormGroup {
|
||||||
return this.formBuilder.group({
|
return this.formBuilder.group({
|
||||||
type: [this.type],
|
type: [this.type],
|
||||||
value: [this.value],
|
value: [this.value],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { BaseCriteria } from "../criteria/BaseCriteria";
|
import { BaseCriteria } from '../criteria/BaseCriteria';
|
||||||
|
|
||||||
export class AutocompleteLookupItem extends BaseCriteria {
|
export class AutocompleteLookupItem extends BaseCriteria {
|
||||||
public profileID: String;
|
public profileID: String;
|
||||||
public fieldID: String;
|
public fieldID: String;
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue