Add functionality create DMP from project list Panel

This commit is contained in:
Diamantis Tziotzios 2019-01-24 12:46:29 +02:00
parent b7f010393c
commit 5ff63f3ce9
14 changed files with 88 additions and 74 deletions

View File

@ -20,3 +20,4 @@
<app-help-content position="bottom"></app-help-content>
</div>
</div>
<app-notification></app-notification>

View File

@ -36,7 +36,7 @@ export class MomentUtcDateAdapter extends MomentDateAdapter {
// manually writing on the textbox
parse(value: any, parseFormat: string | string[]): Moment | null {
const initialParse = super.parse(value, parseFormat);
if (!initialParse.isValid()) { return initialParse; }
if (initialParse === null || !initialParse.isValid()) { return initialParse; }
const result = moment.utc({ year: initialParse.year(), month: initialParse.month(), date: initialParse.date() }).locale(this.locale);
return result;

View File

@ -1,7 +1,8 @@
export enum AuthProvider {
LinkedIn = 1,
Google = 1,
Facebook = 2,
Twitter = 3,
Google = 4,
B2Access = 5
LinkedIn = 4,
//NativeLogin=5,
B2Access = 6
}

View File

@ -1,6 +1,5 @@
import { AfterViewInit, Component } from '@angular/core';
import { AbstractControl, FormArray, FormControl, FormGroup } from '@angular/forms';
import { MatSnackBar } from '@angular/material';
import { ActivatedRoute, Params, Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { takeUntil } from 'rxjs/operators';
@ -11,8 +10,8 @@ import { DmpProfileFieldDataType } from '../../../../core/common/enum/dmp-profil
import { DmpProfileType } from '../../../../core/common/enum/dmp-profile-type';
import { DmpProfile } from '../../../../core/model/dmp-profile/dmp-profile';
import { DmpProfileService } from '../../../../core/services/dmp/dmp-profile.service';
import { SnackBarNotificationLevel, UiNotificationService } from '../../../../core/services/notification/ui-notification-service';
import { EnumUtils } from '../../../../core/services/utilities/enum-utils.service';
import { SnackBarNotificationComponent } from '../../../../library/notification/snack-bar/snack-bar-notification.component';
import { DmpProfileEditorModel, DmpProfileFieldEditorModel } from './dmp-profile-editor.model';
@Component({
@ -30,10 +29,10 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
constructor(
private dmpProfileService: DmpProfileService,
private route: ActivatedRoute,
private snackBar: MatSnackBar,
private router: Router,
private language: TranslateService,
private enumUtils: EnumUtils
private enumUtils: EnumUtils,
private uiNotificationService: UiNotificationService
) {
super();
}
@ -81,10 +80,7 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
}
onCallbackSuccess(): void {
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
duration: 3000,
});
this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
this.router.navigate(['/dmp-profiles']);
}

View File

@ -1,6 +1,5 @@
import { Component, Input, OnInit } from '@angular/core';
import { AbstractControl, FormArray, FormBuilder, FormControl, FormGroup } from '@angular/forms';
import { MatSnackBar } from '@angular/material';
import { TranslateService } from '@ngx-translate/core';
import { takeUntil } from 'rxjs/operators';
import { Validation, ValidationContext } from '../../../../../common/forms/validation/validation-context';
@ -9,7 +8,7 @@ import { AppRole } from '../../../../../core/common/enum/app-role';
import { UserListingModel } from '../../../../../core/model/user/user-listing';
import { UserService } from '../../../../../core/services/user/user.service';
import { EnumUtils } from '../../../../../core/services/utilities/enum-utils.service';
import { SnackBarNotificationComponent } from '../../../../../library/notification/snack-bar/snack-bar-notification.component';
import { SnackBarNotificationLevel, UiNotificationService } from '../../../../../core/services/notification/ui-notification-service';
@Component({
selector: 'app-user-role-editor-component',
@ -26,8 +25,8 @@ export class UserRoleEditorComponent extends BaseComponent implements OnInit {
private language: TranslateService,
private userService: UserService,
private formBuilder: FormBuilder,
private snackBar: MatSnackBar,
private enumUtils: EnumUtils
private enumUtils: EnumUtils,
private uiNotificationService:UiNotificationService
) { super(); }
ngOnInit() {
@ -118,17 +117,12 @@ export class UserRoleEditorComponent extends BaseComponent implements OnInit {
onCallbackSuccess() {
this.nowEditing = false;
this.formGroup.disable();
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
duration: 3000,
});
this.uiNotificationService.snackBarNotification( this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
}
onCallbackError(error: any) {
this.validateAllFormFields(this.formGroup);
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: 'GENERAL.SNACK-BAR.UNSUCCESSFUL-UPDATE', language: this.language },
duration: 3000,
});
this.uiNotificationService.snackBarNotification( this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Error);
}
getPrincipalAppRoleValues(): Number[] {

View File

@ -20,11 +20,11 @@ import { DmpService } from '../../../core/services/dmp/dmp.service';
import { ExternalSourcesConfigurationService } from '../../../core/services/external-sources/external-sources-configuration.service';
import { ExternalSourcesService } from '../../../core/services/external-sources/external-sources.service';
import { SingleAutoCompleteConfiguration } from '../../../library/auto-complete/single/single-auto-complete-configuration';
import { SnackBarNotificationComponent } from '../../../library/notification/snack-bar/snack-bar-notification.component';
import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item';
import { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCrumbComponent';
import { DatasetDescriptionFormEditorModel } from '../../misc/dataset-description-form/dataset-description-form.model';
import { DatasetWizardEditorModel } from './dataset-wizard-editor.model';
import { SnackBarNotificationLevel, UiNotificationService } from '../../../core/services/notification/ui-notification-service';
@Component({
selector: 'app-dataset-wizard-component',
@ -63,7 +63,8 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, Aft
public externalSourcesService: ExternalSourcesService,
public dmpService: DmpService,
public dialog: MatDialog,
public externalSourcesConfigurationService: ExternalSourcesConfigurationService
public externalSourcesConfigurationService: ExternalSourcesConfigurationService,
private uiNotificationService:UiNotificationService
) {
super();
}
@ -293,10 +294,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, Aft
}
onCallbackSuccess(): void {
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
duration: 3000,
});
this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
}
onCallbackError(error: any) {

View File

@ -34,6 +34,13 @@ const routes: Routes = [
breadcrumb: true
},
},
{
path: 'new/project/:projectId',
component: DmpEditorComponent,
data: {
breadcrumbs: 'new'
}
},
{
path: 'new',
component: DmpEditorComponent,

View File

@ -23,7 +23,6 @@ import { ExternalSourcesService } from '../../../core/services/external-sources/
import { ProjectService } from '../../../core/services/project/project.service';
import { MultipleAutoCompleteConfiguration } from '../../../library/auto-complete/multiple/multiple-auto-complete-configuration';
import { SingleAutoCompleteConfiguration } from '../../../library/auto-complete/single/single-auto-complete-configuration';
import { SnackBarNotificationComponent } from '../../../library/notification/snack-bar/snack-bar-notification.component';
import { RequestItem } from '../../../core/query/request-item';
import { LanguageResolverService } from '../../../services/language-resolver/language-resolver.service';
import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item';
@ -33,6 +32,8 @@ import { AvailableProfilesComponent } from './available-profiles/available-profi
import { DmpEditorModel } from './dmp-editor.model';
import { DmpFinalizeDialogComponent } from './dmp-finalize-dialog/dmp-finalize-dialog.component';
import { ValidationErrorModel } from '../../../common/forms/validation/error-model/validation-error-model';
import { SnackBarNotificationLevel, UiNotificationService } from '../../../core/services/notification/ui-notification-service';
import { ProjectModel } from '../../../core/model/project/project';
@Component({
selector: 'app-dmp-editor-component',
@ -77,7 +78,8 @@ export class DmpEditorComponent extends BaseComponent implements AfterViewInit,
private _service: DmpService,
private dialog: MatDialog,
private _viewContainerRef: ViewContainerRef,
public languageResolverService: LanguageResolverService
public languageResolverService: LanguageResolverService,
private uiNotificationService: UiNotificationService
) {
super();
// this.filteredOptions = dmpProfileService.getAll({ criteria: new DmpProfileCriteria() });
@ -88,17 +90,16 @@ export class DmpEditorComponent extends BaseComponent implements AfterViewInit,
.pipe(takeUntil(this._destroyed))
.subscribe((params: Params) => {
const itemId = params['id'];
const projectId = params['projectId'];
const projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
projectRequestItem.criteria = new ProjectCriteria();
const organisationRequestItem: RequestItem<BaseCriteria> = new RequestItem();
organisationRequestItem.criteria = new BaseCriteria();
this.projectAutoCompleteConfiguration = {
filterFn: this.searchProject.bind(this),
initialItems:(extraData) => this.searchProject(''),
initialItems: (extraData) => this.searchProject(''),
displayFn: (item) => item['label'],
titleFn: (item) => item['label']
};
@ -145,24 +146,24 @@ export class DmpEditorComponent extends BaseComponent implements AfterViewInit,
);
this.associatedUsers = data.associatedUsers;
});
} else if (projectId != null) {
this.isNew = true;
this.projectService.getSingle(projectId).map(data => data as ProjectModel)
.pipe(takeUntil(this._destroyed))
.subscribe(data => {
this.dmp = new DmpEditorModel();
this.dmp.project = data;
this.formGroup = this.dmp.buildForm();
this.formGroup.get('project').disable();
this.registerFormEventsForNewItem();
});
} else {
this.dmp = new DmpEditorModel();
setTimeout(async () => {
this.formGroup = this.dmp.buildForm();
if (this.formGroup.get('profile') && this.formGroup.get('profile').value) {
this.textCtrl.patchValue(this.formGroup.get('profile').value);
}
this.breadCrumbs = Observable.of([
{
parentComponentName: 'DmpListingComponent',
label: 'DMPs',
url: 'dmps',
}
]);
});
this.formGroup = this.dmp.buildForm();
this.registerFormEventsForNewItem();
}
});
this.route
.queryParams
.pipe(takeUntil(this._destroyed))
@ -171,6 +172,20 @@ export class DmpEditorComponent extends BaseComponent implements AfterViewInit,
});
}
registerFormEventsForNewItem() {
if (this.formGroup.get('profile') && this.formGroup.get('profile').value) {
this.textCtrl.patchValue(this.formGroup.get('profile').value);
}
this.breadCrumbs = Observable.of([
{
parentComponentName: 'DmpListingComponent',
label: 'DMPs',
url: 'dmps',
}
]);
}
searchProject(query: string) {
const projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
projectRequestItem.criteria = new ProjectCriteria();
@ -189,7 +204,7 @@ export class DmpEditorComponent extends BaseComponent implements AfterViewInit,
}
onSubmit(): void {
this.dmpService.createDmp(this.formGroup.value)
this.dmpService.createDmp(this.formGroup.getRawValue())
.pipe(takeUntil(this._destroyed))
.subscribe(
complete => this.onCallbackSuccess(),
@ -198,10 +213,7 @@ export class DmpEditorComponent extends BaseComponent implements AfterViewInit,
}
onCallbackSuccess(): void {
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
duration: 3000,
});
this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
this.router.navigate(['/plans']);
}

View File

@ -82,7 +82,10 @@
</mat-paginator>
</mat-card>
<button *ngIf="!this.projectId" mat-fab class="mat-fab-bottom-right" color="primary" [routerLink]=" ['./new'] ">
<button *ngIf="!projectId" mat-fab class="mat-fab-bottom-right" color="primary" [routerLink]=" ['./new'] ">
<mat-icon class="mat-24">add</mat-icon>
</button>
<button *ngIf="projectId" mat-fab class="mat-fab-bottom-right" color="primary" [routerLink]=" ['/plans/new/project/', projectId] ">
<mat-icon class="mat-24">add</mat-icon>
</button>
</div>

View File

@ -9,10 +9,10 @@ import { ValidationErrorModel } from '../../../common/forms/validation/error-mod
import { BaseComponent } from '../../../core/common/base/base.component';
import { DmpModel } from '../../../core/model/dmp/dmp';
import { DmpService } from '../../../core/services/dmp/dmp.service';
import { SnackBarNotificationComponent } from '../../../library/notification/snack-bar/snack-bar-notification.component';
import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item';
import { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCrumbComponent';
import { DmpWizardEditorModel } from './dmp-wizard-editor.model';
import { SnackBarNotificationLevel, UiNotificationService } from '../../../core/services/notification/ui-notification-service';
@Component({
selector: 'app-dmp-wizard-component',
@ -32,7 +32,8 @@ export class DmpWizardComponent extends BaseComponent implements OnInit, IBreadC
private language: TranslateService,
private snackBar: MatSnackBar,
private route: ActivatedRoute,
private router: Router
private router: Router,
private uiNotificationService:UiNotificationService
) { super(); }
ngOnInit(): void {
@ -72,10 +73,7 @@ export class DmpWizardComponent extends BaseComponent implements OnInit, IBreadC
}
onCallbackSuccess(): void {
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
duration: 3000,
});
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
this.router.navigate(['/plans']);
}

View File

@ -18,9 +18,8 @@ import { ExternalSourcesService } from '../../../../core/services/external-sourc
import { ProjectService } from '../../../../core/services/project/project.service';
import { MultipleAutoCompleteConfiguration } from '../../../../library/auto-complete/multiple/multiple-auto-complete-configuration';
import { SingleAutoCompleteConfiguration } from '../../../../library/auto-complete/single/single-auto-complete-configuration';
import { SnackBarNotificationComponent } from '../../../../library/notification/snack-bar/snack-bar-notification.component';
import { LanguageResolverService } from '../../../../services/language-resolver/language-resolver.service';
import { ValidationErrorModel } from '../../../../common/forms/validation/error-model/validation-error-model';
import { SnackBarNotificationLevel, UiNotificationService } from '../../../../core/services/notification/ui-notification-service';
@Component({
selector: 'app-dmp-wizard-editor-component',
@ -56,7 +55,8 @@ export class DmpWizardEditorComponent extends BaseComponent implements OnInit {
public router: Router,
public language: TranslateService,
private _service: DmpService,
private languageResolverService: LanguageResolverService
private languageResolverService: LanguageResolverService,
private uiNotificationService:UiNotificationService
) {
super();
}
@ -133,10 +133,7 @@ export class DmpWizardEditorComponent extends BaseComponent implements OnInit {
}
onCallbackSuccess(): void {
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
duration: 3000,
});
this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
this.router.navigate(['/plans']);
}

View File

@ -17,6 +17,7 @@ import { SnackBarNotificationComponent } from '../../../library/notification/sna
import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item';
import { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCrumbComponent';
import { ProjectEditorModel } from './project-editor.model';
import { SnackBarNotificationLevel, UiNotificationService } from '../../../core/services/notification/ui-notification-service';
@Component({
selector: 'app-project-editor-component',
@ -39,6 +40,7 @@ export class ProjectEditorComponent extends BaseComponent implements OnInit, IBr
public language: TranslateService,
private dialog: MatDialog,
private projectFileUploadService: ProjectFileUploadService,
private uiNotificationService:UiNotificationService
) {
super();
}
@ -92,10 +94,7 @@ export class ProjectEditorComponent extends BaseComponent implements OnInit, IBr
}
onCallbackSuccess(): void {
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
duration: 3000,
});
this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
this.router.navigate(['/projects']);
}

View File

@ -20,6 +20,7 @@
right: 20px !important;
bottom: 10px !important;
left: auto !important;
position: fixed !important;
position: fixed !important;
z-index: 5;
}
}

View File

@ -26,7 +26,14 @@
"STATUSES": {
"EDIT": "Edited",
"FINALISED": "Finalized"
}
},
"CONFIRMATION-DIALOG": {
"DELETE-ITEM": "Delete this item?",
"ACTIONS": {
"CONFIRM": "Yes",
"CANCEL": "No"
}
}
},
"NAV-BAR": {
"TITLE": "OpenDMP",