sequenceDiagram
participant U as User
participant MF as Modal Forms
participant MM as Metadata Menu
participant TP as Templater
Note over U: Before creating a new note
U->>MF: Create form
MF->>MF: select MM type
Note over U: 1. Create a new note
U->>TP:
MM->>MF: settings
MF->>MF: file classes from settings
MF->>MF: default values from file classes
alt Without CBs
Note over U: 2. Select file class
MF->>U: file class suggester
MF->>MF: Get fields for type
end
Note over U: 3. Select values
MF->>U: Display form
U->>MF: values
MF->>TP: fields
TP->>TP: format fields
Note over U: 4. Done
Without having looked at the code for MF, the "ideal" solution (at least for my use-case) would look something similar to this.
MF would need to be able to support MM, requested in FR #141. I'm assuming how that could be handled by MF, but there might be a better way, working directly with the maintainter of MM for instance. Maybe it's a feature request that MM feels it wants to add to their public API instead? It would save a lot of work and avoid metadata management in 2 areas, or have some feature that feels very shoe-horned into MF.
At any rate, to make it work with MF I'm highlighting as an alt in the diagram above a new feature request for callbacks. This would allow a form to be presented to the user suggesting a list of file classes. MF could presumably draw the fields for the form on-the-fly on selection change and populate them with default values setup in MM for each field, avoiding an extra step. Callbacks would be very useful in other scenarios too.
MF would also need better support for setting defaults (FR #144). Support for more types (FR #170) would also be very useful. More on that further down.
Before creating a new note, you'd create a new form with a file class field and set its
type to Metadata Menu. With that, all you'd need is to call modalForm.openForm()
in your
TP or QA template and result.getData()
or other Modal Forms API to process and insert
the metadata fields and live happily ever after knowing your data is clean and consistent.
sequenceDiagram
participant U as User
participant MF as Modal Forms
participant MM as Metadata Menu
participant TP as Templater
participant M as Modules
Note over U: 1: Create a new note
U->>TP: New note
TP->>M: get file classes
MM->>M: settings
M->>M: file classes from settings
M->>TP: file classes
Note over U: 2. Select file class
TP->>U: file class suggester
M->>M: fields for file class
Note over U: 3. Select values sequentially
loop
M->>U: field
U->>M: value
end
Note left of M: Other logic
M->>M: dv query templates
M->>TP: fields
TP->>TP: format fields
Note over U: 4. Done
This is my current solution without having the functionality in MF, which would save me lots of round trips! I'm currently relying on the Modules logic to pack messy or reusable logic away into module files. I'd currently need to construct a metadata container of my own based on MM's global settings, which feels very fragile IMO, and then repetitively prompt for each field, or try and use MF to cut down the repitition. The latter hasn't worked smoothly for me since default values have not been easy to set. That only works for string values in my experience. Return values also seem limited to string, when it would be advantageous to return other types like TFile.