-
Notifications
You must be signed in to change notification settings - Fork 707
[RFR] Send API request on reference auto-complete #508
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
d9942ae
Send API request on reference auto-complete
jpetitcolas d91da77
Add ReferenceFieldView test
jpetitcolas d7bf2a5
Implement last tests on reference field
jpetitcolas 092d62f
Add remote API call to reference many field
jpetitcolas 118c1a0
Add more tests
jpetitcolas 1d30f8d
Update documentation
jpetitcolas 68ffb96
Fix various issues on reference fields
jpetitcolas 8295a3b
Allow to embed all references in select list, without API requests
jpetitcolas 4f01bb1
Apply map functions on reference labels
jpetitcolas f4e695d
Fix dependencies
jpetitcolas f0aa340
Base Reference[Many] fields on Choice[s] fields
jpetitcolas 1d3feec
Create ReferenceRefresher service
jpetitcolas 797be96
Fix last unit tests
jpetitcolas 3e2dcad
Fix e2e tests
jpetitcolas 1f16774
Update configuration
jpetitcolas 6133a65
Start optimizing requests for autocomplete
jpetitcolas be7832e
Add more unit tests
jpetitcolas a1578eb
Update reference many field with Refresher getInitialChoices method
jpetitcolas c895200
Use autocompleteOptions instead of refreshDelay option
jpetitcolas b312057
Update ui-select version
jpetitcolas 9c95ec5
Rename autocomplete to remoteComplete
jpetitcolas ae14c31
Fix last tests
jpetitcolas ac00db7
Update admin-config
jpetitcolas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| function maReferenceField(ReferenceRefresher) { | ||
| return { | ||
| scope: { | ||
| 'field': '&', | ||
| 'value': '=', | ||
| 'entry': '=?', | ||
| 'datastore': '&?' | ||
| }, | ||
| restrict: 'E', | ||
| link: function(scope) { | ||
| var field = scope.field(); | ||
| scope.name = field.name(); | ||
| scope.v = field.validation(); | ||
|
|
||
| function refresh(search) { | ||
| return ReferenceRefresher.refresh(field, scope.value, search) | ||
| .then(formattedResults => { | ||
| scope.$broadcast('choices:update', { choices: formattedResults }); | ||
| }); | ||
| } | ||
|
|
||
| if (field.remoteComplete()) { | ||
| ReferenceRefresher.getInitialChoices(field, [scope.value]) | ||
| .then(options => { | ||
| scope.$broadcast('choices:update', { choices: options }); | ||
| }); | ||
|
|
||
| scope.refresh = refresh; | ||
| } else { | ||
| refresh(); | ||
| } | ||
| }, | ||
| template: `<ma-choice-field | ||
| field="field()" | ||
| datastore="datastore()" | ||
| refresh="refresh($search)" | ||
| value="value"> | ||
| </ma-choice-field>` | ||
| }; | ||
| } | ||
|
|
||
| maReferenceField.$inject = ['ReferenceRefresher']; | ||
|
|
||
| module.exports = maReferenceField; | ||
|
|
56 changes: 56 additions & 0 deletions
56
src/javascripts/ng-admin/Crud/field/maReferenceManyField.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| function maReferenceManyField(ReferenceRefresher) { | ||
| 'use strict'; | ||
|
|
||
| return { | ||
| scope: { | ||
| 'field': '&', | ||
| 'value': '=', | ||
| 'entry': '=?', | ||
| 'datastore': '&?' | ||
| }, | ||
| restrict: 'E', | ||
| link: function(scope) { | ||
| var field = scope.field(); | ||
| scope.name = field.name(); | ||
| scope.v = field.validation(); | ||
| scope.choices = []; | ||
|
|
||
| function refresh(search) { | ||
| return ReferenceRefresher.refresh(field, scope.value, search) | ||
| .then(formattedResults => { | ||
| scope.$broadcast('choices:update', { choices: formattedResults }); | ||
| }); | ||
| } | ||
|
|
||
| // if value is set, we should retrieve references label from server | ||
| if (scope.value) { | ||
| ReferenceRefresher.getInitialChoices(field, scope.value) | ||
| .then(options => { | ||
| scope.$broadcast('choices:update', { choices: options }); | ||
|
|
||
| if (field.remoteComplete()) { | ||
| scope.refresh = refresh; | ||
| } else { | ||
| refresh(); | ||
| } | ||
| }); | ||
| } else { | ||
| if (field.remoteComplete()) { | ||
| scope.refresh = refresh; | ||
| } else { | ||
| refresh(); | ||
| } | ||
| } | ||
| }, | ||
| template: `<ma-choices-field | ||
| field="field()" | ||
| datastore="datastore()" | ||
| refresh="refresh($search)" | ||
| value="value"> | ||
| </ma-choice-field>` | ||
| }; | ||
| } | ||
|
|
||
| maReferenceManyField.$inject = ['ReferenceRefresher']; | ||
|
|
||
| module.exports = maReferenceManyField; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised this works, I had to return a function because Angular complained about an infinite look. Needs further testing.