tramway-admin 1.32.2.5 → 1.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +31 -0
- data/app/helpers/tramway/admin/application_helper.rb +1 -0
- data/app/helpers/tramway/admin/records_helper.rb +4 -0
- data/app/views/tramway/admin/records/_list.html.haml +7 -6
- data/app/views/tramway/admin/records/_search.html.haml +1 -1
- data/app/views/tramway/admin/records/index.html.haml +1 -1
- data/app/views/tramway/admin/shared/show/_attribute_tr.html.haml +3 -2
- data/lib/tramway/admin.rb +1 -0
- data/lib/tramway/admin/generators/templates/decorator.rb.erb +7 -3
- data/lib/tramway/admin/records_models.rb +1 -1
- data/lib/tramway/admin/tramway_model_helper.rb +5 -0
- data/lib/tramway/admin/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd63c513ef46a0b0b80b96cc51f28c1ba69f1bc70c5e426da288887f4885cad7
|
4
|
+
data.tar.gz: '03884d0741244a9d7d33b0716c351fa68c05f9df09eb8a6b16994315c2940cfc'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 560e2d59668bfe3559a225dc03163bf2a61f032600e05568456d1c10ee97a7a6c0375c1ade4358fa5a536572582ed3c51c27a6f1cf144c433e3db3aaca254157
|
7
|
+
data.tar.gz: 61e0eda22ab3383e748a451a997303d9bd9130e23a7bb6575c056598838994a598642ee5ebcbc748464e47208ef67ba79c26973bea16e50846ff198336cce507
|
data/README.md
CHANGED
@@ -471,5 +471,36 @@ en:
|
|
471
471
|
|
472
472
|
* **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]`
|
473
473
|
|
474
|
+
## Good features
|
475
|
+
|
476
|
+
### Get actions log in admin panel
|
477
|
+
|
478
|
+
Tramway uses [audited](https://github.com/collectiveidea/audited) to log actions of models. That's why all we need it's creating view for model `Audited::Audit`
|
479
|
+
|
480
|
+
#### 1. Add Audited::Audit model to available models
|
481
|
+
|
482
|
+
*config/initializers/tramway.rb*
|
483
|
+
```
|
484
|
+
Tramway::Admin.set_available_models(
|
485
|
+
Audited::Audit,
|
486
|
+
project: :your_project_name
|
487
|
+
)
|
488
|
+
```
|
489
|
+
|
490
|
+
#### 2. Add this model to navbar
|
491
|
+
|
492
|
+
```
|
493
|
+
Tramway::Admin.set_navbar_structure(
|
494
|
+
Audited::Audit,
|
495
|
+
project: :your_project_name
|
496
|
+
)
|
497
|
+
```
|
498
|
+
|
499
|
+
#### 3. Generate decorator for Audited::Audit
|
500
|
+
|
501
|
+
```
|
502
|
+
rails g tramway:admin:model Audited::Audit
|
503
|
+
```
|
504
|
+
|
474
505
|
## License
|
475
506
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
@@ -16,6 +16,7 @@ module Tramway
|
|
16
16
|
include ::Tramway::Admin::ActionsHelper
|
17
17
|
include ::Tramway::Collections::Helper
|
18
18
|
include ::Tramway::Core::CopyToClipboardHelper
|
19
|
+
include ::Tramway::Admin::TramwayModelHelper
|
19
20
|
|
20
21
|
def object_type(object)
|
21
22
|
object_class_name = if object.class.ancestors.include? ::Tramway::Core::ApplicationDecorator
|
@@ -24,10 +24,11 @@
|
|
24
24
|
|
25
25
|
= delete_button url: current_model_record_path(record.id), form_options: { class: :smart_button }, button_options: { class: 'btn btn-xs btn-danger' } do
|
26
26
|
= fa_icon 'trash-alt'
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
-
|
31
|
-
-
|
32
|
-
|
27
|
+
- if tramway_model?(model_class)
|
28
|
+
%br
|
29
|
+
%br
|
30
|
+
.btn-group{ data: { toggle: :buttons } }
|
31
|
+
- record.model.class.state_machines.keys.each do |state_method|
|
32
|
+
- unless state_method == :state
|
33
|
+
= state_events_buttons record, state_method: state_method, model_param_name: :record, controller: 'tramway/admin/records', action: :update, parameters: { redirect: current_model_records_path(page: params[:page], scope: params[:scope], filter: params[:filter], focus: focus_selector(index)), model: record.class.model_name }, button_options: { class: :smart_button }
|
33
34
|
= paginate @records, theme: 'twitter-bootstrap-4'
|
@@ -5,7 +5,7 @@
|
|
5
5
|
- tabs = get_collection
|
6
6
|
.page-header
|
7
7
|
.row
|
8
|
-
- search_render_show = searchable_model?(model_class) ||
|
8
|
+
- search_render_show = searchable_model?(model_class) || is_there_any_filters?(model_class)
|
9
9
|
%div{ class: "col-md-#{search_render_show ? 4 : 12}" }
|
10
10
|
%h1
|
11
11
|
= current_title
|
@@ -4,5 +4,6 @@
|
|
4
4
|
%td
|
5
5
|
= value
|
6
6
|
%td
|
7
|
-
- if
|
8
|
-
|
7
|
+
- if tramway_model?(model_class)
|
8
|
+
- if attribute_name.to_s != 'state' && object.model.class.state_machines.keys.include?(attribute_name.to_sym)
|
9
|
+
= state_events_buttons object, state_method: attribute_name, model_param_name: :record, controller: 'tramway/admin/records', action: :update, parameters: { model: object.class.model_name }, button_options: { class: :smart_button }
|
data/lib/tramway/admin.rb
CHANGED
@@ -11,6 +11,7 @@ require 'tramway/admin/welcome_page_actions'
|
|
11
11
|
require 'tramway/admin/navbar'
|
12
12
|
require 'tramway/error'
|
13
13
|
require 'tramway/admin/generators/install_generator'
|
14
|
+
require 'tramway/admin/tramway_model_helper'
|
14
15
|
|
15
16
|
module Tramway
|
16
17
|
Auth.layout_path = 'tramway/admin/application'
|
@@ -2,6 +2,12 @@ class <%= class_name %>Decorator < Tramway::Core::ApplicationDecorator
|
|
2
2
|
# Associations you want to show in admin dashboard
|
3
3
|
# decorate_associations :messages, :posts
|
4
4
|
|
5
|
+
delegate_attributes(
|
6
|
+
<% attributes.each do |attr| -%>
|
7
|
+
:<%= attr %>,
|
8
|
+
<% end -%>
|
9
|
+
)
|
10
|
+
|
5
11
|
class << self
|
6
12
|
def collections
|
7
13
|
# [ :all, :scope1, :scope2 ]
|
@@ -47,6 +53,4 @@ class <%= class_name %>Decorator < Tramway::Core::ApplicationDecorator
|
|
47
53
|
# }
|
48
54
|
end
|
49
55
|
end
|
50
|
-
|
51
|
-
# delegate_attributes :title
|
52
|
-
end
|
56
|
+
end
|
@@ -9,7 +9,7 @@ module Tramway::Admin::RecordsModels
|
|
9
9
|
if model.class == Class || model.class == String
|
10
10
|
@available_models[project][role].merge! model.to_s => %i[index show update create destroy]
|
11
11
|
elsif model.class == Hash
|
12
|
-
@available_models[project][role].merge! model
|
12
|
+
@available_models[project][role].merge! model
|
13
13
|
end
|
14
14
|
end
|
15
15
|
@available_models = @available_models.with_indifferent_access
|
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.
|
4
|
+
version: '1.33'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Kalashnikov
|
@@ -300,6 +300,7 @@ files:
|
|
300
300
|
- lib/tramway/admin/record_routes_helper.rb
|
301
301
|
- lib/tramway/admin/records_models.rb
|
302
302
|
- lib/tramway/admin/singleton_models.rb
|
303
|
+
- lib/tramway/admin/tramway_model_helper.rb
|
303
304
|
- lib/tramway/admin/version.rb
|
304
305
|
- lib/tramway/admin/welcome_page_actions.rb
|
305
306
|
homepage: https://github.com/kalashnikovisme/tramway-dev
|