N°3300 - Add creation and modification of 1-n objects in object details (#385)

* Rebase onto develop

* Use exit condition instead of englobing condition

* Add informative modals that can be called from modal toolbox

* Refactor "apply_modify" and "apply_new" into own controller, handle ajax requests with a json response and handle these responses in linkset creation/edition

* Fix merge issues

* Remove inverted condition

* Move linkset create button to a better place, still needs to fix duplicate "New" button caused by a refactor

* Handle "Cancel" button in modals

* Do not display relations when editing an object in a modal

* More elegant way to add "New" button to relations lists

* Factorize vertical highlights in alerts and modal in a single mixin

* Replace button name with dict entry code

* Change route name to snake case

* More elegant way to add "Create in modal" button to relations lists

* Replace triple if with in_array

* Move listener to body

* Rename variable to match boolean rules

* Rename event

* Rename extra param

* Add phpdoc

* Revert changes

* Check indirect linkset rights before allowing creation in modal

* Allow to modify linked object from 1-n relation in modal

* Add "New" button to 1-n relations

* Fix "new" button on 1-n

* Add todo

* Handle multiple classes choice

* Rework multiple classes choice and only allow LinksetController to be called from an ajax context

* PhpDoc

* Update sources/Application/UI/Links/Direct/BlockDirectLinksViewTable.php

Co-authored-by: Molkobain <lajarige.guillaume@free.fr>
This commit is contained in:
Stephen Abello
2023-01-18 15:43:31 +01:00
committed by GitHub
parent e1ffa65d8b
commit c1922e2b3f
3 changed files with 77 additions and 20 deletions

View File

@@ -30,14 +30,23 @@ class BlockDirectLinksViewTable extends AbstractBlockLinksViewTable
/** @inheritdoc * */
public function GetExtraParam(): array
{
return array(
$aExtraParams = array(
'target_attr' => $this->oAttDef->GetExtKeyToMe(),
'object_id' => $this->oDbObject->GetKey(),
'menu' => MetaModel::GetConfig()->Get('allow_menu_on_linkset'),
'default' => $this->GetDefault(),
'table_id' => $this->GetTableId(),
'row_actions' => $this->GetRowActions(),
'currentId' => $this->GetTableId(),
);
// - Add creation in modal if the linkset is not readonly
if (!$this->oAttDef->GetReadOnly()) {
$aExtraParams['creation_in_modal_is_allowed'] = true;
$aExtraParams['creation_in_modal_js_handler'] = 'LinkSetWorker.CreateLinkedObject("'.$this->GetTableId().'");';
}
return $aExtraParams;
}
/** @inheritdoc * */
@@ -77,6 +86,11 @@ class BlockDirectLinksViewTable extends AbstractBlockLinksViewTable
);
break;
}
$aRowActions[] = array(
'tooltip' => 'UI:Links:ActionRow:Modify',
'icon_classes' => 'fas fa-pen',
'js_row_action' => "LinkSetWorker.ModifyLinkedObject('{$this->sTargetClass}', aRowData['{$this->oAttDef->GetLinkedClass()}/_key_/raw'], '{$this->GetTableId()}');",
);
}
return $aRowActions;