@@ -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
0 commit comments