tramway-admin 2.0.0.2 → 2.1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -0
- data/app/assets/javascripts/tramway/admin/application.js +5 -0
- data/app/helpers/tramway/admin/additional_buttons_builder.rb +6 -12
- data/app/views/tramway/admin/shared/_show.html.haml +2 -7
- data/lib/tramway/admin.rb +0 -2
- data/lib/tramway/admin/version.rb +1 -1
- metadata +3 -10
- data/lib/tramway/admin/additional_buttons.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99512a972c7b09fb25d9e7eb49eaea97fbf14eaad9606564355fb073caa47460
|
4
|
+
data.tar.gz: 51de0b468682137a3e1007250530b773bd25f91dadae816dcffd8730f55ba1e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b3326faa5c8799ebff7dbfaf7172b83da7449c20bdd0b6280a816125e604845af54dde91d6115e47ff112506f6a9bc2403a2a9176392cd36a7d4a368f012262
|
7
|
+
data.tar.gz: 991381dfc3e15f393cca4a8f77ed276474d8f4ee3c9e9be073842aa06f07e311d32c1b8e67968c00e3db3357ec15fc1e1a9acde27da3ed1af49f855fb0e4ef6d
|
data/README.md
CHANGED
@@ -526,6 +526,29 @@ en:
|
|
526
526
|
my_dropdown: Very important dropdown
|
527
527
|
```
|
528
528
|
|
529
|
+
## Additional buttons to the show view
|
530
|
+
|
531
|
+
You can additional buttons to the header of show view of your model. Just add its configuration to the decorator
|
532
|
+
|
533
|
+
*app/decorators/your_model_decorator.rb*
|
534
|
+
```ruby
|
535
|
+
class YourModelDecorator < Tramway::Core::ApplicationDecorator
|
536
|
+
def additional_buttons
|
537
|
+
{
|
538
|
+
show: [ # means that this buttons will be shown on show view only
|
539
|
+
{
|
540
|
+
url: ::Tramway::Export::Engine.routes.url_helpers.export_path(object.id, model: object.class, collection: :tasks),
|
541
|
+
inner: lambda do # inner HTML you want to see in the button
|
542
|
+
fa_icon 'file-excel'
|
543
|
+
end,
|
544
|
+
color: :success # bootstrap button color
|
545
|
+
}
|
546
|
+
]
|
547
|
+
}
|
548
|
+
end
|
549
|
+
end
|
550
|
+
```
|
551
|
+
|
529
552
|
## Errors
|
530
553
|
|
531
554
|
* **Model or Form is not available** - `params[:model]` or `params[:form]` is empty **OR** current user does not have access to model or form in `params[:model]` or `params[:form]`
|
@@ -1,17 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Tramway::Admin::AdditionalButtonsBuilder
|
4
|
-
def
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
button[:url], method: button[:method], class: "btn btn-#{button[:color]} btn-xs", **options
|
11
|
-
) do
|
12
|
-
button[:text]
|
13
|
-
end
|
14
|
-
)
|
15
|
-
end
|
4
|
+
def build_button(button)
|
5
|
+
options = button[:options] || {}
|
6
|
+
style = 'margin-right: 8px'
|
7
|
+
concat(link_to(button[:url], method: button[:method], class: "btn btn-#{button[:color]} btn-xs", style: style, **options) do
|
8
|
+
button[:inner]&.call
|
9
|
+
end)
|
16
10
|
end
|
17
11
|
end
|
@@ -1,11 +1,6 @@
|
|
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, view: :show, project: @application.name)
|
6
|
-
-# .btn-group-vertical
|
7
|
-
-# - buttons.each do |button|
|
8
|
-
-# - build_buttons button.call object
|
9
4
|
.page-header
|
10
5
|
.row
|
11
6
|
.col-md-12
|
@@ -15,9 +10,9 @@
|
|
15
10
|
= link_to fa_icon('pencil-alt'), edit_path, class: 'btn btn-warning btn-xs'
|
16
11
|
- if public_path(object)
|
17
12
|
= link_to fa_icon(:share), public_path(object), class: 'btn btn-primary btn-xs'
|
18
|
-
- buttons =
|
13
|
+
- buttons = object.additional_buttons[:show]
|
19
14
|
- buttons&.each do |button|
|
20
|
-
-
|
15
|
+
- build_button button
|
21
16
|
%hr
|
22
17
|
.row
|
23
18
|
%table.table.table-striped.table-bordered
|
data/lib/tramway/admin.rb
CHANGED
@@ -5,7 +5,6 @@ require 'tramway/admin/engine'
|
|
5
5
|
require 'tramway/admin/singleton_models'
|
6
6
|
require 'tramway/admin/records_models'
|
7
7
|
require 'tramway/admin/forms'
|
8
|
-
require 'tramway/admin/additional_buttons'
|
9
8
|
require 'tramway/admin/notifications'
|
10
9
|
require 'tramway/admin/welcome_page_actions'
|
11
10
|
require 'tramway/admin/navbar'
|
@@ -20,7 +19,6 @@ module Tramway
|
|
20
19
|
class << self
|
21
20
|
include ::Tramway::Admin::RecordsModels
|
22
21
|
include ::Tramway::Admin::SingletonModels
|
23
|
-
include ::Tramway::Admin::AdditionalButtons
|
24
22
|
include ::Tramway::Admin::Forms
|
25
23
|
include ::Tramway::Admin::Notifications
|
26
24
|
include ::Tramway::Admin::WelcomePageActions
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tramway-admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Kalashnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tramway-core
|
@@ -110,9 +110,6 @@ dependencies:
|
|
110
110
|
name: kaminari
|
111
111
|
requirement: !ruby/object:Gem::Requirement
|
112
112
|
requirements:
|
113
|
-
- - "~>"
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
version: 1.1.1
|
116
113
|
- - ">="
|
117
114
|
- !ruby/object:Gem::Version
|
118
115
|
version: 1.1.1
|
@@ -120,9 +117,6 @@ dependencies:
|
|
120
117
|
prerelease: false
|
121
118
|
version_requirements: !ruby/object:Gem::Requirement
|
122
119
|
requirements:
|
123
|
-
- - "~>"
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: 1.1.1
|
126
120
|
- - ">="
|
127
121
|
- !ruby/object:Gem::Version
|
128
122
|
version: 1.1.1
|
@@ -302,7 +296,6 @@ files:
|
|
302
296
|
- config/routes.rb
|
303
297
|
- lib/tasks/tramway/admin_tasks.rake
|
304
298
|
- lib/tramway/admin.rb
|
305
|
-
- lib/tramway/admin/additional_buttons.rb
|
306
299
|
- lib/tramway/admin/engine.rb
|
307
300
|
- lib/tramway/admin/forms.rb
|
308
301
|
- lib/tramway/admin/generators/install_generator.rb
|
@@ -336,7 +329,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
336
329
|
- !ruby/object:Gem::Version
|
337
330
|
version: '0'
|
338
331
|
requirements: []
|
339
|
-
rubygems_version: 3.1.
|
332
|
+
rubygems_version: 3.1.4
|
340
333
|
signing_key:
|
341
334
|
specification_version: 4
|
342
335
|
summary: Engine for admin
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Tramway::Admin::AdditionalButtons
|
4
|
-
def set_additional_buttons(buttons, project:)
|
5
|
-
@additional_buttons ||= {}
|
6
|
-
@additional_buttons[project] ||= {}
|
7
|
-
@additional_buttons[project].merge! buttons
|
8
|
-
end
|
9
|
-
|
10
|
-
def additional_buttons(view: nil, record: nil, project: nil)
|
11
|
-
@additional_buttons&.with_indifferent_access&.dig project, record, view
|
12
|
-
end
|
13
|
-
end
|