Skip to content

Commit

Permalink
Create template parameters manually from visual designer #35
Browse files Browse the repository at this point in the history
  • Loading branch information
zaharchenko committed Jul 21, 2020
1 parent 775a054 commit 5c6b4ad
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 6 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ To add parameters and value formats go to the *Parameters and Formats* tab.

![email-template-editor-designer-parameters-formats](img/email-template-editor-designer-parameters-formats.png)

To create parameters automatically from template use `Create from template` action from parameters table.

See the complete parameter guide in [CUBA Platform. Report Generator | External Report Parameters](https://doc.cuba-platform.com/reporting-6.10/parameters.html).

See the complete value format guide in [CUBA Platform. Report Generator | Field Value Formats](https://doc.cuba-platform.com/reporting-6.10/formatters.html).
Expand Down
Binary file modified img/email-template-editor-designer-parameters-formats.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,10 @@ protected void postInit() {
templateEditor.setValue(getItem().getHtml());

templateEditor.addValueChangeListener(e -> {
String value = (String) e.getValue();
String value = e.getValue();
getItem().setHtml(value);
createParameters();
});

subjectField.addValueChangeListener(e -> createParameters());

fileUpload.addFileUploadSucceedListener(fileUploadSucceedEvent -> {
UUID fileID = fileUpload.getFileId();
File file = fileUploadingApi.getFile(fileID);
Expand All @@ -185,7 +182,6 @@ protected void postInit() {
fileUploadingApi.deleteFile(fileID);
getItem().setHtml(new String(bytes, StandardCharsets.UTF_8));
templateEditor.setValue(getItem().getHtml());
createParameters();
} catch (Exception e) {
throw new RuntimeException(e);
}
Expand Down Expand Up @@ -324,6 +320,14 @@ protected void initValuesFormats() {
}

protected void initParameters() {
parametersTable.addAction(new AbstractAction("createFromTemplate") {
@Override
public void actionPerform(Component component) {
createParameters();
orderParameters();
}
});

parametersTable.addAction(
new CreateAction(parametersTable, WindowManager.OpenType.DIALOG) {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
width="100%">
<frame id="parametersFrame"
height="100%"
src="/com/haulmont/reports/gui/report/edit/tabs/parameters.xml"/>
src="/com/haulmont/addon/emailtemplates/web/emailtemplate/parameters/parameters.xml"/>
<frame id="formatsFrame"
height="100%"
src="/com/haulmont/reports/gui/report/edit/tabs/formats.xml"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,5 @@ attachmentNameDescription=Leave blank to use filename from report
overrideSubject=Override subject
blocks=Blocks

createFromTemplate=Create from template

Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,5 @@ attachmentNameDescription=Оставьте пустым, чтобы исполь
overrideSubject=Переопределить тему письма
blocks=Блоки

createFromTemplate=Создать из шаблона

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!--
~ Copyright (c) 2008-2020 Haulmont.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<window xmlns="http://schemas.haulmont.com/cuba/window.xsd">
<layout margin="true" spacing="true" expand="inputParametersTable">
<label value="msg://report.parameters" stylename="h2"/>
<table id="inputParametersTable" sortable="false" width="100%"
reorderingAllowed="false" columnControlVisible="false">
<buttonsPanel>
<button action="inputParametersTable.create"/>
<button action="inputParametersTable.createFromTemplate"/>
<button action="inputParametersTable.edit"/>
<button action="inputParametersTable.remove"/>
<button id="up" icon="icons/up.png"/>
<button id="down" icon="icons/down.png"/>
</buttonsPanel>
<columns>
<column id="locName" caption="msg://parameters.caption"/>
<column id="alias" caption="msg://parameters.alias"/>
<column id="type" caption="msg://parameters.type"/>
<column id="required" caption="msg://parameters.required"/>
<column id="validationOn"/>
</columns>
<rows datasource="parametersDs"/>
</table>
<label value="msg://report.crossParametersValidation" stylename="h2"/>
<groupBox id="validationScriptGroupBox" collapsable="true" collapsed="true">
<vbox id="validationScriptVBox">
<hbox margin="true;true;true;false" spacing="true">
<label value="msg://parameters.crossFieldValidate"/>
<checkBox id="validationOnCheckBox" datasource="reportDs" property="validationOn"/>
</hbox>
<label id="validationScriptLabel" value="msg://parameters.groovyScript"/>
<sourceCodeEditor id="validationScriptCodeEditor"
datasource="reportDs"
property="validationScript"
width="100%"
height="240px"
mode="Groovy"/>
</vbox>
</groupBox>
</layout>
</window>

0 comments on commit 5c6b4ad

Please sign in to comment.