tramway-admin 1.32.1.2 → 1.32.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4dee5f088f753288890da09af68a6f8aab3b0d2370e6d94a6dc6e81b1bb17017
4
- data.tar.gz: 3deb15305b766085f0613ab29833f53c201c845dc4149a91b1ef318d7d071e51
3
+ metadata.gz: dff80b796cc083c3bd26c9985b3369045d3ea8f983e978dfee3880fc550a443c
4
+ data.tar.gz: 15f65fae673edaff024ae501e3bbbbd864536f73cda32f4c79421ea2cbbee1af
5
5
  SHA512:
6
- metadata.gz: f9ae53792e9fbd87d56d771025b274e857216697846bd6a84ca3ef157768aced9dc634efff9397f554c000760be1134a894bcc4d35ab5f67b287e996a56601b7
7
- data.tar.gz: 647c711d44088f38df6605cf166b2f671826423be4baf403f40c759538cf789bc0660c203a155fa1340c9b1f2da0418a81689935d4b94138173c6a5156d181da
6
+ metadata.gz: 2f49d2bbc8a8962a5bd8f99ba38715ee78f37c478a7b025adfabb922afaad03b41c8384f1bb3440a7cfa2a486f2d8a4c1f91b7965f49c11b73d853f2c2c03236
7
+ data.tar.gz: 2ba60b25129fd4ec52e9d27044fa7f94bf42abd45bd22469f173f8ef30755794bfe6e3d285cbc00428b138939b8764dd54af21d38a404152719eb0a2d284d82f
data/README.md CHANGED
@@ -94,11 +94,25 @@ Tramway::Admin.navbar_structure(
94
94
  *app/decorators/your_model_decorator.rb*
95
95
  ```ruby
96
96
  class YourModelDecorator < Tramway::Core::ApplicationDecorator
97
+ decorate_associations :messages, :posts
98
+
97
99
  class << self
98
100
  def collections
99
101
  [ :all, :scope1, :scope2 ]
100
102
  end
101
103
 
104
+ def list_attributes
105
+ [ :begin_date, :end_date ]
106
+ end
107
+
108
+ def show_attributes
109
+ [ :begin_date, :end_date ]
110
+ end
111
+
112
+ def show_associations
113
+ [ :messages ]
114
+ end
115
+
102
116
  def list_filters
103
117
  {
104
118
  filter_name: {
@@ -118,7 +132,7 @@ class YourModelDecorator < Tramway::Core::ApplicationDecorator
118
132
  end
119
133
  end
120
134
 
121
- delegate :title, to: :object
135
+ delegate_attributes :title
122
136
  end
123
137
  ```
124
138
 
@@ -127,6 +141,9 @@ end
127
141
  * `list_filters` method returns hash of filters where:
128
142
  * select_collection - collection which will be in the select of filter. It must be compatible with [options_for_select](https://apidock.com/rails/ActionView/Helpers/FormOptionsHelper/options_for_select) method
129
143
  * query - some Active Record query which be used as a filter of records
144
+ * `list_attributes` method returns array of attributes which will be shown in index page. If empty only `name` will be shown
145
+ * `show_attributes` method returns array of attributes which will be shown in show page. If empty all attributes of the model will be shown
146
+ * `show_associations` method returns array of decorated associations which will be show in show page. If empty no associations will be shown
130
147
 
131
148
  Filters naming:
132
149
 
@@ -5,7 +5,12 @@ class Tramway::Admin::RecordsController < ::Tramway::Admin::ApplicationControlle
5
5
  scope = params[:scope].present? ? params[:scope] : :all
6
6
  records = model_class.active.order(id: :desc).send scope
7
7
  records = records.full_text_search params[:search] if params[:search].present?
8
- records = records.ransack(params[:filter]).result if params[:filter].present?
8
+ if params[:filter].present?
9
+ if params[:filter].is_a? String
10
+ params[:filter] = JSON.parse params[:filter]
11
+ end
12
+ records = records.ransack(params[:filter]).result
13
+ end
9
14
  params[:list_filters]&.each do |filter, value|
10
15
  case decorator_class.list_filters[filter.to_sym][:type]
11
16
  when :select
@@ -6,7 +6,7 @@
6
6
  = text_field_tag :search, params[:search], class: 'text form-control'
7
7
  = hidden_field_tag :model, params[:model]
8
8
  = hidden_field_tag :scope, params[:scope]
9
- = hidden_field_tag :filter, params[:filter]
9
+ = hidden_field_tag :filter, (params[:filter].is_a?(ActionController::Parameters) ? params[:filter].permit!.to_h.to_json : params[:filter])
10
10
  - decorator_class(model_class).list_filters.each_slice(3) do |slice|
11
11
  .row-fluid.filters
12
12
  - slice.each do |filter|
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Admin
5
- VERSION = '1.32.1.2'
5
+ VERSION = '1.32.1.3'
6
6
  end
7
7
  end
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: 1.32.1.2
4
+ version: 1.32.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-26 00:00:00.000000000 Z
11
+ date: 2020-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tramway-core