tramway-admin 2.0.0.1 → 2.1.0.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 +4 -4
- data/README.md +26 -0
- data/app/assets/javascripts/tramway/admin/application.js +5 -0
- data/app/helpers/tramway/admin/additional_buttons_builder.rb +5 -12
- data/app/helpers/tramway/admin/records_helper.rb +1 -1
- 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: e1f1df8f432adde2da452b7fd80c31455b60c0f9780bf2fbef6e5d2df32bbf93
|
4
|
+
data.tar.gz: f89edad193cc1af91d7ed050d0e00e12b5a8b64b0539cdb5236ece6fe9e11cae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3f6f4afc8b26b1eca9bb2d514c123e4402db45ce485703ab16c78c7414bea00e5dccc4ca2db06a04503f920a3c522bddd65e024a5e903aac0fadf23ddb646c2
|
7
|
+
data.tar.gz: 1a7d2edf8c8c43336915d02fd95efc21fcbc6618e8a6cde73ca62513d66149bda94614b5fac4e43819a9af908a74ea65943d3af63799fe2db3e8136b4256b64c
|
data/README.md
CHANGED
@@ -420,6 +420,9 @@ def state
|
|
420
420
|
state_machine_view object, :state
|
421
421
|
end
|
422
422
|
```
|
423
|
+
|
424
|
+
It takes locales from `I18n.t("state_machines.#{model_name}.#{state_machine_name}.states.#{state_value}")`
|
425
|
+
|
423
426
|
#### image_view
|
424
427
|
Returns an image in a particular format depending on the parameters of the original image file
|
425
428
|
|
@@ -523,6 +526,29 @@ en:
|
|
523
526
|
my_dropdown: Very important dropdown
|
524
527
|
```
|
525
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
|
+
|
526
552
|
## Errors
|
527
553
|
|
528
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,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Tramway::Admin::AdditionalButtonsBuilder
|
4
|
-
def
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
)
|
15
|
-
end
|
4
|
+
def build_button(button)
|
5
|
+
options = button[:options] || {}
|
6
|
+
concat(link_to(button[:url], method: button[:method], class: "btn btn-#{button[:color]} btn-xs", **options) do
|
7
|
+
button[:inner]&.call
|
8
|
+
end)
|
16
9
|
end
|
17
10
|
end
|
@@ -95,7 +95,7 @@ module Tramway::Admin
|
|
95
95
|
new_record_path model: association.class_name,
|
96
96
|
redirect: current_model_record_path(object.model),
|
97
97
|
association.options[:class_name].underscore => {
|
98
|
-
as || object.model.class.name.underscore => object.id
|
98
|
+
as || object.model.class.name.underscore.gsub('/', '_') => object.id
|
99
99
|
}
|
100
100
|
end
|
101
101
|
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.1
|
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-09 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
|