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

Show post ID in postselect dropdown option labels #660

Closed
danieliser opened this issue Apr 22, 2019 · 7 comments
Closed

Show post ID in postselect dropdown option labels #660

danieliser opened this issue Apr 22, 2019 · 7 comments
Milestone

Comments

@danieliser
Copy link
Member

danieliser commented Apr 22, 2019

(1): Hello World

Or

Hello World <small>(1)</small>

So that if you have 2 pages with the same name/slug you can tell the difference.

@fpcorso fpcorso added this to the v1.12 milestone Jun 5, 2020
@fpcorso
Copy link
Contributor

fpcorso commented Jul 16, 2020

@danieliser Just to clarify: Which dropdown is this referring to? The selected page/post conditions in the "Targeting" section of the popup editor?

@danieliser
Copy link
Member Author

@fpcorso Yea, plenty of sites with multiple pages using same name, hard to differentiate them in those dropdowns.

@fpcorso
Copy link
Contributor

fpcorso commented Jul 29, 2020

@danieliser The conditions system is a web of files and scripts. After A LOT of hunting, narrowed down to somewhere within pumselect2. We really need to add some sort of documentation/wiki for these systems as I still am not sure how this all works even after spending an hour going through all these files.

First, the _selected conditions are defined here as postselect type: https://github.com/PopupMaker/Popup-Maker/blob/master/classes/Conditions.php#L235

Which gets called to render in conditions.js: https://github.com/PopupMaker/Popup-Maker/blob/master/assets/js/src/admin/popup-editor/plugins/conditions.js#L124

Which calls field in templates.js: https://github.com/PopupMaker/Popup-Maker/blob/master/assets/js/src/admin/general/plugins/templates.js#L384

After a lot of debugging, I found that, upon clicking, it calls the AJAX and processResults in select2.js: https://github.com/PopupMaker/Popup-Maker/blob/master/assets/js/src/admin/general/plugins/select2.js#L30

Which queries the DB in object_search method in Ajax.php: https://github.com/PopupMaker/Popup-Maker/blob/master/classes/Admin/Ajax.php#L19

This eventually fires of a prototype.option of the pumselect2 in the vendor folder: https://github.com/PopupMaker/Popup-Maker/blob/master/assets/js/src/admin/general/vendor/select2.full.custom.js#L3148

I am unsure where we would want to modify the option labels for the dropdown. Should we modify in select2.js in the processResults to foreach over all items and change text to include the ID? Should we modify the Ajax object_search to include the ID in the text key? Both of those seems to be used a variety of places so not sure what that would affect.

@fpcorso
Copy link
Contributor

fpcorso commented Aug 3, 2020

@danieliser Then we don't re-use the select2 pinging that AJAX endpoint anywhere else besides in the conditions, right?

Okay, I'll make those changes and get them committed.

@fpcorso
Copy link
Contributor

fpcorso commented Aug 6, 2020

@danieliser Done. I originally did just the number (15) but it wasn't super clear what that number was so I did (ID: 15) instead.
image

@fpcorso fpcorso closed this as completed Aug 6, 2020
@danieliser
Copy link
Member Author

@fpcorso that is perfect, was exactly what I had envisioned. That solves at least 5-10 tickets a year if not a lot more as that is only what I see. Also just more polished now.

@fpcorso fpcorso mentioned this issue Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants