Amr 5 years ago
parent
commit
239d94267a

+ 4 - 4
src/app/dashboard/view_my_female_requests/view-my-female-requests-add/view-my-female-requests-add.component.html

@@ -155,21 +155,21 @@
                               <thead class="headBackground-w">
                                 <tr>
                                   <th> إسم المرفق</th>
-                                  <th *ngIf="!isAdmin || !tookDes">رفع الملف ( بصيغه pdf )</th>
+                                  <th *ngIf="!isAdmin || tookDes">رفع الملف ( بصيغه pdf )</th>
                                   <th *ngIf="isAdmin || tookDes">عرض الملف</th>
                                   <th *ngIf="!isAdmin || !tookDes">حذف</th>
                                 </tr>
                               </thead>
                               <tbody>
                                 <tr style="text-align:center;" *ngFor="let file of files; let i = index">
-                                    <td><input type="text" class="form-control" placeholder="إسم الملف" [(ngModel)]="file.title"[ngModelOptions]="{standalone: true}" [disabled]="!isAdmin || !tookDes" required/></td>
-                                    <td style="position: relative;" *ngIf="!isAdmin || !tookDes">
+                                    <td><input type="text" class="form-control" placeholder="إسم الملف" [(ngModel)]="file.title"[ngModelOptions]="{standalone: true}" [disabled]="" required/></td>
+                                    <td style="position: relative;" *ngIf="!isAdmin || tookDes">
                                         <input type="file" name="file{{i}}" id="file{{i}}" class="inputfile" alife-file-to-base64 (onFileChanged)="onFileChanges($event,i)" required/>
                                         <label for="file{{i}}" class="iconUpload-w"><i class="fas fa-upload"></i></label>
                                         <span class="fileName-w" *ngIf="file.nameFile" style="color:green"> <i class='fas fa-check'style=" float: left; padding-top: 4px; "></i>
                                         </span>
                                       </td>
-                                      <td *ngIf="isAdmin || tookDes"><a href="{{authSer.pathImg + file.nameFile}}" target="_blank"><i class="fas fa-download"></i></a></td>
+                                      <td *ngIf="isAdmin || tookDes"><a href="{{authSer.pathImg + file.file}}" target="_blank"><i class="fas fa-download"></i></a></td>
                                       <td *ngIf="!isAdmin || !tookDes"><button type="button" class="btn btn-danger form-control deleteRow-w" (click)="onDeleteRow(i)">حذف</button></td>
                                     </tr>
                                   </tbody>

+ 18 - 2
src/app/dashboard/view_my_female_requests/view-my-female-requests-add/view-my-female-requests-add.component.ts

@@ -217,8 +217,8 @@ export class ViewMyFemaleRequestsAddComponent implements OnInit {
           console.log(this.unitInformation.housing_complex_id );
           this.getBuildingType(this.unitInformation.housing_complex_id);
           this.unitInformation.building_type_id = unitInfo.building_type_id;
-          this.getBuilding(this.unitInformation.building_type_id);
           this.unitInformation.building_id = unitInfo.building_id;
+          this.getBuilding(this.unitInformation.building_type_id);
           this.unitInformation.unit_id = unitInfo.unit_id;
 
       },
@@ -404,7 +404,23 @@ getUnit(event){
   
     
     this.disable = true;
-    
+    if(this.addNew){
+      for (let i = 0; i < this.files.length; i++) {
+        if(this.files[i].file_type){
+          this.files[i].file_type = this.files[i].file_type.toLowerCase();
+        }
+        if(!this.files[i].file){
+          this.files.splice(i , 1);
+        }
+       else  if(!this.files[i].title){
+        this.toastr.warning('ادخل عنوان الملف رقم ' + (i+1) );
+        return 0;
+       } else {
+         delete this.files[i].nameFile;
+          this.formData.files.push(this.files[i]);
+        }
+      }
+    }
   if(this.isAdmin){
   
     console.log(this.adminForm);