mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Improved chart names for chart type dropdown. (#7631)
* isolated problem involving user friendly names * Fix to handle horizontalBar * Working rough version, need to implement data structure to store alternative names later * consolidated checks into its own static method, data structure still highly recommended to implement * Version with hashMap implemented
This commit is contained in:
@@ -16,6 +16,21 @@ import { renderFormattedText, renderText, FormattedTextRenderOptions } from 'vs/
|
|||||||
|
|
||||||
const $ = dom.$;
|
const $ = dom.$;
|
||||||
|
|
||||||
|
//Map used to store names and alternative names for chart types.
|
||||||
|
//This is mainly used for comparison when options are parsed into the constructor.
|
||||||
|
const altNameHash : {[oldName: string]: string} = {
|
||||||
|
['horizontalBar']: 'Horziontal Bar',
|
||||||
|
['bar']: 'Bar',
|
||||||
|
['line']: 'Line',
|
||||||
|
['pie']: 'Pie',
|
||||||
|
['scatter']: 'Scatter',
|
||||||
|
['timeSeries']: 'Time Series',
|
||||||
|
['image']: 'Image',
|
||||||
|
['count']: 'Count',
|
||||||
|
['table']: 'Table',
|
||||||
|
['doughnut']: 'Doughnut'
|
||||||
|
};
|
||||||
|
|
||||||
export interface ISelectBoxStyles extends vsISelectBoxStyles {
|
export interface ISelectBoxStyles extends vsISelectBoxStyles {
|
||||||
disabledSelectBackground?: Color;
|
disabledSelectBackground?: Color;
|
||||||
disabledSelectForeground?: Color;
|
disabledSelectForeground?: Color;
|
||||||
@@ -56,8 +71,12 @@ export class SelectBox extends vsSelectBox {
|
|||||||
|
|
||||||
private element: HTMLElement;
|
private element: HTMLElement;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
constructor(options: string[], selectedOption: string, contextViewProvider: IContextViewProvider, container?: HTMLElement, selectBoxOptions?: ISelectBoxOptions) {
|
constructor(options: string[], selectedOption: string, contextViewProvider: IContextViewProvider, container?: HTMLElement, selectBoxOptions?: ISelectBoxOptions) {
|
||||||
super(options.map(option => { return { text: option }; }), 0, contextViewProvider, undefined, selectBoxOptions);
|
//originally {text :option };
|
||||||
|
super(options.map(option => {return {text : SelectBox.parseName(option)}; }), 0, contextViewProvider, undefined, selectBoxOptions);
|
||||||
|
|
||||||
this._optionsDictionary = new Map<string, number>();
|
this._optionsDictionary = new Map<string, number>();
|
||||||
for (let i = 0; i < options.length; i++) {
|
for (let i = 0; i < options.length; i++) {
|
||||||
this._optionsDictionary.set(options[i], i);
|
this._optionsDictionary.set(options[i], i);
|
||||||
@@ -90,6 +109,16 @@ export class SelectBox extends vsSelectBox {
|
|||||||
this._register(focusTracker.onDidFocus(() => this._showMessage()));
|
this._register(focusTracker.onDidFocus(() => this._showMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//static method that is used to replace original names of options into user-friendly ones for display.
|
||||||
|
private static parseName(oldName: string): string {
|
||||||
|
if(altNameHash[oldName] !== undefined) {
|
||||||
|
return altNameHash[oldName];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return oldName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public style(styles: ISelectBoxStyles): void {
|
public style(styles: ISelectBoxStyles): void {
|
||||||
super.style(styles);
|
super.style(styles);
|
||||||
this.enabledSelectBackground = this.selectBackground;
|
this.enabledSelectBackground = this.selectBackground;
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ export class ChartView extends Disposable implements IPanelView {
|
|||||||
type: ChartType.Bar
|
type: ChartType.Bar
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/** parent container */
|
/** parent container */
|
||||||
private container: HTMLElement;
|
private container: HTMLElement;
|
||||||
/** container for the options controls */
|
/** container for the options controls */
|
||||||
@@ -276,6 +277,7 @@ export class ChartView extends Disposable implements IPanelView {
|
|||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case ControlType.combo:
|
case ControlType.combo:
|
||||||
|
|
||||||
let dropdown = new SelectBox(option.displayableOptions || option.options, undefined, this._contextViewService);
|
let dropdown = new SelectBox(option.displayableOptions || option.options, undefined, this._contextViewService);
|
||||||
dropdown.select(option.options.indexOf(value));
|
dropdown.select(option.options.indexOf(value));
|
||||||
dropdown.render(optionContainer);
|
dropdown.render(optionContainer);
|
||||||
|
|||||||
Reference in New Issue
Block a user