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

Pre-populate fields (for referenced_list) #627

Closed
TimoSolo opened this issue Aug 27, 2015 · 8 comments
Closed

Pre-populate fields (for referenced_list) #627

TimoSolo opened this issue Aug 27, 2015 · 8 comments
Assignees

Comments

@TimoSolo
Copy link

Is there a way to create an "add" button on a referenced_list that links to the creation page with the targetReferenceField prepopulated with the current id?

@fzaninotto
Copy link
Member

Nope, note at the time, but that's a good idea for a PR ;)

@TimoSolo
Copy link
Author

might have to dig in the code and add it then ;)

What do you suggest for the process? I was thinking it would be cool to specify a listView object for a referenced_list, then you could specify the list actions, and any filters eg the targetReferenceField would be passed to the creation view of the list table.

What do you think? maybe too ambitious in scope..

@TimoSolo
Copy link
Author

The listView idea would also help with another problem i have where I need to specify a url for a referenced_list. For example the api has a user: /users/123 and a list of friends at /users/123/friends/

I got it to work with an ugly hack:

var users = nga.entity('users')
                        .url(function(entity, view, id, element) {
                            window.user_id = id;
                            return 'users/v1/users/' + ( id ? id+"/" : "" )
                        });
var friends = nga.entity('friends')
                        .url(function(entity, view, id, element) {
                            var user_id = window.user_id || "0"
                            return 'users/'+user_id+'/friends/' + ( id ? id+"/" : "" )
                        });

but would prefer a more elegant solution

@fzaninotto
Copy link
Member

Use another entity object for your referenced_list?

@TimoSolo
Copy link
Author

thats what im doing above ("friends" are also "user" objects), but the url to access them is different, so I had to create a new entity.

@armellarcier
Copy link
Contributor

Maybe these issues should go to StackOverflow? François? (inc. #636)

@TimoSolo
Copy link
Author

TimoSolo commented Sep 1, 2015

I have asked on SO - no answers yet :(
http://stackoverflow.com/questions/tagged/ng-admin

@fzaninotto
Copy link
Member

That's a perfectly valid solution, not a hack ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants