N°2847 - Datatables Fix external keys search

This commit is contained in:
Eric
2020-11-13 09:56:23 +01:00
parent 434c829f7e
commit 89c35f0345
5 changed files with 27 additions and 36 deletions

View File

@@ -17,10 +17,11 @@
* You should have received a copy of the GNU Affero General Public License
*/
use Combodo\iTop\Application\Search\SearchForm;
use Combodo\iTop\Application\UI\Component\Alert\AlertFactory;
use Combodo\iTop\Application\UI\Component\Button\Button;
use Combodo\iTop\Application\UI\Component\Button\ButtonFactory;
use Combodo\iTop\Application\UI\Component\DataContainer\DataContainerFactory;
use Combodo\iTop\Application\UI\Component\DataTable\DataTableSettings;
use Combodo\iTop\Application\UI\Component\Field\Field;
use Combodo\iTop\Application\UI\Component\FieldSet\FieldSet;
use Combodo\iTop\Application\UI\Component\Form\Form;
@@ -58,6 +59,8 @@ require_once(APPROOT.'sources/application/search/criterionconversion/criterionto
require_once(APPROOT.'sources/application/search/criterionconversion/criteriontosearchform.class.inc.php');
use Combodo\iTop\Application\UI\Component\DataTable\DataTableFactory;
use Combodo\iTop\Renderer\Console\ConsoleFormRenderer;
/**
* Class cmdbAbstractObject
*/
@@ -390,11 +393,11 @@ EOF
$aIcons[] = "<div class=\"tag\" title=\"$sTitle\"><span class=\"object-obsolete fas fa-eye-slash fa-1x\">&nbsp;</span>&nbsp;$sLabel</div>";
}
if (count($aIcons) > 0) {
$sTags = '<div class="tags">'.implode('&nbsp;', $aIcons).'</div>';
} else {
$sTags = '';
}
// if (count($aIcons) > 0) {
// $sTags = '<div class="tags">'.implode('&nbsp;', $aIcons).'</div>';
// } else {
// $sTags = '';
// }
$oPage->AddUiBlock(TitleFactory::MakeForObjectDetails($this));
}
@@ -1105,7 +1108,7 @@ HTML
*/
public static function GetDisplaySet(WebPage $oPage, CMDBObjectSet $oSet, $aExtraParams = array())
{
$oPage->AddUiBlock(GetDisplaySetBlock( $oPage, $oSet, $aExtraParams ));
$oPage->AddUiBlock(static::GetDisplaySetBlock( $oPage, $oSet, $aExtraParams ));
return "";
}
@@ -1120,9 +1123,7 @@ HTML
$iListId = $aExtraParams['currentId'];
}
$oDataTable = DataTableFactory::MakeForResult($oPage, $iListId, $oSet, $aExtraParams);
return $oDataTable;
return DataTableFactory::MakeForResult($oPage, $iListId, $oSet, $aExtraParams);
}
/**
* @param \WebPage $oPage
@@ -1722,7 +1723,7 @@ HTML
*/
public static function GetSearchForm(WebPage $oPage, CMDBObjectSet $oSet, $aExtraParams = array())
{
$oSearchForm = new \Combodo\iTop\Application\Search\SearchForm();
$oSearchForm = new SearchForm();
return $oSearchForm->GetSearchForm($oPage, $oSet, $aExtraParams);
}
@@ -2144,7 +2145,7 @@ EOF
$sHTMLValue .= "<input name=\"attr_{$sFieldPrefix}{$sAttCode}{$sNameSuffix}\" type=\"hidden\" id=\"$iId\" value=\"\"/>\n";
$oForm = $value->GetForm($sFormPrefix);
$oRenderer = new \Combodo\iTop\Renderer\Console\ConsoleFormRenderer($oForm);
$oRenderer = new ConsoleFormRenderer($oForm);
$aRenderRes = $oRenderer->Render();
$aFieldSetOptions = array(
@@ -2415,8 +2416,7 @@ JS
if (isset($aExtraParams['wizard_container']) && $aExtraParams['wizard_container']) {
$sClassLabel = MetaModel::GetName($sClass);
$sHeaderTitle = Dict::Format('UI:ModificationTitle_Class_Object', $sClassLabel,
$this->GetName());
//$sHeaderTitle = Dict::Format('UI:ModificationTitle_Class_Object', $sClassLabel, $this->GetName());
$oPage->set_title(Dict::Format('UI:ModificationPageTitle_Object_Class', $this->GetRawName(),
$sClassLabel)); // Set title will take care of the encoding
@@ -4194,12 +4194,9 @@ EOF
if ((!$bEditMode) || ($iFlags & (OPT_ATT_READONLY | OPT_ATT_SLAVE)))
{
// Check if the attribute is not read-only because of a synchro...
$sSynchroIcon = '';
if ($iFlags & OPT_ATT_SLAVE)
{
$aReasons = array();
$iSynchroFlags = $this->GetSynchroReplicaFlags($sAttCode, $aReasons);
$sSynchroIcon = "&nbsp;<img id=\"synchro_$sInputId\" src=\"../images/transp-lock.png\" style=\"vertical-align:middle\"/>";
$sTip = '';
foreach($aReasons as $aRow)
{
@@ -4218,7 +4215,6 @@ EOF
$sHTMLValue .= '<input type="hidden" id="'.$sInputId.'" name="attr_'.$sPrefix.$sAttCode.'" value="'.htmlentities($this->GetEditValue($sAttCode),
ENT_QUOTES, 'UTF-8').'"/>';
$aFieldsMap[$sAttCode] = $sInputId;
$sComment .= $sSynchroIcon;
}
else
{
@@ -4267,7 +4263,6 @@ HTML
public function GetExpectedAttributes($sCurrentState, $sStimulus, $bOnlyNewOnes)
{
$aTransitions = $this->EnumTransitions();
$aStimuli = MetaModel::EnumStimuli(get_class($this));
if (!isset($aTransitions[$sStimulus]))
{
// Invalid stimulus
@@ -4588,6 +4583,7 @@ EOF
*/
public static function DoBulkModify($oP, $sClass, $aSelectedObj, $sCustomOperation, $bPreview, $sCancelUrl, $aContextData = array())
{
/** @var string[] $aHeaders */
$aHeaders = array(
'form::select' => array(
'label' => "<input type=\"checkbox\" onClick=\"CheckAll('.selectList:not(:disabled)', this.checked);\"></input>",
@@ -4663,7 +4659,6 @@ EOF
$sFormAction = utils::GetAbsoluteUrlAppRoot().'pages/UI.php'; // No parameter in the URL, the only parameter will be the ones passed through the form
// Form to submit:
$oP->add("<form method=\"post\" action=\"$sFormAction\" enctype=\"multipart/form-data\">\n");
$aDefaults = utils::ReadParam('default', array());
$oAppContext = new ApplicationContext();
$oP->add($oAppContext->GetForForm());
foreach($aContextData as $sKey => $value)
@@ -4879,7 +4874,6 @@ EOF
if (count($aObjects) == 1)
{
$oObj = $aObjects[0];
$id = $oObj->GetKey();
$oP->p('<h1>'.Dict::Format('UI:Delect:Confirm_Object', $oObj->GetHyperLink()).'</h1>');
}
else

View File

@@ -17,6 +17,7 @@
* You should have received a copy of the GNU Affero General Public License
*/
use Combodo\iTop\Application\Search\SearchForm;
use Combodo\iTop\Application\UI\Component\Badge\BadgeFactory;
use Combodo\iTop\Application\UI\Component\Button\ButtonFactory;
use Combodo\iTop\Application\UI\Component\Dashlet\DashletFactory;
@@ -25,6 +26,7 @@ use Combodo\iTop\Application\UI\Component\Html\Html;
use Combodo\iTop\Application\UI\Component\Toolbar\Toolbar;
use Combodo\iTop\Application\UI\iUIBlock;
use Combodo\iTop\Application\UI\Layout\UIContentBlock;
use Combodo\iTop\Renderer\BlockRenderer;
require_once(APPROOT.'/application/utils.inc.php');
@@ -513,7 +515,7 @@ class DisplayBlock
$iListId = $aExtraParams['currentId'];
}
$oBlock = DataTableFactory::MakeForRendering( $iListId, $this->m_oSet, $aExtraParams);
$sHtml .= "<tr><td>".render_block($oBlock)."</td></tr>\n";
$sHtml .= "<tr><td>".BlockRenderer::RenderBlockTemplates($oBlock)."</td></tr>\n";
}
}
$sHtml .= "</table>\n";
@@ -733,7 +735,7 @@ class DisplayBlock
if (!$oPage->IsPrintableVersion())
{
$aExtraParams['currentId'] = $sId;
$oSearchForm = new \Combodo\iTop\Application\Search\SearchForm();
$oSearchForm = new SearchForm();
$oBlock = $oSearchForm->GetSearchFormUIBlock($oPage, $this->m_oSet, $aExtraParams);
}
break;

View File

@@ -6804,7 +6804,9 @@ class AttributeExternalKey extends AttributeDBFieldVoid
public function GetRenderForDataTable(string $sClassAlias) :string
{
$sRenderFunction = "return '<a class=\'object-ref-link\' href= \'UI.php?operation=details&class=".$this->m_aParams['targetclass']."&id='+data+'\'>'+row['".$sClassAlias."/".$this->m_sCode."_friendlyname']+'</a>' ;";
$oRemoteAtt = $this->GetFinalAttDef();
$sTargetClass = $oRemoteAtt->GetTargetClass();
$sRenderFunction = "return '<a class=\'object-ref-link\' href= \'UI.php?operation=details&class=".$sTargetClass."&id='+data+'\'>'+row['".$sClassAlias."/".$this->GetCode()."_friendlyname']+'</a>' ;";
return $sRenderFunction;
}
}

View File

@@ -32,13 +32,10 @@ use AttributeTagSet;
use CMDBObjectSet;
use Combodo\iTop\Application\Search\CriterionConversion\CriterionToSearchForm;
use Combodo\iTop\Application\UI\Component\Form\Form;
use Combodo\iTop\Application\UI\Component\DataContainer\DataContainer;
use Combodo\iTop\Application\UI\Component\Html\Html;
use Combodo\iTop\Application\UI\Component\Input\InputFactory;
use Combodo\iTop\Application\UI\Component\Panel\Panel;
use Combodo\iTop\Application\UI\Component\Panel\PanelFactory;
use Combodo\iTop\Application\UI\Layout\UIContentBlock;
use Combodo\iTop\Renderer\BlockRenderer;
use CoreException;
use DBObjectSearch;
use DBObjectSet;
@@ -49,11 +46,10 @@ use FieldExpression;
use IssueLog;
use MetaModel;
use MissingQueryArgument;
use ScssPhp\ScssPhp\Block;
use TrueExpression;
use UserRights;
use utils;
use WebPage;
use UserRights;
class SearchForm
{
@@ -63,9 +59,6 @@ class SearchForm
* @param array $aExtraParams
*
* @return string
* @throws \CoreException
* @throws \DictExceptionMissingString
* @throws \Exception
*/
public function GetSearchForm(WebPage $oPage, CMDBObjectSet $oSet, $aExtraParams = array())
{

View File

@@ -99,13 +99,13 @@ var oTable{{ oUIBlock.GetId() }} = $('#{{ oUIBlock.GetId() }}').DataTable({
"processing": true,
"serverSide": true,
"columns": [
{% if oUIBlock.GetOption("select") is not empty %}
{% if oUIBlock.GetOption("select_mode") is not empty %}
{
"width": "auto",
"searchable": false,
"sortable": false,
title:
{% if oUIBlock.GetOption("select") == "multi" %}
"title":
{% if oUIBlock.GetOption("select_mode") == "multi" %}
'<span class="row_input"><input type="checkbox" onclick="checkAllDataTable(\'#{{ oUIBlock.GetId() }}\',this.checked);" class="checkAll" id="field_{{ oUIBlock.GetId() }}_check_all" name="field_{{ oUIBlock.GetId() }}_check_all" title="{{ 'UI:SearchValue:CheckAll'|dict_s }} / {{ 'UI:SearchValue:UncheckAll'|dict_s }}" /></span>'
{% else %}
'<span class="row_input"><input type="checkbox" style="display: none;" onclick="checkAllDataTable(\'#{{ oUIBlock.GetId() }}\',this.checked);" class="checkAll" id="field_{{ oUIBlock.GetId() }}_check_all" name="field_{{ oUIBlock.GetId() }}_check_all" title="{{ 'UI:SearchValue:CheckAll'|dict_s }} / {{ 'UI:SearchValue:UncheckAll'|dict_s }}" /></span>'
@@ -114,7 +114,7 @@ var oTable{{ oUIBlock.GetId() }} = $('#{{ oUIBlock.GetId() }}').DataTable({
"data": "",
"render": function (data, type, row) {
var oCheckboxElem =
{% if oUIBlock.GetOption("select") == "multi" %}
{% if oUIBlock.GetOption("select_mode") == "multi" %}
$('<span class="row_input"><input type="checkbox" class="selectList{{ oUIBlock.GetId() }}" name="selectObject[]" /></span>');
{% else %}
$('<span class="row_input"><input type="radio" class="selectList{{ oUIBlock.GetId() }}" name="selectObject[]" /></span>');