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

Fix Error when setting default value on a reference field in creationView #1398

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions build/ng-admin.min.css

Large diffs are not rendered by default.

113 changes: 57 additions & 56 deletions build/ng-admin.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/ng-admin.min.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
"Fedor Belov (https://github.com/fedotxxl)",
"Tal Avissar (https://github.com/talaviss)",
"yannis despotopoulos (https://github.com/dealboy)",
"James Rivett-Carnac <[email protected]> (https://github.com/yarbelk)"
"James Rivett-Carnac <[email protected]> (https://github.com/yarbelk)",
"Viet Ta <[email protected]> (https://github.com/envil)"
]
}
14 changes: 14 additions & 0 deletions src/javascripts/ng-admin/Crud/routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,20 @@ function routing($stateProvider) {

return entry;
}],
referenceData: ['ReadQueries', 'view', 'entry', function (ReadQueries, view, entry) {
return ReadQueries.getReferenceData(view.fields(), [entry.values]);
}],
referenceEntries: ['dataStore', 'view', 'referenceData', function (dataStore, view, referenceData) {
const references = view.getReferences();
for (var name in referenceData) {
Entry.createArrayFromRest(
referenceData[name],
[references[name].targetField()],
references[name].targetEntity().name(),
references[name].targetEntity().identifier().name()
).map(entry => dataStore.addEntry(references[name].targetEntity().uniqueId + '_values', entry));
}
}],
choiceData: ['ReadQueries', 'view', function (ReadQueries, view) {
return ReadQueries.getAllReferencedData(view.getReferences(false));
}],
Expand Down