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

ISSUE-23: New Panorama Builder Webform Element #24

Merged
merged 55 commits into from
Feb 7, 2020
Merged

Conversation

DiegoPino
Copy link
Member

@DiegoPino DiegoPino commented Oct 3, 2019

What is new panorama?

See #24 23

There is just too much here:

  • New WALL-OF-JS to deal with adding hotspots, keeping track, etc.
  • CSS
  • The new Webform Element.
  • Writes and reads JSON structures for Panorama Tours. And it does it well.
    Example:
{
 "panorama_tour": [
        {
            "scene": "18",
            "hotspots": [
                {
                    "id": "panorama_tour_1",
                    "yaw": "78.53138342389244",
                    "text": "To the Other scene by the lake",
                    "type": "scene",
                    "pitch": "-0.7553843066484961",
                    "sceneId": "17"
                }
            ]
        },
        {
            "scene": "17",
            "hotspots": [
                {
                    "id": "panorama_tour_6",
                    "yaw": "98.9895801803955",
                    "text": "Path Down",
                    "type": "scene",
                    "pitch": "-23.966429397715082",
                    "sceneId": "18"
                },
                {
                    "id": "panorama_tour_7",
                    "yaw": "-60.1068717869932",
                    "text": "Path Up",
                    "type": "info",
                    "pitch": "3.4297621386408266"
                },
                {
                    "id": "panorama_tour_8",
                    "yaw": "-6.4162014764956865",
                    "text": "Base of the path by the lake",
                    "type": "info",
                    "pitch": "-13.273733747760536"
                },
                {
                    "id": "panorama_tour_10",
                    "yaw": "78.53138342389244",
                    "text": "back to another Scene",
                    "type": "scene",
                    "pitch": "-0.7553843066484961",
                    "sceneId": "16"
                }
            ]
        },
        {
            "scene": "16",
            "hotspots": [
                {
                    "id": "panorama_tour_11",
                    "yaw": "78.53138342389244",
                    "text": "To the Other scene by the lake",
                    "type": "scene",
                    "pitch": "-0.7553843066484961",
                    "sceneId": "17"
                }
            ]
        }
    ]
}
  • You can add Hospots of 3 types, Text, Other ADOs, To Other Panoramas as Scenes.
  • New Drupal Ajax Command to add hotspots on the fly
  • This brings also an improvement to the Entity Reference View Display we had. Now we can render out Thumbnails! Means visual auto autoselect! See ISSUE-20: SearchAPI/Views driven Entity Reference Autocomplete #21 Also, this fixes something that has been open in Core D8 for years (at least for us, us that like Solr)
  • Sadly it requires a patch in Webforms (see commented piece)
    if ($element['#selection_handler'] != 'views') { //$options = self::translateOptions($options, $element); }

This should become a patch for archipelago-deployment. Best solution would be to actually check if the #selection_handler set is an actual views, even a custom one. Instead of assuming all is provided by core. We are not CORE!

at \Drupal\webform\Element\WebformEntityTrait::setOptions
Because it assumes that views is the only views selection handler possible. Leaving our custom Solr Views Work out! And we did a great job convincing D8 that ours is legit and follows the path to greatness! But not webfoms... webforms does not like it.

Finally. Found out that Webforms module can only Save Submissions (no worries, not our SBF, those are handled by us!) like the ones that go into logs and its own Database that are 2 levels deep. Another big bug. So yeah.... 2 AM. We should force disable that option (override settings) when using our own Webform Handler. I need to sleep.

@todo (next iteration since this is a beta2 and its already too large).

  • Check validation callbacks for each tiny little field. We have many
  • Check Delete scenes on existing large panoramas. Should work in every case
  • Check if we can add a second UUID key to the panorama in case something needs to be reingested. This can really just be done when serializing things out and not in live data. Just an idea
  • Make code smaller. Its HUGE.

There were quite some issues on the fact i was building a Full app inside a single Form element, so the solution is over worked and required tapping into the whole formBuilder class and looking at the exact data flow inside the form states. For security, consistency, we keep now the full 'All Scenes' complex array inside a Form State Value but also as an input Value, serialized as a JSON string in a hidden field. Feels over-engineered, but for some Webform reason, Value elements don't play well/nor are seeing by the ValueCallback and the Composite Webform base class.

There is just too much here:
- New JS to deal with adding hotspots, keeping track, etc.
- CSS
- The new Element. Needs quite more work, settings, configuration options, etc. I s writing data to JSON correctly, but needs another commit to read it, because of the nested reality of the elements (its a single Render Element with a deep hierarchy)
- Editing added Hotspots is still not working, but close.
- New Drupal Ajax Command to add hotspots on the fly
- Also, this brings also an improvement to the Entity Reference View Display we had. Now we can render out Thumbnails! Means visual auto autoselect!
- Sadly it requires a patch in Webforms
 if ($element['#selection_handler'] != 'views') {
      //$options = self::translateOptions($options, $element);
    }
at \Drupal\webform\Element\WebformEntityTrait::setOptions
Because it assumes that views is the only views selection handler possible. Leaving our custom Solr Views Work out! And we did a great job convincing D8 that ours is legit! But not webfoms.

Finally. Found out that Webforms can only Save Submissions (no worries, not our SBF!) like the ones that go into logs and its own Database that are 2 levels deep. Another big bug. So yeah.... 2 AM. I need to sleep.
@DiegoPino DiegoPino added enhancement New feature or request UI/UX The thing people do when in front of a screen Webform Elements Things with input to fill and interact with while ingesting metadata Search API Anything Solr Driven labels Oct 3, 2019
@DiegoPino DiegoPino self-assigned this Oct 3, 2019
@DiegoPino DiegoPino changed the title New Panorama Builde Webform Element ISSUE-23: New Panorama Builder Webform Element Oct 3, 2019
This requires a second set of arguments
One to include things
another to exclude
When Nomintatim gives us no results, better to have those options initialized!
Don't code when tired. Don't. Don't
Also. Removing for now Validation until its really working
],
'#button_type' => 'default',
'#visible' => 'true',
'#limit_validation_errors' => FALSE
Copy link
Member Author

Choose a reason for hiding this comment

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

Note to myself. This is affecting the Webform interaction when using them as ingest method. If this element is in any other step that the first, when pressed it resets the step counter (which Webform provides) and we go to step 1.

Almost there. Saving and reading back of a single Panorama is working. Also JS loading of hotspots over existing ones in the Source Entity.
Still `@TODO:`
- Multiple Scenes loading for editing: Idea would be to pop first scene and do as we do now, store the other scenes in temp storage in the formstate, so we can use a select box to go back and forth. Would work the same to add other scenes
- Remove the nasty hotspots_tmp array from form state during valueCallback. Tried and i killed hotspot generation via JS. I just need to cleanup those values when done processing, but not during interaction. I have some ideas, but need to re-recall the order of operation of all the callbacks we have, maybe i can even cleanup this during element validation. But pretty sure its Webform that is blindly pushing all internal elements into the #value key of the top/visible element, breaking the need. Will get there.
- Remove all the debug statements! Looks like a Xmas tree now
Since Hotspots are not in the DOM yet, Drupal can not -ajaxify- them manually.

This makes use of format_strawberryfield ISSUE-20 branch and simple adds, on hotspot add, Click handlers that open Modals with the content. All the logic is really on Strawberryfield Formatter.
This is done just to unify functionality since this was already working with the normal ajax-ify method of Drupal (since they become part of the DOM while dialog ajax is already loaded and get processed correctly).
No need to committ this sha-na-ni-gans
Also, i never liked the idea of having extra data in the hotspot metadata.
Now this looks better.
WIP but will commit. Now, if the #default value is an array of scenes, it takes the first scene and pops it into the #default saving the rest of the scenes in a temporary form state.

I also remove the "Multiple" Option for this element, the idea is to have multiple Scenes in a Tour, but not Multiple Tours in a single Object. Too much overhead and adds little to the UX.

A lot of new overriden stuff but also some cleanup and less hardcoded options. Not ready, but way better than today in the morning. tomorrow we will have this done!
Will use this to move hotspot part of the form to one side of the Webform element so make this "decent"
Make sure we can iterate over the thing there. Also, push back to HTML the hfov value. Used to define the initial horizontal field of view. We can do that now!
Still need to remove error_logs all over the place but now it actuall allows to change between Scenes, and add dynamically hotspots, swap back and forth and  only saves what we need, more and not less. Also works when starting from scratch. Well, looking good and not failing after so many tests...

Pretty tired, will just continue first hour in the morning. This is pretty sweet and i feel kinda the largest dev for realz in this panorama thingy we are into
Not my taste, basically doing prefix and suffix. But no time today to do it proper prerender or preprocess callbacks.
Also should fix the JS that is hiding the search button on the top (weirddd)
DiegoPino and others added 22 commits January 23, 2020 00:59
This is just an exception when running beta2 on 8.7, which should never happen because our composer is asking for 8.8. But during dev it can get complex so better do this for now
This was missing. System calls know nothing about streamwrappers, and i happened to know that and neglected!
Not a fix yet, just cleaning some messy undefined options.
This is just for testing, disabling the select element in the meantime.
Finally got it working and did some cleanup.  set initiaThis loads stored complex Panorama Tours and also creates new ones on the fly. Connects Panoramas to each other, allows Other Objects to be used as Pop Ups and also can set initial Position for panoramas, so you are actually looking to where you want they they are loaded, or via navigation you end there. Catch/main thing here is our valuecallback and the fact that we are dealing with an initial situation where form state is not being preserved because there is no form rebuild happening but also, cache has not happened yet.

The fix is a little over worked and required tapping into the whole formBuilder class and looking at the exact data flow inside the formstates. For security, consistency, since this is an actual APP inside a single form element, we keep now the full 'All Scenes' complex array inside a Form State Value but also as an input, serialized as a JSON string in a hidden field. Feels over-engineered, but for some Webform reason, Value elements don't play well/nor are seeing by the ValueCallback and the Composite Webform base class.

What is still needed now? More testing (tonight) and fill the holes of missing element validation callbacks, to make sure people actually do what is required.

This will take me 3-4 more hours. 1200 lines of code to make this happen. UI/UX is such a wonderful thing....

SO HAPPY!!!
@DiegoPino DiegoPino changed the base branch from 8.x-1.0-beta1 to 8.x-1.0-beta2 February 7, 2020 19:24
@DiegoPino
Copy link
Member Author

@marlo-longley i need this in for this iteration of Beta2. I know this has details all over the place but nothing serious breaking. So i will move forward merging. Please give this a look anyway and give it a general code reading. THERE IS A LOT! so feel free to comment inline and make questions. There is next-level code here (like the better Entity Selection View Handler) and also good old known friends. Beta2 process will mean we have 2-3 weeks for fix issues and then pack and move to Beta3. So nothing is final until it is. Thanks

@DiegoPino
Copy link
Member Author

@giancarlobi i know you are so busy. But if you could (after merge, no pressure) just look at the files that changed here it would be great, mostly so you know where we are going. We will be constructing on some of this work for runners and also for IIIF (entity selection piece to push data of collection members into the IIIF Collection manifest Twig). I also know not this weekend, you have a quite heavy week. But i can't help myself mentioning you here!!

@DiegoPino
Copy link
Member Author

Lastly @marlo-longley and @giancarlobi, since i never do such large pull requests i will not squash me merge here. I will keep each individual (including my failures) commits around so we can go back to each piece if needed. Feels better so. Thanks (now you are free of me!)

@DiegoPino DiegoPino added the bug Something isn't working label Feb 7, 2020
@DiegoPino DiegoPino merged commit 7885a2c into 8.x-1.0-beta2 Feb 7, 2020
@DiegoPino DiegoPino deleted the ISSUE-23 branch February 28, 2020 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request Search API Anything Solr Driven UI/UX The thing people do when in front of a screen Webform Elements Things with input to fill and interact with while ingesting metadata
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants