import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; import { SelectItem } from 'primeng/components/common/api'; import { ISelectedFilter } from '../shared/core/ISelectedFilter'; @Component({ selector: 'app-search-n-filter', templateUrl: './search-n-filter.component.html', styleUrls: ['./search-n-filter.component.css'] }) export class SearchNFilterComponent implements OnInit { @Input() filterlist: SelectItem[]; @Input() section:string; @Output() bindFilter: EventEmitter = new EventEmitter(); //this check the section that the filter resides sectionFilter: string; //these inputs for filter dropdowns @Input() dateRangeFilterList : string[]; @Input() personFilterList : string[]; @Input() moduleFilterList: string[]; //outputs from dropdowns @Output() bindStaffLogFilter: EventEmitter = new EventEmitter(); @Output() bindStaffActivityFilter: EventEmitter = new EventEmitter(); @Output() bindStaffEventFilter: EventEmitter = new EventEmitter(); //these vars get selected values from dropdowns selectedDateRange : string; selectedPersonType : string; selectdModuleType : string; //for staff activity list output outputStaffListSelectedFilters : ISelectedFilter; outputStaffLogSelectedFilters : ISelectedFilter; outputStaffEventSelectedFilters : ISelectedFilter; constructor() { } ngOnInit() { //gets input section data to hide and show staff logged time filter this.sectionFilter = this.section; console.log(this.sectionFilter); } listFilter(value:string){ this.bindFilter.emit(value); } //-----------------staff logged time filters---------------- //this method get selected date selectedStaffLogDateFilter(value:string){ this.selectedDateRange = value; this.StaffLogOutputFilterList(); } //this method get selected persontype eg: role-partner, role-manager selectedStaffLogPersonFilter(value: string){ this.selectedPersonType = value; this.StaffLogOutputFilterList(); } //this method bind selectd filter values and do output as a ISelectedFilter obj StaffLogOutputFilterList(){ this.outputStaffLogSelectedFilters = { DateRange: this.selectedDateRange, Module : this.selectdModuleType, PersonType : this.selectedPersonType } this.bindStaffLogFilter.emit(this.outputStaffLogSelectedFilters); } //-----------------end of staff logged time ---------------- //--------------- Staff activity list filters----------------------- //this method get selected date selectedDateFilter(value:string){ this.selectedDateRange = value; this.outputFilterList(); } //this method get selected persontype eg: role-partner, role-manager selectedPersonFilter(value: string){ this.selectedPersonType = value; this.outputFilterList(); } //this method get selected module selectedModuleFilter(value : string){ this.selectdModuleType = value; this.outputFilterList(); } //this method bind all selected filter values and do output as a ISelectedFilter obj outputFilterList(){ this.outputStaffListSelectedFilters = { DateRange: this.selectedDateRange, Module : this.selectdModuleType, PersonType : this.selectedPersonType } this.bindStaffActivityFilter.emit(this.outputStaffListSelectedFilters); } //--------------- end of Staff activity list ----------------------- //--------------- Staff event calendar ----------------------- //this method get selected date selectedEventDateFilter(value:string){ this.selectedDateRange = value; this.outputEventFilterList(); } //this method get selected persontype eg: role-partner, role-manager selectedEventPersonFilter(value: string){ this.selectedPersonType = value; this.outputEventFilterList(); } //this method get selected module selectedEventModuleFilter(value : string){ this.selectdModuleType = value; this.outputEventFilterList(); } //this method bind all selected filter values and do output as a ISelectedFilter obj outputEventFilterList(){ this.outputStaffEventSelectedFilters = { DateRange: this.selectedDateRange, Module : this.selectdModuleType, PersonType : this.selectedPersonType } this.bindStaffEventFilter.emit(this.outputStaffEventSelectedFilters); } //--------------- end of Staff event calendar ----------------------- }