Skip to content

Commit ca9299b

Browse files
authored
Merge pull request #25 from tomolimo/RE-2.1
Added postmessage feature to Output Document form.
2 parents fdaa40b + 8f5bde7 commit ca9299b

File tree

4 files changed

+52
-26
lines changed

4 files changed

+52
-26
lines changed

workflow/engine/methods/cases/cases_Step.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,8 +675,17 @@
675675
}
676676
}
677677

678-
$outputNextStep = 'cases_Step?TYPE=OUTPUT_DOCUMENT&UID=' . $_GET['UID'] . '&POSITION=' . $_SESSION['STEP_POSITION'] . '&ACTION=VIEW&DOC=' . $sDocUID;
679-
G::header('location: ' . $outputNextStep);
678+
if (isset($_REQUEST['glpi_data'])) {
679+
// will return the cases_Step
680+
$_GET['TYPE'] = 'OUTPUT_DOCUMENT';
681+
$_GET['POSITION'] = $_SESSION['STEP_POSITION'];
682+
$_GET['ACTION'] = 'VIEW';
683+
$_GET['DOC'] = $sDocUID;
684+
include(PATH_METHODS . 'cases' . PATH_SEP . 'cases_Step.php');
685+
} else {
686+
$outputNextStep = 'cases_Step?TYPE=OUTPUT_DOCUMENT&UID=' . $_GET['UID'] . '&POSITION=' . $_SESSION['STEP_POSITION'] . '&ACTION=VIEW&DOC=' . $sDocUID;
687+
G::header('location: ' . $outputNextStep);
688+
}
680689
die();
681690
break;
682691
case 'VIEW':
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
22
if (!defined('PM_VERSION')) {
3-
define("PM_VERSION", "3.3.0-community-RE-2.0");
4-
define("PM_BUILD_VERSION", "3.3.0-community-RE-2.0");
3+
define("PM_VERSION", "3.3.0-community-RE-2.1");
4+
define("PM_BUILD_VERSION", "3.3.0-community-RE-2.1");
55
}

workflow/public_html/glpi/glpi.js

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,13 @@ pm_glpi = {
201201

202202
tasks_observer: function (mutationList, observer) {
203203

204-
// hide dyn_forward when it is the last step in the task
205-
let dyn_forward = document.querySelector('a#dyn_forward[href="cases_Step?TYPE=ASSIGN_TASK&UID=-1&POSITION=10000&ACTION=ASSIGN"]');
206-
if (dyn_forward && dyn_forward.style.display != 'none') {
207-
dyn_forward.style.display = 'none';
204+
// hide dyn_forward_assign when it is the last step in the task
205+
let dyn_forward_assign = document.querySelector('a[id*="dyn_forward" i][href="cases_Step?TYPE=ASSIGN_TASK&UID=-1&POSITION=10000&ACTION=ASSIGN"]');
206+
if (dyn_forward_assign) {
207+
dyn_forward_assign.outerHTML = '';
208208
}
209209

210-
if (dyn_forward && document.querySelector('html').postmessage.data.message == 'parentready') {
210+
if (dyn_forward_assign && document.querySelector('html').postmessage.data.message == 'parentready') {
211211
let myForm = document.querySelector('form');
212212
if (myForm && !myForm.setOnSubmitDone) {
213213
myForm.setOnSubmitDone = true;
@@ -240,34 +240,51 @@ pm_glpi = {
240240
}
241241
}
242242

243-
let dyn_backward = document.querySelector('a#dyn_backward[href*="cases_Step?TYPE=DYNAFORM"]');
243+
let append = '&sid=' + GLPI_DATA.glpi_sid +
244+
'&APP_UID=' + GLPI_DATA.glpi_app_uid +
245+
'&DEL_INDEX=' + GLPI_DATA.glpi_del_index +
246+
'&glpi_data=' + encodeURIComponent(JSON.stringify(GLPI_DATA));
247+
248+
let dyn_backward = document.querySelector('a[id*="dyn_backward" i][href*="cases_Step?TYPE="]');
244249
if (dyn_backward && dyn_backward.href.indexOf('&glpi_data=') == -1) {
245-
let append = '&sid=' + GLPI_DATA.glpi_sid +
246-
'&APP_UID=' + GLPI_DATA.glpi_app_uid +
247-
'&DEL_INDEX=' + GLPI_DATA.glpi_del_index +
248-
'&glpi_data=' + encodeURIComponent(JSON.stringify(GLPI_DATA));
249-
dyn_backward.href = dyn_backward.href + append;
250+
dyn_backward.href += append;
251+
}
252+
253+
let dyn_forward = document.querySelector('a[id*="dyn_forward" i][href*="cases_Step?TYPE="]');
254+
if (dyn_forward && dyn_forward.href.indexOf('&glpi_data=') == -1) {
255+
dyn_forward.href += append;
256+
}
257+
258+
// hide Next Step button, this button is displayed by Output Document form
259+
let next_step = document.getElementById('form[NEXT_STEP]');
260+
if (next_step) {
261+
next_step.outerHTML = '';
250262
}
251263

252264
let cancelButton = document.getElementById('form[BTN_CANCEL]');
253-
if (cancelButton && cancelButton.style.display != 'none') {
254-
cancelButton.style.display = 'none';
265+
if (cancelButton) {
266+
cancelButton.outerHTML = '';
255267
let claimButton = document.getElementById('form[BTN_CATCH]');
256-
if (GLPI_DATA.glpi_hide_claim_button
257-
&& claimButton.style.display != 'none') {
258-
claimButton.style.display = 'none';
268+
if (claimButton && GLPI_DATA.glpi_hide_claim_button) {
269+
claimButton.outerHTML = '';
259270
}
260271
}
261272

273+
// this is used by input document list
262274
let docs = document.querySelectorAll('a[href*="{skin}/cases/cases_ShowDocument?a="].fa.fa-download');
263275
docs.forEach((el) => {
264-
//debugger;
265276
if (el.href.indexOf('&glpi_data=') == -1) {
266-
let append = '&sid=' + GLPI_DATA.glpi_sid +
267-
'&glpi_data=' + encodeURIComponent(JSON.stringify(GLPI_DATA));
268-
el.href = el.href + append;
277+
el.href += append;
269278
}
270279
});
280+
281+
// this a[href] is displayed for example by Output Document form
282+
// normally, there is only one document link
283+
let outputdoc = document.getElementById('form[APP_DOC_FILENAME2]');
284+
if (outputdoc && outputdoc.href.indexOf('&glpi_data=') == -1) {
285+
outputdoc.href += append;
286+
}
287+
271288
},
272289

273290

workflow/public_html/sysGeneric.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,10 +956,10 @@ class_exists('PmDynaform');
956956
$noLoginFiles[] = 'cases_SaveData';
957957
$noLoginFiles[] = 'cases_CatchExecute';
958958
$noLoginFiles[] = 'cases_ShowDocument';
959+
$noLoginFiles[] = 'cases_ShowOutputDocument';
960+
$noLoginFiles[] = 'cases_NextStep';
959961
}
960-
$noLoginFiles[] = 'cases_ShowOutputDocument';
961962
$noLoginFiles[] = 'cases_Derivate';
962-
$noLoginFiles[] = 'cases_NextStep';
963963
$noLoginFiles[] = 'genericAjax';
964964
$noLoginFiles[] = 'casesSaveDataView';
965965
$noLoginFiles[] = 'propelTableAjax';

0 commit comments

Comments
 (0)