Collapsible properties (#771)

* started moving properties to home tab

* moved properties

* refactored panel in dashboard

* fix errors

* fix miss-naming

* added collapsable properties

* revert unnecessary change

* add icon for collapsing properties
This commit is contained in:
Anthony Dresser
2018-03-05 10:06:18 -08:00
committed by GitHub
parent 2e67d03b56
commit 692ed02df8
14 changed files with 146 additions and 24 deletions

View File

@@ -197,3 +197,36 @@ export class AddFeatureTabAction extends Action {
}
}
}
export class CollapseWidgetAction extends Action {
private static readonly ID = 'collapseWidget';
private static readonly COLLPASE_LABEL = nls.localize('collapseWidget', "Collapse");
private static readonly EXPAND_LABEL = nls.localize('expandWidget', "Expand");
private static readonly COLLAPSE_ICON = 'maximize-panel-action';
private static readonly EXPAND_ICON = 'minimize-panel-action';
constructor(
private _uri: string,
private _widgetUuid: string,
private collpasedState: boolean,
@IAngularEventingService private _angularEventService: IAngularEventingService
) {
super(
CollapseWidgetAction.ID,
collpasedState ? CollapseWidgetAction.EXPAND_LABEL : CollapseWidgetAction.COLLPASE_LABEL,
collpasedState ? CollapseWidgetAction.EXPAND_ICON : CollapseWidgetAction.COLLAPSE_ICON
);
}
run(): TPromise<boolean> {
this._toggleState();
this._angularEventService.sendAngularEvent(this._uri, AngularEventType.COLLAPSE_WIDGET, this._widgetUuid);
return TPromise.as(true);
}
private _toggleState(): void {
this.collpasedState = !this.collpasedState;
this._setClass(this.collpasedState ? CollapseWidgetAction.EXPAND_ICON : CollapseWidgetAction.COLLAPSE_ICON);
this._setLabel(this.collpasedState ? CollapseWidgetAction.EXPAND_LABEL : CollapseWidgetAction.COLLPASE_LABEL);
}
}

View File

@@ -89,7 +89,6 @@ export abstract class DashboardPage extends Disposable implements OnDestroy {
constructor(
@Inject(forwardRef(() => DashboardServiceInterface)) protected dashboardService: DashboardServiceInterface,
@Inject(BOOTSTRAP_SERVICE_ID) protected bootstrapService: IBootstrapService,
@Inject(forwardRef(() => ElementRef)) protected _el: ElementRef,
@Inject(forwardRef(() => ChangeDetectorRef)) protected _cd: ChangeDetectorRef
) {
@@ -252,12 +251,14 @@ export abstract class DashboardPage extends Disposable implements OnDestroy {
}
private getProperties(): Array<WidgetConfig> {
let properties = this.dashboardService.getSettings<IPropertiesConfig[]>([this.context, 'properties'].join('.'));
let properties = this.dashboardService.getSettings<IPropertiesConfig[] | string | boolean>([this.context, 'properties'].join('.'));
this._propertiesConfigLocation = 'default';
if (types.isUndefinedOrNull(properties)) {
return [this.propertiesWidget];
} else if (types.isBoolean(properties)) {
return properties ? [this.propertiesWidget] : [];
} else if (types.isString(properties) && properties === 'collapsed') {
return [this.propertiesWidget];
} else if (types.isArray(properties)) {
return properties.map((item) => {
let retVal = Object.assign({}, this.propertiesWidget);
@@ -302,6 +303,6 @@ export abstract class DashboardPage extends Disposable implements OnDestroy {
let index = this.tabs.findIndex(i => i.id === tab.identifier);
this.tabs.splice(index, 1);
this._cd.detectChanges();
this.bootstrapService.angularEventingService.sendAngularEvent(this.dashboardService.getUnderlyingUri(), AngularEventType.CLOSE_TAB, { id: tab.identifier });
this.dashboardService.angularEventingService.sendAngularEvent(this.dashboardService.getUnderlyingUri(), AngularEventType.CLOSE_TAB, { id: tab.identifier });
}
}