tramway-admin 1.29 → 1.29.1

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: 01f0328f6e541ce9e16109272920c6878a90dc89577e21a85614f66c54ea29e9
4
- data.tar.gz: c457d21a480b855835a3e55192ba771a2af6a28e8ba663910e2cad3e7e1b86d6
3
+ metadata.gz: 00672d9c37c12d6db9a756f2c1b638db56573a8bac4c70800587ad7e0b940791
4
+ data.tar.gz: 016fd98a4e239d12b24f583a5e2c06f555a85eccfa93fef877c51539289c8071
5
5
  SHA512:
6
- metadata.gz: 63da1c38228db68cf4863e3461953a495141f99d2e8452f5c605d2150803dea6dd942196bb8ff57d36c3ec386570b52377708e119c2497f1aaa203d8137a33a7
7
- data.tar.gz: 2944d285dd6ad080b573eb368b752cc47f1a4012cc2c6294c5e54bd72527a1d41a6c3d504bfa7407b7a2a66d6aab28252d22ccdce9ffeb69c86866aa05c25c66
6
+ metadata.gz: ce14fecc444d493d0b2edb9ff0014a9c392f81cf14bb01da2be6d398427a48d595a1d7609c605fb82f255ca4b8466833aa3923745429a2c78d4058de58b73d48
7
+ data.tar.gz: 275b6d832b5be2f9a894e111b8faf8faea832687482eb779b0a778b23898640142f3b998f4b90869e51bc1d6019f4b829ca8a6ec3c0d5fcb10d19518a303a51d
@@ -2,54 +2,16 @@
2
2
 
3
3
  module Tramway::Admin::AdditionalButtonsBuilder
4
4
  def build_buttons(additional_buttons)
5
- if additional_buttons
6
- additional_buttons = additional_buttons.is_a?(Hash) ? [additional_buttons] : additional_buttons
7
- additional_buttons.each do |button|
8
- concat(
9
- link_to(
10
- send(
11
- "#{button[:action]}_record_path",
12
- build_params(button[:params]).merge(model: button[:model_name])
13
- ),
14
- class: "btn btn-#{button_color(button[:action])} btn-xs"
15
- ) do
16
- button[:text] || button_icon(button[:action])
17
- end
18
- )
19
- end
5
+ additional_buttons = additional_buttons.is_a?(Hash) ? [additional_buttons] : additional_buttons
6
+ additional_buttons.each do |button|
7
+ options = button[:options] || {}
8
+ concat(
9
+ link_to(
10
+ button[:url], method: button[:method], class: "btn btn-#{button[:color]} btn-xs", **options
11
+ ) do
12
+ button[:text]
13
+ end
14
+ )
20
15
  end
21
- nil
22
- end
23
-
24
- private
25
-
26
- BUTTON_STYLES = {
27
- new: { color: :success, icon: :plus },
28
- create: { color: :success, icon: :plus },
29
- edit: { color: :warning, icon: :pencil },
30
- update: { color: :warning, icon: :pencil },
31
- delete: { color: :danger, icon: :remove }
32
- }.freeze
33
-
34
- def button_color(action)
35
- BUTTON_STYLES[action][:color]
36
- end
37
-
38
- def button_icon(action)
39
- BUTTON_STYLES[action][:icon]
40
- end
41
-
42
- def build_params(params)
43
- param = {}
44
- record = @record || @singleton
45
- params.each do |model_name, model_attributes|
46
- attributes = {}
47
- model_attributes.each do |name, value|
48
- value = record.model.instance_exec(&value) if value.is_a? Proc
49
- attributes.merge! name => value
50
- end
51
- param.merge! model_name => attributes
52
- end
53
- param
54
16
  end
55
17
  end
@@ -1,11 +1,11 @@
1
1
  - default_page_title ||= nil; on_site_link ||= nil
2
2
  - current_title = default_page_title || "#{object.name} | #{model_class.model_name.human.pluralize(:ru)}"
3
3
  - title current_title
4
- = content_for :sidebar do
5
- - buttons = ::Tramway::Admin.additional_buttons(record: object.model.class.to_s, view: :show)
6
- - if buttons
7
- .btn-group-vertical
8
- = build_buttons buttons
4
+ -#= content_for :sidebar do
5
+ -# - buttons = ::Tramway::Admin.additional_buttons(record: object.model.class, view: :show, project: @application.name)
6
+ -# .btn-group-vertical
7
+ -# - buttons.each do |button|
8
+ -# - build_buttons button.call object
9
9
  .page-header
10
10
  .row
11
11
  .col-md-12
@@ -15,6 +15,9 @@
15
15
  = link_to fa_icon('pencil-alt'), edit_path, class: 'btn btn-warning btn-xs'
16
16
  - if public_path(object)
17
17
  = link_to fa_icon(:share), public_path(object), class: 'btn btn-primary btn-xs'
18
+ - buttons = ::Tramway::Admin.additional_buttons(record: object.model.class, view: :show, project: @application.name)
19
+ - buttons&.each do |button|
20
+ - build_buttons button.call object
18
21
  %hr
19
22
  .row
20
23
  %table.table.table-striped.table-bordered
@@ -8,6 +8,6 @@ module Tramway::Admin::AdditionalButtons
8
8
  end
9
9
 
10
10
  def additional_buttons(view: nil, record: nil, project: nil)
11
- @additional_buttons&.dig record, view
11
+ @additional_buttons&.with_indifferent_access&.dig project, record, view
12
12
  end
13
13
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Admin
5
- VERSION = '1.29'
5
+ VERSION = '1.29.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.29'
4
+ version: 1.29.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov