mirror of
https://github.com/humhub/humhub.git
synced 2025-01-16 21:58:17 +01:00
Enh: Added random default color to humhub\modules\ui\form\widgets\ColorPicker
This commit is contained in:
parent
12e3e5addf
commit
57443b20ae
@ -19,6 +19,9 @@ HumHub Change Log
|
||||
- Enh: Added `grunt test-server` and `grunt test`
|
||||
- Chng: `humhub\modules\content\models\Content` now implements `humhub\modules\content\interfaces\ContentOwner`
|
||||
- Fix: Target container not available in `humhub\modules\content\components\ContentActiveRecord:afterMove()`
|
||||
- Chng: `humhub\modules\topic\models\Topic::attach` now accepts `humhub\modules\content\interfaces\ContentOwner` instances
|
||||
- Fix: Richtext without focusMenu on small devices overlaps previous sibling
|
||||
- Enh: Added random default color to `humhub\modules\ui\form\widgets\ColorPicker`
|
||||
|
||||
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
namespace humhub\modules\ui\form\widgets;
|
||||
|
||||
use Colors\RandomColor;
|
||||
use humhub\modules\ui\form\widgets\JsInputWidget;
|
||||
|
||||
/**
|
||||
@ -34,6 +35,11 @@ class ColorPicker extends JsInputWidget
|
||||
*/
|
||||
public $attribute = 'color';
|
||||
|
||||
/**
|
||||
* @var bool If set to true, a random color will be set as default
|
||||
*/
|
||||
public $randomDefault = true;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
@ -42,6 +48,11 @@ class ColorPicker extends JsInputWidget
|
||||
if (!empty($this->field)) {
|
||||
$this->attribute = $this->field;
|
||||
}
|
||||
|
||||
if($this->hasModel() && !$this->getValue() && $this->randomDefault) {
|
||||
$attr = $this->attribute;
|
||||
$this->model->$attr = RandomColor::one(['luminosity' => 'dark']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user