improve exception saving
This commit is contained in:
@@ -57,7 +57,7 @@ export class SingleEventDashboardEventActivation {
|
||||
this.calendarService.applyException(eventId, payload ).subscribe(
|
||||
{
|
||||
next: () => {
|
||||
this.onAction()('close');
|
||||
this.onAction()('save-event-success');
|
||||
},
|
||||
error: err => {
|
||||
alert('Failed to change event');
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
}
|
||||
|
||||
<div class="flex gap-2 mt-3">
|
||||
<rs-daisy-button variant="error">
|
||||
<rs-daisy-button variant="error" (click)="doDelete()">
|
||||
<span [outerHTML]="SvgIcons.heroTrash | safeHtml"></span>
|
||||
Törlés
|
||||
</rs-daisy-button>
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { Component, effect, input, output } from '@angular/core';
|
||||
import { Component, effect, inject, input, output } from '@angular/core';
|
||||
import { CalendarEventDto } from '../../../models/events-in-range-dto.model';
|
||||
import { DetailView, DetailViewConfig } from '../../../../../components/detail-view/detail-view';
|
||||
import { SvgIcons } from '../../../../../svg-icons';
|
||||
import { SafeHtmlPipe } from '../../../../../pipes/safe-html-pipe';
|
||||
import { Button } from '@rschneider/ng-daisyui';
|
||||
import { CalendarService } from '../../../services/calendar.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-single-event-dashboard-event-delete',
|
||||
@@ -18,6 +19,7 @@ import { Button } from '@rschneider/ng-daisyui';
|
||||
})
|
||||
export class SingleEventDashboardEventDelete {
|
||||
|
||||
calendarService = inject(CalendarService);
|
||||
event = input<CalendarEventDto>();
|
||||
// Define an input that expects a function
|
||||
onAction = input.required<(msg: string) => void>();
|
||||
@@ -59,6 +61,16 @@ export class SingleEventDashboardEventDelete {
|
||||
this.onAction()('close');
|
||||
}
|
||||
|
||||
doDelete() {
|
||||
this.calendarService.deleteEvent(this.event()!.id).subscribe(
|
||||
{
|
||||
next: ( ) => {
|
||||
this.onAction()('save-event-success');
|
||||
}
|
||||
}
|
||||
)
|
||||
// Call the function passed from the parent
|
||||
}
|
||||
|
||||
protected readonly SvgIcons = SvgIcons;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ export class SingleEventDashboardEventEdit {
|
||||
* proxy to ready event from form to parent
|
||||
*/
|
||||
protected triggerAction(action: string) {
|
||||
console.info("event details dashboard", action)
|
||||
this.onAction()(action)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,17 +9,18 @@ import { CreateExceptionDto } from '../models/event-exception.model';
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class CalendarService {
|
||||
private readonly apiUrl: string;
|
||||
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private configService: ConfigurationService
|
||||
private configService: ConfigurationService,
|
||||
) {
|
||||
this.apiUrl = `${this.configService.getApiUrl()}/calendar`;
|
||||
}
|
||||
|
||||
/**
|
||||
* get events in range
|
||||
*/
|
||||
@@ -44,4 +45,9 @@ export class CalendarService {
|
||||
public applyException(eventId: number, eventException: CreateExceptionDto) {
|
||||
return this.http.post(this.apiUrl + `/events/${eventId}/exceptions`, eventException);
|
||||
}
|
||||
|
||||
public deleteEvent(id: number): Observable<void> {
|
||||
return this.http.delete<void>(this.apiUrl + '/events/' + id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user