From 8a12acd12286b5e64c99dd9f9fbff27eb00b8726 Mon Sep 17 00:00:00 2001 From: Lucas Bartholemy Date: Fri, 10 Jul 2020 12:55:22 +0200 Subject: [PATCH] Enh #4191: Added SortOrder Form Input Field --- protected/humhub/compat/HForm.php | 10 ++- protected/humhub/docs/CHANGELOG_DEV.md | 1 + .../humhub/modules/admin/views/group/edit.php | 5 +- .../admin/views/user-profile/editCategory.php | 8 +-- .../modules/topic/views/manage/editModal.php | 3 +- .../ui/form/widgets/SortOrderField.php | 61 +++++++++++++++++++ .../modules/user/models/ProfileField.php | 2 +- 7 files changed, 78 insertions(+), 12 deletions(-) create mode 100644 protected/humhub/modules/ui/form/widgets/SortOrderField.php diff --git a/protected/humhub/compat/HForm.php b/protected/humhub/compat/HForm.php index dfd283fdbb..c2ac002554 100644 --- a/protected/humhub/compat/HForm.php +++ b/protected/humhub/compat/HForm.php @@ -13,6 +13,7 @@ use humhub\modules\content\widgets\richtext\RichTextField; use humhub\modules\file\components\FileManager; use humhub\modules\ui\form\widgets\DatePicker; use humhub\modules\ui\form\widgets\MultiSelect; +use humhub\modules\ui\form\widgets\SortOrderField; use Yii; use yii\helpers\Html; use yii\widgets\ActiveField; @@ -261,7 +262,7 @@ class HForm extends \yii\base\Component } break; case 'multiselectdropdown': - $field = $this->form->field($model, $name)->widget(MultiSelect::class, [ + $field = $this->form->field($model, $name)->widget(MultiSelect::class, [ 'items' => $definition['items'], 'options' => $definition['options'] ]); @@ -293,7 +294,7 @@ class HForm extends \yii\base\Component $field = $this->form->field($model, $name)->checkboxList($definition['items'], $options); break; case 'textarea': - if(isset($definition['class'])) { + if (isset($definition['class'])) { $options['class'] = $definition['class']; } @@ -338,11 +339,14 @@ class HForm extends \yii\base\Component $field = $this->form->field($model, $name)->widget(RichTextField::class, $options); break; + case 'sortOrder': + $field = $this->form->field($model, $name)->widget(SortOrderField::class, $options); + break; default: return "Field Type " . $definition['type'] . " not supported by Compat HForm"; } - if(!empty($definition['hint']) && $field instanceof ActiveField) { + if (!empty($definition['hint']) && $field instanceof ActiveField) { $field->hint(Html::encode($definition['hint'], false)); } diff --git a/protected/humhub/docs/CHANGELOG_DEV.md b/protected/humhub/docs/CHANGELOG_DEV.md index 5c4c22d594..7d5cf05778 100644 --- a/protected/humhub/docs/CHANGELOG_DEV.md +++ b/protected/humhub/docs/CHANGELOG_DEV.md @@ -13,3 +13,4 @@ HumHub Change Log - Chg #4158: Cleanup post table removed unused column - Fix #4182: Native edge password reveal icons interferes with custom one - Fix #4173: Notification overview HTML compliant issue +- Enh #4191: Added SortOrder Form Input Field diff --git a/protected/humhub/modules/admin/views/group/edit.php b/protected/humhub/modules/admin/views/group/edit.php index 83aa32f7be..99c2a5d71e 100644 --- a/protected/humhub/modules/admin/views/group/edit.php +++ b/protected/humhub/modules/admin/views/group/edit.php @@ -1,5 +1,6 @@ field($group, 'show_at_registration')->checkbox(); ?> field($group, 'show_at_directory')->checkbox(); ?> - field($group, 'sort_order'); ?> + field($group, 'sort_order')->widget(SortOrderField::class) ?> 'btn btn-primary', 'data-ui-loader' => ""]); ?> @@ -55,4 +56,4 @@ use humhub\modules\space\widgets\SpacePickerField; ?> -endContent(); ?> \ No newline at end of file +endContent(); ?> diff --git a/protected/humhub/modules/admin/views/user-profile/editCategory.php b/protected/humhub/modules/admin/views/user-profile/editCategory.php index c363bf3b17..d8f95ab535 100644 --- a/protected/humhub/modules/admin/views/user-profile/editCategory.php +++ b/protected/humhub/modules/admin/views/user-profile/editCategory.php @@ -1,6 +1,7 @@ field($category, 'title') ?> - field($category, 'description')->textarea(['rows' => 5]) ?> - - field($category, 'sort_order') ?> - + field($category, 'sort_order')->widget(SortOrderField::class) ?> field($category, 'translation_category') ?>
@@ -36,7 +34,7 @@ use humhub\libs\Html; isNewRecord && !$category->is_system): ?> link(Url::to(['delete-category', 'id' => $category->id]))->confirm()->right()?> + ->link(Url::to(['delete-category', 'id' => $category->id]))->confirm()->right() ?> diff --git a/protected/humhub/modules/topic/views/manage/editModal.php b/protected/humhub/modules/topic/views/manage/editModal.php index c5b2035129..4c07656792 100644 --- a/protected/humhub/modules/topic/views/manage/editModal.php +++ b/protected/humhub/modules/topic/views/manage/editModal.php @@ -6,6 +6,7 @@ * */ +use humhub\modules\ui\form\widgets\SortOrderField; use humhub\widgets\ModalButton; use humhub\widgets\ModalDialog; use yii\bootstrap\ActiveForm; @@ -18,7 +19,7 @@ use yii\bootstrap\ActiveForm;