Merge changes

This commit is contained in:
venbatechnologies@gmail.com 2019-10-04 21:32:14 +05:30
commit b91246ddd2
2 changed files with 74 additions and 65 deletions

View File

@ -8,29 +8,29 @@
<form [formGroup]="Contribute">
<div fxLayout="row" fxLayoutAlign="start center" class="mb-2 pt-1">
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" style="width: 100%;">
<mat-select placeholder="Select District" formControlName="district_id" (selectionChange)="changeFilterOption($event.value,'district')">
<mat-select placeholder="Select District" formControlName="district_id" (selectionChange)="getFilterValue($event.value,'school')">
<mat-option *ngFor="let item of district" [value]="item.district_id" >
{{ item.district_name }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field dividerColor="accent" class="ml-xs mr-xs" style="width: 100%;">
<mat-select placeholder="Select Schools" formControlName="schoold_id" (selectionChange)="changeFilterOption($event.value,'school')">
<mat-select placeholder="Select Schools" formControlName="schoold_id">
<mat-option *ngFor="let item of school" [value]="item.school_id" >
{{ item.school_name }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field dividerColor="warn" class="ml-xs mr-xs" style="width: 100%;">
<mat-select placeholder="Select Category" formControlName="cad_id" (selectionChange)="changeFilterOption($event.value,'category')">
<mat-option *ngFor="let item of category" [value]="item.cad_id" >
<mat-select placeholder="Select Category" formControlName="cad_id" (selectionChange)="getFilterValue($event.value,'material')">
<mat-option *ngFor="let item of category" [value]="item.cat_id" >
{{ item.cat_name }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field dividerColor="warn" class="ml-xs mr-xs" style="width: 100%;">
<mat-select placeholder="Material Name" formControlName="mat_id" (selectionChange)="changeFilterOption($event.value,'material')">
<mat-option *ngFor="let item of material_category" [value]="item.mat_id" >
<mat-select placeholder="Material Name" formControlName="mat_id">
<mat-option *ngFor="let item of material_category.materials" [value]="item.mat_id" >
{{ item.material_name }}
</mat-option>
</mat-select>
@ -46,8 +46,8 @@
</form>
<!--*********************-->
<div class="mat-elevation-z8">
<table mat-table [dataSource]="dataSource" matSort>
<div class="mat-elevation-z8" >
<table mat-table [dataSource]="dataSource" matSort *ngIf="dataStatus;else status">
<!-- Requirement Column -->
<!-- <ng-container matColumnDef="Requirement">
@ -108,7 +108,7 @@
</table>
<div class="clearfix order-total" style="padding-bottom: 0px !important;">
<div class="calculated-shipping" style="text-align: -webkit-right !important;">
<table class="table-responsive" cellspacing="0" style="width: 50% !important;">
<table class="table-responsive" cellspacing="0" style="width: 50% !important;" *ngIf="dataStatus">
<tr class="order-total" style="text-align: right;">
<td style="font-weight: bold;">Total</td>
<td> <strong><span class="amount"><span class="currency-symbol">&#8377;</span>{{grandTotal}}</span></strong></td>
@ -116,13 +116,15 @@
</table>
</div>
</div>
<mat-paginator [pageSize]="pageSize" [pageSizeOptions]="[5, 10, 25, 50, 100]" showFirstLastButtons></mat-paginator>
<mat-paginator [pageSize]="pageSize" [pageSizeOptions]="[5, 10, 25, 50, 100]" showFirstLastButtons ></mat-paginator>
<div class="pt-1 pr-1" style="text-align: right;">
<div class="pt-1 pr-1" style="text-align: right;" *ngIf="dataStatus">
<button mat-raised-button color="primary" (click)="finalSave(2)" class="mr-1 mb-1">I'd like to Contribute in kind</button>
<button (click)="finalSave(1)" mat-raised-button style="background-color:rgb(69, 189, 189);color:white" >I'd like to Contribute in Cash</button>
</div>
</div>
<ng-template #status><h2>{{msg}}</h2></ng-template>
<!--*********************-->
<!-- <div class="clearfix order-total">
<div class="calculated-shipping">

View File

@ -38,7 +38,9 @@ export class ContributeComponent implements OnInit {
all_category:any=[]
all_school:any=[];
all_material_category:any=[]
all_district:any=[]
all_district:any=[];
dataStatus :boolean = true;
msg: any;
constructor(public restApi:ApiService,public fb:FormBuilder,public router:Router,private apiService:ApiService,public schInfo:SchoolDetailsService) {
// Create 100 users
@ -72,49 +74,11 @@ export class ContributeComponent implements OnInit {
console.log("gfff",res);
})
// window.localStorage.clear();
this.getFilterValue('','district');
this.getFilterValue('','category');
}
filterValue(){
this.apiService.getFilterMasters_get().subscribe(res=>{
if(res['dataStatus']){
this.all_filtered_list=res['records']
this.district=this.all_filtered_list.map(val=>({district_name:val.district_name,district_id:val.district_id,school_id:val.school_id}))
// this.district = this.district.filter(function(elem, index, self) {
// console.log("dis",elem,index,self)
// return index === self.indexOf(elem.district_id);
// })
this.district = this.district.filter((thing, index, self) =>
index === self.findIndex((t) => (
t.district_id === thing.district_id && t.district_name === thing.district_name
)))
this.all_district=this.district
this.category=this.all_filtered_list.map(val=>({cat_name:val.cat_name,cad_id:val.cad_id,mat_id:val.mat_id}))
this.category=this.category.filter((thing,index,self)=>
index === self.findIndex((t)=>(
t.cat_name === thing.cat_name
)
))
this.all_category=this.category
this.school=this.all_filtered_list.map(val=>({school_name:val.school_name,school_id:val.school_id,district_id:val.district_id}))
this.school=this.school.filter((thing,index,self)=>
index === self.findIndex((t)=>(
t.school_name === thing.school_name && t.school_id === thing.school_id
)
))
this.all_school=this.school
this.school=[]
this.material_category=this.all_filtered_list.map(val=>({material_name:val.material_name,mat_id:val.mat_id,cad_id:val.cad_id}))
this.material_category=this.material_category.filter((thing,index,self)=>
index === self.findIndex((t)=>(
t.material_name === thing.material_name && t.mat_id === thing.mat_id
)
))
this.all_material_category=this.material_category
}
})
}
initForm()
{
@ -126,17 +90,50 @@ export class ContributeComponent implements OnInit {
mat_id: new FormControl('')
})
}
changeFilterOption(value,option){
console.log(value,option)
if(option == 'district'){
// this.district=[];
this.school=this.all_school.filter(val=>val.district_id == value )
}
else{
if(option == 'category'){
this.material_category=this.all_material_category.filter(val=>val.cad_id == value)
getFilterValue(value,option){
// console.log(value,option)
let url =`${environment.apiUrl}`;
switch(option)
{
case 'district':
url += `${'getFilterDistricts'}`;
this.apiService.get(url).subscribe(res=>
{
if(res['dataStatus'])
{
this.district = res['records'];
}
})
break;
case 'school':
// let data = {'dist_id':value};
url += `${'getFilterSchools/'}${value}`;
this.apiService.get(url).subscribe(res=>
{
if(res['dataStatus'])
{
this.school = res['records'];
}
})
break;
case 'category':
url += `${'getFilterMaterials'}`;
this.apiService.get(url).subscribe(res=>
{
if(res['dataStatus'])
{
this.category = res['records'];
}
})
break;
case 'material':
this.material_category = this.category.filter(cate=>cate.cat_id==value)[0];
console.log(this.material_category);
break;
}
}
}
getSchoolReqList()
@ -144,8 +141,11 @@ export class ContributeComponent implements OnInit {
let url = `${environment.apiUrl}${'getSchoolReqList'}`;
let data = this.Contribute.value;
this.restApi.post(url,data).subscribe(schDet=>
{
this.dataStatus = schDet.dataStatus;
this.dataLength = 0;
if(schDet.dataStatus==true)
{
let data ='';
@ -157,8 +157,9 @@ export class ContributeComponent implements OnInit {
{
data = schDet.records;
}
this.dataStatus = schDet.dataStatus;
this.dataLength = data.length;
this.dataSource.data = data
this.dataSource.data = data;
console.log("data",this.dataSource)
let store:any
store=sessionStorage.getItem('contribute')
@ -178,6 +179,12 @@ export class ContributeComponent implements OnInit {
// return val;
// })
// console.log(this.dataSource.data);
}else
{
this.dataLength = 0;
this.dataSource.data = [];
this.pageSize = 0;
this.msg = schDet.msg;
}
})
}
@ -292,7 +299,7 @@ export class ContributeComponent implements OnInit {
}
ngAfterViewInit() {
this.filterValue()
// this.filterValue()
// Hack: Scrolls to top of Page after page view initialized
let top = document.getElementById('top');
// console.log("d",top);