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