Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions ProcessMaker/Http/Controllers/TaskController.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,16 @@ public function edit(ProcessRequestToken $task, string $preview = '')
{
$task = $task->loadTokenInstance();
$dataManager = new DataManager();
$userHasComments = Comment::where('commentable_type', ProcessRequestToken::class)
->where('commentable_id', $task->id)
->where('body', 'like', '%{{' . \Auth::user()->id . '}}%')
->count() > 0;

if (!\Auth::user()->can('update', $task) && !$userHasComments) {
$this->authorize('update', $task);
if (!\Auth::user()->can('update', $task)) {
$userHasComments = Comment::where('commentable_type', ProcessRequestToken::class)
->where('commentable_id', $task->id)
->where('body', 'like', '%{{' . \Auth::user()->id . '}}%')
->count() > 0;

if (!$userHasComments) {
$this->authorize('update', $task);
}
}

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

UserResourceView::setViewed(Auth::user(), $task);
dispatch(function () use ($task) {
UserResourceView::setViewed(Auth::user(), $task);
})->afterResponse();
$currentUser = Auth::user()->only([
'id',
'username',
Expand All @@ -189,7 +194,8 @@ public function edit(ProcessRequestToken $task, string $preview = '')
'timezone',
'datetime_format',
]);
$userConfiguration = (new UserConfigurationController())->index();
//$userConfiguration = (new UserConfigurationController())->index();
$userConfiguration = app(UserConfigurationController::class)->index();
$hitlEnabled = config('smart-extract.hitl_enabled', false) && $isSmartExtractTask;

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

return view('tasks.edit', [
'task' => $task,
'canUpdateTask' => $canUpdateTask,
'dueLabels' => self::$dueLabels,
'manager' => $manager,
'submitUrl' => $submitUrl,
Expand Down
21 changes: 19 additions & 2 deletions resources/js/tasks/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ const main = new Vue({
userConfiguration,
urlConfiguration: "users/configuration",
showTabs: true,
loadedTabs: {
form: true,
data: false,
},
},
computed: {
taskDefinitionConfig() {
Expand Down Expand Up @@ -172,6 +176,14 @@ const main = new Vue({
this.setAllowReassignment();
},
methods: {
openDataTab() {
if (!this.loadedTabs.data) {
this.loadedTabs.data = true;
}
this.$nextTick(() => {
this.resizeMonaco();
});
},
defineUserConfiguration() {
this.userConfiguration = JSON.parse(this.userConfiguration.ui_configuration);
this.showMenu = this.userConfiguration.tasks.isMenuCollapse;
Expand Down Expand Up @@ -288,8 +300,13 @@ const main = new Vue({
},
resizeMonaco() {
this.showTree = false;
const editor = this.$refs.monaco.getMonaco();
editor.layout({ height: window.innerHeight * 0.65 });
const editor = this.$refs.monaco?.getMonaco?.();
if (!editor) {
return;
}
editor.layout({
height: window.innerHeight * 0.65,
});
},
prepareData() {
this.updateRequestData = debounce(this.updateRequestData, 1000);
Expand Down
1 change: 1 addition & 0 deletions resources/views/layouts/layoutnext.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
{!! config('global_header') !!}
<!-- End Global Header -->
@endif
@stack('preload')
</head>
<body>
<a class="skip-navigation alert alert-info" role="link" href="#main" tabindex="1">@{{ __('Skip to Content') }}</a>
Expand Down
18 changes: 14 additions & 4 deletions resources/views/tasks/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ function() use ($task) {
], 'attributes' => 'v-cloak'])
@endsection
@section('content')
@push('preload')
<link rel="preload" href="{{ mix('js/manifest.js') }}" as="script">
<link rel="preload" href="{{ mix('js/vue-vendor.js') }}" as="script">
<link rel="preload" href="{{ mix('js/bootstrap-vendor.js') }}" as="script">
<link rel="preload" href="{{ mix('js/fortawesome-vendor.js') }}" as="script">
<link rel="preload" href="{{ mix('js/tasks/loaderEdit.js') }}" as="script">
<link rel="preload" href="{{ mix('js/tasks/edit.js') }}" as="script">
@endpush
<div
id="task"
v-cloak
Expand Down Expand Up @@ -77,7 +85,7 @@ class="nav-link active">
role="tab"
aria-controls="tab-data"
aria-selected="false"
@click="resizeMonaco"
@click="openDataTab"
class="nav-link">
{{__('Data')}}
</a>
Expand All @@ -86,7 +94,7 @@ class="nav-link">
@endcan
<div id="tabContent" class="tab-content tw-flex tw-flex-col tw-grow tw-overflow-y-scroll">
<div id="tab-form" role="tabpanel" aria-labelledby="tab-form" class="tab-pane active show">
@can('update', $task)
@if($canUpdateTask)
@unless($hitlEnabled)
<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>
<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>
Expand All @@ -113,7 +121,7 @@ class="card border-0"
@else
@include('tasks.partials.hitl-iframe', ['iframeSrc' => $iframeSrc ?? null])
@endunless
@endcan
@endif
<div v-if="taskHasComments">
<timeline :commentable_id="task.id"
commentable_type="ProcessMaker\Models\ProcessRequestToken"
Expand All @@ -126,6 +134,7 @@ class="card border-0"
<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">
<!-- data edit -->
<monaco-editor
v-if="loadedTabs.data"
v-show="!showTree"
ref="monaco"
data-cy="editorViewFrame"
Expand Down Expand Up @@ -437,8 +446,9 @@ class="mr-2 custom-badges pl-2 pr-2 rounded-lg">
);

const task = @json($task);

let draftTask = task.draft;
const userHasAccessToTask = {{ Auth::user()->can('update', $task) ? "true": "false" }};
const userHasAccessToTask = @json($canUpdateTask);
const userIsAdmin = {{ Auth::user()->is_administrator ? "true": "false" }};
const userIsProcessManager = {{ in_array(Auth::user()->id, $task->process?->manager_id ?? []) ? "true": "false" }};
const caseNumber = @json($caseNumber);
Expand Down
Loading