|
@@ -260,6 +260,8 @@ export class AddRequestComponent implements OnInit {
|
|
|
for(let i = 0; i < this.departmentsId.length; i++) {
|
|
|
this.addRequestFrom.value['departments_ids'][i] = this.departmentsId[i];
|
|
|
}
|
|
|
+
|
|
|
+ this.checkSaveClick = true;
|
|
|
|
|
|
const editAttachements = [];
|
|
|
|
|
@@ -311,16 +313,22 @@ export class AddRequestComponent implements OnInit {
|
|
|
//edit mode
|
|
|
if(this.departmentsId.length == 0) {
|
|
|
this.toastr.warning('من فضلك ، قم بإختيار قسم كحد أدني !');
|
|
|
+ this.checkSaveClick = false;
|
|
|
} else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['registration_number'] == '') {
|
|
|
this.toastr.warning('قم بإختيار رقم التسجيل !');
|
|
|
+ this.checkSaveClick = false;
|
|
|
} else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['authority_card_number'] == '') {
|
|
|
this.toastr.warning('قم بإختيار رقم البطاقه الهنيه !');
|
|
|
+ this.checkSaveClick = false;
|
|
|
} else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['functional_number'] == '') {
|
|
|
this.toastr.warning('قم بإختيار الرقم الوظيفي!');
|
|
|
+ this.checkSaveClick = false;
|
|
|
} else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['contract_type'] == '') {
|
|
|
this.toastr.warning('قم بإختيار نوع العقد !');
|
|
|
+ this.checkSaveClick = false;
|
|
|
} else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['organization_affiliated_with'] == '') {
|
|
|
this.toastr.warning('الجهه التابع لها المتدرب !');
|
|
|
+ this.checkSaveClick = false;
|
|
|
} else {
|
|
|
//store departments in object save
|
|
|
delete this.addRequestFrom.value['department1'];
|
|
@@ -368,10 +376,12 @@ export class AddRequestComponent implements OnInit {
|
|
|
console.log(error.error['error']);
|
|
|
if(error.error['error'] == 'can not add new request untill old one done') {
|
|
|
this.toastr.warning('لا يمكن التعديل طلب جديد ، حتي يتم إجراءات علي الطلب السابق ، شكراً');
|
|
|
+ this.checkSaveClick = false;
|
|
|
|
|
|
} else {
|
|
|
- this.toastr.error('يوجد مشكله في السرفر ، سيتم معالجتها لاحقاً');
|
|
|
+ this.toastr.error('يوجد مشكله في الحفظ ، سيتم معالجتها لاحقاً');
|
|
|
this.location.back();
|
|
|
+ this.checkSaveClick = false;
|
|
|
}
|
|
|
}
|
|
|
);
|
|
@@ -382,40 +392,48 @@ export class AddRequestComponent implements OnInit {
|
|
|
//add mode
|
|
|
if(this.departmentsId.length == 0) {
|
|
|
this.toastr.warning('من فضلك ، قم بإختيار قسم كحد أدني !');
|
|
|
+ this.checkSaveClick = false;
|
|
|
} else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['registration_number'] == '') {
|
|
|
this.toastr.warning('قم بإختيار رقم التسجيل !');
|
|
|
+ this.checkSaveClick = false;
|
|
|
} else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['authority_card_number'] == '') {
|
|
|
this.toastr.warning('قم بإختيار رقم البطاقه الهنيه !');
|
|
|
+ this.checkSaveClick = false;
|
|
|
} else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['functional_number'] == '') {
|
|
|
this.toastr.warning('قم بإختيار الرقم الوظيفي!');
|
|
|
+ this.checkSaveClick = false;
|
|
|
} else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['contract_type'] == '') {
|
|
|
this.toastr.warning('قم بإختيار نوع العقد !');
|
|
|
+ this.checkSaveClick = false;
|
|
|
} else if(this.addRequestFrom.value['type'] == 'fellowship' && this.addRequestFrom.value['organization_affiliated_with'] == '') {
|
|
|
this.toastr.warning('الجهه التابع لها المتدرب !');
|
|
|
+ this.checkSaveClick = false;
|
|
|
} else {
|
|
|
|
|
|
//store departments in object save
|
|
|
- delete this.addRequestFrom.value['department1'];
|
|
|
- delete this.addRequestFrom.value['department2'];
|
|
|
- delete this.addRequestFrom.value['department3'];
|
|
|
- console.log('successsss save ' , this.addRequestFrom.value);
|
|
|
- this.dashBoardSer.addItem(this.addRequestFrom.value,'request').subscribe(
|
|
|
- (responce) => {
|
|
|
- console.log(responce);
|
|
|
- this.toastr.success('تم الإضافه بنحاج');
|
|
|
- this.addRequestFrom.reset();
|
|
|
- this.location.back();
|
|
|
- },
|
|
|
- (error) => {
|
|
|
- console.log(error);
|
|
|
- console.log(error.error['error']);
|
|
|
- if(error.error['error'] == 'can not add new request untill old one done') {
|
|
|
- this.toastr.warning('لا يمكن إضافه طلب جديد ، حتي يتم إجراءات علي الطلب السابق ، شكراً');
|
|
|
- } else {
|
|
|
- this.toastr.error('يوجد مشكله في السرفر ، سيتم معالجتها لاحقاً');
|
|
|
- }
|
|
|
+ delete this.addRequestFrom.value['department1'];
|
|
|
+ delete this.addRequestFrom.value['department2'];
|
|
|
+ delete this.addRequestFrom.value['department3'];
|
|
|
+ console.log('successsss save ' , this.addRequestFrom.value);
|
|
|
+ this.dashBoardSer.addItem(this.addRequestFrom.value,'request').subscribe(
|
|
|
+ (responce) => {
|
|
|
+ console.log(responce);
|
|
|
+ this.toastr.success('تم الإضافه بنحاج');
|
|
|
+ this.addRequestFrom.reset();
|
|
|
+ this.location.back();
|
|
|
+ },
|
|
|
+ (error) => {
|
|
|
+ console.log(error);
|
|
|
+ console.log(error.error['error']);
|
|
|
+ if(error.error['error'] == 'can not add new request untill old one done') {
|
|
|
+ this.toastr.warning('لا يمكن إضافه طلب جديد ، حتي يتم إجراءات علي الطلب السابق ، شكراً');
|
|
|
+ this.checkSaveClick = false;
|
|
|
+ } else {
|
|
|
+ this.toastr.error('يوجد مشكله في الحفظ ، سيتم معالجتها لاحقاً');
|
|
|
+ this.checkSaveClick = false;
|
|
|
}
|
|
|
- );
|
|
|
+ }
|
|
|
+ );
|
|
|
}
|
|
|
}
|
|
|
|