|
@@ -24,6 +24,7 @@ export class AddEventComponent implements OnInit {
|
|
|
bindingDateSplit;
|
|
|
higriDateVal:string;
|
|
|
checkSaveClick:boolean = false;
|
|
|
+ bindingDateSplitEnd: any;
|
|
|
|
|
|
event = {
|
|
|
employee_name: '',
|
|
@@ -34,6 +35,7 @@ export class AddEventComponent implements OnInit {
|
|
|
type: '',
|
|
|
status: '',
|
|
|
time: '',
|
|
|
+ endTime: '',
|
|
|
}
|
|
|
|
|
|
constructor(private dashboard: DashboardService,
|
|
@@ -86,6 +88,12 @@ export class AddEventComponent implements OnInit {
|
|
|
'day': parseInt(higriDate[2])
|
|
|
};
|
|
|
|
|
|
+ this.bindingDateSplitEnd = {
|
|
|
+ year: parseInt(eventData.created_date.split('-')[0]),
|
|
|
+ month: parseInt(eventData.created_date.split('-')[1]),
|
|
|
+ day: parseInt(eventData.created_date.split('-')[2]),
|
|
|
+ }
|
|
|
+
|
|
|
console.log('hhhhhhhhhhhhhhh' , this.bindingDateSplit);
|
|
|
this.spineer.hide();
|
|
|
},
|
|
@@ -101,28 +109,43 @@ export class AddEventComponent implements OnInit {
|
|
|
}
|
|
|
|
|
|
//get value date from child component
|
|
|
- public getDate(date: any):void {
|
|
|
+ public getDate(date: any, type: string):void {
|
|
|
console.log( date);
|
|
|
- this.higriDateVal = date.year + '-' + date.month + '-' + date.day;
|
|
|
- console.log('higrii date', this.higriDateVal);
|
|
|
+ if(type == 'start'){
|
|
|
+ this.higriDateVal = date.year + '-' + date.month + '-' + date.day;
|
|
|
+ console.log('higrii date', this.higriDateVal);
|
|
|
+ } else if(type == 'end') {
|
|
|
+ this.bindingDateSplitEnd = date.year + '-' + date.month + '-' + date.day;
|
|
|
+ console.log('end higrii date', this.bindingDateSplitEnd);
|
|
|
+ } else {
|
|
|
+ console.log('no date !');
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
//submitted form
|
|
|
onSubmitted() {
|
|
|
- this.checkSaveClick = true;
|
|
|
- console.log(this.eventForm.value);
|
|
|
- console.log(this.eventForm.value.time);
|
|
|
- this.eventForm.value['date'] = this.higriDateVal;
|
|
|
- if(this.event.time) {
|
|
|
- this.eventForm.value.event_time = this.eventForm.value.date + ' ' + this.event.time;
|
|
|
+
|
|
|
+ //this.checkSaveClick = true;
|
|
|
+ if(this.higriDateVal) {
|
|
|
+ this.eventForm.value['event_time'] = this.higriDateVal + ' ' + this.event.time;
|
|
|
+ delete this.eventForm.value.time;
|
|
|
}
|
|
|
- console.log(this.eventForm.value.event_time);
|
|
|
- delete this.eventForm.value.time;
|
|
|
- delete this.eventForm.value.date;
|
|
|
+
|
|
|
+ if(this.bindingDateSplitEnd) {
|
|
|
+ this.eventForm.value['event_end_time'] = this.bindingDateSplitEnd + ' ' + this.event.endTime;
|
|
|
+ delete this.eventForm.value.endTime;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
console.log(this.eventForm.value);
|
|
|
if(this.typeMode) {
|
|
|
+ if(!this.higriDateVal){
|
|
|
+ this.toastr.warning('من فضلك أدخل تاريخ الإبتداء !');
|
|
|
+ } else if(!this.bindingDateSplitEnd) {
|
|
|
+ this.toastr.warning('من فضلك أدخل تاريخ الإنتهاء !');
|
|
|
+ } else {
|
|
|
this.dashboard.editItem( this.eventId ,this.eventForm.value , "events").subscribe(
|
|
|
(responce) => {
|
|
|
console.log(responce);
|
|
@@ -143,7 +166,14 @@ export class AddEventComponent implements OnInit {
|
|
|
this.checkSaveClick = false;
|
|
|
}
|
|
|
);
|
|
|
+ }
|
|
|
+
|
|
|
} else {
|
|
|
+ if(!this.higriDateVal){
|
|
|
+ this.toastr.warning('من فضلك أدخل تاريخ الإبتداء !');
|
|
|
+ } else if(!this.bindingDateSplitEnd) {
|
|
|
+ this.toastr.warning('من فضلك أدخل تاريخ الإنتهاء !');
|
|
|
+ } else {
|
|
|
this.dashboard.addItem(this.eventForm.value, "events").subscribe(
|
|
|
(responce) => {
|
|
|
console.log(responce);
|
|
@@ -163,7 +193,8 @@ export class AddEventComponent implements OnInit {
|
|
|
console.log(error);
|
|
|
this.checkSaveClick = false;
|
|
|
}
|
|
|
- );
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|