Hello,
In order to loose one click on pending transition I was asked to display attachment tab on the pending transition form.
I succeeded in 2.7.7 using this code in an extension via iApplicationUIExtension :
publicfunctionOnFormSubmit($oObject,$sFormPrefix=''){if($oObjectinstanceofUserRequest&&$oObject->get('status')!=='new'){$aAttachmentIds=utils::ReadParam('attachments',array());$aRemovedAttachmentIds=utils::ReadParam('removed_attachments',array());$sOQL='SELECT Attachment WHERE id = :id AND temp_id != "" AND temp_id != -1';$oSearch=DBObjectSearch::FromOQL($sOQL);foreach($aRemovedAttachmentIdsas$iRemovedAttachmentIds){$oSet=newDBObjectSet($oSearch,array(),array('id'=>$iRemovedAttachmentIds));while($oAttachment=$oSet->Fetch()){//Removeattachmentsthatarenolongerattachedtothecurrentobjectif(in_array($oAttachment->GetKey(),$aRemovedAttachmentIds)){$oAttachment->DBDelete();}}}foreach($aAttachmentIdsas$iAttachmentId){$oSet=newDBObjectSet($oSearch,array(),array('id'=>$iAttachmentId));while($oAttachment=$oSet->Fetch()){$oAttachment->SetItem($oObject);$oAttachment->Set('temp_id','');$oAttachment->DBUpdate();}}}}publicfunctionOnDisplayProperties($oObject,WebPage$oPage,$bEditMode=false){if($oObjectinstanceofUserRequest){$sStimulus=utils::ReadParam('stimulus','',false,'raw_data');$sObjClass=utils::ReadParam('class','',false,'raw_data');$iObjKey=utils::ReadParam('id','',false,'raw_data');$sTransactionId=utils::GetUploadTempId();$aTransition=MetaModel::GetModuleSetting('attachment-on-transition','transitions','');if(in_array($sStimulus,$aTransition)){$aAttachmentsDeleted=utils::ReadParam('attachments_deleted',array());$oAttachmentsRenderer=AttachmentsRendererFactory::GetInstance($oPage,$sObjClass,$iObjKey,$sTransactionId);$oPage->add('<fieldset><legend>Piècesjointes</legend><divid="AttachmentsContent">');$oAttachmentsRenderer->RenderEditAttachmentsList();$oPage->add('</div></fieldset>');$oPage->add_ready_script(<<<JSif($('[data-attribute-code="public_log"]:first').length>0){$('[data-attribute-code="public_log"]:first').prepend($('fieldset>#AttachmentsContent>div#AttachmentsListContainer').parent().parent());}else{$('#apply_stimulus>table').append($('fieldset>#AttachmentsContent>div#AttachmentsListContainer').parent().parent())}JS);}}
The issue is that in 3.0 or above, displayBareProperties is no longer called in the Ticket's transition form display.
I tried using GetHeaderBlock() via iPageUIBlockExtension instead but it no longer has $oPage parameter that is needed to AttachmentsRendererFactory::GetInstance($oPage, $sObjClass, $iObjKey, $sTransactionId);
Is there any methods to render attachment download block without using $oPage or should i try somehting else ?
Thanks,
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
In order to loose one click on pending transition I was asked to display attachment tab on the pending transition form.
I succeeded in 2.7.7 using this code in an extension via iApplicationUIExtension :
The issue is that in 3.0 or above, displayBareProperties is no longer called in the Ticket's transition form display.
I tried using GetHeaderBlock() via iPageUIBlockExtension instead but it no longer has $oPage parameter that is needed to AttachmentsRendererFactory::GetInstance($oPage, $sObjClass, $iObjKey, $sTransactionId);
Is there any methods to render attachment download block without using $oPage or should i try somehting else ?
Thanks,