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 +4 -4
- data/app/controllers/tramway/admin/application_controller.rb +4 -2
- data/app/controllers/tramway/admin/records_controller.rb +1 -1
- data/app/models/tramway/user/user.rb +1 -1
- data/lib/tramway/admin.rb +2 -12
- data/lib/tramway/admin/notifications.rb +10 -0
- data/lib/tramway/admin/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6aee5db3732b7fc7b50bd8f3ea9c8c0a3995c2b8c672cad75f81835e67672a58
|
4
|
+
data.tar.gz: 65d394e432da53939aa369352bea71ce381a01bc13d5520eba4998e9680a3571
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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.
|
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
|
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: :
|
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
|
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:
|
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
|