mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-04 09:35:38 -05:00
* enable stricter compile settings in extensions * more strict compile * formatting * formatting * revert some changes * formtting * formatting
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
// This code is originally from https://github.com/DonJayamanne/bowerVSCode
|
|
// License: https://github.com/DonJayamanne/bowerVSCode/blob/master/LICENSE
|
|
|
|
import { window } from 'vscode';
|
|
import Prompt from './prompt';
|
|
import EscapeException from './escapeException';
|
|
|
|
const figures = require('figures');
|
|
|
|
export default class CheckboxPrompt extends Prompt {
|
|
|
|
constructor(question: any, ignoreFocusOut?: boolean) {
|
|
super(question, ignoreFocusOut);
|
|
}
|
|
|
|
public render(): any {
|
|
let choices = this._question.choices.reduce((result: any, choice: any) => {
|
|
let choiceName = choice.name || choice;
|
|
result[`${choice.checked === true ? figures.radioOn : figures.radioOff} ${choiceName}`] = choice;
|
|
return result;
|
|
}, {});
|
|
|
|
let options = this.defaultQuickPickOptions;
|
|
options.placeHolder = this._question.message;
|
|
|
|
let quickPickOptions = Object.keys(choices);
|
|
quickPickOptions.push(figures.tick);
|
|
|
|
return window.showQuickPick(quickPickOptions, options)
|
|
.then(result => {
|
|
if (result === undefined) {
|
|
throw new EscapeException();
|
|
}
|
|
|
|
if (result !== figures.tick) {
|
|
choices[result].checked = !choices[result].checked;
|
|
|
|
return this.render();
|
|
}
|
|
|
|
return this._question.choices.reduce((result2: any, choice: any) => {
|
|
if (choice.checked === true) {
|
|
result2.push(choice.value);
|
|
}
|
|
|
|
return result2;
|
|
}, []);
|
|
});
|
|
}
|
|
}
|