tramway-admin 1.29 → 1.29.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00672d9c37c12d6db9a756f2c1b638db56573a8bac4c70800587ad7e0b940791
|
4
|
+
data.tar.gz: 016fd98a4e239d12b24f583a5e2c06f555a85eccfa93fef877c51539289c8071
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
5
|
-
- buttons = ::Tramway::Admin.additional_buttons(record: object.model.class
|
6
|
-
-
|
7
|
-
.
|
8
|
-
|
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
|