Following on the discussions in #3178648: [META] Support asset hierarchy...
Create a form at location/hierarchy/%parent that serves the same purpose that /admin/structure/taxonomy/farm_areas served in farmOS 1.x: a drag-and-drop UI for arranging the hierarchy of location assets ("area terms" in 1.x lingo).
Key requirements:
- Allow working with subsets of the hierarchy by including a /%parent parent ID argument in the URL.
- Allow modifying the asset parents (hierarchy) but not weight (always sort alphabetically)
- Handle assets with multiple parents intuitively (allow moving the asset under one parent without affecting the other(s))
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 3179023-4.patch | 12.58 KB | pcambra |
| #4 | farm_asset_reorder.zip | 5.5 KB | pcambra |
Issue fork farm-3179023
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
m.stentaComment #3
pcambraComment #4
pcambraHere's a first stub of the feature, integrating it back from the standalone module.
I haven't been able to test this bit because we need to integrate https://www.drupal.org/project/inspire_tree for composer to realise what it needs to do.
Attaching the standalone module too!
Comment #5
m.stentaThanks @pcambra! This is great!!!
I've started a
2.x-location-hierarchybranch with your patch as the first commit: https://github.com/mstenta/farmOS/tree/2.x-location-hierarchy - I figure we can work in this branch moving forward (feel free to check it out yourself and add commits).I moved the relevant code out of the
assetmodule and into a newfarm_ui_locationmodule. I also moved/asset-locationsto simply/locationsand added a top level menu item for it.Lastly, I added
$query->condition('is_location', TRUE);to thebuildTree()method to limit the asset to "location assets".That's as far as I got today. :-)
Here are some things that come to mind as next steps...
Only show
/assets/%/locationstab when an asset is a location and has children.Move
/assets/%/locationsto secondary tabs (like we did in the forest module).I'm curious if we can make the hierarchy editing "togglable". In other words: when the page first loads, it is NOT draggable, but provides some kind of button or link to "modify hierarchy" which then enables the JS. This would enable the page to serve a dual-purpose: both for viewing the list of locations in a hierarchical manner, as well as modifying the hierarchy. If you look at the /farm/areas page in farmOS 1.x right now you'll notice that it serves the former purpose (viewing the hierarchy), but also has a "change hierarchy" link which takes you to the Drupal core taxonomy hierarchy edit form. By having a "view" mode, we can also make the location names into links that take you to the individual asset records. Thus, both goals can be achieved in the same page! What do you think?
Thinking ahead... I'm also imagining adding the farmOS map to the top of the /locations page. Then we'd be at 100% parity (and even better!) with the farmOS 1.x /farm/areas page. It would also be neat to explore adding a map to the /asset/%/locations page (filtered to only include the child assets), but that may be a bit trickier. Both of those can be done in follow-up - they don't need to block this.
Comment #6
m.stentaAnother thought: I'm not sure the "ordered list" adds anything - and may just be confusing. The order doesn't get saved. Perhaps we could just change it to an unordered list?
It's also not super-obvious that the items are actually movable with click-and-drag. But perhaps just making the "toggle to hierarchy editor" step more intentional would fix that?
Comment #7
paul121 commentedThis is great! TIL there is a
Drupal.Message()JS API - awesome!+1
Not sure how much is possible.. but maybe this could replicate parts of the Taxonomy drag and drop UI? The "drag" icon used there is nice. I also like that everything is shown in a table element, its a nice UI. This would be a nice way to add an additional column for the "asset type" field. Also replicating the "Operations" column with a dropbutton to view/edit/delete each location asset could be handy.
I was confused by this too. Having the toggle would be great! But simply including some instructional text could go a long ways as well. Something to the effect of: "These are all of the assets with is_location enabled. The asset parent relationship is represented as the hierarchy." And when in editing mode... add another bit of text that explains "Drag and drop the asset names to modify the location hierarchy."
Comment #8
pcambraComment #9
pcambraMany thanks for the clear branch and feedback, folks!
Adding a toggle button that "enables" the edit of the hierarchy would be really good imho. As it could be a risk to move something by accident.
Regarding the ordered list, I've been looking at this and I think this is how the library works, we could add some CSS to remove the list style type and add some crosshair icon.
Comment #10
pcambraRemainingt tasks:
Comment #11
m.stentaSorry to keep adding things but just found this in my notes... :-)
Comment #12
m.stentaI'm having second thoughts about this - especially in lieu of recent thoughts/discussions around #3188586: Add Views of logs that reference assets.
Let's hold off on moving any tabs to the secondary tab level for now and think about all of them more holistically.
Comment #13
m.stentaComment #14
pcambraWIP is in https://github.com/pcambra/farmOS/tree/2.x-location-hierarchy
Add a crosshair icon that replaces the numbers of the olNot a crosshair but a folder/document structure, we can change it later by overriding the icons from inspire tree in the location ui moduleOnly show the locations tab if there are childrenDone in my location branchAdd local libraries from inspire tree and lodash as npm assets, see https://github.com/farmOS/farmOS/blob/7668715633e6f89a9c8c9db0625d025558... and https://github.com/farmOS/composer-project/blob/f00490da3b62930d8a29ceca...Done in inspire tree moduleMake assets into linksIncluded in the branchAdd a toggle button to enable the drag and drop featureIncluded in the branch, although the UI/UX can be improvedComment #15
pcambraComment #16
pcambraAdded PR on https://github.com/mstenta/farmOS/pull/1
Comment #17
pcambra- Sometimes can't drag child into another folder (parent) - we thought it had to do with the parent being expanded/not - but then it happened even when it was expanded too... seems inconsistent, hard to replicate
- Nice to have: disable link while drag+drop
- When item is moved to a new parent, in the /asset/%/locations page, it ADDs a parent but does not remove the original parent - resulting in 2 parents... but this does NOT happen in /locations. This is caused by the toggle not refreshing the tree properly.
Comment #19
m.stentaThis is awesome @pcambra! Merged!