Allows ordering of component groups. Closes #573.

This commit is contained in:
James Brooks
2015-05-19 22:52:16 +01:00
parent 879a8a5c69
commit 9337c1a75b
12 changed files with 119 additions and 30 deletions
+26
View File
@@ -167,6 +167,32 @@ $(function() {
});
}
// Sortable Component Groups
var componentGroupList = document.getElementById("component-group-list");
if (componentGroupList) {
new Sortable(componentGroupList, {
group: "omega",
handle: ".drag-handle",
onUpdate: function() {
var orderedComponentGroupsIds = $.map(
$('#component-group-list .striped-list-item'),
function(elem) {
return $(elem).data('group-id');
}
);
$.ajax({
async: true,
url: '/dashboard/api/components/groups/order',
type: 'POST',
data: {ids: orderedComponentGroupsIds},
success: function() {
(new CachetHQ.Notifier()).notify('Component groups order has been updated.', 'success');
}
});
}
});
}
// Toggle inline component statuses.
$('form.component-inline').on('click', 'input[type=radio]', function() {
var $form = $(this).parents('form');
@@ -16,11 +16,17 @@
<div class="clearfix"></div>
</div>
<div class="row">
<div class="col-sm-12 striped-list">
<div class="col-sm-12 striped-list" id="component-group-list">
@forelse($groups as $group)
<div class="row striped-list-item">
<div class="row striped-list-item" data-group-id="{{ $group->id }}">
<div class="col-xs-6">
<strong>{{ $group->name }}</strong> <span class="label label-info">{{ $group->components->count() }}</span>
<h4>
@if($groups->count() > 1)
<span class="drag-handle"><i class="ion-drag"></i></span>
@endif
{{ $group->name }}
<span class="label label-info">{{ $group->components->count() }}</span>
</h4>
</div>
<div class="col-xs-6 text-right">
<a href="{{ route('dashboard.components.groups.edit', [$group->id]) }}" class="btn btn-default">{{ trans('forms.edit') }}</a>