maquina 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 253e32217b0c2f5e0a8a352ff4ac26a1e0d904184293205135f1d60fd43392d2
4
- data.tar.gz: a347016c5e76c08fc3165662b47684ff181667a4bea70c25e340bc71e760b1cc
3
+ metadata.gz: 040c1d643734bb33ae456b0bd092b87b250d0b4d56f03548d569594f3d6892f3
4
+ data.tar.gz: a17889606d8033a9e068cd212d5557f7cc77b60fd8f82d7f6f951974a526866f
5
5
  SHA512:
6
- metadata.gz: 77c5d7eb9e6927194b0ea5635f8a535b898010b755e42e254258e2af675c6c4ba08c70372141056e2fd296008d7a120d938019f5fa55966d3d3314cc61744621
7
- data.tar.gz: 1013008ff3b86923b4d055c894d62e01ba23e84c4cad7d029454d1d8f9e80865ac038be1f5693c39a9828cebec1fc57c0a6591d6b16c4c7d134a83d321ef4acd
6
+ metadata.gz: 4654d0514915f2fe7d7577ad73487a78d5b0036df114c82950a80e8f737a5b9d92bf7b163eeb316c2758428c80e0fe5dc52b13563cfeb9a2666323b62a4c773f
7
+ data.tar.gz: fe807c89c747bcf9b7fc95b7590edcd331b0ee6eab5e966ebe5576fb48e580bc445552d3e5d0fd4d773cf8b36054e8b2e9c90c0d9a1c29631c96312d0b0a670e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- maquina (0.2.1)
4
+ maquina (0.2.2)
5
5
  action_policy (~> 0.6.3)
6
6
  bcrypt (~> 3.1.7)
7
7
  importmap-rails (~> 1.2.0)
@@ -0,0 +1,10 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+ import { useTransition } from "stimulus-use";
3
+
4
+ export default class extends Controller {
5
+ static targets = ["backdrop"]
6
+
7
+ connect() {
8
+ useTransition(this, { element: this.backdropTarget })
9
+ }
10
+ }
@@ -2,38 +2,92 @@ import { Controller } from "@hotwired/stimulus"
2
2
  import { useTransition } from "stimulus-use"
3
3
 
4
4
  export default class extends Controller {
5
- static targets = ["content", "container", "frame"]
5
+ static targets = ["modal", "container", "frame", "form", "submit"]
6
+ static outlets = ["backdrop"]
6
7
 
7
8
  connect() {
8
- useTransition(this, { element: this.contentTarget })
9
+ this.timeouts = []
10
+ this.root = document.querySelector("html")
9
11
 
10
- this.resultCallback = this.modalResult.bind(this)
11
- addEventListener("turbo:submit-end", this.resultCallback)
12
+ useTransition(this, { element: this.modalTarget })
13
+
14
+ if (this.hasFormTarget) addEventListener("turbo:submit-end", this.submitResult.bind(this))
12
15
  }
13
16
 
14
17
  disconnect() {
15
- removeEventListener("turbo:submit-end", this.resultCallback)
18
+ this.timeouts.forEach(t => clearTimeout(t))
19
+
20
+ if (this.hasFormTarget) removeEventListener("turbo:submit-end", this.submitResult.bind(this))
16
21
  }
17
22
 
18
- modalResult(event) {
19
- if (event.detail.fetchResponse.response.status == 202) {
20
- this.toggleModal(event)
23
+ submitResult(event) {
24
+ if (this.hasFormTarget) this.submitTarget.removeAttribute("disabled")
25
+
26
+ const status = event.detail.fetchResponse.response.status
27
+ if (status == 201 || status == 202) {
28
+ this.close(event)
21
29
  }
22
30
  }
23
31
 
24
- toggleModal(event) {
32
+ submit(event) {
25
33
  event.preventDefault()
26
34
 
27
- if (this.hasFrameTarget && this.contentTarget.classList.contains("hidden")) {
28
- let url = event.target.getAttribute("href") || this.element.dataset["frameSrc"]
29
- this.frameTarget.setAttribute("src", url)
30
- } else if (!this.contentTarget.classList.contains("hidden")) {
31
- this.frameTarget.setAttribute("src", "")
32
- this.frameTarget.innerText = ""
35
+ if (!this.hasFormTarget) {
36
+ return
33
37
  }
34
38
 
35
- document.documentElement.classList.toggle("overflow-hidden")
36
- this.containerTarget.classList.toggle("hidden")
39
+ this.submitTarget.setAttribute("disabled", "true")
40
+ this.formTarget.requestSubmit()
41
+ }
42
+
43
+ open(event) {
44
+ event.preventDefault()
45
+
46
+ this.configureModal(event.target)
47
+ this.root.classList.toggle("overflow-hidden")
48
+
49
+ this.toggleBackdrop()
50
+ this.toggleTransition()
51
+ }
52
+
53
+ close(event) {
54
+ event.preventDefault()
55
+
56
+ this.timeouts.forEach(t => clearTimeout(t))
57
+
58
+ this.root.classList.toggle("overflow-hidden")
37
59
  this.toggleTransition()
60
+ this.toggleBackdrop()
61
+
62
+
63
+ this.timeouts.push(
64
+ setTimeout(() => this.restoreModal(), 500)
65
+ )
66
+ }
67
+
68
+ configureModal(target) {
69
+ if (this.hasSubmitTarget) {
70
+ const label = target.dataset["submit-label"]
71
+ this.submitTarget.innerText = label
72
+ }
73
+
74
+ const url = target.getAttribute("href")
75
+ this.frameTarget.setAttribute("src", url)
76
+
77
+ this.containerTarget.classList.toggle("hidden")
78
+ }
79
+
80
+ restoreModal() {
81
+ this.containerTarget.classList.toggle("hidden")
82
+
83
+ if (this.hasSubmitTarget) {
84
+ this.submitTarget.innerText = ""
85
+ this.submitTarget.removeAttribute("disabled")
86
+ }
87
+ this.frameTarget.setAttribute("src", "")
88
+ }
89
+
90
+ toggleBackdrop() {
91
+ this.backdropOutlets.forEach(backdrop => backdrop.toggleTransition())
38
92
  }
39
93
  }
@@ -5,6 +5,6 @@ export default class extends Controller {
5
5
 
6
6
  open(event) {
7
7
  event.preventDefault()
8
- this.modalOutlets.forEach(modal => modal.toggleModal(event))
8
+ this.modalOutlets.forEach(modal => modal.open(event))
9
9
  }
10
10
  }
@@ -30,7 +30,7 @@ module Maquina
30
30
 
31
31
  div(class: "pt-5") do
32
32
  div(class: "flex justify-end") do
33
- link_to t("helpers.cancel"), collection_path, class: "button", data: @modal ? {action: "modal#toggleModal"} : {turbo_frame: :_top}
33
+ link_to t("helpers.cancel"), collection_path, class: "button", data: @modal ? {action: "modal#close"} : {turbo_frame: :_top}
34
34
  form.submit class: "ml-3 button button-accented"
35
35
  end
36
36
  end
@@ -7,11 +7,13 @@ module Maquina
7
7
  register_element :turbo_frame
8
8
 
9
9
  def template
10
- div(data_controller: "modal", class: "modal", data_frame_src: "") do
11
- div(class: "fixed inset-0 z-30 hidden overflow-y-auto", aria_labelledby: "modal-title", role: "dialog",
10
+ div(data_controller: "modal", class: "modal", data_modal_backdrop_outlet: ".modal-backdrop") do
11
+ div(class: "hidden fixed inset-0 z-30 overflow-y-auto", aria_labelledby: "modal-title", role: "dialog",
12
12
  aria_modal: "true", data_modal_target: "container") do
13
13
  div(class: "flex items-end justify-center min-h-screen px-4 pt-4 pb-20 text-center sm:block sm:p-0") do
14
- div(class: "fixed inset-0 transition-opacity",
14
+ div(class: "hidden fixed inset-0 transition-opacity modal-backdrop",
15
+ data_controller: "backdrop",
16
+ data_backdrop_target: "backdrop",
15
17
  data_transition_enter: "ease-out duration-300",
16
18
  data_transition_enter_active: "opacity-0",
17
19
  data_transition_enter_to: "opacity-100",
@@ -22,8 +24,8 @@ module Maquina
22
24
  div(class: "fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity", aria_hidden: "true")
23
25
  end
24
26
  span(class: "hidden sm:inline-block sm:align-middle sm:h-screen", aria_hidden: "true") { "​" }
25
- div(class: "inline-block align-bottom bg-white rounded-lg px-4 pt-5 pb-4 text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full sm:p-6",
26
- data_modal_target: "content",
27
+ div(class: "hidden inline-block align-bottom bg-white rounded-lg px-4 pt-5 pb-4 text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full sm:p-6",
28
+ data_modal_target: "modal",
27
29
  data_transition_enter: "ease-out duration-300",
28
30
  data_transition_enter_active: "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
29
31
  data_transition_enter_to: "opacity-100 translate-y-0 sm:scale-100",
@@ -47,8 +47,8 @@ module Maquina
47
47
  def field_attributes(field_name, scope = nil)
48
48
  scope ||= "sessions"
49
49
  {
50
- maxlength: t("maxlength.#{scope}.#{field_name}", default: t("maxlength.default")),
51
- placeholder: t("placeholder.#{scope}.#{field_name}", default: "")
50
+ maxlength: t("helpers.maxlength.#{scope}.#{field_name}", default: t("helpers.maxlength.default")),
51
+ placeholder: t("helpers.placeholder.#{scope}.#{field_name}", default: "")
52
52
  }
53
53
  end
54
54
  end
@@ -3,7 +3,8 @@ en:
3
3
  maquina/plan:
4
4
  title: Configure a plan for your customers
5
5
  maquina/invitation:
6
- title: User will receive an invitation to join this application in the provided email.
6
+ title: Invite user to collaborate
7
+ description: User will receive an invitation to join this application in the provided email.
7
8
 
8
9
  form:
9
10
  sessions:
@@ -26,18 +27,6 @@ en:
26
27
  maquina/invitation:
27
28
  email: Enter user's email
28
29
 
29
- maxlength:
30
- default: 30
31
-
32
- maquina/plan:
33
- name: 60
34
- trial: 3
35
- price: 9
36
-
37
- sessions:
38
- email: 60
39
- password: 60
40
-
41
30
  help:
42
31
  maquina/plan:
43
32
  name: Descriptive plan name
@@ -56,3 +45,14 @@ en:
56
45
  maquina/invitation:
57
46
  create: Send invitation
58
47
 
48
+ maxlength:
49
+ default: 30
50
+
51
+ maquina/plan:
52
+ name: 60
53
+ trial: 3
54
+ price: 9
55
+
56
+ sessions:
57
+ email: 60
58
+ password: 60
@@ -1,3 +1,3 @@
1
1
  module Maquina
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maquina
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Alberto Chávez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-04 00:00:00.000000000 Z
11
+ date: 2023-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -307,6 +307,7 @@ files:
307
307
  - app/assets/javascripts/maquina/application.js
308
308
  - app/assets/javascripts/maquina/controllers/alert_controller.js
309
309
  - app/assets/javascripts/maquina/controllers/application.js
310
+ - app/assets/javascripts/maquina/controllers/backdrop_controller.js
310
311
  - app/assets/javascripts/maquina/controllers/file_controller.js
311
312
  - app/assets/javascripts/maquina/controllers/index.js
312
313
  - app/assets/javascripts/maquina/controllers/mobile_menu_controller.js