Skip to content

Commit c64c2ba

Browse files
author
JelteMX
committed
Fix #21 : Add before commit MF/NF to verify context
1 parent 72b76ec commit c64c2ba

File tree

5 files changed

+55
-14
lines changed

5 files changed

+55
-14
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,10 @@ Verification can be done in two ways:
8181

8282
### 4. Events
8383

84-
![configuration4](/assets/configuration4.png)
85-
86-
- This microflow/nanoflow (can be used both) will be executed after a succesful upload. It will send the file object itself as an input parameter
84+
- Before commit:
85+
- Microflow/Nanoflow that is executed before committing new files. It can be used to test out context object, to see if we need to commit it first (when associating the files with our context)
86+
- After commit:
87+
- This microflow/nanoflow (can be used both) will be executed after a succesful upload. It will send the file object itself as an input parameter
8788

8889
### 5. UI
8990

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"config": {
99
"widgetPath": "./dist/MxTestProject/widgets",
1010
"projectPath": "./dist/MxTestProject/",
11-
"mendixHost": "http://10.211.55.3:8080",
11+
"mendixHost": "http://windows:8080",
1212
"developmentPort": "3000"
1313
},
1414
"packagePath": "com.mendix.widget.custom",

src/FileDropper.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@ class FileDropperContainer extends Component<FileDropperContainerProps, {}> {
193193
return false;
194194
}
195195

196+
const beforeCommitAction = await this.executeBeforeCommit();
197+
if (!beforeCommitAction) {
198+
return false;
199+
}
200+
196201
try {
197202
obj = await createObject(dataFileEntity);
198203
if (dataContextAssociation !== "" && this.store.contextObject !== null) {
@@ -333,6 +338,25 @@ class FileDropperContainer extends Component<FileDropperContainerProps, {}> {
333338
return true;
334339
}
335340

341+
private async executeBeforeCommit(): Promise<boolean> {
342+
const { eventsBeforeCommitMf, eventsBeforeCommitNf } = this.props;
343+
const obj = this.store.contextObject;
344+
if (obj && (eventsBeforeCommitMf !== "" || (eventsBeforeCommitNf && eventsBeforeCommitNf.nanoflow))) {
345+
let action: Action = {};
346+
if (eventsBeforeCommitMf !== "") {
347+
action = {
348+
microflow: eventsBeforeCommitMf
349+
};
350+
} else if (eventsBeforeCommitNf && eventsBeforeCommitNf.nanoflow) {
351+
action = {
352+
nanoflow: eventsBeforeCommitNf
353+
};
354+
}
355+
return this.executeAction(action, true, obj) as Promise<boolean>;
356+
}
357+
return true;
358+
}
359+
336360
private async executeAfterCommit(obj: mendix.lib.MxObject): Promise<void> {
337361
const { eventsAfterCommitMf, eventsAfterCommitNf } = this.props;
338362
if (obj && (eventsAfterCommitMf !== "" || (eventsAfterCommitNf && eventsAfterCommitNf.nanoflow))) {

src/FileDropper.xml

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,30 @@ Note 3: To avoid any other problem, make sure this helper object is detached fro
151151
<!-- EVENTS -->
152152

153153
<propertyGroup caption="Events">
154-
<property key="eventsAfterCommitMf" type="microflow" required="false" entityProperty="dataFileEntity">
155-
<caption>After commit microflow</caption>
156-
<description>After the file is succesfully committed, this microflow can be executed</description>
157-
<returnType type="Void" />
158-
</property>
159-
<property key="eventsAfterCommitNf" type="nanoflow" required="false" entityProperty="dataFileEntity">
160-
<caption>After commit nanoflow</caption>
161-
<description>After the file is succesfully committed, this nanoflow can be executed</description>
162-
<returnType type="Void" />
163-
</property>
154+
<propertyGroup caption="Before commit">
155+
<property key="eventsBeforeCommitMf" type="microflow" required="false">
156+
<caption>Before commit microflow</caption>
157+
<description>Before committing any file, run this microflow. This can be used to verify the context object (needs to be committed before you can commit any file you associate with). It should return a boolean with True before it commits the files</description>
158+
<returnType type="Boolean" />
159+
</property>
160+
<property key="eventsBeforeCommitNf" type="nanoflow" required="false">
161+
<caption>Before commit nanoflow</caption>
162+
<description>Before committing any file, run this nanoflow. This can be used to verify the context object (needs to be committed before you can commit any file you associate with). It should return a boolean with True before it commits the files</description>
163+
<returnType type="Boolean" />
164+
</property>
165+
</propertyGroup>
166+
<propertyGroup caption="After commit">
167+
<property key="eventsAfterCommitMf" type="microflow" required="false" entityProperty="dataFileEntity">
168+
<caption>After commit microflow</caption>
169+
<description>After the file is succesfully committed, this microflow can be executed</description>
170+
<returnType type="Void" />
171+
</property>
172+
<property key="eventsAfterCommitNf" type="nanoflow" required="false" entityProperty="dataFileEntity">
173+
<caption>After commit nanoflow</caption>
174+
<description>After the file is succesfully committed, this nanoflow can be executed</description>
175+
<returnType type="Void" />
176+
</property>
177+
</propertyGroup>
164178
</propertyGroup>
165179

166180
<!-- UI -->

typings/FileDropperProps.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ export interface FileDropperContainerProps extends CommonProps {
5151

5252
eventsAfterCommitMf: string;
5353
eventsAfterCommitNf: Nanoflow;
54+
eventsBeforeCommitMf: string;
55+
eventsBeforeCommitNf: Nanoflow;
5456

5557
uiDeleteButtonStyle: TypeButtonStyle;
5658
uiDeleteButtonGlyph: string;

0 commit comments

Comments
 (0)