cats_core 1.0.10 → 1.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: c511fd3cb4ee9da3373af2685f3d0afc00b5398c8e4383aaa0fe3d07ddfe5ffc
4
- data.tar.gz: dc4d3bc44ef05e623f02456574e1c038efaca0d0fe001c75023717afe4e2ba71
3
+ metadata.gz: 32c70181bd52a346e553ef01325a87cb1c72ba19d831bc1b9ebe6e735b792a32
4
+ data.tar.gz: 00f2b8a381e9d969547fe5a16338b8f02ad374f0dfe40db14b1074614877e6bf
5
5
  SHA512:
6
- metadata.gz: 04c8d868354002f73de37919c6fa4acf069bc4f88dfe7c471dd1b54253ce7bc23721b0c2ba351a8860a8998e2aa8967581fbe8ddf4e198c011dff1125e41cfcb
7
- data.tar.gz: 44a86aaf44b09fcb2bfcc44d38d19220dbcb04f59303508bc308d54535da0d60c4b020b992291a5cc8702d8d3501d935d89332aa3f92407e3c8563b990ad4e8e
6
+ metadata.gz: 5810cd3ad764b6e64d5ec9ba1a86591b0bd25d26051aea58da57ec8bb2fd768d62566aa08092d82a045b46c6af0327d57a40b2dc4062dae69456686135cb9e35
7
+ data.tar.gz: d25a81609c51dbce17369920073f40295d88c93f91533199e795fc06362f690d36e3c754d5b86c3b2893fc7212b02334e9a02eea820d5565c8a5dc11b4ba317f
@@ -0,0 +1,19 @@
1
+ module Cats
2
+ module Core
3
+ class MenusController < ApplicationController
4
+ before_action :set_service
5
+
6
+ def index
7
+ menu = @service.fetch_menu(current_user)
8
+ data = ActiveModelSerializers::SerializableResource.new(menu, each_serializer: RoleMenuSerializer)
9
+ render json: { success: true, data: data }
10
+ end
11
+
12
+ private
13
+
14
+ def set_service
15
+ @service = MenuService.new
16
+ end
17
+ end
18
+ end
19
+ end
@@ -14,6 +14,9 @@ module Cats
14
14
 
15
15
  errors.add(:base, 'Application module does not match for role and menu')
16
16
  end
17
+
18
+ delegate(:label, to: :menu, prefix: false)
19
+ delegate(:icon, to: :menu, prefix: false)
17
20
  end
18
21
  end
19
22
  end
@@ -1,9 +1,20 @@
1
1
  # This is a simple notification class which delivers a
2
2
  # message via database delivery method. It requires a
3
- # +msg+ parameter to instantiate, which represents the
3
+ # +body+ and +title+ parameter to instantiate, which represents the
4
4
  # text message to deliver.
5
- class SimpleNotification < Noticed::Base
6
- deliver_by :database
5
+ module Cats
6
+ module Core
7
+ class SimpleNotification < Noticed::Base
8
+ deliver_by :database
7
9
 
8
- param :msg
10
+ param :body
11
+ param :title
12
+
13
+ def message
14
+ title = params[:title]
15
+ body = params[:body]
16
+ { title: title, body: body }
17
+ end
18
+ end
19
+ end
9
20
  end
@@ -0,0 +1,11 @@
1
+ module Cats
2
+ module Core
3
+ class RoleMenuSerializer < ActiveModel::Serializer
4
+ attributes :id, :label, :icon, :description, :menu_items
5
+
6
+ def menu_items
7
+ object.menu.menu_items
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ module Cats
2
+ module Core
3
+ class MenuService
4
+ def fetch_menu(user)
5
+ user.roles.map(&:role_menus).flatten
6
+ end
7
+ end
8
+ end
9
+ end
data/config/routes.rb CHANGED
@@ -2,7 +2,8 @@ Cats::Core::Engine.routes.draw do
2
2
  post '/login', controller: :access, action: :login
3
3
  get '/notifications/unread', controller: :notifications, action: :unread
4
4
  get '/notifications/read', controller: :notifications, action: :read
5
-
5
+
6
+ resources :menus, only: [:index]
6
7
  resources :notifications, only: [:index] do
7
8
  member do
8
9
  post 'mark_as_read', controller: :notifications, action: :mark_as_read
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.0.10'.freeze
3
+ VERSION = '1.0.11'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cats_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-05 00:00:00.000000000 Z
11
+ date: 2021-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -218,6 +218,7 @@ files:
218
218
  - Rakefile
219
219
  - app/controllers/cats/core/access_controller.rb
220
220
  - app/controllers/cats/core/application_controller.rb
221
+ - app/controllers/cats/core/menus_controller.rb
221
222
  - app/controllers/cats/core/notifications_controller.rb
222
223
  - app/controllers/cats/core/roles_controller.rb
223
224
  - app/controllers/cats/core/users_controller.rb
@@ -245,6 +246,8 @@ files:
245
246
  - app/models/cats/core/way_bill.rb
246
247
  - app/models/cats/core/way_bill_item.rb
247
248
  - app/notifications/cats/core/simple_notification.rb
249
+ - app/serializers/cats/core/role_menu_serializer.rb
250
+ - app/services/cats/core/menu_service.rb
248
251
  - app/services/cats/core/notification_service.rb
249
252
  - app/services/cats/core/token_auth_service.rb
250
253
  - config/routes.rb