Initial commit
This commit is contained in:
51
src/app/admin-view/menu-new/menu-add/menu-add.component.ts
Normal file
51
src/app/admin-view/menu-new/menu-add/menu-add.component.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { MenuUploadComponent } from '../menu-upload/menu-upload.component';
|
||||
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
|
||||
import { FDSelection, weekendFilter } from 'src/app/fd.da';
|
||||
import { FormControl, FormGroup } from '@angular/forms';
|
||||
import { Moment } from 'moment';
|
||||
import { MAT_DATE_RANGE_SELECTION_STRATEGY } from '@angular/material/datepicker';
|
||||
import * as moment from 'moment';
|
||||
|
||||
@Component({
|
||||
selector: 'app-menu-add',
|
||||
templateUrl: './menu-add.component.html',
|
||||
styleUrl: './menu-add.component.scss',
|
||||
providers: [
|
||||
{provide: MAT_DATE_RANGE_SELECTION_STRATEGY, useClass: FDSelection}
|
||||
]
|
||||
})
|
||||
export class MenuAddComponent {
|
||||
type: string | undefined;
|
||||
filter = weekendFilter
|
||||
|
||||
day: Moment = moment.utc();
|
||||
|
||||
range = new FormGroup({
|
||||
start: new FormControl<Moment|null>(null),
|
||||
end: new FormControl<Moment|null>(null),
|
||||
})
|
||||
|
||||
constructor (public dialogRef: MatDialogRef<MenuAddComponent>, private dialog: MatDialog) { }
|
||||
|
||||
submit() {
|
||||
switch (this.type) {
|
||||
case "day":
|
||||
this.dialogRef.close({type: "day", value: this.day.utc()})
|
||||
break;
|
||||
case "week":
|
||||
this.dialogRef.close({type: "week", value: {start: this.range.value.start?.utc().hours(24), count: 5}})
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
activateUpload() {
|
||||
this.dialog.open(MenuUploadComponent).afterClosed().subscribe((data) => {
|
||||
if (data) {
|
||||
this.dialogRef.close({type: "file", ...data});
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user