Skip to content

Commit cb71311

Browse files
Remove row FIX + hasProperty
1 parent 5a3300e commit cb71311

File tree

5 files changed

+41
-8
lines changed

5 files changed

+41
-8
lines changed

src/MultipleInput.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ protected function initData()
161161
}
162162

163163
if ($this->model instanceof Model) {
164-
$data = $this->model->hasAttribute($this->attribute)
164+
$data = ($this->model->hasProperty($this->attribute) || isset($this->model->{$this->attribute}))
165165
? ArrayHelper::getValue($this->model, $this->attribute, [])
166166
: [];
167167

@@ -213,6 +213,18 @@ public function run()
213213
*/
214214
private function createRenderer()
215215
{
216+
if($this->sortable) {
217+
$drag = [
218+
'name' => 'drag',
219+
'type' => MultipleInputColumn::TYPE_DRAGCOLUMN,
220+
'headerOptions' => [
221+
'style' => 'width: 20px;',
222+
]
223+
];
224+
225+
array_unshift($this->columns, $drag);
226+
}
227+
216228
$config = [
217229
'id' => $this->getId(),
218230
'columns' => $this->columns,

src/assets/src/css/sorting.css

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
1-
.multiple-input-list__item,
1+
.drag-handle,
22
.dragging,
33
.dragging * {
44
cursor: move !important;
55
}
66

77
.dragged {
8-
position: absolute
9-
top: 0
10-
opacity: .5
11-
z-index: 2000
8+
position: absolute;
9+
top: 0;
10+
opacity: .5;
11+
z-index: 2000;
12+
}
13+
14+
.drag-handle {
15+
opacity: .5;
16+
padding: 7.5px;
17+
}
18+
19+
.drag-handle:hover {
20+
opacity: 1;
1221
}
1322

1423
tr.placeholder {

src/assets/src/css/sorting.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/BaseColumn.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ abstract class BaseColumn extends Object
3434
const TYPE_STATIC = 'static';
3535
const TYPE_CHECKBOX = 'checkbox';
3636
const TYPE_RADIO = 'radio';
37+
const TYPE_DRAGCOLUMN = 'dragColumn';
3738

3839
/**
3940
* @var string input name
@@ -448,6 +449,17 @@ protected function renderStatic($name, $value, $options)
448449
return Html::tag('p', $value, ['class' => 'form-control-static']);
449450
}
450451

452+
/**
453+
* @param $name
454+
* @param $value
455+
* @param $options
456+
* @return string
457+
*/
458+
protected function renderDragColumn($name, $options)
459+
{
460+
return Html::tag('span', $value, ['class' => 'glyphicon glyphicon-menu-hamburger drag-handle']);
461+
}
462+
451463
/**
452464
* Renders an input.
453465
*

src/renderers/BaseRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ protected function registerAssets()
309309

310310
if($this->sortable) {
311311
MultipleInputSortableAsset::register($view);
312-
$js .= "$('#{$this->id} > table').sortable({containerSelector: 'table', itemPath: '> tbody', itemSelector: 'tr', placeholder: '<tr class=\"placeholder\"/>'});";
312+
$js .= "$('#{$this->id} table').sortable({containerSelector: 'table', itemPath: '> tbody', itemSelector: 'tr', placeholder: '<tr class=\"placeholder\"/>', handle:'.drag-handle'});";
313313
}
314314

315315
$view->registerJs($js);

0 commit comments

Comments
 (0)