import { Widget, EqContext, WidgetGroup } from '@easyquery/core'
import { QueryPanelOptions } from '@easyquery/ui'

declare var jQuery:any;

export class JQueryQueryPanelWidget extends Widget 
{
    private jqueryWrapper : any;

    constructor(slot : HTMLElement) {
        super(slot);

        this.jqueryWrapper = jQuery(slot);
        this.widgetType = "queryPanel";
        this.group = WidgetGroup.Query;
    }

    public init(context : EqContext, options?: QueryPanelOptions) {    
        super.init(context, options);          
     
        this.jqueryWrapper.QueryPanel(options)
        this.jqueryWrapper.QueryPanel("setQuery", this.context.getQuery());
        this.jqueryWrapper.QueryPanel("setContext", this.context);
    }

    protected refreshCore() {
        this.jqueryWrapper.QueryPanel("refresh");
    }

  
}
