Skip to content
Merged
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
25 changes: 12 additions & 13 deletions ProcessMaker/Http/Controllers/Api/ProcessController.php
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ public function update(Request $request, Process $process)
$lastVersion = $process->getDraftOrPublishedLatestVersion();
$process->bpmn = $lastVersion->bpmn;
$process->alternative = $lastVersion->alternative;
$process->stages = $lastVersion->stages;

$rules = Process::rules($process);
if (!$request->has('name')) {
Expand Down Expand Up @@ -2066,24 +2067,22 @@ public function saveStages(Request $request, Process $process)
$stages = $request->input('stages');

if ($alternative === 'B') {

// Get or create alternative B version
$alternativeVersion = ProcessVersion::where('process_id', $process->id)
ProcessVersion::where('process_id', $process->id)
->where('alternative', 'B')
->first();

// Save stages to alternative B version
$alternativeVersion->stages = $stages;
$alternativeVersion->save();

return new ApiCollection($alternativeVersion->stages);
->update([
'stages' => $stages,
]);
} else {
// Save stages to main process (alternative A)
ProcessVersion::where('process_id', $process->id)
->where('alternative', 'A')
->update([
'stages' => $stages,
]);
$process->stages = $stages;
$process->save();

return new ApiCollection($process->stages);
}

return new ApiCollection($stages);
}

/**
Expand Down
5 changes: 4 additions & 1 deletion ProcessMaker/Traits/HasVersioning.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ public function saveDraft(string $alternative = null)
$alternative = $alternative ?: $this->alternative;
$attributes['alternative'] = $alternative;

$processVersion = ProcessVersion::where('process_id', $this->id)->where('alternative', $attributes['alternative'])->first();
$processVersion = ProcessVersion::where('process_id', $this->id)
->where('alternative', $attributes['alternative'])
->where('draft', 1)
->first();
if ($processVersion) {
$attributes['stages'] = $processVersion->stages;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ const getDefinition = () => getHighlightedNode().definition;

const saveProcess = () => {
window.$modelerApp?.autosaveApiCall?.();
//Index 0 implies that the component is in a loop; therefore, it will exist anyway, and its existence is validated.
window.$modelerApp?.$refs["external-ModalSaveVersion"]?.[0]?.saveModal?.();
}

const getConfigFromDefinition = (definition) => {
Expand Down Expand Up @@ -152,6 +150,7 @@ const removeStageToFlow = () => {
const onChange = (stages) => {
updateStagesForAllFlowConfigs(stages);
saveStagesToApi(stages);
saveProcess();
};

const onUpdate = (stages, index, val, Oldal) => {
Expand Down
Loading