N°5904 - Use attribute linked set edit mode to enable actions (#440)

* Add corresponding buttons depending on old edit mode (need to check with piR pour récuperer l'ancienne valeur.

* N°5904 - Handle attribute linked set edit_mode

* N°5904 Move calls to private jquery widget methods to public

* N°5904 - Worker improvements add button on link tagset

* Change itop set widget to new set block UI (5)

* Change itop set widget to new set block UI (5)

* Renommage variables JS avec le prefix combodo

* Search dialog block id conflict with form id

* add moved js files in iTopWebPage compatibility list

---------

Co-authored-by: Stephen Abello <stephen.abello@combodo.com>
This commit is contained in:
bdalsass
2023-02-06 16:07:55 +01:00
committed by GitHub
parent 3fbc5e1ce0
commit 1fe9520b7e
28 changed files with 801 additions and 356 deletions

View File

@@ -10,6 +10,7 @@ use AjaxPage;
use cmdbAbstractObject;
use Combodo\iTop\Application\UI\Base\Component\Form\FormUIBlockFactory;
use Combodo\iTop\Controller\AbstractController;
use Combodo\iTop\Service\Base\ObjectRepository;
use Exception;
use JsonPage;
use CoreException;
@@ -169,8 +170,8 @@ class LinkSetController extends AbstractController
$aPrefillParam = array('source_obj' => $oSourceObj);
$oObj->PrefillForm('creation_from_editinplace', $aPrefillParam);
// We display this form in a modal, once we submit (in ajax) we probably want to only close the modal
$sFormOnSubmitJsCode =
<<<JS
$sFormOnSubmitJsCode =
<<<JS
event.preventDefault();
if(bOnSubmitForm === true)
{
@@ -180,6 +181,8 @@ class LinkSetController extends AbstractController
/* Alerts the results */
sPosting.done(function(data) {
// fire event
oForm.trigger('itop.form.submitted', [data]);
if(data.success !== undefined && data.success === true) {
oForm.closest('[data-role="ibo-modal"]').dialog('close');
}
@@ -195,18 +198,20 @@ class LinkSetController extends AbstractController
JS
;
$aExtraParams = [
'noRelations' => true,
'noRelations' => true,
'hide_transitions' => true,
'fieldsFlags' => $aFieldFlags,
'js_handlers' => [
'form_on_submit' => $sFormOnSubmitJsCode,
'formPrefix' => $sAttCode,
'fieldsFlags' => $aFieldFlags,
'js_handlers' => [
'form_on_submit' => $sFormOnSubmitJsCode,
'cancel_button_on_click' =>
<<<JS
function() {
$(this).closest('[data-role="ibo-modal"]').dialog('close');
};
JS
]
,
],
];
cmdbAbstractObject::DisplayCreationForm($oPage, $sRealClass, $oObj, array(), $aExtraParams);
}
@@ -234,13 +239,50 @@ JS
return false;
JS
);
// - Add a select and a button to validate the form
$oClassForm->AddSubBlock(cmdbAbstractObject::DisplayBlockSelectClassToCreate( $sProposedRealClass, MetaModel::GetName($sProposedRealClass), $aPossibleClasses));
$oClassForm->AddSubBlock(cmdbAbstractObject::DisplayBlockSelectClassToCreate($sProposedRealClass, MetaModel::GetName($sProposedRealClass), $aPossibleClasses));
$oPage->AddUiBlock($oClassForm);
}
return $oPage;
}
/**
* OperationGetRemoteObject.
*
* @return JsonPage
*/
public function OperationGetRemoteObject(): JsonPage
{
$oPage = new JsonPage();
$bSuccess = true;
$aObjectData = null;
// Retrieve query params
$sObjectClass = utils::ReadParam('linked_object_class', '', false, utils::ENUM_SANITIZATION_FILTER_STRING);
$sObjectKey = utils::ReadParam('linked_object_key', '', false, utils::ENUM_SANITIZATION_FILTER_STRING);
$sRemoteClass = utils::ReadParam('remote_class', null, false, utils::ENUM_SANITIZATION_FILTER_STRING);
$sRemoteExtKey = utils::ReadParam('external_key_att_code', null, false, utils::ENUM_SANITIZATION_FILTER_STRING);
// Retrieve object
try {
$oObject = MetaModel::GetObject($sObjectClass, $sObjectKey);
$sLinkKey = $oObject->GetKey();
if ($sRemoteExtKey !== null) {
$oObject = MetaModel::GetObject($sRemoteClass, $oObject->Get($sRemoteExtKey));
}
$aObjectData = ObjectRepository::ConvertObjectToArray($oObject, $sObjectClass);
$aObjectData['link_keys'] = [$sObjectKey];
}
catch (Exception $e) {
$bSuccess = false;
}
return $oPage->SetData([
'object' => $aObjectData,
'success' => $bSuccess,
]);
}
}