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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38545a69081961dbceae8db18e98f49405462bf332aeb852d001bf5332e0b127
4
- data.tar.gz: 7f5e3942cba417767b231005efeddb6ea042ba8b91728946a286f4a97079d00e
3
+ metadata.gz: cd63c513ef46a0b0b80b96cc51f28c1ba69f1bc70c5e426da288887f4885cad7
4
+ data.tar.gz: '03884d0741244a9d7d33b0716c351fa68c05f9df09eb8a6b16994315c2940cfc'
5
5
  SHA512:
6
- metadata.gz: d1e1eaf40a6b789dd0d9c368fa193152c484791397a259222d89a06f623332501e0b3af3d3d8a63d5785b6e8b9eed610bb091e632406b3a8b025cc2535878bfd
7
- data.tar.gz: 14acb2b150a1dd2c5e0ecee95668c73ec93fab2805095d0918a95b36d21534e5afdd640a9f4afd3c02671231ebca72dc5d9e789e3fd534377eafe5d94e766cd8
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
@@ -99,5 +99,9 @@ module Tramway::Admin
99
99
  }
100
100
  end
101
101
  end
102
+
103
+ def is_there_any_filters?(model_class)
104
+ decorator_class(model_class).list_filters&.any?
105
+ end
102
106
  end
103
107
  end
@@ -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
- %br
28
- %br
29
- .btn-group{ data: { toggle: :buttons } }
30
- - record.model.class.state_machines.keys.each do |state_method|
31
- - unless state_method == :state
32
- = 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 }
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'
@@ -1,4 +1,4 @@
1
- - if searchable_model?(model_class) || decorator_class(model_class).list_filters.any?
1
+ - if searchable_model?(model_class) || is_there_any_filters?(model_class)
2
2
  .col-md-8
3
3
  .search
4
4
  = form_tag records_path, class: 'form-inline', method: :get do |f|
@@ -5,7 +5,7 @@
5
5
  - tabs = get_collection
6
6
  .page-header
7
7
  .row
8
- - search_render_show = searchable_model?(model_class) || decorator_class(model_class).list_filters.any?
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 attribute_name.to_s != 'state' && object.model.class.state_machines.keys.include?(attribute_name.to_sym)
8
- = 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 }
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 }
@@ -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.to_s
12
+ @available_models[project][role].merge! model
13
13
  end
14
14
  end
15
15
  @available_models = @available_models.with_indifferent_access
@@ -0,0 +1,5 @@
1
+ module Tramway::Admin::TramwayModelHelper
2
+ def tramway_model?(model_class)
3
+ model_class.ancestors.include? Tramway::Core::ApplicationRecord
4
+ end
5
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Admin
5
- VERSION = '1.32.2.5'
5
+ VERSION = '1.33'
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.32.2.5
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