|
@@ -16,14 +16,14 @@ import { ToastrService } from 'ngx-toastr';
|
|
|
styleUrls: ['./model-vehicle-list.component.css']
|
|
|
})
|
|
|
export class ModelVehicleListComponent implements OnInit {
|
|
|
-
|
|
|
+
|
|
|
pageId: number;
|
|
|
dataList = [];
|
|
|
dataListIds = [];
|
|
|
count: number;
|
|
|
perPagePagenation: number;
|
|
|
currentPage:number = 1;
|
|
|
- filtterStatus = '';
|
|
|
+ filtterStatus = 'all';
|
|
|
selectedAll: any;
|
|
|
userLoginId:number;
|
|
|
serviceId:number;
|
|
@@ -44,7 +44,7 @@ export class ModelVehicleListComponent implements OnInit {
|
|
|
ngOnInit() {
|
|
|
|
|
|
this.spinner.show();
|
|
|
-
|
|
|
+
|
|
|
//init the values of permision boolean
|
|
|
this.authSer.showAddBtn = false;
|
|
|
this.authSer.showDeleteBtn = false;
|
|
@@ -116,24 +116,24 @@ export class ModelVehicleListComponent implements OnInit {
|
|
|
|
|
|
}
|
|
|
|
|
|
- //make all checkbox of user checked
|
|
|
+ //make all checkbox of user checked
|
|
|
selectAll() {
|
|
|
for (var i = 0; i < this.dataList.length; i++) {
|
|
|
this.dataList[i].selected = this.selectedAll;
|
|
|
}
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
checkIfAllSelected() {
|
|
|
this.selectedAll = this.dataList.every(function(item:any) {
|
|
|
return item.selected == true;
|
|
|
});
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
//filtter function
|
|
|
filtterFunc(data) {
|
|
|
this.dataList = [];
|
|
|
console.log(data.target.value);
|
|
|
- const dataSearch = data.target.value;
|
|
|
+ const dataSearch = data.target.value;
|
|
|
this.currentPage = 1;
|
|
|
console.log('search curent page', this.currentPage);
|
|
|
this.dashBoardSer.getDataUSerSearchBar(dataSearch, this.pageId, this.currentPage, this.dataTableNumber).subscribe(
|
|
@@ -150,8 +150,8 @@ export class ModelVehicleListComponent implements OnInit {
|
|
|
}
|
|
|
);
|
|
|
};
|
|
|
-
|
|
|
- //change page
|
|
|
+
|
|
|
+ //change page
|
|
|
onPageChange(pagenationNumber) {
|
|
|
this.spinner.show();
|
|
|
this.currentPage = pagenationNumber;
|
|
@@ -173,12 +173,14 @@ export class ModelVehicleListComponent implements OnInit {
|
|
|
}
|
|
|
);
|
|
|
};
|
|
|
-
|
|
|
- //determine the list count from select element
|
|
|
+
|
|
|
+ //determine the list count from select element
|
|
|
onGetValue(event) {
|
|
|
+
|
|
|
this.spinner.show();
|
|
|
this.dataList = [];
|
|
|
this.dataTableNumber = event.target.value;
|
|
|
+
|
|
|
this.dashBoardSer.getListData(this.pageId, this.currentPage, this.dataTableNumber).subscribe(
|
|
|
(responce) => {
|
|
|
console.log(responce);
|
|
@@ -197,33 +199,35 @@ export class ModelVehicleListComponent implements OnInit {
|
|
|
onGetValueFiltter(event) {
|
|
|
this.spinner.show();
|
|
|
this.dataList = [];
|
|
|
- this.dataTableNumber = event.target.value;
|
|
|
- this.http.get(this.authSer.pathApi +'/page_list/' + this.pageId + '/' + this.currentPage + '/' + this.dataTableNumber + '/' + event.target.value).subscribe(
|
|
|
+ const typeId = event.target.value;
|
|
|
+ console.log(typeId);
|
|
|
+ this.http.get(this.authSer.pathApi +'/page_list/' + this.pageId + '/' + this.currentPage + '/' + this.dataTableNumber + '/' + typeId).subscribe(
|
|
|
(responce) => {
|
|
|
console.log(responce);
|
|
|
this.dataList = responce['vehicle_models'];
|
|
|
this.count = responce['count'];
|
|
|
this.perPagePagenation = responce['per_page'];
|
|
|
this.spinner.hide();
|
|
|
+ console.log('UrL>>', this.authSer.pathApi +'/page_list/' + this.pageId + '/' + this.currentPage + '/' + this.dataTableNumber + '/' + typeId)
|
|
|
},
|
|
|
(error) => {
|
|
|
console.log(error);
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
onDelete() {
|
|
|
-
|
|
|
+
|
|
|
this.dataListIds = [];
|
|
|
for(let i = 0; i < this.dataList.length; i++) {
|
|
|
if(this.dataList[i].selected == true) {
|
|
|
this.dataListIds.push(this.dataList[i].id);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
console.log(this.dataListIds);
|
|
|
-
|
|
|
+
|
|
|
if(this.dataListIds.length > 0) {
|
|
|
const dialogRef = this.modal.alert()
|
|
|
.size('sm')
|
|
@@ -233,16 +237,16 @@ export class ModelVehicleListComponent implements OnInit {
|
|
|
<h4>هل ترغب في حذف العناصر المحدده ؟ </h4>
|
|
|
`)
|
|
|
.open();
|
|
|
-
|
|
|
+
|
|
|
dialogRef.result
|
|
|
- .then( result =>
|
|
|
+ .then( result =>
|
|
|
this.dashBoardSer.deleteItem(this.dataListIds , this.pageId).subscribe(
|
|
|
(responce) => {
|
|
|
console.log(responce);
|
|
|
this.toastr.success('تم الحذف');
|
|
|
this.spinner.show();
|
|
|
this.dataList = [];
|
|
|
- //get list data
|
|
|
+ //get list data
|
|
|
this.dashBoardSer.getListData(this.pageId, this.currentPage ,this.dataTableNumber).subscribe(
|
|
|
(responce) => {
|
|
|
console.log(responce);
|
|
@@ -267,13 +271,13 @@ export class ModelVehicleListComponent implements OnInit {
|
|
|
this.toastr.warning('لم يتم إختيار أي عنصر للمسح !');
|
|
|
}
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
//add function
|
|
|
onAdd() {
|
|
|
console.log('service/' + this.userLoginId + '/' + this.serviceId + '/addTab');
|
|
|
this.router.navigate(['service/' + this.userLoginId + '/' + this.serviceId + '/vehicleModel/add']);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//edit function
|
|
|
onEdit(editTabID) {
|
|
|
this.router.navigate(['service/' + this.userLoginId + '/' + this.serviceId + '/' + 'vehicleModel/edit/' + editTabID]);
|