mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 02:28:44 +02:00
N°3190 - Edit n:n LinkedSetIndirect in object details using a tagset-like widget
- Add generic set block ui component - Add model link set (direct and indirect) attribute (display style) - Add model link set direct allowed values - Create link set viewer block UI (BlockLinksSetDisplayAsProperty) - Add set block ui factory for linkset - Add object factory and create new endpoint in object controller (with data binder) - Add link set model, link set repository and link set data transformer services
This commit is contained in:
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2013-2022 Combodo SARL
|
||||
*
|
||||
* This file is part of iTop.
|
||||
*
|
||||
* iTop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* iTop is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Base\Component\Input\Set\DataProvider;
|
||||
|
||||
/**
|
||||
* Class AbstractDataProvider
|
||||
*
|
||||
* @package Combodo\iTop\Application\UI\Base\Component\Input\Set\DataProvider
|
||||
* @since 3.1.0
|
||||
*/
|
||||
abstract class AbstractDataProvider implements iDataProvider
|
||||
{
|
||||
/** @var string $sDataValueField Field used for input value */
|
||||
private string $sDataValueField;
|
||||
|
||||
/** @var string $sDataLabelField Field used for label rendering */
|
||||
private string $sDataLabelField;
|
||||
|
||||
/** @var array $aDataSearchFields Fields used for search engine */
|
||||
private array $aDataSearchFields;
|
||||
|
||||
/** @var string|null $sGroupField Field used for grouping options */
|
||||
private ?string $sGroupField;
|
||||
|
||||
/** @var string|null $sTooltipField Field used for item tooltip */
|
||||
private ?string $sTooltipField;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialization
|
||||
$this->Init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function Init()
|
||||
{
|
||||
$this->sDataLabelField = 'label';
|
||||
$this->sDataValueField = 'value';
|
||||
$this->aDataSearchFields = ['search'];
|
||||
$this->sGroupField = null;
|
||||
$this->sTooltipField = 'label';
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public function GetDataValueField(): string
|
||||
{
|
||||
return $this->sDataValueField;
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public function SetDataValueField(string $sField): AbstractDataProvider
|
||||
{
|
||||
$this->sDataValueField = $sField;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public function GetDataLabelField(): string
|
||||
{
|
||||
return $this->sDataLabelField;
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public function SetDataLabelField(string $sField): AbstractDataProvider
|
||||
{
|
||||
$this->sDataLabelField = $sField;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public function GetDataSearchFields(): array
|
||||
{
|
||||
return $this->aDataSearchFields;
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public function SetDataSearchFields(array $aFields): AbstractDataProvider
|
||||
{
|
||||
$this->aDataSearchFields = $aFields;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public function GetGroupField(): ?string
|
||||
{
|
||||
return $this->sGroupField;
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public function SetGroupField(string $sField): iDataProvider
|
||||
{
|
||||
$this->sGroupField = $sField;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public function GetTooltipField(): ?string
|
||||
{
|
||||
return $this->sTooltipField;
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public function SetTooltipField(string $sField): iDataProvider
|
||||
{
|
||||
$this->sTooltipField = $sField;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* IsAjaxProviderType.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function IsAjaxProviderType(): bool
|
||||
{
|
||||
return $this->GetType() === iDataProvider::TYPE_AJAX_PROVIDER;
|
||||
}
|
||||
|
||||
/**
|
||||
* IsSimpleProviderType.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function IsSimpleProviderType(): bool
|
||||
{
|
||||
return $this->GetType() === iDataProvider::TYPE_SIMPLE_PROVIDER;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2013-2022 Combodo SARL
|
||||
*
|
||||
* This file is part of iTop.
|
||||
*
|
||||
* iTop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* iTop is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Base\Component\Input\Set\DataProvider;
|
||||
|
||||
/**
|
||||
* Class AjaxDataProvider
|
||||
*
|
||||
* @package Combodo\iTop\Application\UI\Base\Component\Input\Set\DataProvider
|
||||
* @since 3.1.0
|
||||
*/
|
||||
class AjaxDataProvider extends SimpleDataProvider
|
||||
{
|
||||
/** @var int DEFAULT_MAX_RESULTS maximum results fetched */
|
||||
const DEFAULT_MAX_RESULTS = 25;
|
||||
|
||||
/**
|
||||
* @see \Combodo\iTop\Router\Router
|
||||
* @var string $sAjaxRoute Router route name
|
||||
*/
|
||||
private string $sRoute;
|
||||
|
||||
/** @var array $aParams Query string params */
|
||||
private array $aParams = [];
|
||||
|
||||
/** @var array $aPostParams Post params */
|
||||
private array $aPostParams = [];
|
||||
|
||||
/** @var int $iMaxResults Maximum entries */
|
||||
private int $iMaxResults = AjaxDataProvider::DEFAULT_MAX_RESULTS;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $sRoute Router route name
|
||||
* @param array $aParams Query string params
|
||||
* @param array $aPostParams Post params
|
||||
*/
|
||||
public function __construct(string $sRoute, array $aParams = [], array $aPostParams = [])
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// Retrieve parameters
|
||||
$this->sRoute = $sRoute;
|
||||
$this->aParams = $aParams;
|
||||
$this->aPostParams = $aPostParams;
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public function GetType(): string
|
||||
{
|
||||
return iDataProvider::TYPE_AJAX_PROVIDER;
|
||||
}
|
||||
|
||||
/**
|
||||
* SetParam.
|
||||
*
|
||||
* @param string $sName
|
||||
* @param string $sValue
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function SetParam(string $sName, string $sValue): AjaxDataProvider
|
||||
{
|
||||
$this->aParams[$sName] = $sValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* GetParam.
|
||||
*
|
||||
* @param string $sName
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetParam(string $sName): string
|
||||
{
|
||||
return $this->aParams[$sName];
|
||||
}
|
||||
|
||||
/**
|
||||
* GetParams.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function GetParams(): array
|
||||
{
|
||||
return $this->aParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* GetParamsAsQueryString.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetParamsAsQueryString(): string
|
||||
{
|
||||
$aFlattened = $this->aParams;
|
||||
array_walk($aFlattened, function (&$sValue, $key) {
|
||||
$sValue = "{$key}={$sValue}";
|
||||
});
|
||||
|
||||
return '&'.implode('&', $aFlattened);
|
||||
}
|
||||
|
||||
/**
|
||||
* GetPostParamsAsJsonString.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetPostParamsAsJsonString(): string
|
||||
{
|
||||
return json_encode($this->aPostParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* SetPostParam.
|
||||
*
|
||||
* @param string $sName
|
||||
* @param $oValue
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function SetPostParam(string $sName, $oValue): AjaxDataProvider
|
||||
{
|
||||
$this->aPostParams[$sName] = $oValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* GetRoute.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function GetRoute(): string
|
||||
{
|
||||
return $this->sRoute;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return maximum results count.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function GetMaxResults(): int
|
||||
{
|
||||
return $this->iMaxResults;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2013-2022 Combodo SARL
|
||||
*
|
||||
* This file is part of iTop.
|
||||
*
|
||||
* iTop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* iTop is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Base\Component\Input\Set\DataProvider;
|
||||
|
||||
/**
|
||||
* Class AjaxDataProviderForOQL
|
||||
*
|
||||
* @package Combodo\iTop\Application\UI\Base\Component\Input\Set\DataProvider
|
||||
* @since 3.1.0
|
||||
*/
|
||||
class AjaxDataProviderForOQL extends AjaxDataProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $sObjectClass Db Object class
|
||||
* @param string $sOql Oql
|
||||
* @param string|null $sWizardHelperJsVarName Wizard helper name
|
||||
* @param array $aFieldsToLoad Array of fields to load
|
||||
*/
|
||||
public function __construct(string $sObjectClass, string $sOql, string $sWizardHelperJsVarName = null, array $aFieldsToLoad = [])
|
||||
{
|
||||
parent::__construct('object.search', [
|
||||
'object_class' => $sObjectClass,
|
||||
'oql' => $sOql,
|
||||
'fields_to_load' => json_encode($aFieldsToLoad),
|
||||
], [
|
||||
'this_object_data' => $sWizardHelperJsVarName != null ? "EVAL_JAVASCRIPT{{$sWizardHelperJsVarName}.UpdateWizardToJSON();}" : "",
|
||||
]);
|
||||
|
||||
// Initialization
|
||||
$this->Init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function Init()
|
||||
{
|
||||
$this->SetDataLabelField('friendlyname')
|
||||
->SetDataValueField('key')
|
||||
->SetDataSearchFields(['friendlyname', 'additional_field']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2013-2022 Combodo SARL
|
||||
*
|
||||
* This file is part of iTop.
|
||||
*
|
||||
* iTop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* iTop is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Base\Component\Input\Set\DataProvider;
|
||||
|
||||
/**
|
||||
* Class SimpleDataProvider
|
||||
*
|
||||
* @package Combodo\iTop\Application\UI\Base\Component\Input\Set\DataProvider
|
||||
* @since 3.1.0
|
||||
*/
|
||||
class SimpleDataProvider extends AbstractDataProvider
|
||||
{
|
||||
/** @var array $aOptions */
|
||||
private array $aOptions;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $aOptions
|
||||
*/
|
||||
public function __construct(array $aOptions = [])
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// retrieve parameters
|
||||
$this->SetOptions($aOptions);
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public function GetType(): string
|
||||
{
|
||||
return iDataProvider::TYPE_SIMPLE_PROVIDER;
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public function SetOptions(array $aOptions): SimpleDataProvider
|
||||
{
|
||||
$this->aOptions = $aOptions;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public function SetOption(string $sKey, string $sValue): SimpleDataProvider
|
||||
{
|
||||
$this->aOptions[$sKey] = $sValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public function GetOptions(): array
|
||||
{
|
||||
return $this->aOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* GetOptionsGroups.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function GetOptionsGroups(): array
|
||||
{
|
||||
$aGroups = [];
|
||||
if ($this->GetGroupField() != null) {
|
||||
foreach ($this->GetOptions() as $aOption) {
|
||||
if (array_key_exists($this->GetGroupField(), $aOption)) {
|
||||
$aGroups[$aOption[$this->GetGroupField()]] = [
|
||||
'label' => $aOption[$this->GetGroupField()],
|
||||
'value' => $aOption[$this->GetGroupField()],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array_values($aGroups);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2013-2022 Combodo SARL
|
||||
*
|
||||
* This file is part of iTop.
|
||||
*
|
||||
* iTop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* iTop is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Base\Component\Input\Set\DataProvider;
|
||||
|
||||
/**
|
||||
* Interface iDataProvider
|
||||
*
|
||||
* @package Combodo\iTop\Application\UI\Base\Component\Input\Set\DataProvider
|
||||
* @since 3.1.0
|
||||
*/
|
||||
interface iDataProvider
|
||||
{
|
||||
public const TYPE_AJAX_PROVIDER = "AJAX_PROVIDER";
|
||||
public const TYPE_SIMPLE_PROVIDER = "SIMPLE_PROVIDER";
|
||||
|
||||
/**
|
||||
* GetType.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetType(): string;
|
||||
|
||||
/**
|
||||
* SetOptions.
|
||||
*
|
||||
* @param array $aOptions
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function SetOptions(array $aOptions): iDataProvider;
|
||||
|
||||
/**
|
||||
* SetOption.
|
||||
*
|
||||
* @param string $sKey
|
||||
* @param string $sValue
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function SetOption(string $sKey, string $sValue): iDataProvider;
|
||||
|
||||
/**
|
||||
* GetOptions.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function GetOptions(): array;
|
||||
|
||||
/**
|
||||
* GetDataValueField.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetDataValueField(): string;
|
||||
|
||||
/**
|
||||
* SetDataValueField.
|
||||
*
|
||||
* @param string $sField
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function SetDataValueField(string $sField): iDataProvider;
|
||||
|
||||
/**
|
||||
* GetDataLabelField.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetDataLabelField(): string;
|
||||
|
||||
/**
|
||||
* SetDataLabelField.
|
||||
*
|
||||
* @param string $sField
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function SetDataLabelField(string $sField): iDataProvider;
|
||||
|
||||
/**
|
||||
* GetDataSearchFields.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function GetDataSearchFields(): array;
|
||||
|
||||
/**
|
||||
* SetDataSearchFields.
|
||||
*
|
||||
* @param array $aFields
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function SetDataSearchFields(array $aFields): iDataProvider;
|
||||
|
||||
/**
|
||||
* GetGroupField.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function GetGroupField(): ?string;
|
||||
|
||||
/**
|
||||
* SetGroupField.
|
||||
*
|
||||
* @param string $sField
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function SetGroupField(string $sField): iDataProvider;
|
||||
|
||||
/**
|
||||
* GetTooltipField.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function GetTooltipField(): ?string;
|
||||
|
||||
/**
|
||||
* SetTooltipField.
|
||||
*
|
||||
* @param string $sField
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function SetTooltipField(string $sField): iDataProvider;
|
||||
}
|
||||
Reference in New Issue
Block a user