diff --git a/src/managers/filterManager.ts b/src/managers/filterManager.ts index 56138dd..beec1cd 100644 --- a/src/managers/filterManager.ts +++ b/src/managers/filterManager.ts @@ -14,6 +14,11 @@ export class FilterManager implements IFilterManager{ constructor(host:IVisualHost){ this.host=host; } + public clear():void{ + console.debug("clear start:"); + this.host.applyJsonFilter(null,"general","filter",powerbi.FilterAction.remove); + console.debug("clear end"); + } public update(field:powerbi.DataViewCategoryColumn):void{ let queryName:string=field.source.queryName; let splitPosition:number=queryName.indexOf('.'); diff --git a/src/managers/layoutManager.ts b/src/managers/layoutManager.ts index 702ef51..bb58a8a 100644 --- a/src/managers/layoutManager.ts +++ b/src/managers/layoutManager.ts @@ -3,13 +3,22 @@ import powerbi from "powerbi-visuals-api"; import DataView = powerbi.DataView; import * as visualInterfaces from "../visual/visualInterfaces"; import * as d3 from "d3"; -import { ILayoutManager } from "../visual/visualInterfaces"; +import { ILayoutManager,IFilterManager } from "../visual/visualInterfaces"; +import { IFilter } from "powerbi-models"; type Selection = d3.Selection; export class LayoutManager implements ILayoutManager{ layout:Selection; // constructor(layout:Selection){ // this.layout=layout; // } + header:Selection + constructor(layout:Selection,filterManager:IFilterManager){ + this.layout=layout; + this.header=this.layout.append('div').attr('header',true); + this.header.append('button').attr('clear',true).text('clear').on('click',function(){ + filterManager.clear(); + }); + } update(dataView:DataView,width:number,height:number):void{ //this.layout.style("width",width+"px").style("height",height+"px"); } diff --git a/src/managers/managerFactory.ts b/src/managers/managerFactory.ts index 8df9000..fa1ac24 100644 --- a/src/managers/managerFactory.ts +++ b/src/managers/managerFactory.ts @@ -4,8 +4,8 @@ import * as d3 from "d3"; import powerbi from "powerbi-visuals-api"; type Selection = d3.Selection; export class ManagerFactory{ - public static CreateLayoutManager(classLayoutManager:visualInterfaces.ILayoutManagerConstructor,container:Selection):visualInterfaces.ILayoutManager{ - return new classLayoutManager(container); + public static CreateLayoutManager(classLayoutManager:visualInterfaces.ILayoutManagerConstructor,container:Selection,filterManager:visualInterfaces.IFilterManager):visualInterfaces.ILayoutManager{ + return new classLayoutManager(container,filterManager); } public static CreateSelectorManager(classSelectorManager:visualInterfaces.ISelectorManagerConstructor,container:Selection,filterManager:visualInterfaces.IFilterManager):visualInterfaces.ISelectorManager{ return new classSelectorManager(container,filterManager); diff --git a/src/managers/selectorManager.ts b/src/managers/selectorManager.ts index c19f74c..2c96616 100644 --- a/src/managers/selectorManager.ts +++ b/src/managers/selectorManager.ts @@ -67,44 +67,22 @@ abstract class Selector implements ISelector{ public abstract update(categories: powerbi.DataViewCategoryColumn, defaultSelect: powerbi.DataViewValueColumn, defaultStart: powerbi.DataViewValueColumn, defaultEnd: powerbi.DataViewValueColumn):void; } class DropDownSelector extends Selector{ - private dropDown:Selection; + private dropDown:Selection; protected createView() { console.debug('dropDownViewManager','createView start'); - this.dropDown=this.manager.selectorContainer.append("select").classed("dropDown-selector",true).classed("selector",true).attr("multiple",true); + + this.dropDown=this.manager.selectorContainer.append('div').classed('dropDown-selector',true) + .append('select').attr('id','dropDown-select').attr('multiple','true'); console.debug('dropDownViewManager','createView end'); } public dispose(){ this.dropDown.remove(); } - public update(categories: powerbi.DataViewCategoryColumn, defaultSelect: powerbi.DataViewValueColumn, defaultStart: powerbi.DataViewValueColumn, defaultEnd: powerbi.DataViewValueColumn) { + public update(field: powerbi.DataViewCategoryColumn, defaultSelect: powerbi.DataViewValueColumn, defaultStart: powerbi.DataViewValueColumn, defaultEnd: powerbi.DataViewValueColumn) { console.debug('dropDownViewManager','update start'); - let options=this.dropDown.selectAll("option").data(categories.values,function(d){return d.toString();});//map data - options.enter().append("option").text(function(d){return d.toString();}).attr('dropDown-option');//add - options.exit().remove();//delete - console.debug("dropDown:",this.dropDown); let filterManager:IFilterManager=this.manager.filterManager; - // this.dropDown.on("input change",function(){ - // console.debug('DropDownSelector:',"input change"); - // console.debug('this',this); - // console.debug('filterManager:',filterManager); - // let selectedValues:string[]=[]; - // for(let i=0;i{ + options.push({ + label:item.toString() + }); + }); + $('#dropDown-select').multiselect('dataprovider',options); + $('.dropDown-selector').css('overflow','visible').css('z-index',1000).css('position','relative'); + $('.dropdown-menu').css('overflow','flow').css('z-index',1000).css('position','relative'); + //$('#dropDown-select').multiselect('rebuild'); + + console.debug("dropDown:",this.dropDown); + console.debug('dropDownViewManager','update end'); } } diff --git a/src/visual/visual.ts b/src/visual/visual.ts index 12a604d..3e05cbd 100644 --- a/src/visual/visual.ts +++ b/src/visual/visual.ts @@ -63,20 +63,22 @@ export class Visual implements IVisual { if (document) { this.selectionManager =options.host.createSelectionManager(); let container=d3.select(options.element).append("div").classed("container",true); - d3.select(options.element).on('contextmenu', () => { - const mouseEvent: MouseEvent = d3.event; - //const eventTarget: EventTarget = mouseEvent.target; - //let dataPoint = d3.select(eventTarget).datum(); - this.selectionManager.showContextMenu({}, { - x: mouseEvent.clientX, - y: mouseEvent.clientY - }); - //mouseEvent.preventDefault(); - }); + // d3.select(options.element).on('contextmenu', () => { + // const mouseEvent: MouseEvent = d3.event; + // //const eventTarget: EventTarget = mouseEvent.target; + // //let dataPoint = d3.select(eventTarget).datum(); + // this.selectionManager.showContextMenu({}, { + // x: mouseEvent.clientX, + // y: mouseEvent.clientY + // }); + // //mouseEvent.preventDefault(); + // }); let headerContainer=container.append("div").classed("header-container",true); let selectorContainer=container.append("div").classed("selector-container",true); - this.layoutManager=ManagerFactory.CreateLayoutManager(LayoutManager,container); + //First, create the filterManager this.filterManager=ManagerFactory.CreateFilterManager(FilterManager,options.host); + //Then, layoutManager and selectorManager + this.layoutManager=ManagerFactory.CreateLayoutManager(LayoutManager,container,this.filterManager); this.selectorManager=ManagerFactory.CreateSelectorManager(SelectorManager,selectorContainer,this.filterManager); } console.debug('end constructor'); diff --git a/src/visual/visualInterfaces.ts b/src/visual/visualInterfaces.ts index 3218c1a..a63ecbf 100644 --- a/src/visual/visualInterfaces.ts +++ b/src/visual/visualInterfaces.ts @@ -16,7 +16,7 @@ export interface ILayoutManager{ update(dataView:DataView,width:number,height:number):void; } export interface ILayoutManagerConstructor{ - new(container:Selection):ILayoutManager; + new(container:Selection,filterManager:IFilterManager):ILayoutManager; }; //ISelectorManager @@ -35,6 +35,7 @@ export interface ISelectorManagerConstructor{ export interface IFilterManager{ update(field:powerbi.DataViewCategoryColumn):void; filterStringField(selection:string[]):void; + clear():void; } export interface IFilterManagerConstructor{ new(host:IVisualHost):IFilterManager; diff --git a/webpack.statistics.dev.html b/webpack.statistics.dev.html index 38e1650..ca7ed40 100644 --- a/webpack.statistics.dev.html +++ b/webpack.statistics.dev.html @@ -3,7 +3,7 @@ - Webpack Bundle Analyzer [29 Apr 2020 at 22:12] + Webpack Bundle Analyzer [1 May 2020 at 02:35] diff --git a/webpack.statistics.prod.html b/webpack.statistics.prod.html index 8c5d340..e92e5c1 100644 --- a/webpack.statistics.prod.html +++ b/webpack.statistics.prod.html @@ -3,7 +3,7 @@ - Webpack Bundle Analyzer [29 Apr 2020 at 02:22] + Webpack Bundle Analyzer [1 May 2020 at 02:19]