N°7157 - Allow users to unsubscribe from notification channels (#611)

* N°7157 - Allow users to unsubscribe from notification channels

* Fix type hinting

* Add missing dict entries

* Allows to subscribe/unsubscribe from notifications individually

* Refactor NotificationsService to singleton pattern

* Refactor NotificationsRepository to singleton pattern and rename methods to a more functional naming

* Add PHPDoc and type hints

* Dump autoloaders

* Replace modals with toasts

* Add dict entry

---------

Co-authored-by: Molkobain <lajarige.guillaume@free.fr>
This commit is contained in:
Stephen Abello
2024-02-19 09:25:47 +01:00
committed by GitHub
parent efe5f004a1
commit ceba1ad1e9
28 changed files with 1305 additions and 24 deletions

View File

@@ -43,10 +43,17 @@ class Set extends AbstractInput
'js/selectize/plugin_combodo_auto_position.js',
'js/selectize/plugin_combodo_update_operations.js',
'js/selectize/plugin_combodo_multi_values_synthesis.js',
'js/selectize/plugin_combodo_min_items.js',
];
protected $bIsDisabled = false;
/** @var int|null $iMaxItems Maximum number of items selectable */
private ?int $iMaxItems;
/** @var int|null $iMinItems Minimum number of items selectable */
private ?int $iMinItems;
/** @var int|null $iMaxItem Maximum number of displayed options */
private ?int $iMaxOptions;
@@ -63,6 +70,18 @@ class Set extends AbstractInput
/** @var string $sAddButtonTitle Add button title */
private string $sAddButtonTitle;
/** @var string|null $sOnOptionRemoveJs JS code to execute when an option is no longer among available options */
private ?string $sOnOptionRemoveJs;
/** @var string|null $sOnOptionAddJs JS code to execute when an option is added to the available options */
private ?string $sOnOptionAddJs;
/** @var string|null $sOnItemRemoveJs JS code to execute when a selected item is removed */
private ?string $sOnItemRemoveJs;
/** @var string|null $sOnItemAddJs JS code to execute when a new item is selected */
private ?string $sOnItemAddJs;
/** @var bool $bIsPreloadEnabled Load data at initialization (ajax data provider only) */
private bool $bIsPreloadEnabled;
@@ -107,16 +126,22 @@ class Set extends AbstractInput
// @todo BDA placeholder depending on autocomplete activation (search...., click to add...)
$this->SetPlaceholder(Dict::S('Core:AttributeSet:placeholder'));
$this->iMaxItems = null;
$this->iMinItems = null;
$this->iMaxOptions = null;
$this->bHasRemoveItemButton = true;
$this->bHasAddOptionButton = false;
$this->sAddOptionButtonJsOnClick = null;
$this->sAddButtonTitle = Dict::S('UI:Button:Create');
$this->sOnItemAddJs = null;
$this->sOnItemRemoveJs = null;
$this->sOnOptionAddJs = null;
$this->sOnOptionRemoveJs = null;
$this->bIsPreloadEnabled = false;
$this->sTemplateOptions = null;
$this->sTemplateItems = null;
$this->bIsMultiValuesSynthesis = false;
$this->bHasError = false;
$this->bIsDisabled = false;
}
/**
@@ -143,6 +168,32 @@ class Set extends AbstractInput
return $this->iMaxItems;
}
/**
* SetMinItems.
*
* @param int|null $iMinItems
*
* @return $this
* @since 3.2.0
*/
public function SetMinItems(?int $iMinItems)
{
$this->iMinItems = $iMinItems;
return $this;
}
/**
* GetMinItems.
*
* @return int|null
* @since 3.2.0
*/
public function GetMinItems(): ?int
{
return $this->iMinItems;
}
/**
* SetMaxOptions.
*
@@ -458,4 +509,103 @@ class Set extends AbstractInput
return $this;
}
/**
* @param string|null $sOnOptionRemoveJs
*
* @return $this
*/
public function SetOnOptionRemoveJs(?string $sOnOptionRemoveJs)
{
$this->sOnOptionRemoveJs = $sOnOptionRemoveJs;
return $this;
}
/**
* @return string|null
*/
public function GetOnOptionRemoveJs(): ?string
{
return $this->sOnOptionRemoveJs;
}
/**
* @param string|null $sOnOptionAddJs
*
* @return $this
*/
public function SetOnOptionAddJs(?string $sOnOptionAddJs)
{
$this->sOnOptionAddJs = $sOnOptionAddJs;
return $this;
}
/**
* @return string|null
*/
public function GetOnOptionAddJs(): ?string
{
return $this->sOnOptionAddJs;
}
/**
* @param string|null $sOnItemRemoveJs
*
* @return $this
*/
public function SetOnItemRemoveJs(?string $sOnItemRemoveJs)
{
$this->sOnItemRemoveJs = $sOnItemRemoveJs;
return $this;
}
/**
* @return string|null
*/
public function GetOnItemRemoveJs(): ?string
{
return $this->sOnItemRemoveJs;
}
/**
* @param string|null $sOnItemAddJs
*
* @return $this
*/
public function SetOnItemAddJs(?string $sOnItemAddJs)
{
$this->sOnItemAddJs = $sOnItemAddJs;
return $this;
}
/**
* @return string|null
*/
public function GetOnItemAddJs(): ?string
{
return $this->sOnItemAddJs;
}
/**
* @return bool
*/
public function IsDisabled(): bool
{
return $this->bIsDisabled;
}
/**
* @param bool $bIsDisabled
*
* @return $this
*/
public function SetIsDisabled(bool $bIsDisabled)
{
$this->bIsDisabled = $bIsDisabled;
return $this;
}
}

View File

@@ -56,7 +56,7 @@ class SetUIBlockFactory extends AbstractUIBlockFactory
*
* @return \Combodo\iTop\Application\UI\Base\Component\Input\Set\Set
*/
public static function MakeForSimple(string $sId, array $aOptions, string $sLabelFields, string $sValueField, array $aSearchFields, ?string $sGroupField = null): Set
public static function MakeForSimple(string $sId, array $aOptions, string $sLabelFields, string $sValueField, array $aSearchFields, ?string $sGroupField = null, ?string $sTooltipField = null): Set
{
// Create set ui block
$oSetUIBlock = new Set($sId);
@@ -67,7 +67,7 @@ class SetUIBlockFactory extends AbstractUIBlockFactory
->SetDataLabelField($sLabelFields)
->SetDataValueField($sValueField)
->SetDataSearchFields($aSearchFields)
->SetTooltipField($sLabelFields);
->SetTooltipField($sTooltipField ?? $sLabelFields);
if ($sGroupField != null) {
$oDataProvider->SetGroupField($sGroupField);
}