From 16955dcee6c9a17f71d794bf45acb413ff127230 Mon Sep 17 00:00:00 2001 From: Luka Murn Date: Mon, 16 Jan 2017 15:58:37 +0100 Subject: [PATCH] Fix Hound errors. --- app/datatables/sample_datatable.rb | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/app/datatables/sample_datatable.rb b/app/datatables/sample_datatable.rb index be61cb1e6..a022ef4eb 100644 --- a/app/datatables/sample_datatable.rb +++ b/app/datatables/sample_datatable.rb @@ -110,13 +110,13 @@ class SampleDatatable < AjaxDatatablesRails::Base '1': assigned_cell(record), '2': record.name, '3': record.sample_type.nil? ? I18n.t('samples.table.no_type') : record.sample_type.name, - '4': record.sample_group.nil? ? - " " + I18n.t("samples.table.no_group") : - " " + record.sample_group.name, + '4': sample_group_cell(record), "5": I18n.l(record.created_at, format: :full), "6": record.user.full_name, - "sampleInfoUrl": Rails.application.routes.url_helpers.sample_path(record.id), - "sampleUpdateUrl": Rails.application.routes.url_helpers.sample_path(record.id) + "sampleInfoUrl": + Rails.application.routes.url_helpers.sample_path(record.id), + "sampleUpdateUrl": + Rails.application.routes.url_helpers.sample_path(record.id) } # Add custom attributes @@ -137,6 +137,17 @@ class SampleDatatable < AjaxDatatablesRails::Base " " end + def sample_group_cell(record) + if record.sample_group.nil? + " " \ + "#{I18n.t('samples.table.no_group')}" + else + " " \ + "#{record.sample_group.name}" + end + end + # Query database for records (this will be later paginated and filtered) # after that "data" function will return json def get_raw_records