-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds server-side sorting for the columns on the `zizia_csv_import_details` table. Sorting the additional headers will require more complex queries or a different solution. Connected to curationexperts/in-house#420
- Loading branch information
Showing
7 changed files
with
61 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.desc::after { | ||
content: ' ▾' | ||
} | ||
.asc::after { | ||
content: ' ▴' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,30 @@ | ||
# frozen_string_literal: true | ||
module Zizia | ||
class CsvImportDetailsController < ApplicationController | ||
helper_method :sort_column, :sort_direction | ||
load_and_authorize_resource | ||
with_themed_layout 'dashboard' | ||
|
||
def index | ||
@csv_import_details = Zizia::CsvImportDetail.order(:id).page csv_import_detail_params[:page] | ||
@csv_import_details = Zizia::CsvImportDetail.order(sort_column + ' ' + sort_direction).page csv_import_detail_params[:page] | ||
end | ||
|
||
def show | ||
@csv_import_detail = Zizia::CsvImportDetail.find(csv_import_detail_params["id"]) | ||
@csv_import_detail = Zizia::CsvImportDetail.find(csv_import_detail_params['id']) | ||
end | ||
|
||
private | ||
|
||
def sort_column | ||
Zizia::CsvImportDetail.column_names.include?(params[:sort]) ? params[:sort] : 'created_at' | ||
end | ||
|
||
def sort_direction | ||
%w[asc desc].include?(params[:direction]) ? params[:direction] : 'desc' | ||
end | ||
|
||
def csv_import_detail_params | ||
params.permit(:id, :page) | ||
params.permit(:id, :page, :sort, :direction) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters