Search page improvve

This commit is contained in:
Peter Maquiran
2021-01-18 14:59:09 +01:00
parent ac654811cc
commit c4bbbb948d
11 changed files with 180 additions and 57 deletions
+40 -9
View File
@@ -7,7 +7,6 @@ import { SearchDocument } from "src/app/models/search-document";
import { formatDate } from '@angular/common';
import { CloudData, CloudOptions } from 'angular-tag-cloud-module';
import { SenderPage } from 'src/app/pages/search/sender/sender.page';
@Component({
selector: 'app-search',
templateUrl: './search.page.html',
@@ -23,7 +22,10 @@ export class SearchPage implements OnInit {
private searchDocTypeId: string;
searchCategories: SearchCategory[];
showSearchDocuments: SearchDocument[];
showCategory: string;
searchDocuments: SearchDocument[];
showDocuments = false;
showAdvanceSearch = false;
@@ -46,9 +48,6 @@ export class SearchPage implements OnInit {
slidesPerView: 3,
initialSlide: 0,
speed: 400,
autoHeight: true,
calculateHeight:true,
height: 50
}
constructor(private modalController: ModalController,
@@ -63,17 +62,26 @@ export class SearchPage implements OnInit {
}
sortArrayISODate(myArray: any){
return myArray.sort(function(a, b) {
return (a.Data < b.Data) ? -1 : ((a.Data > b.Data) ? 1 : 0);
});
}
/**
* @description Basic search
*/
basicSearch(){
console.log(this.searchDocumentDate);
this.search.basicSearch(this.searchSubject, this.searchDocumentDate, this.searchSender
,this.searchOrganicEntiry, this.searchDocTypeId).subscribe(res=>{
// bind respose
this.searchCategories = res.Categories;
this.searchDocuments = res.Documents;
this.searchDocuments = this.sortArrayISODate(res.Documents);
this.showSearchDocuments = this.sortArrayISODate(this.searchDocuments);
// hide show document
if(this.searchDocuments.length >= 1){
@@ -82,7 +90,6 @@ export class SearchPage implements OnInit {
this.showDocuments = false
}
});
}
@@ -103,12 +110,24 @@ export class SearchPage implements OnInit {
return formatDate(date, 'dd/MM/yyyy', 'pt');
}
clearInputRemetente(){
this.searchSender = "";
}
clearInputDocumentDate(){
this.searchDocumentDate = "";
}
clearInputOrganicEntity(){
this.searchOrganicEntiry = "";
}
/**
* @description Clean inputs
*/
showHideAdvanceSearch(show:boolean) {
this.showAdvanceSearch = show;
/* Clear inputs */
this.searchDocumentDate = "";
this.searchSender = "";
@@ -117,7 +136,6 @@ export class SearchPage implements OnInit {
this.searchSubject = "";
}
async openAdvanceSearchSelection() {
const modal = await this.modalController.create({
@@ -131,4 +149,17 @@ export class SearchPage implements OnInit {
}
}
async filterDocList(categoryName:string){
// show all category
if(this. showCategory == categoryName ){
this.showSearchDocuments = this.searchDocuments;
} else { // filter category
this.showSearchDocuments = this.searchDocuments.filter((e) => e.DocTypeDesc == categoryName);
}
this.showCategory = categoryName;
}
}