mirror of
https://github.com/humhub/humhub.git
synced 2025-04-21 23:52:04 +02:00
Fix widgetAction events case issue
Added `humhub.modules.util.string.capitalizeFirstLetter` and `lowerCaseFirstLetter` Chng: Rename `Upload::model` to `Upload:forModel` Chng: Rename `Upload::name` to `Upload:withName`
This commit is contained in:
parent
58b3df94b7
commit
8ab13b8a04
@ -19,7 +19,9 @@ HumHub Change Log
|
||||
- Enh: Added `humhub\modules\file\models\isAssignedTo($record)` argument in order to check if a File is attached to a specific record
|
||||
- Fix: rich-text mobile view wrong min-height calculation
|
||||
- Fix #3314: layout container width differences
|
||||
|
||||
- Fix comment scroll overflows button
|
||||
- Fix widgetAction events case issue
|
||||
- Added `humhub.modules.util.string.capitalizeFirstLetter` and `lowerCaseFirstLetter`
|
||||
|
||||
1.3.4 (September 25, 2018)
|
||||
---------------------------
|
||||
|
@ -91,10 +91,9 @@ use yii\helpers\Html;
|
||||
*/
|
||||
class Upload extends Widget
|
||||
{
|
||||
/**
|
||||
* @var string upload input widget id
|
||||
*/
|
||||
public $id;
|
||||
const DEFAULT_SUBMIT_NAME = 'fileList[]';
|
||||
const DEFAULT_UPLOAD_NAME = 'files[]';
|
||||
const DEFAULT_ATTRIBUTE_NAME = 'files';
|
||||
|
||||
/**
|
||||
* @var Model the model the file array should be
|
||||
@ -109,7 +108,7 @@ class Upload extends Widget
|
||||
/**
|
||||
* @var string upload input name
|
||||
*/
|
||||
public $name = 'files[]';
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var string defines the input name of file items attached to the form after the upload
|
||||
@ -141,7 +140,7 @@ class Upload extends Widget
|
||||
* @return static
|
||||
* @throws \yii\base\InvalidConfigException
|
||||
*/
|
||||
public static function model($model, $attribute = 'files', $cfg = [])
|
||||
public static function forModel($model, $attribute = self::DEFAULT_ATTRIBUTE_NAME, $cfg = [])
|
||||
{
|
||||
return static::create(array_merge($cfg, ['model' => $model, 'attribute' => $attribute]));
|
||||
}
|
||||
@ -155,7 +154,7 @@ class Upload extends Widget
|
||||
* @return static
|
||||
* @throws \yii\base\InvalidConfigException
|
||||
*/
|
||||
public static function name($submitName, $uploadName, $cfg = [])
|
||||
public static function withName($submitName = self::DEFAULT_SUBMIT_NAME, $uploadName = self::DEFAULT_UPLOAD_NAME, $cfg = [])
|
||||
{
|
||||
return static::create(array_merge($cfg, ['submitName' => $submitName, 'name' => $uploadName]));
|
||||
}
|
||||
@ -188,6 +187,26 @@ class Upload extends Widget
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
* @return $this
|
||||
*/
|
||||
public function submitName($submitName = self::DEFAULT_SUBMIT_NAME)
|
||||
{
|
||||
$this->submitName = $submitName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
* @return $this
|
||||
*/
|
||||
public function uploadName($uploadName = self::DEFAULT_UPLOAD_NAME)
|
||||
{
|
||||
$this->name = $uploadName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to define the `postState` flag which manages the input attachment of posted files.
|
||||
* If set to true (default) the upload component will try to fetch uploaded files from the request and attach input
|
||||
|
@ -203,6 +203,10 @@ class UploadInput extends JsWidget
|
||||
|
||||
$files = Yii::$app->request->post($postSubmit);
|
||||
|
||||
if(!$files) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if(!is_array($files)) {
|
||||
$files = [$files];
|
||||
}
|
||||
|
@ -48,9 +48,9 @@ humhub.module('ui.widget', function(module, require, $) {
|
||||
// Bind dom events to widget events actions.
|
||||
$.each(this.options, function(key, value) {
|
||||
if(string.startsWith(key, 'widgetAction')) {
|
||||
var eventType = string.cutPrefix(key, 'widgetAction').toLowerCase();
|
||||
that.$.on(eventType+'.humhub:widget:events', function() {
|
||||
that.fire(eventType);
|
||||
var eventType = string.lowerCaseFirstLetter(string.cutPrefix(key, 'widgetAction'));
|
||||
that.$.on(eventType+'.humhub:widget:events '+eventType.toLowerCase+'.humhub:widget:events', function() {
|
||||
that.fire(eventType, null, false);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -223,6 +223,21 @@ humhub.module('util', function(module, require, $) {
|
||||
}
|
||||
return val.indexOf(suffix, val.length - suffix.length) !== -1;
|
||||
},
|
||||
capitalizeFirstLetter: function capitalizeFirstLetter(s) {
|
||||
if(!s || !s.length) {
|
||||
return s;
|
||||
}
|
||||
|
||||
return s.charAt(0).toUpperCase() + s.slice(1);
|
||||
},
|
||||
lowerCaseFirstLetter: function capitalizeFirstLetter(s) {
|
||||
if(!s || !s.length) {
|
||||
return s;
|
||||
}
|
||||
|
||||
return s.charAt(0).toLowerCase() + s.slice(1);
|
||||
},
|
||||
|
||||
/* @deptecated use encode */
|
||||
htmlEncode: function(value) {
|
||||
return $('<div/>').text(value).html();
|
||||
|
@ -111,4 +111,10 @@
|
||||
padding-right: 72px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.comment-create-input-group.scrollActive {
|
||||
.comment-buttons {
|
||||
right: 22px;
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user