Skip to content

Commit

Permalink
Merge branch 'release-2024-fall' into observation/FOUR-19998
Browse files Browse the repository at this point in the history
  • Loading branch information
gproly committed Nov 11, 2024
2 parents 7a90e79 + ac9224a commit e3b420d
Show file tree
Hide file tree
Showing 22 changed files with 511 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use ProcessMaker\Http\Resources\ApiResource;
use ProcessMaker\Http\Resources\ProcessRequests as ProcessRequestResource;
use ProcessMaker\Jobs\CancelRequest;
use ProcessMaker\Jobs\CaseUpdateStatus;
use ProcessMaker\Jobs\TerminateRequest;
use ProcessMaker\Managers\DataManager;
use ProcessMaker\Models\Comment;
Expand Down Expand Up @@ -602,6 +603,8 @@ private function cancelRequestToken(ProcessRequest $request)
// Close process request
$request->status = 'CANCELED';
$request->save();
// Update case status
CaseUpdateStatus::dispatchSync($request);

event(new RequestAction($request, RequestAction::ACTION_CANCELED));
}
Expand Down
1 change: 1 addition & 0 deletions ProcessMaker/Http/Controllers/Api/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ public function index(Request $request)
public function getUsersTaskCount(Request $request)
{
$query = User::nonSystem();
$query->select('id', 'username', 'firstname', 'lastname');

$filter = $request->input('filter', '');
if (!empty($filter)) {
Expand Down
5 changes: 3 additions & 2 deletions ProcessMaker/Http/Middleware/GenerateMenus.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Lavary\Menu\Facade as Menu;
use ProcessMaker\Models\Permission;
use ProcessMaker\Models\Setting;
Expand Down Expand Up @@ -208,7 +209,7 @@ public function handle(Request $request, Closure $next)
'id' => 'process-scripts',
])->data('order', 2);
}
if ($this->userHasPermission('view-collections')) {
if (hasPackage('package-collections') && $this->userHasPermission('view-collections')) {
$submenu->add(__('Collections'), [
'route' => 'plugin-collections-index',
'customicon' => 'nav-icon fas fa-database',
Expand Down Expand Up @@ -323,7 +324,7 @@ public function handle(Request $request, Closure $next)

public static function userHasPermission($permission)
{
$user = \Auth::user();
$user = Auth::user();

if (!$user || !$user->is_administrator) {
return $user && $user->can($permission) && $user->hasPermission($permission);
Expand Down
9 changes: 8 additions & 1 deletion ProcessMaker/ImportExport/Exporters/ScreenExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,14 @@ public function import() : bool

// There should only be one default interstitial screen
if ($screen->key === 'interstitial') {
$screen->key = null;
$existingScreenInterstitial = Screen::where('key', 'interstitial')->first();
// If the screen we are trying to import is not this system's default interstitial screen
// then set the key to null since there should only be one default interstitial screen
if ($existingScreenInterstitial && $existingScreenInterstitial->id !== $screen->id) {
$screen->key = null;
}
// On the other hand, if this import is attempting to update the default interstitial screen,
// that should be allowed and there should be no changes to the key or id, but the config will be updated.
}

$success = $screen->saveOrFail();
Expand Down
8 changes: 7 additions & 1 deletion ProcessMaker/Repositories/CaseRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ public function update(ExecutionInstanceInterface $instance, TokenInterface $tok
*/
public function updateStatus(ExecutionInstanceInterface $instance): void
{
if (is_null($instance->case_number)) {
Log::error('case started not found, method=updateStatus, instance=' . $instance->getKey());

return;
}

// If a sub-process is completed, do not update the case started status
if (!is_null($instance->parent_request_id)) {
return;
Expand All @@ -130,7 +136,7 @@ public function updateStatus(ExecutionInstanceInterface $instance): void
'case_status' => $caseStatus,
];

if ($caseStatus === CaseStatusConstants::COMPLETED) {
if (in_array($caseStatus, [CaseStatusConstants::COMPLETED, CaseStatusConstants::CANCELED])) {
$data['completed_at'] = $instance->completed_at;
}

Expand Down
32 changes: 24 additions & 8 deletions ProcessMaker/Repositories/TokenRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,7 @@ public function persistActivityException(ActivityInterface $activity, TokenInter
$token->save();
$token->setId($token->getKey());

// Update Case Started Task
$caseTaskRepo = new CaseTaskRepository($token->getInstance()->case_number, $token);
$caseTaskRepo->updateCaseStartedTaskStatus();
$caseTaskRepo->updateCaseParticipatedTaskStatus();
$this->updateCaseStartedTask($token);

$request = $token->getInstance();
$request->notifyProcessUpdated('ACTIVITY_EXCEPTION', $token);
Expand Down Expand Up @@ -354,10 +351,7 @@ public function persistActivityCompleted(ActivityInterface $activity, TokenInter
$token->save();
$token->setId($token->getKey());

// Update Case Started Task
$caseTaskRepo = new CaseTaskRepository($token->getInstance()->case_number, $token);
$caseTaskRepo->updateCaseStartedTaskStatus();
$caseTaskRepo->updateCaseParticipatedTaskStatus();
$this->updateCaseStartedTask($token);

$request = $token->getInstance();
$request->notifyProcessUpdated('ACTIVITY_COMPLETED', $token);
Expand Down Expand Up @@ -690,4 +684,26 @@ public function persistEventBasedGatewayActivated(EventBasedGatewayInterface $ev
{
Log::info('persistEventBasedGatewayActivated');
}

/**
* The function updates the status of a case task.
*
* @param TokenInterface token The `token` parameter in the `updateCaseStartedTask` function is an object of type
* `TokenInterface`. It is used to access the instance's case number and pass the token itself to the
* `CaseTaskRepository` constructor for further processing.
*
* @return void
*/
private function updateCaseStartedTask(TokenInterface $token): void
{
if (is_null($token->getInstance()->case_number)) {
Log::info('CaseException: case number not found, method=updateCaseStartedTask, instance=' . $token->getInstance()->getKey());

return;
}

$caseTaskRepo = new CaseTaskRepository($token->getInstance()->case_number, $token);
$caseTaskRepo->updateCaseStartedTaskStatus();
$caseTaskRepo->updateCaseParticipatedTaskStatus();
}
}
2 changes: 1 addition & 1 deletion resources/js/Mobile/Card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export default {
return this.item.case_number;
}
if (this.type === "tasks") {
return this.item.process_request.id;
return this.item.process_request.case_number;
}
return null;
},
Expand Down
3 changes: 2 additions & 1 deletion resources/js/components/AvatarImage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<template v-for="(value, key) in options">
<div class="vertical-view">
<b-button
v-if="value.initials"
ref="button"
:variant="variant(value)"
class="avatar-button rounded-circle overflow-hidden p-0 m-0 d-inline-flex"
Expand Down Expand Up @@ -44,7 +45,7 @@
{{ limitCharacters(value.name) }}
</template>
</span>
<span v-else>ProcessMaker</span>
<span v-else><b-badge class="status-alternative-a">{{ $t('Unclaimed') }}</b-badge></span>
</span>
</div>
</template>
Expand Down
57 changes: 0 additions & 57 deletions resources/js/tasks/components/TasksList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,9 @@
width="20"
height="20"
/>
<b-form-checkbox v-else-if="column.field === 'check_control'"
v-model="headCheckbox"
@change="changeHeadCheckbox">
</b-form-checkbox>
<span v-else>{{ $t(column.label) }}</span>
</div>
<b-tooltip
v-if="column.field !== 'check_control'"
:key="index"
:target="`tasks-table-column-${column.field}`"
custom-class="pm-table-tooltip-header"
Expand Down Expand Up @@ -152,12 +147,6 @@
</span>
<span>{{ getNestedPropertyValue(row, header) }}</span>
</template>
<template v-else-if="header.field === 'check_control'">
<b-form-checkbox :checked="arrayOfCheckedRows.includes(row.id)"
ref="checkboxRegister"
@change="changeCheckbox($event, row)">
</b-form-checkbox>
</template>
<template v-else-if="header.field === 'is_priority'">
<span>
<img
Expand Down Expand Up @@ -232,7 +221,6 @@
:tooltip-button="tooltipFromButton"
@onSetViewed="setViewed"
@onWatchShowPreview="onWatchShowPreview"
@on-reassign-user="onReassignUser"
>
<template v-slot:header="{ close, screenFilteredTaskData, taskReady }">
<slot name="preview-header" v-bind:close="close" v-bind:screenFilteredTaskData="screenFilteredTaskData" v-bind:taskReady="taskReady"></slot>
Expand Down Expand Up @@ -410,8 +398,6 @@ export default {
hideTimer: null,
ellipsisShow: false,
columnMouseover: null,
headCheckbox: false,
arrayOfCheckedRows: []
};
},
computed: {
Expand Down Expand Up @@ -464,7 +450,6 @@ export default {
}
this.$emit('count', newData.meta?.total);
this.$emit("tab-count", newData.meta?.total);
this.checkHeadCheckboxAfterChangeData();
},
shouldShowLoader(value) {
if (this.apiNoResults) {
Expand Down Expand Up @@ -938,48 +923,6 @@ export default {
handleColumnMouseleave() {
this.columnMouseover = null;
},
addCheckedItem(value, row) {
if (value === true) {
if (!this.arrayOfCheckedRows.includes(row.id)) {
this.arrayOfCheckedRows.push(row.id);
}
} else {
let index = this.arrayOfCheckedRows.indexOf(row.id);
this.arrayOfCheckedRows.splice(index, 1);
}
this.$emit('add-checked-item', this.arrayOfCheckedRows);
},
getArrayOfCheckedRows() {
return this.arrayOfCheckedRows;
},
clearArrayOfCheckedRows() {
this.arrayOfCheckedRows = [];
},
changeHeadCheckbox(event) {
this.data.data.forEach(row => {
this.addCheckedItem(event, row);
});
},
changeCheckbox(event, row) {
this.addCheckedItem(event, row);
this.$nextTick(() => {
if (this.$refs.checkboxRegister) {
let sw = this.$refs.checkboxRegister.every(item => item.checked === true);
this.headCheckbox = sw;
}
});
},
checkHeadCheckboxAfterChangeData() {
this.$nextTick(() => {
if (this.$refs.checkboxRegister) {
let sw = this.$refs.checkboxRegister.every(item => item.checked === true);
this.headCheckbox = sw;
}
});
},
onReassignUser(idUser) {
this.fetch();
}
},
};
</script>
Expand Down
6 changes: 6 additions & 0 deletions resources/jscomposition/cases/casesDetail/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,9 @@ export const getCommentsData = (params) => {

return response;
};

export const updateRequest = async (id, data) => {
const response = await ProcessMaker.apiClient.put(`requests/${id}`, data);

return response;
};
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,32 @@
v-show="!showPlaceholder && screen"
class="tw-pointer-events-none"
>
<vue-form-renderer
v-if="screen !== null"
v-model="previewData"
:data="previewData"
:config="configScreen"
:custom-css="screen.custom_css"
:show-errors="true"
/>
<div
v-for="(page, index) in pagesPrintable"
:key="index"
class="card"
>
<div class="card-body">
<vue-form-renderer
v-if="screen !== null"
ref="formRender"
v-model="previewData"
:data="previewData"
:config="configScreen"
:custom-css="screen.custom_css"
:show-errors="true"
/>
</div>
</div>
</div>
</transition>
</div>
</template>

<script setup>
import { onMounted, ref, computed } from "vue";
import {
onMounted, ref, computed, nextTick,
} from "vue";
import { getScreenData } from "../api/index";
import LoadingPlaceholder from "./placeholder/LoadingPlaceholder.vue";
Expand All @@ -62,6 +73,35 @@ const previewData = computed(() => props.data.taskData);
const screen = ref(null);
const configScreen = ref({});
const showPlaceholder = ref(false);
const pagesPrintable = ref([]);
const formRender = ref([]);
const findPagesInNavButtons = (object, found = []) => {
if (object.items) {
object.items.forEach((item) => {
findPagesInNavButtons(item, found);
});
} else if (object instanceof Array) {
object.forEach((item) => {
findPagesInNavButtons(item, found);
});
} else if (object.config && object.config.event === "pageNavigate" && object.config.eventData) {
const page = parseInt(object.config.eventData, 10);
if (found.indexOf(page) === -1) {
found.push(page);
}
}
};
const loadPages = () => {
const pages = [0];
if (screen.value.config instanceof Array) {
screen.value.config.forEach((page) => {
findPagesInNavButtons(page, pages);
});
}
return pages;
};
const disableForm = (screenConfig) => {
if (screenConfig instanceof Array) {
Expand All @@ -88,6 +128,16 @@ const disableForm = (screenConfig) => {
return screenConfig;
};
const loadPagesPrint = () => {
nextTick(() => {
formRender.value.forEach((page, index) => {
if (page.setCurrentPage) {
page.setCurrentPage(pagesPrintable.value[index]);
}
});
});
};
const getScreen = async (screenId) => {
showPlaceholder.value = true;
Expand All @@ -98,7 +148,9 @@ const getScreen = async (screenId) => {
if (response.data) {
screen.value = response.data;
pagesPrintable.value = loadPages();
configScreen.value = disableForm(screen.value.config);
loadPagesPrint();
}
}, 300);
};
Expand Down
Loading

0 comments on commit e3b420d

Please sign in to comment.