tramway-admin 1.20 → 1.20.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 702d94df42264ec7071d530f1ebc90de8ac9aaf381509476b1cb0b3b4761bdfb
4
- data.tar.gz: ba7ef0a0220664b4db23509cd29a445cc29c7c7ac39a6ab799a8fe43370fa38c
3
+ metadata.gz: 6aee5db3732b7fc7b50bd8f3ea9c8c0a3995c2b8c672cad75f81835e67672a58
4
+ data.tar.gz: 65d394e432da53939aa369352bea71ce381a01bc13d5520eba4998e9680a3571
5
5
  SHA512:
6
- metadata.gz: 007abdd45e940b99aca62a1b0ef3ec6106d9be2a039f2f4a426adb510edd6efb8915ddda257d6d0939edb672427982a6df36b637c7f90b11a7442a768a544dd7
7
- data.tar.gz: 60e457aad9172456e90dc276588cd9b80179facd370441e550349c678eba13d108be043a4fa62e63ff2a96523e67a470b5ddd3af4c87e7d12d519b76dff85bf2
6
+ metadata.gz: bf76db73861ba917c79e4e876c2e6570d323d9e58fc25e3428106ddff283e3bb4ce9b07688e88f15ea4112462a2c07f1be539880585fc4efda30cca339f98888
7
+ data.tar.gz: 0bd22bce1018e38c3905239e57652148530f8230bd0310246b568d19162e834d0788582a461aa624ff050a280e2b36e7911f635bd14264c3998046653d88ada8
@@ -32,7 +32,7 @@ module Tramway
32
32
  def collections_counts
33
33
  @counts = decorator_class.collections.reduce({}) do |hash, collection|
34
34
  records = model_class.active.send(collection)
35
- records = records.send "#{current_user.role}_scope", current_user.id unless current_user.role.admin?
35
+ records = records.send "#{current_user.role}_scope", current_user.id
36
36
  hash.merge! collection => records.count
37
37
  end
38
38
  end
@@ -44,7 +44,9 @@ module Tramway
44
44
  end
45
45
 
46
46
  def notifications
47
- @notifications ||= Tramway::Admin.notifications
47
+ @notifications ||= Tramway::Admin.notificable_queries&.reduce({}) do |hash, notification|
48
+ hash.merge! notification[0] => notification[1].call(current_user)
49
+ end
48
50
  @notifications
49
51
  end
50
52
 
@@ -6,7 +6,7 @@ class Tramway::Admin::RecordsController < ::Tramway::Admin::ApplicationControlle
6
6
  records = model_class.active.order(id: :desc).send scope
7
7
  records = records.full_text_search params[:search] if params[:search]
8
8
  records = records.ransack(params[:filter]).result if params[:filter].present?
9
- records = records.send "#{current_user.role}_scope", current_user.id unless current_user.role.admin?
9
+ records = records.send "#{current_user.role}_scope", current_user.id
10
10
  @records = decorator_class.decorate records.page params[:page]
11
11
  end
12
12
 
@@ -3,7 +3,7 @@
3
3
  class Tramway::User::User < ::Tramway::Core::ApplicationRecord
4
4
  has_secure_password # FIXME: remove repeating from tramway-user
5
5
 
6
- enumerize :role, in: %i[user admin], default: :user
6
+ enumerize :role, in: %i[user admin], default: :admin
7
7
 
8
8
  def admin?
9
9
  role.admin?
data/lib/tramway/admin.rb CHANGED
@@ -4,6 +4,7 @@ require 'tramway/admin/engine'
4
4
  require 'tramway/admin/singleton_models'
5
5
  require 'tramway/admin/records_models'
6
6
  require 'tramway/admin/additional_buttons'
7
+ require 'tramway/admin/notifications'
7
8
  require 'tramway/error'
8
9
 
9
10
  module Tramway
@@ -11,10 +12,10 @@ module Tramway
11
12
 
12
13
  module Admin
13
14
  class << self
14
-
15
15
  include ::Tramway::Admin::RecordsModels
16
16
  include ::Tramway::Admin::SingletonModels
17
17
  include ::Tramway::Admin::AdditionalButtons
18
+ include ::Tramway::Admin::Notifications
18
19
 
19
20
  attr_reader :customized_admin_navbar
20
21
 
@@ -30,17 +31,6 @@ module Tramway
30
31
  def get_models_by_key(checked_models, project, role)
31
32
  checked_models && checked_models != [] && checked_models[project][role] || []
32
33
  end
33
-
34
- def set_notificable_queries(**queries)
35
- @notificable_queries ||= {}
36
- @notificable_queries.merge! queries
37
- end
38
-
39
- def notifications
40
- @notificable_queries&.reduce({}) do |hash, notification|
41
- hash.merge! notification[0] => notification[1].call
42
- end
43
- end
44
34
  end
45
35
  end
46
36
  end
@@ -0,0 +1,10 @@
1
+ module Tramway::Admin::Notifications
2
+ def set_notificable_queries(**queries)
3
+ @notificable_queries ||= {}
4
+ @notificable_queries.merge! queries
5
+ end
6
+
7
+ def notificable_queries
8
+ @notificable_queries
9
+ end
10
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Admin
5
- VERSION = '1.20'
5
+ VERSION = '1.20.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.20'
4
+ version: 1.20.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
@@ -270,6 +270,7 @@ files:
270
270
  - lib/tramway/admin.rb
271
271
  - lib/tramway/admin/additional_buttons.rb
272
272
  - lib/tramway/admin/engine.rb
273
+ - lib/tramway/admin/notifications.rb
273
274
  - lib/tramway/admin/record_routes_helper.rb
274
275
  - lib/tramway/admin/records_models.rb
275
276
  - lib/tramway/admin/singleton_models.rb