motor-admin 0.1.67 → 0.1.68

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: 33a7b2555fe1a052dc108c562080e56bc1f7850cde53bfcd94958a1f1254d867
4
- data.tar.gz: 3f3bdf80802854525a0115ed8bdf404657f59e486a43d0ad171f4a55e3b2d3de
3
+ metadata.gz: 5e112faacd3ff1806f8ac4c0520b87a649ea98d004a1745cdc1e3de7040aea92
4
+ data.tar.gz: 1d5ef79ead4b16cadab43e0e970cc8a6ae0bf553fa5526a961df6a83edb4157a
5
5
  SHA512:
6
- metadata.gz: 4708009ff1464c24214afac7fc9711c5f0a50c153e75a1ca4fedf60a78d8a72567eb4ba8bc7c3228ae5569590b638b4fb89d839418512eb00a26e79b0ba424c8
7
- data.tar.gz: c0af8ed7425f902438a29ebc41dab4ca52c55def49e505e9e18416bbaecfd58e318631e64f3b63090610d22fe37d0886a2c30dcc3a6f957fd78ac5c99dc38d2e
6
+ metadata.gz: 59b77ef4d3546c94361644598d12d832eb5fdcf354c8edd2ce0d2918b1115b38d8011080ecd402dcf5d2c79130dc9b1daf87ec707f4ccbbf19c80ee5ff5ef595
7
+ data.tar.gz: a725435fe5d93e71d8d0bde3e40429f8a1a3538b5053035338ceb08c62a0ac7936d990fcc0d08ef126d437046cd54c14e8f070a9f50fb60c8a0362eae4a3849f
data/README.md CHANGED
@@ -27,6 +27,7 @@ $ rails motor:install && rake db:migrate
27
27
 
28
28
  * [Customizable CRUD](#customizable-crud)
29
29
  * [Custom actions](#custom-actions)
30
+ * [Virtual attributes](#virtual-attributes)
30
31
  * [Forms builder](#forms-builder)
31
32
  * [SQL queries](#sql-queries)
32
33
  * [Data visualization](#data-visualization)
@@ -54,6 +55,22 @@ Data displayed on the resource page can be completely customized via [SQL querie
54
55
 
55
56
  Custom resource actions can be added via Active Record method call, API endpoint, or [custom forms](#forms-builder). Also, it's possible to override default create/update/delete actions.
56
57
 
58
+ ### Virtual attributes
59
+
60
+ Any ActiveRecord model method or attribute can be exposed to the admin panel by adding a new column with the name that matches the method name from the resource model:
61
+
62
+ ```ruby
63
+ class Customer < ApplicationRecord
64
+ has_many :orders
65
+
66
+ def lifetime_value
67
+ orders.sum(&:total_price)
68
+ end
69
+ end
70
+ ```
71
+
72
+ ![Virtual attribute](https://user-images.githubusercontent.com/5418788/123373683-76321c80-d58e-11eb-914d-675444b7eb2a.png)
73
+
57
74
  ### Forms Builder
58
75
 
59
76
  ![Custom form](https://user-images.githubusercontent.com/5418788/119264008-1391dd80-bbea-11eb-9f14-cb405e77fb60.png)
@@ -5,3 +5,14 @@ ActiveRecord::Filter.module_eval do
5
5
  @filters ||= HashWithIndifferentAccess.new
6
6
  end
7
7
  end
8
+
9
+ if Rails::VERSION::MAJOR == 6
10
+ ActiveRecord::Relation::Filter.module_eval do
11
+ def build_arel(aliases = nil)
12
+ arel = super
13
+ my_alias_tracker = ActiveRecord::Associations::AliasTracker.create(connection, table.name, [])
14
+ build_filters(arel, my_alias_tracker)
15
+ arel
16
+ end
17
+ end
18
+ end
data/lib/motor/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Motor
4
- VERSION = '0.1.67'
4
+ VERSION = '0.1.68'
5
5
  end
@@ -2068,11 +2068,11 @@
2068
2068
  "mail-opened.svg": "icons/mail-opened.svg",
2069
2069
  "mail.svg": "icons/mail.svg",
2070
2070
  "mailbox.svg": "icons/mailbox.svg",
2071
- "main-8ec599650b99734d9348.css.gz": "main-8ec599650b99734d9348.css.gz",
2072
- "main-8ec599650b99734d9348.js.LICENSE.txt": "main-8ec599650b99734d9348.js.LICENSE.txt",
2073
- "main-8ec599650b99734d9348.js.gz": "main-8ec599650b99734d9348.js.gz",
2074
- "main.css": "main-8ec599650b99734d9348.css",
2075
- "main.js": "main-8ec599650b99734d9348.js",
2071
+ "main-9350c345bc241fd25d73.css.gz": "main-9350c345bc241fd25d73.css.gz",
2072
+ "main-9350c345bc241fd25d73.js.LICENSE.txt": "main-9350c345bc241fd25d73.js.LICENSE.txt",
2073
+ "main-9350c345bc241fd25d73.js.gz": "main-9350c345bc241fd25d73.js.gz",
2074
+ "main.css": "main-9350c345bc241fd25d73.css",
2075
+ "main.js": "main-9350c345bc241fd25d73.js",
2076
2076
  "man.svg": "icons/man.svg",
2077
2077
  "manual-gearbox.svg": "icons/manual-gearbox.svg",
2078
2078
  "map-2.svg": "icons/map-2.svg",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motor-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.67
4
+ version: 0.1.68
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Matsyburka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-24 00:00:00.000000000 Z
11
+ date: 2021-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord-filter
@@ -1494,8 +1494,8 @@ files:
1494
1494
  - ui/dist/icons/zoom-money.svg.gz
1495
1495
  - ui/dist/icons/zoom-out.svg.gz
1496
1496
  - ui/dist/icons/zoom-question.svg.gz
1497
- - ui/dist/main-8ec599650b99734d9348.css.gz
1498
- - ui/dist/main-8ec599650b99734d9348.js.gz
1497
+ - ui/dist/main-9350c345bc241fd25d73.css.gz
1498
+ - ui/dist/main-9350c345bc241fd25d73.js.gz
1499
1499
  - ui/dist/manifest.json
1500
1500
  homepage:
1501
1501
  licenses: