Skip to content

Commit 38ec5c8

Browse files
committed
fixes for new baseline
1 parent c64a9b0 commit 38ec5c8

File tree

2 files changed

+1
-49
lines changed

2 files changed

+1
-49
lines changed

app/helpers/application_helper.rb

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,4 @@
22

33
module ApplicationHelper
44
include Baseline::Helper
5-
6-
def page_classes
7-
[
8-
controller.controller_name,
9-
{ "create" => "new", "update" => "edit" }.fetch(controller.action_name, controller.action_name)
10-
].join(" ")
11-
end
12-
13-
def alert(level, text = nil, &block)
14-
tag.div class: "alert alert-#{level} alert-dismissible fade show" do
15-
concat tag.button(type: "button", class: "btn-close", data: { bs_dismiss: "alert" })
16-
concat text&.html_safe || capture_haml(&block)
17-
end
18-
end
19-
20-
def flash_messages
21-
flash.map do |level, message|
22-
level = { notice: "success", alert: "danger" }[level.to_sym] || level
23-
alert level, message
24-
end.compact.join("\n").html_safe
25-
end
26-
27-
def async_turbo_frame(name, **attributes, &block)
28-
# If a ActiveRecord record is passed to `turbo_frame_tag`,
29-
# `dom_id` is called to determine its DOM ID.
30-
# This exposes the record ID, which is not desirable if the record has a slug.
31-
if name.is_a?(ActiveRecord::Base) && name.respond_to?(:slug)
32-
name = [name.class.to_s.underscore, name.slug].join("_")
33-
end
34-
35-
unless url = attributes[:src]
36-
raise "async_turbo_frame needs a `src` attribute."
37-
end
38-
39-
uris = [
40-
url_for(url),
41-
request.fullpath
42-
].map { Addressable::URI.parse _1 }
43-
uris_match = %i(path query_values).all? { uris.map(&_1).uniq.size == 1 }
44-
45-
if uris_match
46-
turbo_frame_tag name, &block
47-
else
48-
turbo_frame_tag name, **attributes do
49-
render "shared/loading"
50-
end
51-
end
52-
end
535
end

app/views/layouts/application.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@
2626
%body{ class: page_classes }
2727
= render "shared/header"
2828
%main.container-lg
29-
= flash_messages
29+
= flashes
3030
= yield

0 commit comments

Comments
 (0)