Module: Card::Set::All::RichHtml::Error::HtmlFormat
- Extended by:
- Card::Set::AbstractFormat
- Defined in:
- tmpsets/set/mod021-standard/all/rich_html/error.rb
Instance Method Summary collapse
- #backtrace_link(cardname, exception) ⇒ Object
- #commentable?(view) ⇒ Boolean
- #createable ⇒ Object
- #error_cardname(exception) ⇒ Object
- #error_message(exception) ⇒ Object
- #error_messages ⇒ Object
- #error_modal_id ⇒ Object
- #loud_denial ⇒ Object
- #loud_denial_message ⇒ Object
- #missing_link(text) ⇒ Object
- #not_denied_task_read? ⇒ Boolean
- #not_found_errors ⇒ Object
- #quiet_denial ⇒ Object
- #rendering_error(exception, view) ⇒ Object
- #show_all_errors? ⇒ Boolean
- #sign_in_or_up_links(to_task) ⇒ Object
- #signin_link ⇒ Object
- #signup_link ⇒ Object
- #signup_ok? ⇒ Boolean
- #standard_error_message(attribute, message) ⇒ Object
- #standard_errors(heading = nil) ⇒ Object
- #to_do_unauthorized_task ⇒ Object
- #view_for_unknown(view) ⇒ Object
Instance Method Details
#backtrace_link(cardname, exception) ⇒ Object
118 119 120 121 |
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 118 def backtrace_link cardname, exception # TODO: make this a modal link after new modal handling is merged in wrap_with(:span, title: (exception)) { cardname } end |
#commentable?(view) ⇒ Boolean
85 86 87 88 89 90 |
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 85 def commentable? view return false unless view_setting(:commentable, view) && show_view?(:comment_box, :hide) ok? :comment end |
#createable ⇒ Object
27 28 29 |
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 27 def createable card.ok?(:create) ? yield : "" end |
#error_cardname(exception) ⇒ Object
97 98 99 100 |
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 97 def error_cardname exception cardname = super show_all_errors? ? backtrace_link(cardname, exception) : cardname end |
#error_message(exception) ⇒ Object
110 111 112 113 114 115 116 |
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 110 def exception %{ <h3>Error message (visible to admin only)</h3> <p><strong>#{CGI.escapeHTML exception.}</strong></p> <div>#{exception.backtrace * "<br>\n"}</div> } end |
#error_messages ⇒ Object
132 133 134 135 136 |
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 132 def card.errors.map do |attrib, msg| attrib == :abort ? h(msg) : (attrib, msg) end end |
#error_modal_id ⇒ Object
106 107 108 |
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 106 def error_modal_id @error_modal_id ||= unique_id end |
#loud_denial ⇒ Object
180 181 182 183 184 185 186 |
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 180 def loud_denial voo.hide :menu frame do [wrap_with(:h1, tr(:sorry)), wrap_with(:div, )] end end |
#loud_denial_message ⇒ Object
188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 188 def to_task = @denied_task ? tr(:denied_task, denied_task: @denied_task) : tr(:to_do_that) case when not_denied_task_read? tr(:read_only) when Auth.signed_in? tr(:need_permission_task, task: to_task) else Env.save_interrupted_action request.env["REQUEST_URI"] sign_in_or_up_links end end |
#missing_link(text) ⇒ Object
31 32 33 34 |
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 31 def missing_link text path_opts = voo.type ? { card: { type: voo.type } } : {} link_to_view :new, text, path: path_opts, class: "missing-link" end |
#not_denied_task_read? ⇒ Boolean
202 203 204 |
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 202 def not_denied_task_read? @denied_task != :read && Card.config.read_only end |
#not_found_errors ⇒ Object
142 143 144 145 146 147 148 |
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 142 def not_found_errors if card.errors.any? standard_errors else haml :not_found end end |
#quiet_denial ⇒ Object
174 175 176 177 178 |
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 174 def quiet_denial wrap_with :span, class: "denied" do "<!-- Sorry, you don't have permission (#{@denied_task}) -->" end end |
#rendering_error(exception, view) ⇒ Object
102 103 104 |
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 102 def rendering_error exception, view wrap_with(:span, class: "render-error alert alert-danger") { super } end |
#show_all_errors? ⇒ Boolean
92 93 94 95 |
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 92 def show_all_errors? # make configurable by env Auth.always_ok? || Rails.env.development? end |
#sign_in_or_up_links(to_task) ⇒ Object
150 151 152 153 154 155 156 157 |
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 150 def sign_in_or_up_links to_task return if Auth.signed_in? links = [signin_link, signup_link].compact.join " #{tr :or} " wrap_with(:div) do [tr(:please), links, to_task].join(" ") + "." end end |
#signin_link ⇒ Object
159 160 161 |
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 159 def signin_link link_to_card :signin, tr(:sign_in), remote: true, class: "slotter" end |
#signup_link ⇒ Object
163 164 165 166 167 168 |
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 163 def signup_link return unless signup_ok? link_to tr(:sign_up), path: { action: :new, mark: :signup }, remote: true, class: "slotter" end |
#signup_ok? ⇒ Boolean
170 171 172 |
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 170 def signup_ok? Card.new(type_id: Card::SignupID).ok? :create end |
#standard_error_message(attribute, message) ⇒ Object
138 139 140 |
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 138 def attribute, "<div><strong>#{h attribute.to_s.upcase}:</strong> #{h }</div>" end |
#standard_errors(heading = nil) ⇒ Object
123 124 125 126 127 128 129 130 |
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 123 def standard_errors heading=nil alert "warning", true do [ (wrap_with(:h4, heading, class: "alert-heading") if heading), .join("<hr>") ] end end |
#to_do_unauthorized_task ⇒ Object
206 207 208 |
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 206 def @denied_task ? tr(:denied_task, denied_task: @denied_task) : tr(:to_do_that) end |
#view_for_unknown(view) ⇒ Object
77 78 79 80 81 82 83 |
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 77 def view_for_unknown view case when main? && ok?(:create) then :new when commentable?(view) then view else super end end |