thecore_ui_commons 3.0.10 → 3.0.11

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: 0b596fc87cfced8af2a9e669d6be3380ed5385f88badbdba2c3faf854c93a168
4
- data.tar.gz: a3ea71ef03a235f945d53b34405384ac287acec6d72f2d12db9d705ee488f5f7
3
+ metadata.gz: dd76f97a808fa400e1c08fa5b467e9d708f43450295f0025cce65a68c5f875a0
4
+ data.tar.gz: '08bbaeeeb52df83cb053c1210685abc94b88a373ed88690210c44bdf4fbfc559'
5
5
  SHA512:
6
- metadata.gz: 2cd62c9cc3e9162be1aeaef0dbe52e7dac00f67d7f7b0295d1dc558b77f7ab220516185bd6dade3d141de07997ebc4e34162164188e802d30c3add576a99bcf2
7
- data.tar.gz: ae8ba9bd83dc897310fd35b1ee81ff4e3d0815024a1b3206ac874cf9196e19e7c77a54e34c275cef884124e92ae719913c02605505e822a3d2315f5c59eb52c4
6
+ metadata.gz: 6a671522375a69039ed9add52f68ccd958ca9d1bcbcb05b49c7beec1f4c44c6b77b6da8f651147ca613a18cf4a17f0d193b145e76512c03e6ae93d1cb48405f1
7
+ data.tar.gz: fed6ba02869995a012a2191f13b361175ba688d48a916eb93cfc7d814907672a0bf5b68b02a38faa7b87039187288016b837b371a21ae07149829608d057ad53
data/README.md CHANGED
@@ -8,7 +8,7 @@ How to use my plugin.
8
8
  Add this line to your application's Gemfile:
9
9
 
10
10
  ```ruby
11
- gem 'thecore_ui_commons'
11
+ gem "thecore_ui_commons"
12
12
  ```
13
13
 
14
14
  And then execute:
data/Rakefile CHANGED
@@ -1,32 +1,3 @@
1
- begin
2
- require 'bundler/setup'
3
- rescue LoadError
4
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
- end
1
+ require "bundler/setup"
6
2
 
7
- require 'rdoc/task'
8
-
9
- RDoc::Task.new(:rdoc) do |rdoc|
10
- rdoc.rdoc_dir = 'rdoc'
11
- rdoc.title = 'ThecoreUiCommons'
12
- rdoc.options << '--line-numbers'
13
- rdoc.rdoc_files.include('README.md')
14
- rdoc.rdoc_files.include('lib/**/*.rb')
15
- end
16
-
17
- APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
18
- load 'rails/tasks/engine.rake'
19
-
20
- load 'rails/tasks/statistics.rake'
21
-
22
- require 'bundler/gem_tasks'
23
-
24
- require 'rake/testtask'
25
-
26
- Rake::TestTask.new(:test) do |t|
27
- t.libs << 'test'
28
- t.pattern = 'test/**/*_test.rb'
29
- t.verbose = false
30
- end
31
-
32
- task default: :test
3
+ require "bundler/gem_tasks"
@@ -0,0 +1 @@
1
+ console.log("APP/active_job_monitor.js")
@@ -0,0 +1 @@
1
+ console.log("Rails Admin Main JS")
@@ -0,0 +1,20 @@
1
+ // This file can be overridden in your engine
2
+
3
+ let currentURL = new URL(window.location.href);
4
+
5
+ $(document).on('turbo:load', function (event) {
6
+ currentURL = new URL(event.originalEvent.detail.url);
7
+ console.log("Page loaded listening to turbo:load event", currentURL.href);
8
+ console.log(" - Protocol:", currentURL.protocol);
9
+ console.log(" - Username:", currentURL.username);
10
+ console.log(" - Password:", currentURL.password);
11
+ console.log(" - Host:", currentURL.host);
12
+ console.log(" - Hostname:", currentURL.hostname);
13
+ console.log(" - Port:", currentURL.port);
14
+ console.log(" - Pathname:", currentURL.pathname);
15
+ console.log(" - Search:", currentURL.search);
16
+ currentURL.searchParams.forEach((v, k) => {
17
+ console.log(` - ${k}: ${v}`);
18
+ })
19
+ console.log(" - Hash:", currentURL.hash);
20
+ });
@@ -6,6 +6,10 @@ body {
6
6
  margin: 0;
7
7
  background-color: #37505C;
8
8
  overflow: hidden;
9
+ color: #FFEAD0;
10
+ }
11
+ h2 {
12
+ display: none;
9
13
  }
10
14
  /* unvisited link */
11
15
  a:link {
@@ -67,9 +71,8 @@ a:active {
67
71
  .contained div {
68
72
  margin-bottom: 1em;
69
73
  }
70
- .form-control {
74
+ #user_password, #user_email {
71
75
  display: block;
72
- width: 100%;
73
76
  height: 34px;
74
77
  padding: 6px 12px;
75
78
  font-size: 14px;
@@ -151,3 +154,32 @@ a:active {
151
154
  border: 1px solid transparent;
152
155
  border-radius: 4px;
153
156
  }
157
+
158
+ input[name=commit] {
159
+ color: white;
160
+ background-color: #ED6A16;
161
+ width: 100%;
162
+ border-color: #BD4B39;
163
+ border-radius: 2em;
164
+ -webkit-appearance: button;
165
+ cursor: pointer;
166
+ text-decoration: none;
167
+ display: inline-block;
168
+ margin-bottom: 0;
169
+ font-weight: normal;
170
+ text-align: center;
171
+ white-space: nowrap;
172
+ vertical-align: middle;
173
+ touch-action: manipulation;
174
+ cursor: pointer;
175
+ background-image: none;
176
+ border: 1px solid transparent;
177
+ padding: 6px 12px;
178
+ font-size: 14px;
179
+ line-height: 1.428571429;
180
+ border-radius: 4px;
181
+ -webkit-user-select: none;
182
+ -moz-user-select: none;
183
+ -ms-user-select: none;
184
+ user-select: none;
185
+ }
@@ -0,0 +1,2 @@
1
+ // This file can be overridden in your engine
2
+
@@ -0,0 +1,9 @@
1
+ module ThecoreHelper
2
+ def bootstrap_class_for(flash_type)
3
+ { success: "alert-success", error: "alert-error", alert: "alert-danger", notice: "alert-info" }[flash_type.to_sym] || flash_type.to_s
4
+ end
5
+
6
+ def line_break s
7
+ s.gsub("\n", "<br/>")
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ module Abilities
2
+ class ThecoreUiCommons
3
+ include CanCan::Ability
4
+ def initialize user
5
+ # Main abilities file for Thecore applications
6
+ if user.present?
7
+ # Users' abilities
8
+ if user.admin?
9
+ # Admins' abilities
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ # This method defines the migrations paths for the engine and adds them to the migrations paths of
2
+ # the parent Rails app by using ActiveRecord::Migrator.migrations_paths.concat.
3
+ # migrations_paths = [File.expand_path("../../db/migrate", __dir__)]
4
+ # ActiveRecord::Migrator.migrations_paths.concat(migrations_paths)
5
+ Rails.application.config.paths['db/migrate'] << File.expand_path("../../db/migrate", __dir__)
@@ -0,0 +1,8 @@
1
+ Rails.application.configure do
2
+ config.after_initialize do
3
+ # Controllers
4
+ ApplicationController.send :include, ConcernApplicationController
5
+ RailsAdmin::ApplicationController.send :include, ConcernApplicationController
6
+ User.send(:include, ThecoreUiCommonsUserConcern)
7
+ end
8
+ end
@@ -0,0 +1,12 @@
1
+ Rails.application.config.filter_parameters += [:password]
2
+
3
+ Rails.application.config.active_record.raise_in_transactional_callbacks = true
4
+
5
+ Rails.application.config.serviceworker.routes.draw do
6
+ match "/manifest.json"
7
+ end
8
+
9
+ Rails.application.config.assets.configure do |env|
10
+ env.export_concurrent = false
11
+ end
12
+
@@ -0,0 +1,13 @@
1
+ Rails.application.config.assets.precompile += %w(
2
+ android-chrome-192x192.png
3
+ android-chrome-512x512.png
4
+ apple-touch-icon.png
5
+ favicon.ico
6
+ customer_logo.png
7
+ logo.png
8
+ manifest.json
9
+ devise/sessions.css
10
+ devise/sessions.js
11
+ thecore_ui_commons.js
12
+ thecore_ui_commons.css
13
+ )
@@ -0,0 +1,79 @@
1
+ require 'active_support/concern'
2
+
3
+ module ConcernApplicationController
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ protect_from_forgery prepend: true
8
+
9
+ rescue_from CanCan::AccessDenied do |exception|
10
+ redirect_to main_app.root_url, alert: exception.message
11
+ end
12
+
13
+ before_action :store_user_location!, if: :storable_location?
14
+ before_action :reject_locked!, if: :devise_controller?
15
+
16
+ # Redirects on successful sign in
17
+ def after_sign_in_path_for resource
18
+ root_actions = RailsAdmin::Config::Actions.all(:root).select {|action| can? action.action_name, :all }.collect(&:action_name)
19
+
20
+ # Default root action as landing page: the first to which I have authorization to read
21
+ action = root_actions.first
22
+ puts "after_sign_in_path_for action: #{action}"
23
+ # Otherwise, if I set a Manual override for landing actions in config, I can test if I'm authorized to see it
24
+ override_landing_page = Settings.ns(:main).after_sign_in_redirect_to_root_action
25
+ action = override_landing_page.to_sym if !override_landing_page.blank? && root_actions.include?(override_landing_page.to_sym)
26
+
27
+ # If I ask for a specific page, Let's try to go back there if I need to login or re-login
28
+ # This takes precedence on automatic computed action
29
+ stored_location = stored_location_for(resource)
30
+ puts "after_sign_in_path_for stored_location: #{stored_location}"
31
+ if !stored_location.blank? && can?(resource, :all)
32
+ # Go to the latest navigated page
33
+ puts "after_sign_in_path_for Redirect to stored_location"
34
+ return stored_location
35
+ elsif action
36
+ path = rails_admin.send("#{action}_path").sub("#{ENV['RAILS_RELATIVE_URL_ROOT']}#{ENV['RAILS_RELATIVE_URL_ROOT']}", "#{ENV['RAILS_RELATIVE_URL_ROOT']}")
37
+ puts "after_sign_in_path_for Redirect to action #{path}"
38
+ return path
39
+ else
40
+ puts "after_sign_in_path_for ERROR! Signing out user :-("
41
+ sign_out current_user
42
+ user_session = nil
43
+ current_user = nil
44
+ flash[:alert] = "Your user is not authorized to access any page."
45
+ flash[:notice] = nil
46
+ return root_path
47
+ end
48
+ end
49
+
50
+ # Auto-sign out locked users
51
+ def reject_locked!
52
+ if !current_user.blank? && current_user.locked?
53
+ puts " - Cleaning session"
54
+ sign_out current_user
55
+ user_session = nil
56
+ current_user = nil
57
+ flash[:alert] = "Your account is locked."
58
+ flash[:notice] = nil
59
+ redirect_to root_url
60
+ end
61
+ end
62
+
63
+ # Its important that the location is NOT stored if:
64
+ # - The request method is not GET (non idempotent)
65
+ # - The request is handled by a Devise controller such as
66
+ # Devise::SessionsController as that could cause an
67
+ # infinite redirect loop.
68
+ # - The request is an Ajax request as this can lead to very unexpected
69
+ # behaviour.
70
+ def storable_location?
71
+ request.get? && is_navigational_format? && !devise_controller? && !request.xhr?
72
+ end
73
+
74
+ def store_user_location!
75
+ # :user is the scope we are authenticating
76
+ store_location_for(:user, request.fullpath)
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,9 @@
1
+ require 'active_support/concern'
2
+
3
+ module ThecoreUiCommonsUserConcern
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ devise :trackable, :timeoutable, timeout_in: 30.minutes
8
+ end
9
+ end
data/config/routes.rb CHANGED
@@ -1,2 +1,6 @@
1
1
  Rails.application.routes.draw do
2
- end
2
+ devise_for :users
3
+ devise_scope :user do
4
+ root to: "devise/sessions#new"
5
+ end
6
+ end
data/db/seeds.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  puts "Loading ThecoreUiCommons seeds"
2
2
 
3
3
  Thecore::Seed.save_setting :importer, :import_from_folder, "tmp/imports"
4
- Thecore::Seed.save_setting :importer, :extension, "txt"
4
+ Thecore::Seed.save_setting :importer, :extension, "txt"
@@ -1,14 +1,4 @@
1
1
  module ThecoreUiCommons
2
2
  class Engine < ::Rails::Engine
3
- initializer 'thecore_ui_commons.add_to_migrations' do |app|
4
- # Adds the list of Thecore Engines, so to manage seeds loading, i.e.:
5
- Thecore::Base.thecore_engines << self.class
6
- unless app.root.to_s.match root.to_s
7
- # APPEND TO MAIN APP MIGRATIONS FROM THIS GEM
8
- config.paths['db/migrate'].expanded.each do |expanded_path|
9
- app.config.paths['db/migrate'] << expanded_path
10
- end
11
- end
12
- end
13
3
  end
14
4
  end
@@ -1,14 +1,9 @@
1
- require 'haml'
2
- require 'haml-rails'
3
-
4
- require 'thecore_background_jobs' # This brings backend commons also.
5
- # Rails
6
- require 'serviceworker-rails'
1
+ require "thecore_backend_commons"
2
+ require "haml"
3
+ require "haml-rails"
4
+ require "serviceworker-rails"
7
5
  require "groupdate"
8
6
  require "apexcharts"
9
- require "image_processing"
10
-
11
- require 'concerns/thecore_ui_commons_user'
12
7
 
13
8
  require "thecore_ui_commons/engine"
14
9
 
metadata CHANGED
@@ -1,121 +1,106 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thecore_ui_commons
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.10
4
+ version: 3.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-07 00:00:00.000000000 Z
11
+ date: 2023-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: haml
14
+ name: thecore_backend_commons
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: haml-rails
28
+ name: haml
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '6.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '6.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: thecore_background_jobs
42
+ name: haml-rails
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.0'
47
+ version: '2.1'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.0'
54
+ version: '2.1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: serviceworker-rails
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '0.6'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '0.6'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: groupdate
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '6.0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '6.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: apexcharts
85
85
  requirement: !ruby/object:Gem::Requirement
86
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'
97
- - !ruby/object:Gem::Dependency
98
- name: image_processing
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
87
+ - - "~>"
102
88
  - !ruby/object:Gem::Version
103
- version: '0'
89
+ version: '0.2'
104
90
  type: :runtime
105
91
  prerelease: false
106
92
  version_requirements: !ruby/object:Gem::Requirement
107
93
  requirements:
108
- - - ">="
94
+ - - "~>"
109
95
  - !ruby/object:Gem::Version
110
- version: '0'
96
+ version: '0.2'
111
97
  description: Engine to serve configurations and rails module useful for all the UIs.
112
98
  email:
113
- - gabriele.tassoni@gmail.com
99
+ - g.tassoni@bancolini.com
114
100
  executables: []
115
101
  extensions: []
116
102
  extra_rdoc_files: []
117
103
  files:
118
- - MIT-LICENSE
119
104
  - README.md
120
105
  - Rakefile
121
106
  - app/assets/images/android-chrome-192x192.png
@@ -124,13 +109,16 @@ files:
124
109
  - app/assets/images/customer_logo.png
125
110
  - app/assets/images/favicon.ico
126
111
  - app/assets/images/logo.png
112
+ - app/assets/javascripts/app/active_job_monitor.js
127
113
  - app/assets/javascripts/browserconfig.xml
128
114
  - app/assets/javascripts/devise/sessions.js.erb
129
115
  - app/assets/javascripts/manifest.json
116
+ - app/assets/javascripts/rails_admin/main.js
117
+ - app/assets/javascripts/thecore_ui_commons.js
130
118
  - app/assets/stylesheets/devise/sessions.css
131
- - app/controllers/application_controller.rb
119
+ - app/assets/stylesheets/thecore_ui_commons.scss
120
+ - app/helpers/thecore_helper.rb
132
121
  - app/views/contact_mailer/contact_message.html.erb
133
- - app/views/devise/sessions/new.html.erb
134
122
  - app/views/kaminari/_first_page.html.erb
135
123
  - app/views/kaminari/_gap.html.erb
136
124
  - app/views/kaminari/_last_page.html.erb
@@ -146,10 +134,14 @@ files:
146
134
  - app/views/layouts/mailer.text.erb
147
135
  - app/views/shared/_flash.html.erb
148
136
  - app/views/thecore_utils/_drag_drop_uploader.html.erb
149
- - config/initializers/charts_helper.rb
150
- - config/initializers/thecore_ui_commons_assets.rb
151
- - config/initializers/thecore_ui_commons_configs.rb
152
- - config/initializers/thecore_ui_commons_helper.rb
137
+ - config/initializers/abilities.rb
138
+ - config/initializers/add_to_db_migrations.rb
139
+ - config/initializers/after_initialize.rb
140
+ - config/initializers/application_config.rb
141
+ - config/initializers/assets.rb
142
+ - config/initializers/concern_application_controller.rb
143
+ - config/initializers/concern_user.rb
144
+ - config/initializers/helper_charts.rb
153
145
  - config/locales/en.ra_settings.yml
154
146
  - config/locales/en.simple_form.yml
155
147
  - config/locales/en.yml
@@ -157,19 +149,18 @@ files:
157
149
  - config/locales/it.simple_form.yml
158
150
  - config/locales/it.yml
159
151
  - config/routes.rb
160
- - db/migrate/20200515070620_add_username_to_user.rb
161
- - db/migrate/20200515132932_add_rememberable_to_user.rb
162
152
  - db/seeds.rb
163
- - lib/concerns/thecore_ui_commons_user.rb
164
153
  - lib/tasks/thecore_ui_commons_tasks.rake
165
154
  - lib/thecore_ui_commons.rb
166
155
  - lib/thecore_ui_commons/engine.rb
167
156
  - lib/thecore_ui_commons/version.rb
168
157
  homepage: https://github.com/gabrieletassoni/thecore_ui_commons
169
- licenses:
170
- - MIT
158
+ licenses: []
171
159
  metadata:
172
160
  allowed_push_host: https://rubygems.org
161
+ homepage_uri: https://github.com/gabrieletassoni/thecore_ui_commons
162
+ source_code_uri: https://github.com/gabrieletassoni/thecore_ui_commons
163
+ changelog_uri: https://github.com/gabrieletassoni/thecore_ui_commons/blob/master/CHANGELOG.md
173
164
  post_install_message:
174
165
  rdoc_options: []
175
166
  require_paths:
data/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright 2020 Gabriele Tassoni
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,2 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- end
@@ -1,25 +0,0 @@
1
- <div class=login-container id="login-form">
2
- <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
3
- <div class="field">
4
- <%= f.text_field :login, autofocus: true, :class => "form-control", placeholder: t("devise.sessions.new.login") %>
5
- </div>
6
-
7
- <div class="field">
8
- <%= f.password_field :password, autocomplete: "off", :class => "form-control", placeholder: t("devise.sessions.new.password") %>
9
- </div>
10
-
11
- <% if devise_mapping.rememberable? -%>
12
- <div class="form-check">
13
- <%= f.check_box :remember_me, class: "form-check-input" %>
14
- <label class="form-check-label" for="defaultCheck1">
15
- <%=t "activerecord.attributes.user.remember_me" %>
16
- </label>
17
- </div>
18
- <% end -%>
19
-
20
- <div class="actions">
21
- <%= f.submit t("devise.sessions.new.sign_in"), class: "btn" %>
22
- <%= render "devise/shared/links" %>
23
- </div>
24
- <% end %>
25
- </div>
@@ -1,12 +0,0 @@
1
- Rails.application.configure do
2
- config.assets.precompile += %w(
3
- android-chrome-192x192.png
4
- android-chrome-512x512.png
5
- apple-touch-icon.png
6
- favicon.ico
7
- customer_logo.png
8
- logo.png
9
- manifest.json
10
- )
11
- config.assets.precompile += %w( devise/sessions.css devise/sessions.js )
12
- end
@@ -1,17 +0,0 @@
1
- Rails.application.configure do
2
- config.filter_parameters += [:password]
3
-
4
- config.active_record.raise_in_transactional_callbacks = true
5
-
6
- config.serviceworker.routes.draw do
7
- match "/manifest.json"
8
- end
9
-
10
- config.assets.configure do |env|
11
- env.export_concurrent = false
12
- end
13
-
14
- config.after_initialize do
15
- User.send(:include, ThecoreUiCommonsUser)
16
- end
17
- end
@@ -1,29 +0,0 @@
1
- module Helpers
2
- module ThecoreUiCommonsHelper
3
- def get_asset_tags_for(basename)
4
- out = []
5
-
6
- # Needs to reverse since Paths are traversed in the order they occur in the search path. By default, this means the files in app/assets take precedence, and will mask corresponding paths in lib and vendor.
7
- Rails.application.config.assets.paths.reverse.each do |basedir|
8
- base = "#{basedir}/**/#{basename}"
9
- base_s = Dir["#{base}.{css,scss}"]
10
- base_j = Dir["#{base}.js"]
11
-
12
- (out << stylesheet_link_tag("#{get_folder base_s}/#{basename}", media: 'all', 'data-turbo-track' => true) if base_s.any?) rescue nil
13
- (out << javascript_include_tag("#{get_folder base_j}/#{basename}", 'data-turbo-track' => true) if base_j.any?) rescue nil
14
- end
15
-
16
- # Application level assets
17
- (out << stylesheet_link_tag('application', media: 'all', 'data-turbo-track' => true)) rescue nil
18
- (out << javascript_include_tag('application', 'data-turbo-track' => true)) rescue nil
19
-
20
- out.join("\n").html_safe
21
- end
22
-
23
- def get_folder(base)
24
- base.first.split("/")[-2]
25
- end
26
- end
27
- end
28
-
29
- ActiveSupport.on_load(:action_view) { include Helpers::ThecoreUiCommonsHelper }
@@ -1,53 +0,0 @@
1
- class AddUsernameToUser < ActiveRecord::Migration[6.0]
2
- class User < ApplicationRecord
3
- # Include default devise modules. Others available are:
4
- # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
5
- devise :database_authenticatable, :trackable, :validatable
6
- # TODO: If it works, these must be added to another gem one which deal
7
- # more with sessions
8
- # devise :database_authenticatable
9
- # devise :rememberable
10
- # devise :trackable
11
- # devise :validatable
12
- # devise :timeoutable, timeout_in: 30.minutes
13
- # REFERENCES
14
- has_many :role_users, dependent: :destroy, inverse_of: :user
15
- has_many :roles, through: :role_users, inverse_of: :users
16
- # VALIDATIONS
17
- validates :email, uniqueness: { case_sensitive: false }, presence: true, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i }
18
- validates :password, presence: true, on: :create
19
- validates :password_confirmation, presence: true, on: :create
20
- validate :check_password_and_confirmation_equal
21
- validates_each :admin do |record, attr, value|
22
- # Don't want admin == false if the current user is the only admin
23
- record.errors.add(attr, I18n.t("validation.errors.cannot_unadmin_last_admin")) if record.admin_changed? && record.admin_was == true && User.where(admin: true).count == 1
24
- end
25
-
26
- def display_name
27
- email
28
- end
29
-
30
- def has_role? role
31
- roles.include? role
32
- end
33
-
34
- protected
35
-
36
- def check_password_and_confirmation_equal
37
- errors.add(:password, I18n.t("validation.errors.password_and_confirm_must_be_the_same")) unless password == password_confirmation
38
- end
39
- end
40
-
41
- def change
42
- add_column :users, :username, :string
43
- add_index :users, :username
44
-
45
- puts "Computing username for existing emails"
46
- User.reset_column_information
47
- User.all.each do |u|
48
- puts "User: #{u.email} into #{u.email.split("@").first}"
49
- u.username = u.email.split("@").first
50
- u.save!
51
- end
52
- end
53
- end
@@ -1,5 +0,0 @@
1
- class AddRememberableToUser < ActiveRecord::Migration[6.0]
2
- def change
3
- add_column :users, :remember_created_at, :datetime
4
- end
5
- end
@@ -1,29 +0,0 @@
1
- require 'active_support/concern'
2
-
3
- module ThecoreUiCommonsUser
4
- extend ActiveSupport::Concern
5
-
6
- included do
7
- devise :database_authenticatable, :trackable, :validatable, :rememberable, :timeoutable, timeout_in: 30.minutes, authentication_keys: [:login]
8
- validates :username, uniqueness: { case_sensitive: false }, presence: true, length: { in: 4..15 }
9
- validates_format_of :username, with: /\A[a-zA-Z0-9]*\z/, on: :create, message: "can only contain letters and digits"
10
-
11
- attr_writer :login
12
-
13
- def login
14
- @login || (self.username rescue self.email)
15
- end
16
- # Use login
17
- def self.find_first_by_auth_conditions(warden_conditions)
18
- conditions = warden_conditions.dup
19
- if login = conditions.delete(:login)
20
- where(conditions.to_h).where(["lower(username) = :value OR lower(email) = :value", { :value => login.downcase }]).first
21
- elsif conditions.has_key?(:username) || conditions.has_key?(:email)
22
- # Case insensitive login
23
- conditions[:email].downcase! if conditions[:email]
24
- conditions[:username].downcase! if conditions[:username]
25
- where(conditions.to_h).first
26
- end
27
- end
28
- end
29
- end