mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
1654a2681f
Summary: This moves all client code to core, and makes minimal fix-ups to get grist and grist-core to compile correctly. The client works in core, but I'm leaving clean-up around the build and bundles to follow-up. Test Plan: existing tests pass; server-dev bundle looks sane Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D2627
28 lines
769 B
JavaScript
28 lines
769 B
JavaScript
var _ = require('underscore');
|
|
var dispose = require('../lib/dispose');
|
|
var TextEditor = require('./TextEditor');
|
|
|
|
const {autocomplete} = require('app/client/ui2018/menus');
|
|
|
|
/**
|
|
* ChoiceEditor - TextEditor with a dropdown for possible choices.
|
|
*/
|
|
function ChoiceEditor(options) {
|
|
TextEditor.call(this, options);
|
|
|
|
this.choices = options.field.widgetOptionsJson.peek().choices || [];
|
|
|
|
// Add autocomplete if there are any choices to select from
|
|
if (this.choices.length > 0) {
|
|
|
|
autocomplete(this.textInput, this.choices, {
|
|
allowNothingSelected: true,
|
|
onClick: () => this.options.commands.fieldEditSave(),
|
|
});
|
|
}
|
|
}
|
|
dispose.makeDisposable(ChoiceEditor);
|
|
_.extend(ChoiceEditor.prototype, TextEditor.prototype);
|
|
|
|
module.exports = ChoiceEditor;
|