Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Choices: Introduce an API to define the value for choices added using a Fast Entry pop-up editor #5514

Closed
JaneSjs opened this issue May 21, 2024 · 0 comments · Fixed by #5525
Assignees
Labels
enhancement user issue An issue or bug reported by users.
Milestone

Comments

@JaneSjs
Copy link
Contributor

JaneSjs commented May 21, 2024

IMPLEMENTED

Use the onFastEntryFinished event to handle entered text lines the way your require.

import { SurveyCreatorModel } from "survey-creator-core";
const options = { ... };
const creator = new SurveyCreatorModel(options);

creator.onFastEntryFinished.add((_, options) => {
  // `options.lines` - An array of entered text lines
  // `options.items` - An array of choices that were created based on the entered text lines
  options.items[0].text = "Custom display text";
  options.items[0].value = "Custom value";
});

Documentation


T18227 - Automatic choice injection
https://surveyjs.answerdesk.io/internal/ticket/details/T18227


When you use the fast entry editor, you expect to specify the value and text separated by |.

1 | Option-1
2 | Option-2
3 | Option-3
4 | Option-4
5 | Option-5

image

Choices with a corresponding value and text will be created.
image

However, if you do not explicitly specify the value attribute, as follows:

Option-1
Option-2
Option-3
Option-4
Option-5

Those strings will be used as values:
image

In a usage scenario, it's required to use supplied strings as texts and auto-generate ordered numbers for these choices to achieve the following output:
image

Consider introducing an API which would allow developers to manage auto-generated choices and override their values and texts. For the record: creator.onItemValueAdded is raised only when adding a new choice via the Add New button.

@JaneSjs JaneSjs added enhancement user issue An issue or bug reported by users. labels May 21, 2024
andrewtelnov added a commit that referenced this issue May 23, 2024
tsv2013 pushed a commit that referenced this issue May 27, 2024
#5525)

* Choices - Introduce an API which would allow defining the value for choices added via a Fast Entry editor fix #5514

* Fix unit tests

* Rename event and options type #5514

* Add descriptions

---------

Co-authored-by: RomanTsukanov <sergeich16@gmail.com>
@OlgaLarina OlgaLarina added this to the v1.10.6 milestone May 29, 2024
@RomanTsukanov RomanTsukanov changed the title Choices - Introduce an API which would allow defining the value for choices added via a Fast Entry editor Choices: Introduce an API that would allow defining the value for choices added using a Fast Entry pop-up editor May 29, 2024
@RomanTsukanov RomanTsukanov changed the title Choices: Introduce an API that would allow defining the value for choices added using a Fast Entry pop-up editor Choices: Introduce an API to define the value for choices added using a Fast Entry pop-up editor May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement user issue An issue or bug reported by users.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants