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

Allow to filter query_args in post_select ajax call #744

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ivankristianto
Copy link

@ivankristianto ivankristianto commented Jun 15, 2017

I add post id to the post_select ajax call, then a allow to alter the query args for more extendability.

This will solve my issue that return the post list based on which post type it's currently editing.
and it also can fix this issue #625

@goldenapples
Copy link
Contributor

I can see how this would be useful, but - since editors containing shortcodes can appear in more places than just on a post edit screen - I think we might need to figure out a more abstract way of representing the context of the current editor, which then can be passed into queries like ajax call for 'post_select' fields.

I have a branch started locally trying to address this for #661 which I need to polish up. I'll see if it can work well with what you have here.

Finally, it might be good to see the javascript logic live inside the parent class editAttributeSelect2Field, rather than in editAttributeFieldPostSelect, so that we can make use of the same filters for user select and term select fields?

@ivankristianto
Copy link
Author

Thanks @goldenapples interested to see how you did the abstraction.
And yes, I agree with you to move the postId arg to parent class. PR updated.

@@ -43,7 +43,8 @@ sui.views.editAttributeSelect2Field = sui.views.editAttributeField.extend( {
var request = {
include : _preselected,
shortcode : this.shortcode.get( 'shortcode_tag'),
attr : this.model.get( 'attr' )
attr : this.model.get( 'attr' ),
postid : $( '#post_ID' ).val()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's actually one other place in select2-fields.js where we should be passing the post ID. Can we also add the postid argument to the search ajax request here?

(Sorry, I think I highlighted the wrong array in my earlier comment - this is the request for initially loading the preselected posts when opening a shortcode ui.)

@goldenapples goldenapples added this to the next release milestone Jun 29, 2017
@ivankristianto
Copy link
Author

@goldenapples lol i didn't realize that either. I updated the PR

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

Successfully merging this pull request may close these issues.

2 participants