-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
85c5179
commit ef59cf2
Showing
21 changed files
with
93 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
Object.assign(Turbo.StreamActions, { | ||
dialog() { | ||
this.removeDuplicateTargetChildren(); | ||
this.targetElements.forEach(e => e.remove()) | ||
function last(arr) { | ||
return arr[arr.length - 1]; | ||
} | ||
|
||
let content = this.templateContent | ||
let dialog = content.querySelector('dialog') | ||
dialog.onclose = dialog.oncancel = () => dialog.remove() | ||
this.ownerDocument.body.append(dialog) | ||
dialog.showModal() | ||
document.addEventListener("click", event => { | ||
if (event.target.matches(".Modal_Close")) { | ||
event.preventDefault() | ||
event.target.closest(".Modal").remove() | ||
} else if (event.target.matches(".Modal")) { | ||
event.preventDefault() | ||
event.target.remove() | ||
} | ||
}) | ||
|
||
document.addEventListener("click", event => { | ||
if (!event.target.matches(".Modal_Close")) return | ||
event.preventDefault() | ||
event.target.closest(".Modal").remove() | ||
document.addEventListener("keydown", event => { | ||
switch (event.key) { | ||
case "Escape": | ||
let modal = event.target.closest(".Modal") || | ||
last(document.querySelectorAll(".Modal-fixed")) | ||
modal?.remove() | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function last(arr) { | ||
return arr[arr.length - 1]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
= ui.card do | ||
%pre= parsed_params.to_unsafe_h.pretty_inspect | ||
= ui.card title: "Debug" do |card| | ||
= card.section do | ||
%pre= request.params.pretty_inspect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,10 @@ | ||
- title ||= nil | ||
- actions ||= nil | ||
|
||
= form_for object do |f| | ||
= ui.card title:, actions: do |card| | ||
= card.section do | ||
= render "fields", f: | ||
= card.section do | ||
= render "fields", f: | ||
|
||
= card.section class: "row" do | ||
= render("extra_fields", f:) | ||
= card.section class: "row" do | ||
= render("extra_fields", f:) | ||
|
||
= card.foot do | ||
= render "submit", f: | ||
= render("errors", f:) | ||
= card.foot do | ||
= render "submit", f: | ||
= render("errors", f:) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
= turbo_stream.dialog_for object, :edit do | ||
= render "form", title: "Edit #{model_name.human}", actions: dialog_close | ||
- if action.edit? | ||
= turbo_stream.append_all("body") do | ||
= ui.modal :fixed do |m| | ||
= ui.card title: "Edit #{model_name.human}", actions: m.close("✕") do |card| | ||
= render "form", card: | ||
- else | ||
= turbo_stream.replace(dom_id(object, :edit)) do | ||
= render "form", card: ui.card.context |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
- title = title model_name.human(count: :all) | ||
- actions = render "index_actions" | ||
|
||
= ui.page title:, actions: do |page| | ||
= ui.page :wide, title:, actions: do |page| | ||
= page.left do | ||
= render "debug" if params.key?(:debug) | ||
= render "filters" | ||
|
||
= page.body do | ||
= render "index" | ||
= yield :debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
|
||
= ui.page title:, actions: do |page| | ||
= page.body do | ||
= render "form" | ||
= ui.card do |card| | ||
= render "form", card: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
= turbo_stream.dialog_for object, :new do | ||
= render "form", title: "New #{model_name.human}", actions: dialog_close | ||
- if action.new? | ||
= turbo_stream.append_all("body") do | ||
= ui.modal :fixed do |m| | ||
= ui.card title: "New #{model_name.human}", actions: m.close("✕") do |card| | ||
= render "form", card: | ||
- else | ||
= turbo_stream.replace(dom_id(object, :new)) do | ||
= render "form", card: ui.card.context |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
= turbo_stream.refresh(request_id: nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,4 @@ | ||
module CafeCar | ||
module TurboTagBuilder | ||
def dialog_for(record, prefix = :dialog, **, &) | ||
id = @view_context.dom_id(record, prefix) | ||
action(:dialog, id, **) do | ||
@view_context.tag.dialog(id:, class: @view_context.ui_class(:dialog), &) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters