motor-admin 0.2.36 → 0.2.41

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: 2247da648b9add9fcaab6b8688289ae7a9908e9b8fb23ead4f5acc5917257491
4
- data.tar.gz: b14931d1e8ce8a71cd4e686b29517ddf84a599f8d46d7d1f4dab5c3fca9a5e0f
3
+ metadata.gz: a51c13e10df9707cb2130c580660133d07a543c55e97157ebe8660099ff602e6
4
+ data.tar.gz: 81a887350a6fec48cae6fa7c0d74d1efaae29456685e7d2bb63d8347d6aab7e4
5
5
  SHA512:
6
- metadata.gz: e1bfce35dcbc6f43985617e1c4cb47be55b00b10aa3df1bc07c6ceb28c18e9351af69f7467b2f52ac30fdd13ab62910ae20d978a6a02f4d361343333f526701c
7
- data.tar.gz: 4a3671b36ba7704f58140dcfa1db3c0798a7395a57e1ad20648a0898ad026f0dc03444136cea87998d57a7cc8ada53b35a84ac23ed1a2d3e90421b0ba2ac8432
6
+ metadata.gz: f9d5172d6d3014145c39f3640def2f7dbedf4b79dd0c2021562933d6da5caff0430f95334a30cb8c3fed6afa884753d1bd268cf28f8171fe9e03fc3d755d1049
7
+ data.tar.gz: 8a56bce2407c3314d41ecb5d977e275da6b36fd40ac41468912ded8d02b386f3af27b4410e1be0e6c4b4c6b99736239326c663f4aadac4b9f5e30c5bcf30c2f3
@@ -287,3 +287,12 @@ en:
287
287
  sql: SQL
288
288
  api: API
289
289
  searchable_columns: Searchable columns
290
+ validate: Validate
291
+ error_message: Error message
292
+ validation_regexp: Validation RegExp
293
+ regexp: RegExp
294
+ message: Message
295
+ should_be_a_valid_regexp: Should be a valid RegExp string
296
+ order_by: Order by
297
+ ascending: Ascending
298
+ descending: Descending
@@ -287,6 +287,15 @@ es:
287
287
  sql: SQL
288
288
  api: API
289
289
  searchable_columns: Columnas de búsqueda
290
+ validate: Validar
291
+ error_message: Mensaje de error
292
+ validation_regexp: Validación RegExp
293
+ regexp: RegExp
294
+ message: Mensaje
295
+ should_be_a_valid_regexp: Debe ser una cadena RegExp válida
296
+ order_by: Ordenar por
297
+ ascending: Ascendente
298
+ descending: Descendente
290
299
  i:
291
300
  locale: es
292
301
  select:
@@ -283,6 +283,15 @@ pt:
283
283
  sql: SQL
284
284
  api: API
285
285
  searchable_columns: Colunas pesquisáveis
286
+ validate: Validar
287
+ error_message: Mensagem de erro
288
+ validation_regexp: Validação RegExp
289
+ regexp: RegExp
290
+ message: Mensagem
291
+ should_be_a_valid_regexp: Deve ser uma string RegExp válida
292
+ order_by: Encomendar por
293
+ ascending: Ascendente
294
+ descending: Decrescente
286
295
  i:
287
296
  locale: pt
288
297
  select:
@@ -87,9 +87,9 @@ module Motor
87
87
 
88
88
  def name_already_exists?(alert)
89
89
  if alert.new_record?
90
- Alert.exists?(name: alert.name)
90
+ Alert.exists?(name: alert.name, deleted_at: nil)
91
91
  else
92
- Alert.exists?(['name = ? AND id != ?', alert.name, alert.id])
92
+ Alert.exists?(['name = ? AND id != ? AND deleted_at IS NULL', alert.name, alert.id])
93
93
  end
94
94
  end
95
95
  end
@@ -26,7 +26,17 @@ module Motor
26
26
 
27
27
  return rel unless scope_configs
28
28
 
29
- ApiQuery::Filter.call(rel, scope_configs[:preferences][:filter])
29
+ rel = ApiQuery::Filter.call(rel, scope_configs[:preferences][:filter])
30
+
31
+ apply_order(rel, scope_configs[:preferences][:sort])
32
+ end
33
+
34
+ def apply_order(rel, params)
35
+ return rel if params.blank?
36
+
37
+ sort_key, sort_order = params.values_at(:key, :order)
38
+
39
+ rel.order(sort_key => sort_order)
30
40
  end
31
41
  end
32
42
  end
@@ -16,7 +16,7 @@ module Motor
16
16
 
17
17
  selected_columns ||= columns.first(SELECT_COLUMNS_AMOUNT)
18
18
 
19
- ([model.primary_key] + selected_columns).sort
19
+ ([model.primary_key] + selected_columns).compact.sort
20
20
  end
21
21
 
22
22
  def find_searchable_columns(model)
@@ -63,9 +63,9 @@ module Motor
63
63
 
64
64
  def title_already_exists?(dashboard)
65
65
  if dashboard.new_record?
66
- Motor::Dashboard.exists?(title: dashboard.title)
66
+ Motor::Dashboard.exists?(title: dashboard.title, deleted_at: nil)
67
67
  else
68
- Motor::Dashboard.exists?(['title = ? AND id != ?', dashboard.title, dashboard.id])
68
+ Motor::Dashboard.exists?(['title = ? AND id != ? AND deleted_at IS NULL', dashboard.title, dashboard.id])
69
69
  end
70
70
  end
71
71
  end
@@ -63,9 +63,9 @@ module Motor
63
63
 
64
64
  def name_already_exists?(form)
65
65
  if form.new_record?
66
- Motor::Form.exists?(['name = ?', form.name])
66
+ Motor::Form.exists?(['name = ? AND deleted_at IS NULL', form.name])
67
67
  else
68
- Motor::Form.exists?(['name = ? AND id != ?', form.name, form.id])
68
+ Motor::Form.exists?(['name = ? AND id != ? AND deleted_at IS NULL', form.name, form.id])
69
69
  end
70
70
  end
71
71
  end
@@ -63,9 +63,9 @@ module Motor
63
63
 
64
64
  def name_already_exists?(query)
65
65
  if query.new_record?
66
- Query.exists?(name: query.name)
66
+ Query.exists?(name: query.name, deleted_at: nil)
67
67
  else
68
- Query.exists?(['name = ? AND id != ?', query.name, query.id])
68
+ Query.exists?(['name = ? AND id != ? AND deleted_at IS NULL', query.name, query.id])
69
69
  end
70
70
  end
71
71
  end
@@ -194,7 +194,9 @@ module Motor
194
194
  def normalize_statement_for_sql(statement)
195
195
  sql, _, attributes = statement
196
196
 
197
- sql = ActiveRecord::Base.sanitize_sql([sql.gsub(STATEMENT_VARIABLE_REGEXP, '?'), attributes.map(&:value)])
197
+ sql = ActiveRecord::Base.send(:replace_bind_variables,
198
+ sql.gsub(STATEMENT_VARIABLE_REGEXP, '?'),
199
+ attributes.map(&:value))
198
200
 
199
201
  [sql, 'SQL', attributes]
200
202
  end
@@ -41,7 +41,7 @@ module Motor
41
41
  def define_default_scope(klass, config)
42
42
  return klass if config[:custom_sql].blank?
43
43
 
44
- klass.instance_variable_set(:@__motor_custom_sql, config[:custom_sql].squish)
44
+ klass.instance_variable_set(:@__motor_custom_sql, config[:custom_sql].squish.delete_suffix(';'))
45
45
 
46
46
  klass.instance_eval do
47
47
  default_scope do
@@ -4,7 +4,8 @@ module Motor
4
4
  module Resources
5
5
  RESOURCE_ATTRS = %w[display_name display_column icon custom_sql visible display_primary_key
6
6
  searchable_columns].freeze
7
- COLUMN_ATTRS = %w[name display_name column_type access_type default_value reference virtual format].freeze
7
+ COLUMN_ATTRS = %w[name display_name column_type access_type default_value reference virtual format
8
+ validators].freeze
8
9
  ASSOCIATION_ATTRS = %w[name display_name model_name icon visible foreign_key primary_key options virtual
9
10
  polymorphic slug].freeze
10
11
  SCOPE_ATTRS = %w[name display_name scope_type preferences visible].freeze
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.36'
4
+ VERSION = '0.2.41'
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-348da28bba8cc2014150.css.gz": "main-348da28bba8cc2014150.css.gz",
2605
- "main-348da28bba8cc2014150.js.LICENSE.txt": "main-348da28bba8cc2014150.js.LICENSE.txt",
2606
- "main-348da28bba8cc2014150.js.gz": "main-348da28bba8cc2014150.js.gz",
2607
- "main.css": "main-348da28bba8cc2014150.css",
2608
- "main.js": "main-348da28bba8cc2014150.js"
2604
+ "main-f7a83db6d8381e2638a1.css.gz": "main-f7a83db6d8381e2638a1.css.gz",
2605
+ "main-f7a83db6d8381e2638a1.js.LICENSE.txt": "main-f7a83db6d8381e2638a1.js.LICENSE.txt",
2606
+ "main-f7a83db6d8381e2638a1.js.gz": "main-f7a83db6d8381e2638a1.js.gz",
2607
+ "main.css": "main-f7a83db6d8381e2638a1.css",
2608
+ "main.js": "main-f7a83db6d8381e2638a1.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.36
4
+ version: 0.2.41
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-12-17 00:00:00.000000000 Z
11
+ date: 2021-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord-filter
@@ -1526,8 +1526,8 @@ files:
1526
1526
  - ui/dist/icons/zoom-money.svg.gz
1527
1527
  - ui/dist/icons/zoom-out.svg.gz
1528
1528
  - ui/dist/icons/zoom-question.svg.gz
1529
- - ui/dist/main-348da28bba8cc2014150.css.gz
1530
- - ui/dist/main-348da28bba8cc2014150.js.gz
1529
+ - ui/dist/main-f7a83db6d8381e2638a1.css.gz
1530
+ - ui/dist/main-f7a83db6d8381e2638a1.js.gz
1531
1531
  - ui/dist/manifest.json
1532
1532
  homepage:
1533
1533
  licenses: