2019-04-01 15:58:13 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-02-12 23:52:43 +08:00
|
|
|
module ResultsHelper
|
|
|
|
def published_text_for_result(result)
|
|
|
|
if result.is_text
|
2019-04-01 15:58:13 +08:00
|
|
|
t('my_modules.results.published_text', timestamp: l(result.created_at, format: :full))
|
2016-02-12 23:52:43 +08:00
|
|
|
elsif result.is_table
|
2019-04-01 15:58:13 +08:00
|
|
|
t('my_modules.results.published_table', timestamp: l(result.created_at, format: :full))
|
2016-02-12 23:52:43 +08:00
|
|
|
elsif result.is_asset
|
2019-04-01 15:58:13 +08:00
|
|
|
t('my_modules.results.published_asset', timestamp: l(result.created_at, format: :full))
|
2016-02-12 23:52:43 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit_result_link(result)
|
|
|
|
if result.is_text
|
|
|
|
edit_result_text_path(result.result_text, format: :json)
|
|
|
|
elsif result.is_table
|
|
|
|
edit_result_table_path(result.result_table, format: :json)
|
|
|
|
elsif result.is_asset
|
|
|
|
edit_result_asset_path(result.result_asset, format: :json)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def result_path_of_type(result)
|
|
|
|
if result.is_asset
|
|
|
|
result_asset_path(result.result_asset)
|
|
|
|
elsif result.is_text
|
|
|
|
result_text_path(result.result_text)
|
|
|
|
elsif result.is_table
|
|
|
|
result_table_path(result.result_table)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit_result_button_class(result)
|
|
|
|
if result.is_asset
|
2019-04-01 15:58:13 +08:00
|
|
|
'edit-result-asset'
|
2016-02-12 23:52:43 +08:00
|
|
|
elsif result.is_text
|
2019-04-01 15:58:13 +08:00
|
|
|
'edit-result-text'
|
2016-02-12 23:52:43 +08:00
|
|
|
elsif result.is_table
|
2019-04-01 15:58:13 +08:00
|
|
|
'edit-result-table'
|
2016-02-12 23:52:43 +08:00
|
|
|
end
|
|
|
|
end
|
2019-04-01 15:58:13 +08:00
|
|
|
|
2019-03-27 00:03:56 +08:00
|
|
|
def result_icon_class(result)
|
2019-04-01 15:58:13 +08:00
|
|
|
return 'fas fa-table' unless result
|
|
|
|
|
2019-03-27 00:03:56 +08:00
|
|
|
if result.is_asset
|
2019-04-01 15:58:13 +08:00
|
|
|
'fas fa-paperclip'
|
2019-03-27 00:03:56 +08:00
|
|
|
elsif result.is_text
|
2019-04-01 15:58:13 +08:00
|
|
|
'fas fa-font'
|
2019-03-27 00:03:56 +08:00
|
|
|
elsif result.is_table
|
2019-04-01 15:58:13 +08:00
|
|
|
'fas fa-table'
|
2019-03-27 00:03:56 +08:00
|
|
|
else
|
|
|
|
# just return table for any other result
|
2019-04-01 15:58:13 +08:00
|
|
|
'fas fa-table'
|
2019-03-27 00:03:56 +08:00
|
|
|
end
|
|
|
|
end
|
2016-02-12 23:52:43 +08:00
|
|
|
end
|