Skip to content

Commit

Permalink
fixed drag and drop ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
Trexology committed Jul 24, 2016
1 parent dfd6c6c commit 4dd2971
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/Controllers/TaxonomyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function postOrderTerms($id) {
$this->vocabulary->find($id);

$request = \Request::instance();
$content = json_decode(Request::get('json'));
$content = json_decode($request->json);

foreach ($content as $parent_key => $parent){
$parent_term = Term::find($parent->id);
Expand Down
4 changes: 2 additions & 2 deletions src/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

Route::resource('taxonomy', 'Trexology\Taxonomy\Controllers\TaxonomyController');

Route::post('taxonomy/{id}/order', array(
Route::post('taxonomy/order-terms/{id}', array(
'as' => $prefix .'.taxonomy.order.terms',
'uses' => 'Trexology\Taxonomy\Controllers\TaxonomyController@orderTerms',
'uses' => 'Trexology\Taxonomy\Controllers\TaxonomyController@postOrderTerms',
));

Route::resource('terms', 'Trexology\Taxonomy\Controllers\TermsController');
Expand Down
33 changes: 2 additions & 31 deletions src/views/terms/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Nestable
*/
.dd { position: relative; display: block; margin: 0; padding: 0; max-width: 600px; list-style: none; font-size: 13px; line-height: 20px; }
.dd { position: relative; display: block; margin: 0; padding: 0; list-style: none; font-size: 13px; line-height: 20px; }
.dd-list { display: block; position: relative; margin: 0; padding: 0; list-style: none; }
.dd-list .dd-list { padding-left: 30px; }
Expand Down Expand Up @@ -104,36 +104,8 @@
</div>
</div>
</div>

<ul class="dd-list">
@foreach ($parent['children'] as $term_weight => $child)
<li class="dd-item" data-id="{!! $child->id !!}">
<!-- drag handle -->
<div class="handle dd-handle">
<i class="fa fa-ellipsis-v"></i>
<i class="fa fa-ellipsis-v"></i>
&nbsp;
<!-- checkbox -->
<!-- todo text -->
<span class="text">{!! $child->name !!}</span>
<!-- Emphasis label -->
<!-- General tools such as edit or delete-->
<div class="pull-right">
<div class="btn-group">
{!! Form::open(array('method' => 'GET', 'url' => action('\Trexology\Taxonomy\Controllers\TermsController@getEdit', $child->id))) !!}
{!! Form::button(Lang::get('taxonomy::general.button.edit'), array('class'=>'btn btn-xs btn-primary btn-flat', 'type' => 'submit')) !!}
{!! Form::close() !!}
</div>

<div class="btn-group">
{!! Form::open(array('method' => 'DELETE', 'url' => action('\Trexology\Taxonomy\Controllers\TermsController@deleteDestroy', $child->id))) !!}
{!! Form::button(Lang::get('taxonomy::general.button.delete'), array('class'=>'delete-confirm-dialog btn btn-xs btn-danger btn-flat', 'type' => 'submit')) !!}
{!! Form::close() !!}
</div>
</div>
</div>
</li>
@endforeach
@each('taxonomy::terms.term', $parent['children'], 'child')
</ul>
</li>
@endforeach
Expand All @@ -157,7 +129,6 @@
listNodeName: 'ul',
expandBtnHTML: '',
collapseBtnHTML: '',
maxDepth:2,
});
$('.dd').on('change', function() {
Expand Down
34 changes: 34 additions & 0 deletions src/views/terms/term.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<li class="dd-item" data-id="{!! $child->id !!}">
<!-- drag handle -->
<div class="handle dd-handle">
<i class="fa fa-ellipsis-v"></i>
<i class="fa fa-ellipsis-v"></i>
&nbsp;
<!-- checkbox -->
<!-- todo text -->
<span class="text">{!! $child->name !!}</span>
<!-- Emphasis label -->
<!-- General tools such as edit or delete-->
<div class="pull-right">
<div class="btn-group">
{!! Form::open(array('method' => 'GET', 'url' => action('\Trexology\Taxonomy\Controllers\TermsController@getEdit', $child->id))) !!}
{!! Form::button(Lang::get('taxonomy::general.button.edit'), array('class'=>'btn btn-xs btn-primary btn-flat', 'type' => 'submit')) !!}
{!! Form::close() !!}
</div>

<div class="btn-group">
{!! Form::open(array('method' => 'DELETE', 'url' => action('\Trexology\Taxonomy\Controllers\TermsController@deleteDestroy', $child->id))) !!}
{!! Form::button(Lang::get('taxonomy::general.button.delete'), array('class'=>'delete-confirm-dialog btn btn-xs btn-danger btn-flat', 'type' => 'submit')) !!}
{!! Form::close() !!}
</div>
</div>
</div>
</li>

{{--
@foreach ($child['children'] as $term_weight => $child)
@include('taxonomy::terms.term', $child)
@endforeach
--}}

0 comments on commit 4dd2971

Please sign in to comment.