module ProtocolStatusHelper def protocol_status_href(protocol) parent = protocol.parent res = '' res << '' + protocol_name(parent) + '' res.html_safe end private def protocol_private_for_current_user?(protocol) protocol.in_repository_private? && protocol.added_by != current_user end def protocol_name(protocol) if protocol_private_for_current_user?(protocol) I18n.t('my_modules.protocols.protocol_status_bar.private_parent') else escape_input(protocol.name) end end def protocol_status_popover_title(protocol) res = "" if protocol.in_repository_public? res << "" elsif protocol.in_repository_private? res << "" end res << " " if can_view_protocol(protocol) res << "" + protocol_name(protocol) + "" else res << "" + protocol_name(protocol) + "" end res << " - " res << "" + I18n.t("my_modules.protocols.protocol_status_bar.added_by") + " " res << "" + escape_input(protocol.added_by.full_name) + '' res end def protocol_status_popover_content(protocol) if protocol_private_for_current_user?(protocol) res = "

" + I18n.t("my_modules.protocols.protocol_status_bar.private_protocol_desc") + "

" else res = "

" if protocol.description.present? res << protocol.description else res << "" + I18n.t("my_modules.protocols.protocol_status_bar.no_description") + "" end res << "

" res << "

" + I18n.t("my_modules.protocols.protocol_status_bar.keywords") + ": " if protocol.protocol_keywords.size > 0 protocol.protocol_keywords.each do |kw| res << kw.name + ", " end res = res[0..-3] else res << "" + I18n.t("my_modules.protocols.protocol_status_bar.no_keywords") + "" end res << "

" end sanitize_input(res) end end