(core) Label editor for Choice/ChoiceList column editor

Summary:
Allowing a user to change labels' in Choice/ChoiceList entry editor. For updated
entries, renaming those values in all cells in the column.

Test Plan: Updated tests

Reviewers: alexmojaki

Reviewed By: alexmojaki

Subscribers: alexmojaki

Differential Revision: https://phab.getgrist.com/D3057
This commit is contained in:
Jarosław Sadziński
2021-10-06 15:12:45 +02:00
parent cf7a3153f9
commit a2e066176c
3 changed files with 111 additions and 23 deletions

View File

@@ -73,13 +73,7 @@ export class ChoiceTextBox extends NTextBox {
ChoiceListEntry,
this._choiceValues,
this._choiceOptionsByName,
(choices, choiceOptions) => {
return this.options.setAndSave({
...this.options.peek(),
choices,
choiceOptions: toObject(choiceOptions)
});
}
this.save.bind(this)
)
)
];
@@ -96,6 +90,15 @@ export class ChoiceTextBox extends NTextBox {
protected getChoiceOptions(): Computed<ChoiceOptionsByName> {
return this._choiceOptionsByName;
}
protected save(choices: string[], choiceOptions: ChoiceOptionsByName, renames: Record<string, string>) {
const options = {
...this.options.peek(),
choices,
choiceOptions: toObject(choiceOptions)
};
return this.field.updateChoices(renames, options);
}
}
// Converts a POJO containing choice options to an ES6 Map