mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
refactored collapsing widget, fixed refreshing a collapsed widget (#1107)
This commit is contained in:
@@ -210,7 +210,6 @@ export class CollapseWidgetAction extends Action {
|
|||||||
private _uri: string,
|
private _uri: string,
|
||||||
private _widgetUuid: string,
|
private _widgetUuid: string,
|
||||||
private collpasedState: boolean,
|
private collpasedState: boolean,
|
||||||
private collapsedStateChangedEvent: Event<boolean>,
|
|
||||||
@IAngularEventingService private _angularEventService: IAngularEventingService
|
@IAngularEventingService private _angularEventService: IAngularEventingService
|
||||||
) {
|
) {
|
||||||
super(
|
super(
|
||||||
@@ -218,7 +217,6 @@ export class CollapseWidgetAction extends Action {
|
|||||||
collpasedState ? CollapseWidgetAction.EXPAND_LABEL : CollapseWidgetAction.COLLPASE_LABEL,
|
collpasedState ? CollapseWidgetAction.EXPAND_LABEL : CollapseWidgetAction.COLLPASE_LABEL,
|
||||||
collpasedState ? CollapseWidgetAction.EXPAND_ICON : CollapseWidgetAction.COLLAPSE_ICON
|
collpasedState ? CollapseWidgetAction.EXPAND_ICON : CollapseWidgetAction.COLLAPSE_ICON
|
||||||
);
|
);
|
||||||
this.collapsedStateChangedEvent(collapsed => this._updateState(collapsed));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
run(): TPromise<boolean> {
|
run(): TPromise<boolean> {
|
||||||
@@ -232,8 +230,15 @@ export class CollapseWidgetAction extends Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _updateState(collapsed: boolean): void {
|
private _updateState(collapsed: boolean): void {
|
||||||
|
if (collapsed === this.collpasedState) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.collpasedState = collapsed;
|
this.collpasedState = collapsed;
|
||||||
this._setClass(this.collpasedState ? CollapseWidgetAction.EXPAND_ICON : CollapseWidgetAction.COLLAPSE_ICON);
|
this._setClass(this.collpasedState ? CollapseWidgetAction.EXPAND_ICON : CollapseWidgetAction.COLLAPSE_ICON);
|
||||||
this._setLabel(this.collpasedState ? CollapseWidgetAction.EXPAND_LABEL : CollapseWidgetAction.COLLPASE_LABEL);
|
this._setLabel(this.collpasedState ? CollapseWidgetAction.EXPAND_LABEL : CollapseWidgetAction.COLLPASE_LABEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public set state(collapsed: boolean) {
|
||||||
|
this._updateState(collapsed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ export class DashboardWidgetWrapper extends AngularDisposable implements OnInit
|
|||||||
@Input() private _config: WidgetConfig;
|
@Input() private _config: WidgetConfig;
|
||||||
@Input() private collapsable = false;
|
@Input() private collapsable = false;
|
||||||
|
|
||||||
|
private _collapseAction: CollapseWidgetAction;
|
||||||
private _collapsed = false;
|
private _collapsed = false;
|
||||||
|
|
||||||
public get collapsed(): boolean {
|
public get collapsed(): boolean {
|
||||||
@@ -64,17 +65,13 @@ export class DashboardWidgetWrapper extends AngularDisposable implements OnInit
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._collapsed = val;
|
this._collapsed = val;
|
||||||
if (this.collapsedStateChangedEmitter) {
|
this._collapseAction.state = val;
|
||||||
this.collapsedStateChangedEmitter.fire(this._collapsed);
|
|
||||||
}
|
|
||||||
this._changeref.detectChanges();
|
this._changeref.detectChanges();
|
||||||
if (!val) {
|
if (!val) {
|
||||||
this.loadWidget();
|
this.loadWidget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private collapsedStateChangedEmitter: Emitter<boolean>;
|
|
||||||
|
|
||||||
@memoize
|
@memoize
|
||||||
public get guid(): string {
|
public get guid(): string {
|
||||||
return generateUuid();
|
return generateUuid();
|
||||||
@@ -114,8 +111,8 @@ export class DashboardWidgetWrapper extends AngularDisposable implements OnInit
|
|||||||
this._actionbar = new ActionBar(this._actionbarRef.nativeElement);
|
this._actionbar = new ActionBar(this._actionbarRef.nativeElement);
|
||||||
if (this._actions) {
|
if (this._actions) {
|
||||||
if (this.collapsable) {
|
if (this.collapsable) {
|
||||||
this.collapsedStateChangedEmitter = new Emitter<boolean>();
|
this._collapseAction = this._bootstrap.instantiationService.createInstance(CollapseWidgetAction, this._bootstrap.getUnderlyingUri(), this.guid, this.collapsed);
|
||||||
this._actionbar.push(this._bootstrap.instantiationService.createInstance(CollapseWidgetAction, this._bootstrap.getUnderlyingUri(), this.guid, this.collapsed, this.collapsedStateChangedEmitter.event), { icon: true, label: false });
|
this._actionbar.push(this._collapseAction, { icon: true, label: false });
|
||||||
}
|
}
|
||||||
this._actionbar.push(this._bootstrap.instantiationService.createInstance(ToggleMoreWidgetAction, this._actions, this._component.actionsContext), { icon: true, label: false });
|
this._actionbar.push(this._bootstrap.instantiationService.createInstance(ToggleMoreWidgetAction, this._actions, this._component.actionsContext), { icon: true, label: false });
|
||||||
}
|
}
|
||||||
@@ -123,13 +120,13 @@ export class DashboardWidgetWrapper extends AngularDisposable implements OnInit
|
|||||||
}
|
}
|
||||||
|
|
||||||
public refresh(): void {
|
public refresh(): void {
|
||||||
if (this._component && this._component.refresh) {
|
if (!this.collapsed && this._component && this._component.refresh) {
|
||||||
this._component.refresh();
|
this._component.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public layout(): void {
|
public layout(): void {
|
||||||
if (this._component && this._component.layout) {
|
if (!this.collapsed && this._component && this._component.layout) {
|
||||||
this._component.layout();
|
this._component.layout();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -170,7 +167,7 @@ export class DashboardWidgetWrapper extends AngularDisposable implements OnInit
|
|||||||
this._component = componentRef.instance;
|
this._component = componentRef.instance;
|
||||||
let actions = componentRef.instance.actions;
|
let actions = componentRef.instance.actions;
|
||||||
if (componentRef.instance.refresh) {
|
if (componentRef.instance.refresh) {
|
||||||
actions.push(new RefreshWidgetAction(componentRef.instance.refresh, componentRef.instance));
|
actions.push(new RefreshWidgetAction(this.refresh, this));
|
||||||
}
|
}
|
||||||
if (actions !== undefined && actions.length > 0) {
|
if (actions !== undefined && actions.length > 0) {
|
||||||
this._actions = actions;
|
this._actions = actions;
|
||||||
|
|||||||
Reference in New Issue
Block a user