mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-14 13:16:28 +08:00
61 lines
1.8 KiB
Ruby
61 lines
1.8 KiB
Ruby
module ResultsHelper
|
|
def published_text_for_result(result)
|
|
if result.is_text
|
|
t("my_modules.results.published_text", timestamp: l(result.created_at, format: :full))
|
|
elsif result.is_table
|
|
t("my_modules.results.published_table", timestamp: l(result.created_at, format: :full))
|
|
elsif result.is_asset
|
|
t("my_modules.results.published_asset", timestamp: l(result.created_at, format: :full))
|
|
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 can_edit_result(result)
|
|
if result.is_text
|
|
can_edit_result_text_in_module(result.my_module)
|
|
elsif result.is_table
|
|
can_edit_result_table_in_module(result.my_module)
|
|
elsif result.is_asset
|
|
can_edit_result_asset_in_module(result.my_module)
|
|
end
|
|
end
|
|
|
|
def can_archive_result(result)
|
|
if result.is_text
|
|
can_archive_result_text_in_module(result.my_module)
|
|
elsif result.is_table
|
|
can_archive_result_table_in_module(result.my_module)
|
|
elsif result.is_asset
|
|
can_archive_result_asset_in_module(result.my_module)
|
|
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
|
|
"edit-result-asset"
|
|
elsif result.is_text
|
|
"edit-result-text"
|
|
elsif result.is_table
|
|
"edit-result-table"
|
|
end
|
|
end
|
|
end
|