Add delete functionality to events
parent
98b549b955
commit
9b804fbd40
|
|
@ -1,8 +1,10 @@
|
|||
import { Component, AfterContentInit, Input, Inject } from '@angular/core';
|
||||
import { MdDialog, MdDialogConfig } from '@angular/material';
|
||||
import { trigger, state, style, transition, animate } from '@angular/animations';
|
||||
import { EventService } from './../../services/event.service';
|
||||
|
||||
import { SharePopupComponent } from './../popups/share-popup/share-popup.component';
|
||||
import { YesNoPopupComponent } from './../popups/yes-no-popup/yes-no-popup.component';
|
||||
|
||||
import { MONTHS_FULL } from '../../constants/months';
|
||||
|
||||
|
|
@ -69,7 +71,8 @@ export class EventLargeComponent implements AfterContentInit {
|
|||
return "/api2/cim/" + monthName + "/" + this.startDate.getDate();
|
||||
}
|
||||
|
||||
constructor(private dialog: MdDialog){
|
||||
constructor(private dialog: MdDialog,
|
||||
private eventService: EventService){
|
||||
console.log(this.title);
|
||||
|
||||
}
|
||||
|
|
@ -94,7 +97,19 @@ export class EventLargeComponent implements AfterContentInit {
|
|||
}
|
||||
|
||||
delete(){
|
||||
let opts = new MdDialogConfig;
|
||||
opts.data = { title:'Delete','message':'Are you sure you want to delete "' + this.title + '"?' };
|
||||
let dialog = this.dialog.open(YesNoPopupComponent, opts);
|
||||
|
||||
dialog.afterClosed().subscribe(s => {
|
||||
s = s as boolean;
|
||||
if (s === true){
|
||||
this.eventService.deleteEvent(this.id).subscribe(
|
||||
success => { console.log(success); },
|
||||
error => { console.log(error); }
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
export const EVENTS_ADD_URL = "/api2/events/a/";
|
||||
export const EVENT_BY_ID = "/api2/events/";
|
||||
export const EVENTS_BY_PAGE_URL = "/api2/events/page/";
|
||||
export const EVENTS_DELETE_BY_ID_URL = "/api2/events/a/";
|
||||
export const SERMONS_BY_ID = '/api2/sermons/';
|
||||
export const SERMONS_BY_PAGE_URL = '/api2/sermons/page/';
|
||||
export const SERMONS_BY_SEARCH_URL = '/api2/sermons/search';
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ import { Event } from '../interfaces/event';
|
|||
|
||||
import { EVENTS_BY_PAGE_URL,
|
||||
EVENT_BY_ID,
|
||||
EVENTS_ADD_URL } from '../constants/urls';
|
||||
EVENTS_ADD_URL,
|
||||
EVENTS_DELETE_BY_ID_URL } from '../constants/urls';
|
||||
|
||||
@Injectable()
|
||||
export class EventService {
|
||||
|
|
@ -36,6 +37,12 @@ export class EventService {
|
|||
.catch(this.dataError);
|
||||
}
|
||||
|
||||
deleteEvent(eventId: number){
|
||||
return this.http.delete(EVENTS_DELETE_BY_ID_URL,{withCredentials:true,body:{"id":eventId}})
|
||||
.map(d => {return d.json(); })
|
||||
.catch(this.dataError);
|
||||
}
|
||||
|
||||
gotDataSingle(res: Response){
|
||||
let body = res.json();
|
||||
return this.toEvent(body.event);
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ exports.deleteEvent = function(eventIdOrEventObject, callback){
|
|||
callback(error);
|
||||
return;
|
||||
}
|
||||
dbSermons.getEvent(eventIdOrEventObject,function(error,event){
|
||||
dbEvents.getEvent(eventIdOrEventObject,function(error,event){
|
||||
if (error){
|
||||
callback(error);
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in New Issue