lato 0.1.6 → 0.1.8

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: df735930c50baedc7cd02983684c95b44df0ac32e3acdd3724cc0a8b6a017f3d
4
- data.tar.gz: b5442d7576eed9fa4ccab09472895ebfdf1ee47ab66bf81c90ce71efff38b31f
3
+ metadata.gz: d6adeb777cb566b2e9d542140ebf059a817c6f94a7afa11b508f194d3ffe6a1a
4
+ data.tar.gz: 6e462303df7baf36f4dac902c5c25d1a5da45abeeaf3dca434c6333cc3793555
5
5
  SHA512:
6
- metadata.gz: 61b499814b967a6d6eb46cff9de9d4df83104a6487bdcc2bd876db7b9d53477e8b72df26de44182b4f8b7ddadf542b324652ccefea1bf7b460986189dd25d337
7
- data.tar.gz: c68a2c8f7682d11eeef3462e0f940747f3cf370f9e5b3fc6cc370907c49fd57ce0a9aa42dc45850957555cd4c5885456cc2fb7583cddcf43c3dfaec86c6c9a3a
6
+ metadata.gz: fb537cf7b8d676714301243ed815eb50e3ee9216ce72d10c0f034a38119952c8c5e8b404e70d641ba26c576c89de5a5ebe04085404cc5cb3749cee0ccbbbd931
7
+ data.tar.gz: 8b9ef05c50607bce795873155a4be715162abe82c96f9792299fd4aeb91f4f07f50f8e5721d1361c11a9fe916dd13ce8b5531e0a8a8c1dd059d50634a0db0921
data/README.md CHANGED
@@ -98,4 +98,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
98
98
 
99
99
  ## To do
100
100
  - Gestione abbonamenti e acquisti singoli con integrazione Stripe
101
- - Gestione input file operazione
101
+ - Gestione input file operazione
@@ -22,18 +22,46 @@ export default class extends Controller {
22
22
 
23
23
  modalTarget.addEventListener('show.bs.modal', () => {
24
24
  this.usedModals.push(index)
25
+
26
+ // update backdrop z-index in case of multiple opened modals
27
+ setTimeout(() => { // use setTimeout because bsModalBackdropElement is not always ready after 'show.bs.modal' event
28
+ if (this.usedModals.length > 1) {
29
+ for (let i = 0; i < this.usedModals.length; i++) {
30
+ const bsModal = this.bsModals[this.usedModals[i]]
31
+
32
+ const bsModalElement = bsModal._element
33
+ if (bsModalElement) bsModalElement.style.zIndex = 1055 + i + 1
34
+
35
+ const bsModalBackdropElement = bsModal._backdrop._element
36
+ if (bsModalBackdropElement) bsModalBackdropElement.style.zIndex = 1055 + i
37
+ }
38
+ }
39
+ }, 1)
25
40
  })
26
41
  modalTarget.addEventListener('hide.bs.modal', () => {
27
- this.usedModals = this.usedModals.filter((i) => i != index)
28
- this.modalBodyTargets[index].innerHTML = ''
42
+ setTimeout(() => {
43
+ this.usedModals = this.usedModals.filter((i) => i != index)
44
+ this.modalBodyTargets[index].innerHTML = ''
45
+ }, 500)
29
46
  })
30
47
  })
31
48
  }
32
49
 
33
50
  disconnect() {
51
+ // call dispose to all bootstrap modals (clear bootstrap modal)
34
52
  this.bsModals.forEach((bsModal) => {
35
53
  bsModal.dispose()
36
54
  })
55
+
56
+ // clean modalTitle content
57
+ this.modalTitleTargets.forEach((modalTitleTarget) => {
58
+ modalTitleTarget.innerHTML = ''
59
+ })
60
+
61
+ // clean modalBody content
62
+ this.modalBodyTargets.forEach((modalBodyTarget) => {
63
+ modalBodyTarget.innerHTML = ''
64
+ })
37
65
  }
38
66
 
39
67
  triggerTargetConnected(element) {
@@ -12,12 +12,16 @@ export default class extends Controller {
12
12
 
13
13
  connect() {
14
14
  if (this.hasUpdateTarget) {
15
- setTimeout(() => {
15
+ this._timeout = setTimeout(() => {
16
16
  this.updateTarget.click()
17
17
  }, 2000)
18
18
  }
19
19
  }
20
20
 
21
+ disconnect() {
22
+ if (this._timeout) clearTimeout(this._timeout)
23
+ }
24
+
21
25
  outputFileTargetConnected(element) {
22
26
  element.click()
23
27
  }
@@ -0,0 +1,9 @@
1
+ module LatoUserApplication
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ # Add here custom relations, scopes, ecc.
6
+ end
7
+
8
+ # Add here custom methods
9
+ end
@@ -1,5 +1,7 @@
1
1
  module Lato
2
2
  class User < ApplicationRecord
3
+ include LatoUserApplication
4
+
3
5
  has_secure_password
4
6
 
5
7
  # Kredis
@@ -4,86 +4,94 @@
4
4
  <%= hidden_field_tag :key, key %>
5
5
  <%= hidden_field_tag :sort_by, params[:sort_by] %>
6
6
 
7
- <div class="table-responsive">
8
- <table class="table table-striped table-bordered">
9
- <thead>
10
- <% if custom_actions.any? || searchable_columns.any? %>
11
- <tr>
12
- <td colspan="<%= columns.length %>">
13
- <div class="d-flex justify-content-between">
14
- <% if searchable_columns.any? %>
15
- <div class="input-group">
16
- <input type="text" name="search" class="form-control" placeholder="Ricerca per: <%= searchable_columns.map { |c| collection.model.human_attribute_name(c) }.to_sentence %>" value="<%= params[:search] %>">
17
- <button class="btn btn-outline-primary" type="submit"><i class="bi bi-search"></i></button>
18
- </div>
19
- <% else %>
20
- <div></div>
21
- <% end %>
7
+ <% if false && browser.device.mobile? %>
22
8
 
23
- <div class="btn-group ms-2">
24
- <% if custom_actions.any? %>
25
- <% custom_actions.each do |action_key, action_params| %>
26
- <%= link_to action_params[:path], { class: 'btn btn-primary' }.merge(action_params) do %>
27
- <i class="<%= action_params[:icon] %>"></i>
28
- <% end %>
29
- <% end %>
30
- <% end %>
31
- </div>
32
- </div>
33
- </td>
34
- </tr>
35
- <% end %>
36
- <tr class="align-middle">
37
- <% columns.each do |column| %>
38
- <th scope="col">
39
- <div class="d-flex align-items-center">
40
- <span><%= collection.model.human_attribute_name column %></span>
41
- <% if sortable_columns.include?(column) %>
42
- <div class="btn-group ms-3">
43
- <div class="position-relative btn btn-sm <%= params[:sort_by] == "#{column}|ASC" ? 'btn-primary' : 'btn-outline-primary' %>">
44
- <input type="submit" name="sort_by" value="<%= column %>|ASC" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0">
45
- <i class="bi bi-sort-up"></i>
46
- </div>
9
+ <p>Work in progress</p>
10
+
11
+ <% else %>
47
12
 
48
- <div class="position-relative btn btn-sm <%= params[:sort_by] == "#{column}|DESC" ? 'btn-primary' : 'btn-outline-primary' %>">
49
- <input type="submit" name="sort_by" value="<%= column %>|DESC" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0">
50
- <i class="bi bi-sort-down"></i>
13
+ <div class="table-responsive">
14
+ <table class="table table-striped table-bordered">
15
+ <thead>
16
+ <% if custom_actions.any? || searchable_columns.any? %>
17
+ <tr>
18
+ <td colspan="<%= columns.length %>">
19
+ <div class="d-flex justify-content-between">
20
+ <% if searchable_columns.any? %>
21
+ <div class="input-group">
22
+ <input type="text" name="search" class="form-control" placeholder="Ricerca per: <%= searchable_columns.map { |c| collection.model.human_attribute_name(c) }.to_sentence %>" value="<%= params[:search] %>">
23
+ <button class="btn btn-outline-primary" type="submit"><i class="bi bi-search"></i></button>
51
24
  </div>
25
+ <% else %>
26
+ <div></div>
27
+ <% end %>
28
+
29
+ <div class="btn-group ms-2">
30
+ <% if custom_actions.any? %>
31
+ <% custom_actions.each do |action_key, action_params| %>
32
+ <%= link_to action_params[:path], { class: 'btn btn-primary' }.merge(action_params) do %>
33
+ <i class="<%= action_params[:icon] %>"></i>
34
+ <% end %>
35
+ <% end %>
36
+ <% end %>
52
37
  </div>
53
- <% end %>
54
- </div>
55
- </th>
38
+ </div>
39
+ </td>
40
+ </tr>
56
41
  <% end %>
57
- </tr>
58
- </thead>
59
- <tbody>
60
- <% collection.each do |member| %>
61
- <tr>
42
+ <tr class="align-middle">
62
43
  <% columns.each do |column| %>
63
- <td>
64
- <% viewer_function_name = "#{model_name_underscore}_#{column}" %>
65
- <%= respond_to?(viewer_function_name) ? send(viewer_function_name, member) : member.send(column) %>
66
- </td>
44
+ <th scope="col">
45
+ <div class="d-flex align-items-center">
46
+ <span><%= collection.model.human_attribute_name column %></span>
47
+ <% if sortable_columns.include?(column) %>
48
+ <div class="btn-group ms-3">
49
+ <div class="position-relative btn btn-sm <%= params[:sort_by] == "#{column}|ASC" ? 'btn-primary' : 'btn-outline-primary' %>">
50
+ <input type="submit" name="sort_by" value="<%= column %>|ASC" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0">
51
+ <i class="bi bi-sort-up"></i>
52
+ </div>
53
+
54
+ <div class="position-relative btn btn-sm <%= params[:sort_by] == "#{column}|DESC" ? 'btn-primary' : 'btn-outline-primary' %>">
55
+ <input type="submit" name="sort_by" value="<%= column %>|DESC" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0">
56
+ <i class="bi bi-sort-down"></i>
57
+ </div>
58
+ </div>
59
+ <% end %>
60
+ </div>
61
+ </th>
67
62
  <% end %>
68
63
  </tr>
69
- <% end %>
70
- </tbody>
71
- <tfoot>
72
- <tr>
73
- <td colspan="<%= columns.length %>">
74
- <div class="d-flex justify-content-between align-items-center">
75
- <% if collection.respond_to?(:total_pages) %>
76
- <div><%= paginate collection %></div>
77
- <% else %>
78
- <div></div>
64
+ </thead>
65
+ <tbody>
66
+ <% collection.each do |member| %>
67
+ <tr>
68
+ <% columns.each do |column| %>
69
+ <td>
70
+ <% viewer_function_name = "#{model_name_underscore}_#{column}" %>
71
+ <%= respond_to?(viewer_function_name) ? send(viewer_function_name, member) : member.send(column) %>
72
+ </td>
79
73
  <% end %>
80
- <span class="text-muted"><%= collection.count %> risultati visualizzati
81
- </div>
82
- </td>
83
- </tr>
84
- </tfoot>
85
- </table>
86
- </div>
74
+ </tr>
75
+ <% end %>
76
+ </tbody>
77
+ <tfoot>
78
+ <tr>
79
+ <td colspan="<%= columns.length %>">
80
+ <div class="d-flex justify-content-between align-items-center">
81
+ <% if collection.respond_to?(:total_pages) %>
82
+ <div><%= paginate collection %></div>
83
+ <% else %>
84
+ <div></div>
85
+ <% end %>
86
+ <span class="text-muted"><%= collection.count %> risultati visualizzati
87
+ </div>
88
+ </td>
89
+ </tr>
90
+ </tfoot>
91
+ </table>
92
+ </div>
93
+
94
+ <% end %>
87
95
  <% end %>
88
96
 
89
97
  <% end %>
@@ -1 +1,6 @@
1
- <%= Lato.config.application_title %>
1
+ <%= Lato.config.application_title %>
2
+
3
+ <!--
4
+ <img src="https://getbootstrap.com/docs/5.0/assets/brand/bootstrap-logo.svg" alt="" width="30" height="24" class="d-inline-block align-text-top">
5
+ <span><%= Lato.config.application_title %></span>
6
+ -->
@@ -7,7 +7,7 @@
7
7
  <%= csrf_meta_tags %>
8
8
  <%= csp_meta_tag %>
9
9
 
10
- <%= stylesheet_link_tag "application", media: "all" %>
10
+ <%= stylesheet_link_tag Lato.config.assets_stylesheet_entry, media: "all" %>
11
11
  <%= javascript_importmap_tags %>
12
12
  </head>
13
13
  <body
data/lib/lato/config.rb CHANGED
@@ -12,6 +12,9 @@ module Lato
12
12
  # Authentication configs
13
13
  attr_accessor :auth_disable_signup
14
14
 
15
+ # Assets configs
16
+ attr_accessor :assets_stylesheet_entry
17
+
15
18
  # Email configs
16
19
  attr_accessor :email_from
17
20
 
@@ -25,6 +28,8 @@ module Lato
25
28
 
26
29
  @auth_disable_signup = false
27
30
 
31
+ @assets_stylesheet_entry = 'application'
32
+
28
33
  @session_lifetime = 30.days
29
34
  @session_root_path = nil # :tutorial_path
30
35
 
data/lib/lato/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lato
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.8"
3
3
  end
data/lib/lato.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "kaminari"
2
2
  require "bootstrap"
3
+ require "browser"
3
4
 
4
5
  require "lato/version"
5
6
  require "lato/engine"
@@ -5,6 +5,8 @@ namespace :lato do
5
5
  desc 'Install Lato engine and run tasks on main rails application'
6
6
  task :application do
7
7
  # Copy all "_content.html.erb" parials on layouts/lato from gem to main application
8
+ ##
9
+
8
10
  gem_layout_path = Lato::Engine.root.join('app', 'views', 'layouts', 'lato').to_s
9
11
  app_layout_path = Rails.root.join('app', 'views', 'layouts', 'lato').to_s
10
12
 
@@ -23,6 +25,11 @@ namespace :lato do
23
25
 
24
26
  FileUtils.copy(src_file_path, dest_file_path) unless File.exist? dest_file_path
25
27
  end
28
+
29
+ # Copy "lato_user_application.rb" model concern from ghem to main application
30
+ gem_concern_path = Lato::Engine.root.join('app', 'models', 'concerns', 'lato_user_application.rb').to_s
31
+ app_concern_path = Rails.root.join('app', 'models', 'concerns', 'lato_user_application.rb').to_s
32
+ FileUtils.copy(gem_concern_path, app_concern_path) unless File.exist? app_concern_path
26
33
  end
27
34
  end
28
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lato
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregorio Galante
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-26 00:00:00.000000000 Z
11
+ date: 2022-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: browser
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description: A Rails engine that includes what you need to build a new project!
84
98
  email:
85
99
  - me@gregoriogalante.com
@@ -117,6 +131,7 @@ files:
117
131
  - app/jobs/lato/application_job.rb
118
132
  - app/mailers/lato/application_mailer.rb
119
133
  - app/mailers/lato/user_mailer.rb
134
+ - app/models/concerns/lato_user_application.rb
120
135
  - app/models/lato/application_record.rb
121
136
  - app/models/lato/operation.rb
122
137
  - app/models/lato/session.rb