Skip to content

Commit

Permalink
Merge pull request #5394 from ProcessMaker/bugfix/FOUR-10881
Browse files Browse the repository at this point in the history
FOUR-10881: Screen interstitial now is displayed when a request is cr…
  • Loading branch information
ryancooley authored Oct 4, 2023
2 parents 01f5a78 + 818f97b commit 68ad511
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ProcessMaker/Http/Controllers/ProcessController.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public function triggerStartEventApi(Process $process, Request $request)
$apiRequest = new ApiProcessController();
$response = $apiRequest->triggerStartEvent($process, $request);

return redirect('/requests/' . $response->id . '?fromRedirect=true');
return redirect('/requests/' . $response->id)->cookie('fromTriggerStartEvent', true, 1);
}

private function checkAuth()
Expand Down
4 changes: 2 additions & 2 deletions ProcessMaker/Http/Controllers/RequestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ public function show(ProcessRequest $request, Media $mediaItems)
if (isset($definition['allowInterstitial'])) {
$allowInterstitial = filter_var($definition['allowInterstitial'], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
}
if ($allowInterstitial && $request->user_id == Auth::id() && request()->has('fromRedirect')) {
if ($allowInterstitial && $request->user_id == Auth::id() && request()->cookie('fromTriggerStartEvent')) {
$active = $request->tokens()
->where('user_id', Auth::id())
->where('element_type', 'task')
->where('status', 'ACTIVE')
->orderBy('id')->first();

return redirect(route('tasks.edit', ['task' => $active ? $active->getKey() : $startEvent->getKey()]));
return redirect(route('tasks.edit', ['task' => $active ? $active->getKey() : $startEvent->getKey()]))->withoutCookie('fromTriggerStartEvent');
}
}
}
Expand Down
1 change: 1 addition & 0 deletions ProcessMaker/Http/Middleware/EncryptCookies.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ class EncryptCookies extends BaseEncrypter
* Add any cookie names where we should not encrypt it's data here
*/
'device_id',
'fromTriggerStartEvent',
];
}
5 changes: 3 additions & 2 deletions resources/js/components/requests/card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ export default {
.then(response => {
this.spin = 0;
var instance = response.data;
this.$cookies.set('fromTriggerStartEvent', true, '1min');
if (this.$cookies.get("isMobile")) {
window.location = "/requests/mobile/" + instance.id + '?fromRedirect=true';
window.location = "/requests/mobile/" + instance.id;
} else {
window.location = "/requests/" + instance.id + '?fromRedirect=true';
window.location = "/requests/" + instance.id;
}
}).catch((err) => {
this.disabled = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,20 @@ import ScreenSelect from "./ScreenSelect";
export default {
components: { ScreenSelect },
props: ["value", "label", "helper", "enabledByDefault"],
props: {
label: {
type: String,
default: '',
},
helper: {
type: String,
default: '',
},
enabledByDefault: {
type: Boolean,
default: false
},
},
data() {
return {
screen: null,
Expand All @@ -45,7 +58,7 @@ export default {
const { node } = this;
// Get the value of allowInterstitial or set it to true if it hasn't been defined yet.
const value = _.get(node, "allowInterstitial", this.enabledByDefault || false);
const value = _.get(node, "allowInterstitial", this.enabledByDefault);
this.screen = _.get(node, "interstitialScreenRef");
return value;
Expand All @@ -70,5 +83,10 @@ export default {
this.$set(this.node, "allowInterstitial", value);
},
},
mounted() {
if (!("allowInterstitial" in this.node)) {
this.$set(this.node, "allowInterstitial", this.enabledByDefault);
}
}
};
</script>

0 comments on commit 68ad511

Please sign in to comment.