Closed macMikey closed 4 years ago
@macMikey It seems to me that you are confusing the demo application file structure with the DataView helper file structure. A helper's file structure is completely independent of the Levure application that they are used in. The DataView is, by design, a barebones control. It is meant to be built upon. I touch upon that in a recent blog post:
In the demo application the templates
folder holds the templates used in the application. That is logical. They are specific to that demo app. They are not intended to be distributed as individual helpers (they would require much more work).
What you are trying to do is create a helper that extends the DataView (or DataView Tree) in a very specific way and has had the extra work done to make a standalone control that can be dropped into an app. Because you are creating a specialized control by extending the DataView it makes sense to include the templates within your helper folder. Helpers already have support for including all of the stack files you need so there won't be a problem.
If you are trying to create a file browser helper then your helper.yml file might look like this:
behaviors:
- filename: filebrowser.livecodescript
ui:
- filename: ./templates/dataview directory tree.livecode
encrypt: false
- filename: filebrowser_template.livecode
encrypt: false
The filebrowser.livecodescript
behavior will use the "DataView Tree Behavior" as the parent behavior (e.g. script "FileBrowser DataView Behavior" with behavior "DataView Tree Behavior"
). This behavior will contain all of your code that makes the File Browser behavior possible. This is where you can add additional setProp handlers, etc., just like the DataView Tree does.
Next is the row template(s). Because your file browser will require one or more row templates you include them in the helper folder. You can create a ./templates
folder in the helper folder and place the "dataview directory tree" folder in there. If you end up using more row templates just add them to the templates
folder.
You bring the row templates and the behavior script together in the filebrowser.livecodescript
stack file. This stack has your File Browser DataView group control. The behavior assigned to this group is the "FileBrowser DataView Behavior" stack. The viewProps["row style templates"]
DataView custom property points to the groups in your template stacks.
This control can be copied and pasted into any card in the Levure application and the developer should have a working control that they can use. I don't know the best way to do that. Can someone add a control to the tools palette? Maybe your helper has a command in a library script that copies the template control onto the current card of the defaultStack?
Hopefully this helps clarify how you can distribute more specialized controls built on top of the DataView or the DataView Tree.
You are correct, I didn't go the other way (start at DVT and dive headlong into building up from there). Thanks for this in-depth response. Back to banging on it...
After I read the above explanation, I'm back to "this needs effort". After three paragraphs, I was left asking "Is this really better than a datagrid or a list field or a modTableField?" Perhaps a video will help change my mind. The demo looks cool, and the idea seems cool, but when diving in and trying to build something with it, it feels like more work than using another technique.
It is the exact same technique as a DataGrid Form. There is a row template and you assign templates to row types. There is no UI though so it is a more manual process right now. That makes it much more difficult because there are no prompts and nothing is automated.
DataView is faster and more efficient than a DataGrid and can be extended to support things likes trees. The UI is much more customizable than a list field since each row is defined with a group. It has no table fields so it wouldn't replace modTableField or a DataGrid table.
I’m going to have some time this evening. I’ll put together a file browser example helper.
If you have time, do a video, please. Whatever it is that is mental-blocking me might make it all clearer.
I've uploaded what I've done so far. I created a file_browser repo:
https://github.com/trevordevore/levurehelper-file_browser
And I updated the demo to use it:
https://github.com/trevordevore/dataview_demo
Request for video noted.
Cool, thanks. I will pick both of these apart and see if I can get past my mental mush.
I am not a fan of the current DV/DVT file structure. I am trying to deconstruct the directory demo so I can build a helper that can be submoduled and included in other projects fairly easily. The file structure makes this a challenge because of the placement and use of the various files. I think that a rethink of the placement and use of the templates folder would be helpful, as I think it is going to make deployment of DV's and DVT's more complicated than it should be. After I stripped everything else out of the demo except for pieces-parts directly related to this, I still have a bunch of work to do. I don't know if I can simplify this enough to make it easy to add. We'll see. See screenshot. Exercises for the reader: