PresetSaveUnderDialog created
parent
5c06b48808
commit
e54678bf48
|
|
@ -38,6 +38,7 @@ import {MomentDateModule} from '@angular/material-moment-adapter';
|
|||
import {PlanTimeBarComponent} from './plan-time-bar/plan-time-bar.component';
|
||||
import { RenamePresetDialogComponent } from './rename-preset-dialog/rename-preset-dialog.component';
|
||||
import { DeletePresetDialogComponent } from './delete-preset-dialog/delete-preset-dialog.component';
|
||||
import { SavePresetUnderDialogComponent } from './save-preset-under-dialog/save-preset-under-dialog.component';
|
||||
|
||||
|
||||
@NgModule({
|
||||
|
|
@ -50,7 +51,8 @@ import { DeletePresetDialogComponent } from './delete-preset-dialog/delete-prese
|
|||
FilterDialogComponent,
|
||||
PlanTimeBarComponent,
|
||||
RenamePresetDialogComponent,
|
||||
DeletePresetDialogComponent
|
||||
DeletePresetDialogComponent,
|
||||
SavePresetUnderDialogComponent
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ export class DataService {
|
|||
let user = [];
|
||||
let admin = [];
|
||||
for (const preset of res.presets) {
|
||||
if(preset.presetType == "Sysdemdefault"){
|
||||
if(preset.presetType == "System"){
|
||||
system.push(preset);
|
||||
}else{
|
||||
user.push(preset);
|
||||
|
|
@ -187,7 +187,7 @@ export class DataService {
|
|||
}
|
||||
presetGroups = [
|
||||
{
|
||||
name: 'Sysdemdefault',
|
||||
name: 'System',
|
||||
presets: system,
|
||||
},
|
||||
{
|
||||
|
|
@ -253,6 +253,7 @@ export class DataService {
|
|||
* @param change the Change (the Resource) from which the date should be changed
|
||||
*/
|
||||
public async updatePreset(preset: any){
|
||||
console.log(preset);
|
||||
const promise = new Promise(resolve=>{
|
||||
let serializableResource = {id: preset.id, definition: JSON.stringify(preset.definition)};
|
||||
let strigifiedResource = JSON.stringify(serializableResource);
|
||||
|
|
|
|||
|
|
@ -51,8 +51,8 @@
|
|||
</mat-optgroup>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<button mat-basic-button class="editButton" (click)="openRenameDialog()" color="" style="" ><mat-icon>edit</mat-icon></button>
|
||||
<button mat-basic-button class="deleteButton" (click)="openDeleteDialog()" color="" style="" ><mat-icon>delete_forever</mat-icon></button>
|
||||
<button mat-basic-button *ngIf="isUserPreset" class="editButton" (click)="openRenameDialog()" color="" style="" ><mat-icon>edit</mat-icon></button>
|
||||
<button mat-basic-button *ngIf="isUserPreset" class="deleteButton" (click)="openDeleteDialog()" color="" style="" ><mat-icon>delete_forever</mat-icon></button>
|
||||
</div>
|
||||
|
||||
<div class="filterContainer">
|
||||
|
|
@ -60,7 +60,7 @@
|
|||
{{languageService.lMap.get('nttGanttFilterButton')}} <mat-icon style="color: #00a79d;">filter_alt</mat-icon>
|
||||
</button>
|
||||
<button *ngIf="showSaveButton" mat-raised-button (click)="updatePreset()">Speichern</button>
|
||||
<button *ngIf="showSaveUnderButton" mat-raised-button >Speichern unter</button>
|
||||
<button *ngIf="showSaveUnderButton" mat-raised-button (click)="openSaveUnderDialog()" >Speichern unter</button>
|
||||
<button [disabled]="!filterEnabled" mat-icon-button aria-label="clear Filters and Sort" class="clearFilter" (click)="clearFilter()">
|
||||
{{languageService.lMap.get('clearFilter')}} <mat-icon>close</mat-icon>
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import { MatSnackBar, MatSnackBarHorizontalPosition, MatSnackBarVerticalPosition
|
|||
import { MAT_DATE_FORMATS } from '@angular/material/core';
|
||||
import { RenamePresetDialogComponent } from '../rename-preset-dialog/rename-preset-dialog.component';
|
||||
import { DeletePresetDialogComponent } from '../delete-preset-dialog/delete-preset-dialog.component';
|
||||
import { SavePresetUnderDialogComponent } from '../save-preset-under-dialog/save-preset-under-dialog.component';
|
||||
|
||||
export const MY_DATE_FORMATS = {
|
||||
parse: {
|
||||
|
|
@ -161,6 +162,7 @@ export class NttGanttComponent implements OnInit {
|
|||
public userPreferences: {language:'', showDetails: false, view: ''};
|
||||
public showSaveButton: boolean = false;
|
||||
public showSaveUnderButton: boolean = false;
|
||||
public isUserPreset: boolean = false;
|
||||
|
||||
|
||||
/**###################################################################### Initial Loading functions ######################################################################*/
|
||||
|
|
@ -269,6 +271,12 @@ export class NttGanttComponent implements OnInit {
|
|||
public selectPreset(event: any){
|
||||
this.showSaveButton = false;
|
||||
this.showSaveUnderButton = false;
|
||||
|
||||
if(event.value.presetType == 'System' || event.value.presetType == 'Admin'){
|
||||
this.isUserPreset = false;
|
||||
}else{
|
||||
this.isUserPreset = true;
|
||||
}
|
||||
console.log(event);
|
||||
this.dataService.selectPreset(event.value).then((res)=>{
|
||||
this.refreshGanttwithPresets();
|
||||
|
|
@ -331,6 +339,19 @@ export class NttGanttComponent implements OnInit {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The function openFilterDialog triggers the opening of the filterDialog, recieves the results of the filterDialog and refrehses the gantt chart.
|
||||
* This function is triggered by the filter button.
|
||||
*/
|
||||
public openSaveUnderDialog(){
|
||||
console.log(this.filters);
|
||||
let dialogRef = SavePresetUnderDialogComponent;
|
||||
this.matDialog.open(dialogRef,
|
||||
{data : [{preset: this.selectedPreset, definition: this.filters}], width: '20%', maxWidth: '800px'}).afterClosed().subscribe((res)=>{
|
||||
this.refreshGanttwithPresets();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The function openFilterDialog triggers the opening of the filterDialog, recieves the results of the filterDialog and refrehses the gantt chart.
|
||||
* This function is triggered by the filter button.
|
||||
|
|
@ -351,6 +372,13 @@ export class NttGanttComponent implements OnInit {
|
|||
this.dataService.initPresets().then((res: any)=>{
|
||||
this.presets = res.presets;
|
||||
this.selectedPreset = res.selectedPreset;
|
||||
if(this.selectedPreset.presetType == 'User' ){
|
||||
this.isUserPreset = true;
|
||||
}else{
|
||||
this.isUserPreset = false;
|
||||
}
|
||||
|
||||
|
||||
this.presetGroups = res.presetGroups;
|
||||
this.filters = this.selectedPreset.definition;
|
||||
this.filterEnabled = true;
|
||||
|
|
@ -432,6 +460,16 @@ export class NttGanttComponent implements OnInit {
|
|||
this.sort = null;
|
||||
this.sortEnabled = false;
|
||||
this.refreshData();
|
||||
if(this.filters !== this.selectedPreset.definition){
|
||||
if(this.isUserPreset){
|
||||
this.showSaveButton = true;
|
||||
this.showSaveUnderButton = false;
|
||||
}else{
|
||||
this.showSaveButton = false;
|
||||
this.showSaveUnderButton = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/**
|
||||
* The function mapRequestJSON maps the requestObject for the refreshData function, it evaluates if filters or sort parameters are set.
|
||||
|
|
@ -489,9 +527,11 @@ export class NttGanttComponent implements OnInit {
|
|||
// console.log(res);
|
||||
// });
|
||||
if(this.filters !== this.selectedPreset.definition){
|
||||
if(this.selectedPreset.presetType == 'Admin'){
|
||||
if(this.isUserPreset){
|
||||
this.showSaveButton = true;
|
||||
this.showSaveUnderButton = false;
|
||||
}else{
|
||||
this.showSaveButton = false;
|
||||
this.showSaveUnderButton = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
<h2 style="font-family: Roboto;">Als neues Preset speichern?</h2>
|
||||
<mat-form-field class="example-full-width">
|
||||
<mat-label>Preset Name</mat-label>
|
||||
<input matInput [(ngModel)]="newName">
|
||||
</mat-form-field>
|
||||
<mat-dialog-actions align="end">
|
||||
<button mat-raised-button style="margin-right: 3px;" matDialogClose>Abbrechen</button>
|
||||
<button mat-raised-button color = "primary" style="margin-left: 3px;" (click)="savePreset()" matDialogClose>Umbenennen</button>
|
||||
</mat-dialog-actions>
|
||||
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { SavePresetUnderDialogComponent } from './save-preset-under-dialog.component';
|
||||
|
||||
describe('SavePresetUnderDialogComponent', () => {
|
||||
let component: SavePresetUnderDialogComponent;
|
||||
let fixture: ComponentFixture<SavePresetUnderDialogComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ SavePresetUnderDialogComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(SavePresetUnderDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { LanguageService } from '../language.service';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { RenamePresetDialogComponent } from '../rename-preset-dialog/rename-preset-dialog.component';
|
||||
import { DataService } from '../data.service';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
|
||||
@Component({
|
||||
selector: 'app-save-preset-under-dialog',
|
||||
templateUrl: './save-preset-under-dialog.component.html',
|
||||
styleUrls: ['./save-preset-under-dialog.component.css']
|
||||
})
|
||||
export class SavePresetUnderDialogComponent implements OnInit {
|
||||
public preset;
|
||||
public newName: string;
|
||||
public definition: any;
|
||||
|
||||
constructor(public languageService: LanguageService, public dialogRef: MatDialogRef<RenamePresetDialogComponent>, @Inject(MAT_DIALOG_DATA) public data: any, private dataService: DataService, private _snackBar: MatSnackBar) {
|
||||
this.preset = data[0].preset;
|
||||
this.newName = 'Copy of ' + this.preset.name;
|
||||
this.definition = data[0].definition;
|
||||
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
public savePreset(){
|
||||
this.dataService.savePreset({name: this.newName, definition: this.definition});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>SyncfusionGantt</title>
|
||||
<title>Change Calender</title>
|
||||
<base href="/">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||
|
|
|
|||
Loading…
Reference in New Issue