bug #13734 [JS] add empty value to autocomplete selects (SirDomin)

This PR was merged into the 1.10 branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | 1.10
| Bug fix?        | no
| New feature?    | yes
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | 
| License         | MIT

<img width="688" alt="image" src="https://user-images.githubusercontent.com/22825722/157185202-a7e49b9f-4826-4044-b68c-0a1a2e7d71af.png">

Adds empty field, which allows user to reset autoselect.

<!--
 - Bug fixes must be submitted against the 1.10 or 1.11 branch(the lowest possible)
 - Features and deprecations must be submitted against the master branch
 - Make sure that the correct base branch is set

 To be sure you are not breaking any Backward Compatibilities, check the documentation:
 https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html
-->


Commits
-------

0c24045f7f [JS] add empty value to autocomplete selects
This commit is contained in:
Grzegorz Sadowski 2022-03-11 06:52:37 +01:00 committed by GitHub
commit c79a481bd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -35,12 +35,19 @@ $.fn.extend({
return settings; return settings;
}, },
onResponse(response) { onResponse(response) {
let results = response.map(item => ({
name: item[choiceName],
value: item[choiceValue],
}));
results.unshift({
name: '&nbsp;',
value: '',
});
return { return {
success: true, success: true,
results: response.map(item => ({ results: results,
name: item[choiceName],
value: item[choiceValue],
})),
}; };
}, },
}, },