|
@@ -36,6 +36,7 @@ export class LinkUnitToCovenantsAddComponent implements OnInit {
|
|
|
covenants = [];
|
|
|
final = [] ;
|
|
|
over : boolean = false;
|
|
|
+ unitId = '';
|
|
|
constructor(
|
|
|
private dashBoardSer: DashboardService,
|
|
|
private toastr: ToastrService,
|
|
@@ -109,25 +110,25 @@ export class LinkUnitToCovenantsAddComponent implements OnInit {
|
|
|
this.formData.housing_complex_id = res['unit'].housing_complex_id;
|
|
|
this.getBuildingType( this.formData.housing_complex_id);
|
|
|
this.formData.building_type_id = res['unit'].building_type_id;
|
|
|
+ this.unitId = res['unit'].id;
|
|
|
+
|
|
|
this.getBuilding(this.formData.building_type_id);
|
|
|
this.formData.building_id = res['unit'].building_id;
|
|
|
- // this.getUnit( this.formData.building_id);
|
|
|
- this.formData.unit_id = res['unit'].unit_id;
|
|
|
this.covenant(this.formData.covenants[0].category_id);
|
|
|
this.covenants = res['unit'].covenants;
|
|
|
console.log('conv form',this.formData.covenants);
|
|
|
console.log('conv', this.covenants);
|
|
|
-
|
|
|
- for (let i = 0 , n = this.formData.covenants.length; i < n; i++) {
|
|
|
- const arr= this.formData.covenants[i].covenants_data;
|
|
|
- for (let ii = 0, k = arr.length; ii < k; ii++) {
|
|
|
+
|
|
|
+ for (let i = 0 , n = this.formData.covenants.length; i < n; i++) {
|
|
|
+ const arr= this.formData.covenants[i].covenants_data;
|
|
|
+ for (let ii = 0, k = arr.length; ii < k; ii++) {
|
|
|
for (let j = 0 , m = this.covenants.length; j < m; j++) {
|
|
|
if(arr[ii].id == this.covenants[j].covenant_id){
|
|
|
arr[ii].selected = true;
|
|
|
arr[ii].covenant_amount = this.covenants[j].covenant_amount;
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
@@ -201,6 +202,8 @@ export class LinkUnitToCovenantsAddComponent implements OnInit {
|
|
|
}
|
|
|
|
|
|
getUnit(event){
|
|
|
+ console.log('unit id >>' , this.unitId);
|
|
|
+
|
|
|
this.http.get(this.authSer.pathApi + '/units_list_by_building_id/' + event ).subscribe(
|
|
|
res => {
|
|
|
console.log(res);
|
|
@@ -209,6 +212,7 @@ getUnit(event){
|
|
|
this.isBuilding = true;
|
|
|
console.log(this.units);
|
|
|
|
|
|
+
|
|
|
}else{
|
|
|
this.isBuilding = false;
|
|
|
}
|
|
@@ -219,6 +223,14 @@ getUnit(event){
|
|
|
|
|
|
}
|
|
|
);
|
|
|
+ this.formData.unit_id = this.unitId;
|
|
|
+ console.log('dffd',this.formData.unit_id);
|
|
|
+ if (this.editPageId) {
|
|
|
+ this.showcovenant_categories()
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
covenant(event){
|
|
@@ -239,16 +251,17 @@ getUnit(event){
|
|
|
|
|
|
//final finalCov array to add categories in covenants
|
|
|
for(let j = 0 , n = this.formData.covenants[i].covenants_data.length; j < n; j++) {
|
|
|
+
|
|
|
if(event == this.formData.covenants[i].covenants_data[j].id ){
|
|
|
|
|
|
this.formData.covenants[i].covenants_data[j].covenant_amount = 1
|
|
|
-
|
|
|
-
|
|
|
- // if(this.formData.covenants[i].covenants_data[j].selected == false){
|
|
|
- // this.formData.covenants[i].covenants_data[j].covenant_amount = 1
|
|
|
- // }else{
|
|
|
- // this.formData.covenants[i].covenants_data[j].covenant_amount = 0
|
|
|
- // }
|
|
|
+ if(this.formData.covenants[i].covenants_data[j].selected == false){
|
|
|
+ this.formData.covenants[i].covenants_data[j].covenant_amount = 1
|
|
|
+ }else{
|
|
|
+ this.formData.covenants[i].covenants_data[j].covenant_amount = 0
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|