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

Instance Method Details



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: error_message(exception)) { cardname }
end

#commentable?(view) ⇒ Boolean

Returns:

  • (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

#createableObject



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 error_message exception
  %{
    <h3>Error message (visible to admin only)</h3>
    <p><strong>#{CGI.escapeHTML exception.message}</strong></p>
    <div>#{exception.backtrace * "<br>\n"}</div>
  }
end

#error_messagesObject



132
133
134
135
136
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 132

def error_messages
  card.errors.map do |attrib, msg|
    attrib == :abort ? h(msg) : standard_error_message(attrib, msg)
  end
end

#error_modal_idObject



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_denialObject



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, loud_denial_message)]
  end
end

#loud_denial_messageObject



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 loud_denial_message
  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"]
     to_do_unauthorized_task
  end
end


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

Returns:

  • (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_errorsObject



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_denialObject



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

Returns:

  • (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


150
151
152
153
154
155
156
157
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 150

def  to_task
  return if Auth.signed_in?

  links = [, ].compact.join " #{tr :or} "
  wrap_with(:div) do
    [tr(:please), links, to_task].join(" ") + "."
  end
end


159
160
161
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 159

def 
  link_to_card :signin, tr(:sign_in), remote: true, class: "slotter"
end


163
164
165
166
167
168
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 163

def 
  return unless 

  link_to tr(:sign_up), path: { action: :new, mark: :signup },
                            remote: true, class: "slotter"
end

#signup_ok?Boolean

Returns:

  • (Boolean)


170
171
172
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 170

def 
  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 standard_error_message attribute, message
  "<div><strong>#{h attribute.to_s.upcase}:</strong> #{h message}</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),
      error_messages.join("<hr>")
    ]
  end
end

#to_do_unauthorized_taskObject



206
207
208
# File 'tmpsets/set/mod021-standard/all/rich_html/error.rb', line 206

def to_do_unauthorized_task
  @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