2011-03-09 19:27:51 +00:00
|
|
|
module PlatformsHelper
|
2011-03-31 13:13:04 +01:00
|
|
|
def repository_name_postfix(platform)
|
|
|
|
return "" unless platform
|
|
|
|
return platform.released ? '/update' : '/release'
|
|
|
|
end
|
2012-05-10 16:30:41 +01:00
|
|
|
|
|
|
|
def platform_printed_name(platform)
|
2012-04-01 16:19:54 +01:00
|
|
|
return "" unless platform
|
|
|
|
platform.released? ? "#{platform.name} #{I18n.t("layout.platforms.released_suffix")}" : platform.name
|
|
|
|
end
|
2012-05-10 16:30:41 +01:00
|
|
|
|
2013-07-24 15:43:41 +01:00
|
|
|
def platform_arch_settings(platform)
|
2013-08-30 08:57:27 +01:00
|
|
|
settings = platform.platform_arch_settings
|
2013-09-09 11:33:34 +01:00
|
|
|
arches = if (arch_ids = settings.map(&:arch_id)) && arch_ids.present?
|
2013-08-30 08:57:27 +01:00
|
|
|
Arch.where('id not in (?)', arch_ids)
|
|
|
|
else
|
|
|
|
Arch.all
|
|
|
|
end
|
|
|
|
settings |= arches.map do |arch|
|
2013-07-24 15:43:41 +01:00
|
|
|
platform.platform_arch_settings.build(
|
|
|
|
:arch_id => arch.id,
|
|
|
|
:time_living => PlatformArchSetting::DEFAULT_TIME_LIVING
|
|
|
|
)
|
|
|
|
end
|
|
|
|
settings.sort_by{ |s| s.arch.name }
|
|
|
|
end
|
|
|
|
|
2014-06-26 13:29:07 +01:00
|
|
|
def fa_platform_visibility_icon(platform)
|
|
|
|
return nil unless platform
|
|
|
|
image, color = platform.hidden? ? ['lock', 'text-danger fa-fw']: ['unlock-alt', 'text-success fa-fw']
|
|
|
|
fa_icon(image, class: color)
|
|
|
|
end
|
2011-03-09 19:27:51 +00:00
|
|
|
end
|