motor-admin 0.2.19 → 0.2.23

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: e1189d1c955046a61940254f58bc78e3743e51e912a6c1e1443ffa9d4df8b22e
4
- data.tar.gz: 69cbcc3fcc34ee51c03979896f6862ada18d9bd410c297141d14959009e5f38f
3
+ metadata.gz: bf26c048e51c1aa9f5b43c2356fef76668d00c6f0c5de13a9fe52db8dfc25ee1
4
+ data.tar.gz: 3b0ffc4caf26e63b813fa93a777254e0117c2e9484c71cca539f384868eae68a
5
5
  SHA512:
6
- metadata.gz: 57f991559988e88d2a8abc00bc302946dc986fa75b5e6bc6953a1d05552810339a95d5ef5aae8b0c3bc98c806d7ecfc1b2bacf051471fd2088e10594c8e6fed6
7
- data.tar.gz: d72ff24ee69ea6db86585efb92dfab69582fb6c712d12c97b19bbd16f5a506b41e72f95d1fea05a153fa430e9a1c014542db8e684dc91dd948027ae9464a5b73
6
+ metadata.gz: 01ad26d6c0d7a9c74143051a8d11efbcc35c953d1995998826d68e87ac60a8d4c65ec3a7a6cbb1c68df4e14fb06b3885244a9d7721f7a4adcb01545eca51d707
7
+ data.tar.gz: 80ca3dea1aae9d8c477a63a51d8023d0365d2f5a96b15d157f8035af842369667dd2356c2d8759d0be8264694eb3b04e875b6ed001a940b7c5d5b1cdb6ec218c
@@ -4,7 +4,7 @@ module Motor
4
4
  module CurrentAbility
5
5
  def current_ability
6
6
  @current_ability ||=
7
- if defined?(Motor::Ability) && current_user
7
+ if defined?(Motor::Ability)
8
8
  klass = Motor::Ability.dup.tap do |k|
9
9
  k.prepend(Motor::CancanUtils::AbilityPatch)
10
10
  end
@@ -276,3 +276,5 @@ en:
276
276
  user_dropdown: User dropdown
277
277
  upload: Upload
278
278
  there_is_nothing_here_yet: There is nothing here yet 🤷‍♂️
279
+ is_null: Is null
280
+ is_not_null: Is not null
@@ -276,6 +276,8 @@ es:
276
276
  user_dropdown: Despliegue del usuario
277
277
  upload: Subir a
278
278
  there_is_nothing_here_yet: Todavía no hay nada aquí 🤷‍♂️
279
+ is_null: Es nulo
280
+ is_not_null: No es nulo
279
281
  i:
280
282
  locale: es
281
283
  select:
@@ -272,6 +272,8 @@ pt:
272
272
  user_dropdown: Desistência do utilizador
273
273
  upload: Carregar
274
274
  there_is_nothing_here_yet: Ainda não há nada aqui 🤷‍♂️
275
+ is_null: É nulo
276
+ is_not_null: Não é nulo
275
277
  i:
276
278
  locale: pt
277
279
  select:
@@ -16,7 +16,7 @@ module Motor
16
16
  def generate_csv_for_relation(relation, reset_limit: false)
17
17
  relation = relation.limit(nil).offset(nil) if reset_limit
18
18
 
19
- result = relation.klass.connection.exec_query(relation.to_sql)
19
+ result = load_query_for_csv(relation)
20
20
 
21
21
  CSV.generate do |csv|
22
22
  csv << result.columns
@@ -24,6 +24,14 @@ module Motor
24
24
  result.rows.each { |row| csv << row }
25
25
  end
26
26
  end
27
+
28
+ def load_query_for_csv(relation)
29
+ model_name = relation.klass.model_name.human(count: :many, default: relation.klass.name.titleize.pluralize)
30
+
31
+ query = Motor::Query.find_by(name: "Export #{model_name}")
32
+
33
+ relation.klass.connection.exec_query(query&.sql_body || relation.to_sql)
34
+ end
27
35
  end
28
36
  end
29
37
 
@@ -67,6 +67,10 @@ module Motor
67
67
  ['ilike', value.sub(LIKE_FILTER_VALUE_REGEXP, '\1%')]
68
68
  when 'ends_with'
69
69
  ['ilike', value.sub(LIKE_FILTER_VALUE_REGEXP, '%\1')]
70
+ when 'eqnull'
71
+ ['eq', nil]
72
+ when 'neqnull'
73
+ ['neq', nil]
70
74
  else
71
75
  [action, value]
72
76
  end
@@ -142,6 +142,11 @@ module Motor
142
142
 
143
143
  return { select_options: enum.keys } if enum
144
144
 
145
+ return {} if column.name == 'year'
146
+
147
+ return { number_format: true } if !column.name.match?(/_(?:id|year)\z/) &&
148
+ %i[integer float].include?(column.type)
149
+
145
150
  {}
146
151
  end
147
152
 
@@ -157,7 +157,7 @@ module Motor
157
157
  expresion = table.project(table[Arel.star])
158
158
  expresion = expresion.where(arel_filters) if arel_filters.present?
159
159
 
160
- expresion.take(limit.to_i).to_sql
160
+ expresion.take(limit.to_i).to_sql.delete('"')
161
161
  end
162
162
 
163
163
  # @param filters [Hash]
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.2.19'
4
+ VERSION = '0.2.23'
5
5
  end
@@ -2601,9 +2601,9 @@
2601
2601
  "icons/zoom-out.svg.gz": "icons/zoom-out.svg.gz",
2602
2602
  "icons/zoom-question.svg": "icons/zoom-question.svg",
2603
2603
  "icons/zoom-question.svg.gz": "icons/zoom-question.svg.gz",
2604
- "main-25e14f5ae8855e7368e7.css.gz": "main-25e14f5ae8855e7368e7.css.gz",
2605
- "main-25e14f5ae8855e7368e7.js.LICENSE.txt": "main-25e14f5ae8855e7368e7.js.LICENSE.txt",
2606
- "main-25e14f5ae8855e7368e7.js.gz": "main-25e14f5ae8855e7368e7.js.gz",
2607
- "main.css": "main-25e14f5ae8855e7368e7.css",
2608
- "main.js": "main-25e14f5ae8855e7368e7.js"
2604
+ "main-6570149f716eae327cdc.css.gz": "main-6570149f716eae327cdc.css.gz",
2605
+ "main-6570149f716eae327cdc.js.LICENSE.txt": "main-6570149f716eae327cdc.js.LICENSE.txt",
2606
+ "main-6570149f716eae327cdc.js.gz": "main-6570149f716eae327cdc.js.gz",
2607
+ "main.css": "main-6570149f716eae327cdc.css",
2608
+ "main.js": "main-6570149f716eae327cdc.js"
2609
2609
  }
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.2.19
4
+ version: 0.2.23
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-11-03 00:00:00.000000000 Z
11
+ date: 2021-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord-filter
@@ -1525,8 +1525,8 @@ files:
1525
1525
  - ui/dist/icons/zoom-money.svg.gz
1526
1526
  - ui/dist/icons/zoom-out.svg.gz
1527
1527
  - ui/dist/icons/zoom-question.svg.gz
1528
- - ui/dist/main-25e14f5ae8855e7368e7.css.gz
1529
- - ui/dist/main-25e14f5ae8855e7368e7.js.gz
1528
+ - ui/dist/main-6570149f716eae327cdc.css.gz
1529
+ - ui/dist/main-6570149f716eae327cdc.js.gz
1530
1530
  - ui/dist/manifest.json
1531
1531
  homepage:
1532
1532
  licenses: