thecore_ui_commons 2.1.5 → 2.1.10

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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/config/thecore_ui_commons_manifest.js +0 -2
  3. data/app/assets/images/android-chrome-192x192.png +0 -0
  4. data/app/assets/images/android-chrome-512x512.png +0 -0
  5. data/app/assets/images/apple-touch-icon.png +0 -0
  6. data/app/assets/images/favicon-16x16.png +0 -0
  7. data/app/assets/images/favicon-32x32.png +0 -0
  8. data/app/assets/images/favicon.ico +0 -0
  9. data/app/assets/images/logo.png +0 -0
  10. data/app/assets/images/mstile-150x150.png +0 -0
  11. data/app/assets/images/safari-pinned-tab.svg +1042 -0
  12. data/app/assets/images/up-arrow.png +0 -0
  13. data/app/assets/javascripts/browserconfig.xml +9 -0
  14. data/app/assets/javascripts/ie.js +19 -0
  15. data/app/assets/javascripts/manifest.json +20 -0
  16. data/app/assets/javascripts/pages.coffee +3 -0
  17. data/app/assets/javascripts/thecore_ui_commons/thecore.js +8 -0
  18. data/app/assets/javascripts/timer.js +135 -0
  19. data/app/assets/stylesheets/thecore_ui_commons/actiontext.scss +19 -20
  20. data/app/assets/stylesheets/thecore_ui_commons/thecore.scss +18 -0
  21. data/app/views/contact_mailer/contact_message.html.erb +5 -0
  22. data/app/views/devise/confirmations/new.html.erb +16 -0
  23. data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  24. data/app/views/devise/mailer/password_change.html.erb +5 -0
  25. data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  26. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  27. data/app/views/devise/menu/_login_items.html.erb +7 -0
  28. data/app/views/devise/passwords/edit.html.erb +25 -0
  29. data/app/views/devise/passwords/new.html.erb +18 -0
  30. data/app/views/devise/registrations/edit.html.erb +45 -0
  31. data/app/views/devise/registrations/new.html.erb +29 -0
  32. data/app/views/devise/sessions/new.html.erb +28 -0
  33. data/app/views/devise/shared/_links.html.erb +25 -0
  34. data/app/views/devise/unlocks/new.html.erb +16 -0
  35. data/app/views/kaminari/_first_page.html.erb +3 -0
  36. data/app/views/kaminari/_gap.html.erb +3 -0
  37. data/app/views/kaminari/_last_page.html.erb +3 -0
  38. data/app/views/kaminari/_next_page.html.erb +3 -0
  39. data/app/views/kaminari/_page.html.erb +9 -0
  40. data/app/views/kaminari/_paginator.html.erb +15 -0
  41. data/app/views/kaminari/_prev_page.html.erb +3 -0
  42. data/app/views/layouts/_footer.html.erb +3 -0
  43. data/app/views/layouts/_messages.html.erb +9 -0
  44. data/app/views/layouts/_navigation.html.erb +20 -0
  45. data/app/views/layouts/_navigation_links.html.erb +7 -0
  46. data/app/views/layouts/mailer.html.erb +6 -0
  47. data/app/views/layouts/mailer.text.erb +1 -0
  48. data/app/views/layouts/thecore.html.erb +45 -0
  49. data/config/initializers/charts_helper.rb +45 -0
  50. data/config/initializers/thecore_ui_commons_application_config.rb +20 -8
  51. data/config/initializers/thecore_ui_commons_helper.rb +22 -0
  52. data/config/locales/en.ra_settings.yml +4 -0
  53. data/config/locales/en.yml +44 -0
  54. data/config/locales/it.ra_settings.yml +4 -0
  55. data/config/locales/it.yml +44 -0
  56. data/db/migrate/20200515070620_add_username_to_user.rb +53 -0
  57. data/db/migrate/20200515132932_add_rememberable_to_user.rb +5 -0
  58. data/lib/concerns/thecore_ui_commons_user.rb +29 -0
  59. data/lib/thecore_ui_commons.rb +10 -3
  60. data/lib/thecore_ui_commons/version.rb +1 -1
  61. metadata +87 -7
  62. data/app/controllers/pages_controller.rb +0 -43
  63. data/db/migrate/20190920115550_create_action_text_tables.action_text.rb +0 -14
@@ -0,0 +1,53 @@
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
@@ -0,0 +1,5 @@
1
+ class AddRememberableToUser < ActiveRecord::Migration[6.0]
2
+ def change
3
+ add_column :users, :remember_created_at, :datetime
4
+ end
5
+ end
@@ -0,0 +1,29 @@
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 || 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
@@ -1,8 +1,15 @@
1
- require "thecore_ui_commons/engine"
2
-
3
- require 'thecore_backend_commons'
1
+ require 'thecore_background_jobs' # This brings backend commons also.
4
2
  # Rails
5
3
  require 'serviceworker-rails'
4
+ require "groupdate"
5
+ require "apexcharts"
6
+
7
+ require 'concerns/thecore_ui_commons_user'
8
+
9
+ # require 'helpers/thecore_ui_commons_helper'
10
+ # require 'helpers/charts_helper'
11
+
12
+ require "thecore_ui_commons/engine"
6
13
 
7
14
  module ThecoreUiCommons
8
15
  # Your code goes here...
@@ -1,3 +1,3 @@
1
1
  module ThecoreUiCommons
2
- VERSION = '2.1.5'
2
+ VERSION = '2.1.10'
3
3
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thecore_ui_commons
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.5
4
+ version: 2.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-12 00:00:00.000000000 Z
11
+ date: 2020-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: thecore_backend_commons
14
+ name: thecore_background_jobs
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.2'
19
+ version: '2.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: '2.2'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: serviceworker-rails
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: groupdate
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: apexcharts
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.1'
41
69
  description: Engine to serve configurations and rails module useful for all the UIs.
42
70
  email:
43
71
  - gabriele.tassoni@gmail.com
@@ -49,15 +77,67 @@ files:
49
77
  - README.md
50
78
  - Rakefile
51
79
  - app/assets/config/thecore_ui_commons_manifest.js
80
+ - app/assets/images/android-chrome-192x192.png
81
+ - app/assets/images/android-chrome-512x512.png
82
+ - app/assets/images/apple-touch-icon.png
83
+ - app/assets/images/favicon-16x16.png
84
+ - app/assets/images/favicon-32x32.png
85
+ - app/assets/images/favicon.ico
86
+ - app/assets/images/logo.png
87
+ - app/assets/images/mstile-150x150.png
88
+ - app/assets/images/safari-pinned-tab.svg
89
+ - app/assets/images/up-arrow.png
90
+ - app/assets/javascripts/browserconfig.xml
91
+ - app/assets/javascripts/ie.js
92
+ - app/assets/javascripts/manifest.json
93
+ - app/assets/javascripts/pages.coffee
94
+ - app/assets/javascripts/thecore_ui_commons/thecore.js
95
+ - app/assets/javascripts/timer.js
52
96
  - app/assets/stylesheets/thecore_ui_commons/actiontext.scss
97
+ - app/assets/stylesheets/thecore_ui_commons/thecore.scss
53
98
  - app/controllers/application_controller.rb
54
- - app/controllers/pages_controller.rb
55
99
  - app/views/active_storage/blobs/_blob.html.erb
100
+ - app/views/contact_mailer/contact_message.html.erb
101
+ - app/views/devise/confirmations/new.html.erb
102
+ - app/views/devise/mailer/confirmation_instructions.html.erb
103
+ - app/views/devise/mailer/password_change.html.erb
104
+ - app/views/devise/mailer/reset_password_instructions.html.erb
105
+ - app/views/devise/mailer/unlock_instructions.html.erb
106
+ - app/views/devise/menu/_login_items.html.erb
107
+ - app/views/devise/passwords/edit.html.erb
108
+ - app/views/devise/passwords/new.html.erb
109
+ - app/views/devise/registrations/edit.html.erb
110
+ - app/views/devise/registrations/new.html.erb
111
+ - app/views/devise/sessions/new.html.erb
112
+ - app/views/devise/shared/_links.html.erb
113
+ - app/views/devise/unlocks/new.html.erb
114
+ - app/views/kaminari/_first_page.html.erb
115
+ - app/views/kaminari/_gap.html.erb
116
+ - app/views/kaminari/_last_page.html.erb
117
+ - app/views/kaminari/_next_page.html.erb
118
+ - app/views/kaminari/_page.html.erb
119
+ - app/views/kaminari/_paginator.html.erb
120
+ - app/views/kaminari/_prev_page.html.erb
121
+ - app/views/layouts/_footer.html.erb
122
+ - app/views/layouts/_messages.html.erb
123
+ - app/views/layouts/_navigation.html.erb
124
+ - app/views/layouts/_navigation_links.html.erb
125
+ - app/views/layouts/mailer.html.erb
126
+ - app/views/layouts/mailer.text.erb
127
+ - app/views/layouts/thecore.html.erb
128
+ - config/initializers/charts_helper.rb
56
129
  - config/initializers/thecore_ui_commons_application_config.rb
130
+ - config/initializers/thecore_ui_commons_helper.rb
131
+ - config/locales/en.ra_settings.yml
57
132
  - config/locales/en.simple_form.yml
133
+ - config/locales/en.yml
134
+ - config/locales/it.ra_settings.yml
58
135
  - config/locales/it.simple_form.yml
136
+ - config/locales/it.yml
59
137
  - config/routes.rb
60
- - db/migrate/20190920115550_create_action_text_tables.action_text.rb
138
+ - db/migrate/20200515070620_add_username_to_user.rb
139
+ - db/migrate/20200515132932_add_rememberable_to_user.rb
140
+ - lib/concerns/thecore_ui_commons_user.rb
61
141
  - lib/tasks/thecore_ui_commons_tasks.rake
62
142
  - lib/thecore_ui_commons.rb
63
143
  - lib/thecore_ui_commons/engine.rb
@@ -1,43 +0,0 @@
1
- class PagesController < ApplicationController
2
- before_action :authenticate_user!, only: [
3
- :inside, :contact
4
- ]
5
-
6
- # So the static link navigation can be set runtime (yes it's an hack
7
- # since I have to set this dynamically at runtime, using a class
8
- # continously re-evaluated)
9
- RailsAdmin.config do |config|
10
- config.navigation_static_label = I18n.t('admin.links.label')
11
- end
12
-
13
- def home
14
- end
15
-
16
- def inside
17
- end
18
-
19
-
20
- def email
21
- @name = params[:name]
22
- @email = params[:email]
23
- @message = params[:message]
24
-
25
- if @name.blank?
26
- flash[:alert] = "Please enter your name before sending your message. Thank you."
27
- render :contact
28
- elsif @email.blank? || @email.scan(/\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i).size < 1
29
- flash[:alert] = "You must provide a valid email address before sending your message. Thank you."
30
- render :contact
31
- elsif @message.blank? || @message.length < 10
32
- flash[:alert] = "Your message is empty. Requires at least 10 characters. Nothing to send."
33
- render :contact
34
- elsif @message.scan(/<a href=/).size > 0 || @message.scan(/\[url=/).size > 0 || @message.scan(/\[link=/).size > 0 || @message.scan(/http:\/\//).size > 0
35
- flash[:alert] = "You can't send links. Thank you for your understanding."
36
- render :contact
37
- else
38
- ContactMailer.contact_message(@name,@email,@message).deliver_now
39
- redirect_to root_path, notice: "Your message was sent. Thank you."
40
- end
41
- end
42
-
43
- end
@@ -1,14 +0,0 @@
1
- # This migration comes from action_text (originally 20180528164100)
2
- class CreateActionTextTables < ActiveRecord::Migration[6.0]
3
- def change
4
- create_table :action_text_rich_texts do |t|
5
- t.string :name, null: false
6
- t.text :body, size: :long
7
- t.references :record, null: false, polymorphic: true, index: false
8
-
9
- t.timestamps
10
-
11
- t.index [ :record_type, :record_id, :name ], name: "index_action_text_rich_texts_uniqueness", unique: true
12
- end
13
- end
14
- end