Hi everyone,
This proposal is a follow-up to Live Data's entry creation save behavior, focusing on template support (including default values) as mentioned in Loading....
As a reminder, once Loading... is merged, a new row in edit mode stays a draft until it receives an edit, which then creates the entry.
With a template, the draft would simply start pre-filled: the source exposes the template’s values in the addEntry action (as it already does for the location), and the preview action is called with the template parameter. Pre-filled values don’t count as an edit, so “Add entry” keeps having no side effect, and on creation the template is actually applied server-side and merges the values received from the user.
While this behavior is straightforward, there are a few questions left:
1. What should we use as a template?
- A template provider, for AWM, we currently have template providers (
XWiki.TemplateProviderClass): a provider references a template document, and can also define where to store pages (more on that in section 3). - Default values in the Live Data configuration: a
defaultValueparameter on the property descriptors (next to the newmandatoryflag), set in the JSON content of the Live Data macro. Unlike templates, it doesn’t depend on the source, so it would work for any Live Data.
I’d go with 1: it reuses an existing mechanism and also works well as a livetable replacement for AWM. Note that the two aren’t mutually exclusive; it’s definitely possible to have the two mechanisms later on.
2. How should the user configure the template?
This only really applies if we go with option 1 of section 1.
- Explicit only: a
newRowTemplateProvidersource parameter, likenewRowLocation. - Implicit only: always use the class’s template provider following AWM’s naming convention (the class name with
Classreplaced byTemplateProvider), without any parameter. AWM applications would get their template without any configuration. However, there would be no way to use another template, or disable it (unless we add adisableTemplateProvideroption). - Explicit, with an implicit default: a
newRowTemplateProvidersource parameter, falling back on the provider from 2 when it isn’t set.
I lean towards 3, which would also allow disabling the template by providing an explicitly empty newRowTemplateProvider parameter.
3. Where should the entries be created?
Again, this only really applies if we go with option 1 of section 1.
Besides the template, the provider’s creationRestrictions may contain a location for new entries. In AWM, the entry is then named after what the user typed, which is also used as its title. On the Live Data side, this is currently the job of the naming strategy (newRowNamingStrategy, with newRowLocation), so the two overlap:
- Independent: the template only provides default values, and the naming strategy and
newRowLocationstay required and unchanged. - A new
templatestrategy: if used, we basically follow AWM’s convention: location if present in the template, current space if empty, and use the title as page name (so, same as Loading...). - Implicit AWM logic: AWM’s convention applies automatically, without any naming strategy.
I lean towards 2: it adds the most flexibility while still supporting AWM with a simple setting.
What do you think? Don’t hesitate to add anything I might have missed.
Thanks.