mirror of
https://github.com/humhub/humhub.git
synced 2025-01-16 21:58:17 +01:00
Enh: Added DurationPickerWidget
This commit is contained in:
parent
c27a7c2e00
commit
18f5bdce4c
@ -20,6 +20,7 @@
|
||||
"yiisoft/yii2-swiftmailer": "~2.0.0",
|
||||
"yiisoft/yii2-authclient": "~2.0.0",
|
||||
"yiisoft/yii2-imagine": "~2.0.0",
|
||||
"yiisoft/yii2-httpclient": "~2.0.0",
|
||||
"raoul2000/yii2-jcrop-widget": "*",
|
||||
"kartik-v/yii2-widgets": "*",
|
||||
"phpoffice/phpexcel": "*",
|
||||
@ -50,7 +51,8 @@
|
||||
"bower-asset/html5shiv": "^3.7",
|
||||
"bower-asset/clipboard.js": "*",
|
||||
"bower-asset/jPlayer": "2.9.2",
|
||||
"bower-asset/imagesloaded": "*"
|
||||
"bower-asset/imagesloaded": "*",
|
||||
"bower-asset/jquery-timeentry": "^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"codeception/codeception": "*",
|
||||
|
41
protected/humhub/assets/JqueryTimeEntryAsset.php
Normal file
41
protected/humhub/assets/JqueryTimeEntryAsset.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @link https://www.humhub.org/
|
||||
* @copyright Copyright (c) 2017 HumHub GmbH & Co. KG
|
||||
* @license https://www.humhub.com/licences
|
||||
*/
|
||||
|
||||
namespace humhub\assets;
|
||||
|
||||
use Yii;
|
||||
use yii\web\AssetBundle;
|
||||
|
||||
/**
|
||||
* TimeAgo Asset Bundle
|
||||
*
|
||||
* @author luke
|
||||
*/
|
||||
class JqueryTimeEntryAsset extends AssetBundle
|
||||
{
|
||||
|
||||
public $publishOptions = [
|
||||
'forceCopy' => false
|
||||
];
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public $sourcePath = '@bower/jquery-timeentry';
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public $js = ['jquery.plugin.js', 'jquery.timeentry.js'];
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public $css = ['jquery.timeentry.css'];
|
||||
|
||||
}
|
@ -26,7 +26,9 @@ Important note for LDAP users: There is a new setting "ID Attribute" which shoul
|
||||
- Fix #2730: Mentioning search with `-` not working
|
||||
- Fix: File search with suffix not working
|
||||
- Enh: Added SearchAttributesEvent to improve content addon indexing (comment/file)
|
||||
- Fix: Do not automatically reload on stream edit modals
|
||||
- Fix: Do not automatically force modal close on stream edit
|
||||
- Enh: Added DurationPickerWidget
|
||||
|
||||
|
||||
1.2.2 (August 2, 2017)
|
||||
--------------------------------
|
||||
|
59
protected/humhub/widgets/DurationPicker.php
Normal file
59
protected/humhub/widgets/DurationPicker.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @link https://www.humhub.org/
|
||||
* @copyright Copyright (c) 2017 HumHub GmbH & Co. KG
|
||||
* @license https://www.humhub.com/licences
|
||||
*/
|
||||
|
||||
namespace humhub\widgets;
|
||||
|
||||
use Yii;
|
||||
use humhub\libs\Html;
|
||||
use yii\helpers\Json;
|
||||
use humhub\assets\JqueryTimeEntryAsset;
|
||||
use humhub\widgets\InputWidget;
|
||||
|
||||
/**
|
||||
* DurationPicker renders an UI form widget to select time durations.
|
||||
*
|
||||
* @since 1.2.3
|
||||
* @author Luke
|
||||
*/
|
||||
class DurationPicker extends InputWidget
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$view = $this->getView();
|
||||
$id = $this->options['id'];
|
||||
|
||||
$options = [
|
||||
'show24Hours' => true,
|
||||
'unlimitedHours' => true,
|
||||
'defaultTime' => '01:00',
|
||||
'timeSteps' => [1, 15],
|
||||
'spinnerImage' => ''
|
||||
];
|
||||
|
||||
JqueryTimeEntryAsset::register($view);
|
||||
$view->registerJs("$('#{$id}').timeEntry(" . Json::htmlEncode($options) . ");");
|
||||
|
||||
Html::addCssClass($this->options, 'form-control');
|
||||
|
||||
if ($this->model !== null) {
|
||||
return Html::activeTextInput($this->model, $this->attribute, $this->getOptions());
|
||||
} else {
|
||||
return Html::input($this->name, $this->value, $this->getOptions());
|
||||
}
|
||||
}
|
||||
|
||||
public static function getDuration(\DateTime $start, \DateTime $end)
|
||||
{
|
||||
$duration = $start->diff($end);
|
||||
return $duration->h . ':' . $duration->m;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user