Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{
"name": "laravel-admin-ext/grid-sortable",
"name": "superoryco/grid-sortable",
"description": "Sort the grid data by drag and drop rows",
"type": "library",
"keywords": ["laravel-admin", "extension", "grid", "sortable"],
"keywords": [
"laravel-admin",
"extension",
"grid",
"sortable"
],
"homepage": "https://github.com/laravel-admin-ext/grid-sortable",
"license": "MIT",
"authors": [
Expand Down Expand Up @@ -31,4 +36,4 @@
]
}
}
}
}
15 changes: 12 additions & 3 deletions src/SaveOrderBtn.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ protected function script()

$class = str_replace('\\', '\\\\', $class);

$name = $this->getButtonId();

$script = <<<SCRIPT
(function () {

$('.grid-save-order-btn').click(function () {
$('#{$name}').click(function () {

$.post('{$route}', {
_token: $.admin.token,
Expand All @@ -45,12 +47,19 @@ public function render()
{
$this->script();

$name = $this->getButtonId();

$text = __('Save order');

return <<<HTML
<button type="button" class="btn btn-sm btn-info grid-save-order-btn" style="margin-left: 10px;display: none;">
<button id={$name} type="button" class="btn btn-sm btn-info grid-save-order-btn" style="margin-left: 10px;display: none;">
<i class="fa fa-save"></i><span class="hidden-xs">&nbsp;&nbsp;{$text}</span>
</button>
HTML;
}
}

private function getButtonId()
{
return $this->getGrid()->getName() ?: 'grid-save-order-btn';
}
}