no message

This commit is contained in:
Diamantis Tziotzios 2017-12-18 17:53:17 +02:00
parent 0fdf82728b
commit 1f9d07885f
5 changed files with 68 additions and 36 deletions

View File

@ -2,7 +2,7 @@
<form *ngIf="formGroup" (ngSubmit)="formSubmit()" [formGroup]="formGroup">
<mat-card>
<mat-card-title *ngIf="isNew">{{'PROJECT-EDITOR.TITLE.NEW' | translate}}</mat-card-title>
<mat-card-title *ngIf="!isNew">{{'PROJECT-EDITOR.TITLE.EDIT' | translate}} {{project.label}}</mat-card-title>
<mat-card-title *ngIf="!isNew">{{formGroup.get('label').value}}</mat-card-title>
<mat-card-content>
<mat-form-field>
@ -51,7 +51,8 @@
</table>
<mat-form-field class="full-width">
<textarea matInput class="description-area" placeholder="{{'PROJECT-EDITOR.FIELDS.DESCRIPTION' | translate}}" formControlName="description" required></textarea>
<textarea matInput class="description-area" placeholder="{{'PROJECT-EDITOR.FIELDS.DESCRIPTION' | translate}}" formControlName="description"
required></textarea>
<mat-error *ngIf="formGroup.get('description').errors?.backendError">{{errorModel.description}}</mat-error>
<mat-error *ngIf="formGroup.get('description').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
@ -59,7 +60,7 @@
<div layout="row" class="full-width text-right" align="end">
<button mat-raised-button color="primary" (click)="cancel()" type="button">{{'PROJECT-EDITOR.ACTIONS.CANCEL' | translate}}</button>
<button mat-raised-button color="primary" type="submit">{{'PROJECT-EDITOR.ACTIONS.SAVE' | translate}}</button>
<button *ngIf="!isNew" mat-raised-button color="primary" type="submit" (click)="delete()">{{'PROJECT-EDITOR.ACTIONS.DELETE' | translate}}</button>
<button *ngIf="!isNew" mat-raised-button color="primary" type="button" (click)="delete()">{{'PROJECT-EDITOR.ACTIONS.DELETE' | translate}}</button>
</div>
</mat-card-content>

View File

@ -11,6 +11,7 @@ import { JsonSerializer } from "../../utilities/JsonSerializer";
import { FormGroup } from "@angular/forms";
import { SnackBarNotificationComponent } from "../../shared/components/notificaiton/snack-bar-notification.component";
import { BaseErrorModel } from "../../models/error/BaseErrorModel";
import { TdDialogService } from "@covalent/core";
@ -32,7 +33,8 @@ export class ProjectEditorComponent implements AfterViewInit {
private route: ActivatedRoute,
public snackBar: MatSnackBar,
public router: Router,
public language: TranslateService
public language: TranslateService,
private dialogService: TdDialogService
) {
}
@ -97,4 +99,22 @@ export class ProjectEditorComponent implements AfterViewInit {
public cancel(): void {
this.router.navigate(['/projects']);
}
public delete(): void {
this.language.get('GENERAL.DELETE-CONFIRMATION').subscribe((messages: any) => {
this.dialogService.openConfirm({
message: messages.MESSAGE,
title: messages.TITLE,
cancelButton: messages.NEGATIVE,
acceptButton: messages.POSITIVE
}).afterClosed().subscribe((accept: boolean) => {
if (accept) {
this.projectService.inactivate(this.project.id).subscribe(
complete => { this.router.navigate(['/projects']); },
error => this.onCallbackError(error)
);
}
});
});
}
}

View File

@ -37,4 +37,8 @@ export class ProjectService {
createProject(projectModel: ProjectModel): Observable<ProjectModel> {
return this.http.post<ProjectModel>(this.actionUrl + 'createOrUpdate', projectModel, { headers: this.headers });
}
inactivate(id: String): Observable<ProjectModel> {
return this.http.delete<ProjectModel>(this.actionUrl + 'inactivate' + id, { headers: this.headers });
}
}

View File

@ -27,7 +27,7 @@ import {
} from '@angular/material';
import { CdkTableModule } from '@angular/cdk/table';
import { SnackBarNotificationComponent } from '../components/notificaiton/snack-bar-notification.component';
import { CovalentLayoutModule, CovalentChipsModule } from '@covalent/core';
import { CovalentLayoutModule, CovalentChipsModule, CovalentDialogsModule } from '@covalent/core';
@NgModule({
imports: [
@ -59,7 +59,8 @@ import { CovalentLayoutModule, CovalentChipsModule } from '@covalent/core';
MatCheckboxModule,
MatTabsModule,
CovalentLayoutModule,
CovalentChipsModule
CovalentChipsModule,
CovalentDialogsModule
],
providers: [

View File

@ -2,6 +2,12 @@
"GENERAL": {
"VALIDATION": {
"REQUIRED": "Required"
},
"DELETE-CONFIRMATION": {
"TITLE": "Warning",
"MESSAGE": "Are you sure you want to delete this item?",
"POSITIVE": "Yes",
"NEGATIVE": "Cancel"
}
},
"NAV-BAR": {