Writing page blueprints includes to configure wizards for easy page creation. If the field identifier contains dots there is a problem with a simple solution.
A Template Author may need to specify the identifier for an input field of a wizard for the blueprint for one of the doctypes. This identifier my contain dots which cause problems since in the JavaScript environment a dot signals a dereference of an object property. In our case the dot is just a character that is part of the identifier.
This tip is intended for users of the projectdoc Toolbox, but it will work for any blueprint for Confluence.
Change with Version 6.0
Since version 6.0 of the projectdoc Toolbox the dots in identifiers are replaced by underscores.
This is true for all identifiers used in the wizard.
projectdoc.doctype.common.name
is now specified as projectdoc_doctype_common_name
The trick is to escape the dot with two backslashes, not one.
#projectdoc\\.strategic-theme\\.duration\\.from
The identifier is specified for the Soy template that is the basis for the UI of the page blueprint wizard.
For the projectdoc Toolbox this is configured in the doctype descriptor like this:
<doctype ...>
...
<wizard template="no-homepage" form-id="strategic-theme-form">
<field template="text-field" name="projectdoc.strategic-theme.duration.from"/>
<field template="text-field" name="projectdoc.strategic-theme.duration.to"/>
</wizard>
</doctype>
We have two fields that allow the author of a new document to specify two values used as property values in the new document.
<doctype ...>
...
<properties>
...
<property key="projectdoc.doctype.common.duration.from">
<value><xml><![CDATA[<at:var at:name="projectdoc.strategic-theme.duration.from" at:rawxhtml="true"/>]]></xml></value>
<controls>hide</controls>
<resource-bundle>
<l10n>
<description>
Log the start date of the cycle this strategic theme is pursued.
</description>
</l10n>
</resource-bundle>
</property>
<property key="projectdoc.doctype.common.duration.to">
<value><xml><![CDATA[<at:var at:name="projectdoc.strategic-theme.duration.to" at:rawxhtml="true"/>]]></xml></value>
<controls>hide</controls>
<resource-bundle>
<l10n>
<description>
Log the end date of the cycle this strategic theme is pursued.
</description>
</l10n>
</resource-bundle>
</property>
...
</properties>
...
</doctype>
The wizard requires to configure the fields with a date picker.
Here is the configuration to attach date pickers to the two input fields of the wizard:
Confluence.Blueprint.setWizard(
'de.smartics.atlassian.confluence.smartics-doctype-addon-okrs:create-doctype-template-strategic-theme', function(wizard) {
wizard.on('pre-render.page1Id', function(e, state) {
state.wizardData.selectedWebItemData = PROJECTDOC.prerenderWizard(e, state);
});
wizard.on("post-render.page1Id", function(e, state) {
$('#projectdoc\\.strategic-theme\\.duration\\.from').datePicker({
overrideBrowserDefault: true
});
$('#projectdoc\\.strategic-theme\\.duration\\.to').datePicker({
overrideBrowserDefault: true
});
PROJECTDOC.postrenderWizard(e, state);
});
wizard.on('submit.page1Id', function(e, state) {
PROJECTDOC.adjustToLocation(state);
});
wizard.assembleSubmissionObject = PROJECTDOC.assemblePageCreationData;
});
Please note that there are two backslashes to escape the dot. Now the dots are correctly recognized as characters.