Skip to content

Commit 7fe3629

Browse files
committed
general clean-up and introduce partial for iframe rendering
1 parent 1588be9 commit 7fe3629

4 files changed

Lines changed: 56 additions & 106 deletions

File tree

ProcessMaker/Http/Controllers/TaskController.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,6 @@ public function edit(ProcessRequestToken $task, string $preview = '')
191191
]);
192192
$userConfiguration = (new UserConfigurationController())->index();
193193

194-
// TODO: Remove this after testing and replace with the correct iframe source
195-
$is_hitl_task = true;
196-
$iframe_src = 'https://assets.processmaker.net/tces/edit.html?documentToken=6519c0f184aa123baaee296111e5247c&fileId=nOh7qKiHnLL3786w3N3QUu1u7RI3p_6b02cbd0-7551-446b-9b57-5cb931037845';
197-
198194
return view('tasks.edit', [
199195
'task' => $task,
200196
'dueLabels' => self::$dueLabels,
@@ -208,8 +204,7 @@ public function edit(ProcessRequestToken $task, string $preview = '')
208204
'screenFields' => $screenFields,
209205
'taskDraftsEnabled' => $taskDraftsEnabled,
210206
'userConfiguration' => $userConfiguration,
211-
'is_hitl_task' => $is_hitl_task,
212-
'iframe_src' => $iframe_src,
207+
'hitlEnabled' => config('smart-extract.hitl_enabled', false),
213208
]);
214209
}
215210
}

resources/js/tasks/edit.js

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ const main = new Vue({
6363
userConfiguration,
6464
urlConfiguration: "users/configuration",
6565
showTabs: true,
66-
isNavbarExpanded: false,
6766
},
6867
computed: {
6968
taskDefinitionConfig() {
@@ -494,49 +493,5 @@ const main = new Vue({
494493

495494
return response;
496495
},
497-
toggleNavbar() {
498-
this.isNavbarExpanded = !this.isNavbarExpanded;
499-
},
500496
},
501497
});
502-
503-
// Make toggleNavbar available globally for the navbar component
504-
window.toggleNavbar = function() {
505-
if (window.ProcessMaker.navbar && window.ProcessMaker.navbar.toggleNavbar) {
506-
window.ProcessMaker.navbar.toggleNavbar();
507-
} else if (main && main.toggleNavbar) {
508-
main.toggleNavbar();
509-
}
510-
};
511-
512-
window.addEventListener('message', function(event) {
513-
// Get reference to the iframe
514-
var iframe = document.querySelector('iframe');
515-
516-
// Only process messages from the iframe
517-
if (event.source === iframe.contentWindow) {
518-
var messageData = event.data;
519-
520-
// Only show alert and console.log when status is "MarkedAsCorrect"
521-
if (messageData && messageData.status === 'MarkedAsCorrect') {
522-
// Log all messages for debugging
523-
console.log('Received message from iframe Edit.js:', event);
524-
525-
// Show alert with the message data (remove later)
526-
var alertMessage = 'Message received from iframe Edit.js:\n';
527-
528-
if (typeof messageData === 'object') {
529-
alertMessage += JSON.stringify(messageData, null, 2);
530-
} else {
531-
alertMessage += messageData;
532-
}
533-
534-
alert(alertMessage);
535-
536-
// Also log to console (remove later)
537-
console.log('Message data:', messageData);
538-
console.log('Message origin:', event.origin);
539-
console.log('Message source:', event.source);
540-
}
541-
}
542-
});

resources/views/tasks/edit.blade.php

Lines changed: 32 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -86,52 +86,38 @@ class="nav-link">
8686
@endcan
8787
<div id="tabContent" class="tab-content tw-flex tw-flex-col tw-grow tw-overflow-y-scroll">
8888
<div id="tab-form" role="tabpanel" aria-labelledby="tab-form" class="tab-pane active show">
89-
@if(isset($is_hitl_task) && $is_hitl_task === true)
90-
<!-- Smart Extract Manual Edit content when $hitl is true -->
91-
@if(isset($iframe_src))
92-
<div id="manual-edit-iframe-container" style="position: relative; width: 100%; height: calc(100vh - 200px); border: none; margin: 0; padding: 0;">
93-
<x-package-smart-extract::iframe-loader
94-
:src="$iframe_src"
95-
:title="__('Smart Extract')"
96-
loading-message="{{ __('Loading dashboard') }}"
97-
/>
98-
</div>
89+
@can('update', $task)
90+
@unless($hitlEnabled)
91+
<task
92+
ref="task"
93+
class="card border-0"
94+
v-model="formData"
95+
:initial-task-id="{{ $task->id }}"
96+
:initial-request-id="{{ $task->process_request_id }}"
97+
:screen-version="{{ $task->screen['id'] ?? null }}"
98+
:user-id="{{ Auth::user()->id }}"
99+
csrf-token="{{ csrf_token() }}"
100+
initial-loop-context="{{ $task->getLoopContext() }}"
101+
:wait-loading-listeners="true"
102+
@task-updated="taskUpdated"
103+
@updated-page-core="updatePage"
104+
@submit="submit"
105+
@completed="completed"
106+
@@error="error"
107+
@closed="closed"
108+
@redirect="redirectToTask"
109+
@form-data-changed="handleFormDataChange" />
99110
@else
100-
<div class="alert alert-warning">
101-
{{__('No iframe source provided for Manual Edit.')}}
102-
</div>
103-
@endif
104-
@else
105-
<!-- Original Form content when $hitl is false or not set -->
106-
@can('update', $task)
107-
<task
108-
ref="task"
109-
class="card border-0"
110-
v-model="formData"
111-
:initial-task-id="{{ $task->id }}"
112-
:initial-request-id="{{ $task->process_request_id }}"
113-
:screen-version="{{ $task->screen['id'] ?? null }}"
114-
:user-id="{{ Auth::user()->id }}"
115-
csrf-token="{{ csrf_token() }}"
116-
initial-loop-context="{{ $task->getLoopContext() }}"
117-
:wait-loading-listeners="true"
118-
@task-updated="taskUpdated"
119-
@updated-page-core="updatePage"
120-
@submit="submit"
121-
@completed="completed"
122-
@@error="error"
123-
@closed="closed"
124-
@redirect="redirectToTask"
125-
@form-data-changed="handleFormDataChange" />
126-
@endcan
127-
<div v-if="taskHasComments">
128-
<timeline :commentable_id="task.id"
129-
commentable_type="ProcessMaker\Models\ProcessRequestToken"
130-
:adding="false"
131-
:readonly="task.status === 'CLOSED'"
132-
:timeline="false" />
133-
</div>
134-
@endif
111+
@include('tasks.partials.hitl-iframe')
112+
@endunless
113+
@endcan
114+
<div v-if="taskHasComments">
115+
<timeline :commentable_id="task.id"
116+
commentable_type="ProcessMaker\Models\ProcessRequestToken"
117+
:adding="false"
118+
:readonly="task.status === 'CLOSED'"
119+
:timeline="false" />
120+
</div>
135121
</div>
136122
@can('editData', $task->processRequest)
137123
<div v-if="task.process_request.status === 'ACTIVE'" id="tab-data" role="tabpanel" aria-labelledby="tab-data" class="card card-body border-top-0 tab-pane p-3">
@@ -451,7 +437,7 @@ class="mr-2 custom-badges pl-2 pr-2 rounded-lg">
451437
let draftTask = task.draft;
452438
const userHasAccessToTask = {{ Auth::user()->can('update', $task) ? "true": "false" }};
453439
const userIsAdmin = {{ Auth::user()->is_administrator ? "true": "false" }};
454-
const userIsProcessManager = {{ in_array(Auth::user()->id, $task->process?->manager_id ?? []) ? "true": "false" }};
440+
const userIsProcessManager = {{ Auth::user()->id === $task->process?->manager_id ? "true": "false" }};
455441
const userConfiguration = @json($userConfiguration);
456442
let screenFields = @json($screenFields);
457443
window.Processmaker.user = @json($currentUser);
@@ -463,15 +449,6 @@ class="mr-2 custom-badges pl-2 pr-2 rounded-lg">
463449
@endforeach
464450

465451
<script src="{{mix('js/tasks/edit.js')}}"></script>
466-
<script>
467-
// Simple iframe setup for Manual Edit
468-
document.addEventListener('DOMContentLoaded', function() {
469-
const iframe = document.getElementById('manual-edit-iframe');
470-
if (iframe) {
471-
console.log('Manual Edit iframe loaded and ready');
472-
}
473-
});
474-
</script>
475452
@endsection
476453

477454
@section('css')
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{{-- Smart Extract Manual Edit content when HITL is enabled --}}
2+
@php
3+
// Note: This URL will be obtained from request data in future implementation.
4+
$iframeSrc =
5+
'https://assets.processmaker.net/tces/edit.html?documentToken=6519c0f184aa123baaee296111e5247c&fileId=nOh7qKiHnLL3786w3N3QUu1u7RI3p_6b02cbd0-7551-446b-9b57-5cb931037845';
6+
@endphp
7+
8+
@if (!empty($iframeSrc))
9+
<div
10+
id="manual-edit-iframe-container"
11+
style="position: relative; width: 100%; height: calc(100vh - 200px); border: none; margin: 0; padding: 0;"
12+
>
13+
<x-package-smart-extract::iframe-loader
14+
:src="$iframeSrc"
15+
:title="__('Smart Extract')"
16+
loading-message="{{ __('Loading dashboard') }}"
17+
/>
18+
</div>
19+
@else
20+
<div class="alert alert-warning">
21+
{{ __('No iframe source provided for Manual Edit.') }}
22+
</div>
23+
@endif

0 commit comments

Comments
 (0)