add calendar dashboard edit
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<h2 class="text-2xl">
|
||||
@if (mode() == 'cancel') {
|
||||
Esemény lemondása
|
||||
} @else {
|
||||
Esemény aktiválása
|
||||
}
|
||||
</h2>
|
||||
<app-single-event-dashboard-event-details-view [event]="event()"></app-single-event-dashboard-event-details-view>
|
||||
<div class="flex gap-2 mt-3">
|
||||
|
||||
@if (mode() == 'cancel') {
|
||||
<rs-daisy-button variant="error" (click)="cancelEventOccurrence()">
|
||||
<span [outerHTML]="SvgIcons.heroTrash | safeHtml"></span>
|
||||
Lemondás
|
||||
</rs-daisy-button>
|
||||
}
|
||||
@if (mode() == 'activate') {
|
||||
<rs-daisy-button variant="error" (click)="activateEventOccurrence()">
|
||||
<span [outerHTML]="SvgIcons.heroTrash | safeHtml"></span>
|
||||
Aktiválás
|
||||
</rs-daisy-button>
|
||||
}
|
||||
<rs-daisy-button variant="primary" (click)="closeDialog()">
|
||||
<span [outerHTML]="SvgIcons.heroXcircle | safeHtml"></span>
|
||||
Mégsem
|
||||
</rs-daisy-button>
|
||||
</div>
|
||||
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { SingleEventDashboardEventActivation } from './single-event-dashboard-event-activation.component';
|
||||
|
||||
describe('SingleEventDashboardEventCancel', () => {
|
||||
let component: SingleEventDashboardEventActivation;
|
||||
let fixture: ComponentFixture<SingleEventDashboardEventActivation>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [SingleEventDashboardEventActivation]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(SingleEventDashboardEventActivation);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,63 @@
|
||||
import { Component, inject, input } from '@angular/core';
|
||||
import { CalendarEventDto } from '../../../models/events-in-range-dto.model';
|
||||
import {
|
||||
SingleEventDashboardEventDetailsView
|
||||
} from '../single-event-dashboard-event-details-view/single-event-dashboard-event-details-view';
|
||||
import { Button } from '@rschneider/ng-daisyui';
|
||||
import { SvgIcons } from '../../../../../svg-icons';
|
||||
import { SafeHtmlPipe } from '../../../../../pipes/safe-html-pipe';
|
||||
import { CalendarService } from '../../../services/calendar.service';
|
||||
|
||||
export type ACTIVATION_TYPE = 'cancel' | 'activate';
|
||||
|
||||
@Component({
|
||||
selector: 'app-single-event-dashboard-event-cancel',
|
||||
imports: [
|
||||
SingleEventDashboardEventDetailsView,
|
||||
Button,
|
||||
SafeHtmlPipe,
|
||||
],
|
||||
templateUrl: './single-event-dashboard-event-activation.component.html',
|
||||
styleUrl: './single-event-dashboard-event-activation.component.css',
|
||||
})
|
||||
export class SingleEventDashboardEventActivation {
|
||||
|
||||
mode = input<ACTIVATION_TYPE>('cancel');
|
||||
calendarService = inject(CalendarService);
|
||||
event = input<CalendarEventDto>();
|
||||
onAction = input.required<(msg: string) => void>();
|
||||
|
||||
protected readonly SvgIcons = SvgIcons;
|
||||
|
||||
|
||||
protected setEventOccurrenceActivation(activated: boolean) {
|
||||
|
||||
const eventId =this.event()?.id!;
|
||||
const startTime = this.event()?.startTime!;
|
||||
|
||||
this.calendarService.applyException(eventId,{
|
||||
originalStartTime: new Date(startTime),
|
||||
isCancelled: !activated,
|
||||
}).subscribe(
|
||||
{
|
||||
next: () => {
|
||||
this.onAction()('close');
|
||||
},
|
||||
error: err => {
|
||||
alert("Failed to change event");
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
protected cancelEventOccurrence() {
|
||||
this.setEventOccurrenceActivation(false);
|
||||
}
|
||||
protected activateEventOccurrence() {
|
||||
this.setEventOccurrenceActivation(true);
|
||||
}
|
||||
protected closeDialog() {
|
||||
this.onAction()('close')
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user