Skip to content

Commit 2d02f75

Browse files
authored
Merge pull request #8875 from ProcessMaker/feature/FOUR-31831
feat(FOUR-31831): review Improve Task page loading
2 parents 5f0485a + b986b4b commit 2d02f75

4 files changed

Lines changed: 50 additions & 14 deletions

File tree

ProcessMaker/Http/Controllers/TaskController.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,16 @@ public function edit(ProcessRequestToken $task, string $preview = '')
108108
{
109109
$task = $task->loadTokenInstance();
110110
$dataManager = new DataManager();
111-
$userHasComments = Comment::where('commentable_type', ProcessRequestToken::class)
112-
->where('commentable_id', $task->id)
113-
->where('body', 'like', '%{{' . \Auth::user()->id . '}}%')
114-
->count() > 0;
115111

116-
if (!\Auth::user()->can('update', $task) && !$userHasComments) {
117-
$this->authorize('update', $task);
112+
if (!\Auth::user()->can('update', $task)) {
113+
$userHasComments = Comment::where('commentable_type', ProcessRequestToken::class)
114+
->where('commentable_id', $task->id)
115+
->where('body', 'like', '%{{' . \Auth::user()->id . '}}%')
116+
->count() > 0;
117+
118+
if (!$userHasComments) {
119+
$this->authorize('update', $task);
120+
}
118121
}
119122

120123
//Mark notification as read
@@ -178,7 +181,9 @@ public function edit(ProcessRequestToken $task, string $preview = '')
178181
]);
179182
}
180183

181-
UserResourceView::setViewed(Auth::user(), $task);
184+
dispatch(function () use ($task) {
185+
UserResourceView::setViewed(Auth::user(), $task);
186+
})->afterResponse();
182187
$currentUser = Auth::user()->only([
183188
'id',
184189
'username',
@@ -189,7 +194,8 @@ public function edit(ProcessRequestToken $task, string $preview = '')
189194
'timezone',
190195
'datetime_format',
191196
]);
192-
$userConfiguration = (new UserConfigurationController())->index();
197+
//$userConfiguration = (new UserConfigurationController())->index();
198+
$userConfiguration = app(UserConfigurationController::class)->index();
193199
$hitlEnabled = config('smart-extract.hitl_enabled', false) && $isSmartExtractTask;
194200

195201
// Build the iframe source
@@ -209,9 +215,11 @@ public function edit(ProcessRequestToken $task, string $preview = '')
209215
$iframeSrc = $dashboardUrl . '?' . $queryParams;
210216
}
211217
}
218+
$canUpdateTask = Auth::user()->can('update', $task);
212219

213220
return view('tasks.edit', [
214221
'task' => $task,
222+
'canUpdateTask' => $canUpdateTask,
215223
'dueLabels' => self::$dueLabels,
216224
'manager' => $manager,
217225
'submitUrl' => $submitUrl,

resources/js/tasks/edit.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ const main = new Vue({
6464
userConfiguration,
6565
urlConfiguration: "users/configuration",
6666
showTabs: true,
67+
loadedTabs: {
68+
form: true,
69+
data: false,
70+
},
6771
},
6872
computed: {
6973
taskDefinitionConfig() {
@@ -172,6 +176,14 @@ const main = new Vue({
172176
this.setAllowReassignment();
173177
},
174178
methods: {
179+
openDataTab() {
180+
if (!this.loadedTabs.data) {
181+
this.loadedTabs.data = true;
182+
}
183+
this.$nextTick(() => {
184+
this.resizeMonaco();
185+
});
186+
},
175187
defineUserConfiguration() {
176188
this.userConfiguration = JSON.parse(this.userConfiguration.ui_configuration);
177189
this.showMenu = this.userConfiguration.tasks.isMenuCollapse;
@@ -288,8 +300,13 @@ const main = new Vue({
288300
},
289301
resizeMonaco() {
290302
this.showTree = false;
291-
const editor = this.$refs.monaco.getMonaco();
292-
editor.layout({ height: window.innerHeight * 0.65 });
303+
const editor = this.$refs.monaco?.getMonaco?.();
304+
if (!editor) {
305+
return;
306+
}
307+
editor.layout({
308+
height: window.innerHeight * 0.65,
309+
});
293310
},
294311
prepareData() {
295312
this.updateRequestData = debounce(this.updateRequestData, 1000);

resources/views/layouts/layoutnext.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
{!! config('global_header') !!}
9696
<!-- End Global Header -->
9797
@endif
98+
@stack('preload')
9899
</head>
99100
<body>
100101
<a class="skip-navigation alert alert-info" role="link" href="#main" tabindex="1">@{{ __('Skip to Content') }}</a>

resources/views/tasks/edit.blade.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ function() use ($task) {
2727
], 'attributes' => 'v-cloak'])
2828
@endsection
2929
@section('content')
30+
@push('preload')
31+
<link rel="preload" href="{{ mix('js/manifest.js') }}" as="script">
32+
<link rel="preload" href="{{ mix('js/vue-vendor.js') }}" as="script">
33+
<link rel="preload" href="{{ mix('js/bootstrap-vendor.js') }}" as="script">
34+
<link rel="preload" href="{{ mix('js/fortawesome-vendor.js') }}" as="script">
35+
<link rel="preload" href="{{ mix('js/tasks/loaderEdit.js') }}" as="script">
36+
<link rel="preload" href="{{ mix('js/tasks/edit.js') }}" as="script">
37+
@endpush
3038
<div
3139
id="task"
3240
v-cloak
@@ -77,7 +85,7 @@ class="nav-link active">
7785
role="tab"
7886
aria-controls="tab-data"
7987
aria-selected="false"
80-
@click="resizeMonaco"
88+
@click="openDataTab"
8189
class="nav-link">
8290
{{__('Data')}}
8391
</a>
@@ -86,7 +94,7 @@ class="nav-link">
8694
@endcan
8795
<div id="tabContent" class="tab-content tw-flex tw-flex-col tw-grow tw-overflow-y-scroll">
8896
<div id="tab-form" role="tabpanel" aria-labelledby="tab-form" class="tab-pane active show">
89-
@can('update', $task)
97+
@if($canUpdateTask)
9098
@unless($hitlEnabled)
9199
<span v-if="tceEnableCaseNumberScreen" class="tw-block tw-gap-2 tw-mb-0 tw-px-2 tw-bg-white tw-border-l tw-border-l-[#d7dde5] tw-border-r tw-border-r-[#d7dde5]" v-cloak>
92100
<span class="tw-font-medium tw-text-[#728092] tw-text-xs">Case #:</span> <span class="tw-font-normal tw-text-[#9fa8b5] tw-text-xs">{{ $caseNumber }}</span>
@@ -113,7 +121,7 @@ class="card border-0"
113121
@else
114122
@include('tasks.partials.hitl-iframe', ['iframeSrc' => $iframeSrc ?? null])
115123
@endunless
116-
@endcan
124+
@endif
117125
<div v-if="taskHasComments">
118126
<timeline :commentable_id="task.id"
119127
commentable_type="ProcessMaker\Models\ProcessRequestToken"
@@ -126,6 +134,7 @@ class="card border-0"
126134
<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">
127135
<!-- data edit -->
128136
<monaco-editor
137+
v-if="loadedTabs.data"
129138
v-show="!showTree"
130139
ref="monaco"
131140
data-cy="editorViewFrame"
@@ -437,8 +446,9 @@ class="mr-2 custom-badges pl-2 pr-2 rounded-lg">
437446
);
438447
439448
const task = @json($task);
449+
440450
let draftTask = task.draft;
441-
const userHasAccessToTask = {{ Auth::user()->can('update', $task) ? "true": "false" }};
451+
const userHasAccessToTask = @json($canUpdateTask);
442452
const userIsAdmin = {{ Auth::user()->is_administrator ? "true": "false" }};
443453
const userIsProcessManager = {{ in_array(Auth::user()->id, $task->process?->manager_id ?? []) ? "true": "false" }};
444454
const caseNumber = @json($caseNumber);

0 commit comments

Comments
 (0)