From 3d4ab7016bcaf8699e427f0650cda12db74a6efb Mon Sep 17 00:00:00 2001 From: gregapompe Date: Wed, 18 Feb 2015 13:10:55 +0100 Subject: [PATCH] Sorting bugfix --- lib/TableEdit/Routes/API.pm | 18 +++++++++++------- public/app.js | 3 +-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/TableEdit/Routes/API.pm b/lib/TableEdit/Routes/API.pm index 64e8e25..41a110e 100644 --- a/lib/TableEdit/Routes/API.pm +++ b/lib/TableEdit/Routes/API.pm @@ -253,10 +253,12 @@ get '/menu' => require_login sub { }; -get '/:class/:column/image/:file' => require_login sub { - my $class_info = schema_info->class(param('class')); - my $column_info = $class_info->column(param('column')); - my $file = param('file'); +get '/:class/:column/image/**' => require_login sub { + my ($splat) = splat; + my (undef, $class,$column, undef, @file) = @$splat; + my $class_info = schema_info->class($class); + my $column_info = $class_info->column($column); + my $file = join '/', @file; my $path = $column_info->upload_dir; return send_file($path.$file); }; @@ -490,10 +492,12 @@ Returns sql order by parameter. sub grid_sort { my ($class_info, $get_params) = @_; # Direction - ($get_params->{descending} ? $class_info->sort_direction('DESC') : $class_info->sort_direction('')) if $get_params->{sort}; + ($get_params->{descending} ? $class_info->sort_direction('-desc') : $class_info->sort_direction('-asc')) if $get_params->{sort}; # Selected or Predefined sort - $class_info->sort_column($get_params->{sort}) if $get_params->{sort}; - return $class_info->sort_column . " " . $class_info->sort_direction if $class_info->sort_column; + if( $get_params->{sort} and $class_info->column($get_params->{sort})){ + $class_info->sort_column($get_params->{sort}) ; + } + return {$class_info->sort_direction => $class_info->sort_column} if $class_info->sort_column; } diff --git a/public/app.js b/public/app.js index ce72aea..e318d83 100644 --- a/public/app.js +++ b/public/app.js @@ -183,7 +183,6 @@ CrudApp.factory('AuthInterceptor',['$q','$location','$rootScope', function($q,$l $rootScope.user = null; console.log("Response Error 403",rejection); } - $location.path('/login'); return $q.reject(rejection); } } @@ -901,7 +900,7 @@ var ListCtrl = function ($scope, $rootScope, $routeParams, $location, Class, Cla var from_page = (current_page - page_scope > 0) ? (current_page - page_scope) : 1; var to_page = (current_page + page_scope < pages) ? (current_page + page_scope) : pages; $scope.data.sort_column = data.sort_column; - $scope.sort_desc = data.sort_direction == 'DESC' ? true : false; + $scope.sort_desc = data.sort_direction == '-desc' ? true : false; $scope.page_list = []; for (var i = from_page; i <= to_page; i++) {