para 0.12.1 → 0.12.2

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: 5ee25a77e578b14d822cbf8827991f6c6920c580acddeb2120d0e6a2570795fa
4
- data.tar.gz: 41ee3d94327eeeacfb5ee1da6430956d5862ed0e242d0d09180bef828e46a921
3
+ metadata.gz: e5f4c1a9a889b3800d615452bda318bac05fc3d49b88c612af3cd2a714cb3fe8
4
+ data.tar.gz: a665a5affd7b2a3938baf185c41221eed335b42be7dabf8ff1d17145212dfecb
5
5
  SHA512:
6
- metadata.gz: acd659f13038e225325293d30820d115f5054ca6ba36cccc44e5404bc2e5d0e01226815b41aa38bc3f8c76f6299891c621c4e7d1d2306eaaa76a9f1c97f24891
7
- data.tar.gz: 7da8328b9591a785d922ddd3f12c61f95d57f7c3e8a327b5667ad22cbfabeeaaabac1c7c8d0e6ed50dee7bc48ceb7e172aac92b3a9593b6919678e4b957bcc1a
6
+ metadata.gz: 7a71ed497361f0b442965a7331159d9c2c2dfd7f745674f8698f446e1a6651f3bdfacd96f314f2e00d657ba13390f55ca317221aca45284d6770419bd820be79
7
+ data.tar.gz: 6e1bb4347edeacd0f067dc401e77ce72926ed9ae9d4e61326799376d3ca7063db196a275c58b79d96c29e21ba5004d56f8cdbb976c98dfac22f91522b352955a
@@ -31,12 +31,15 @@
31
31
  content: "\f0dc";
32
32
  opacity: .3;
33
33
  }
34
+
34
35
  .sort_link.asc:before {
35
- content: "\f0d7";
36
+ content: "\f0d8";
36
37
  }
38
+
37
39
  .sort_link.desc:before {
38
- content: "\f0d8";
40
+ content: "\f0d7";
39
41
  }
42
+
40
43
  .sort_link.asc.disabled:before,
41
44
  .sort_link.desc.disabled:before {
42
45
  opacity: .1;
@@ -22,11 +22,11 @@ function trackProgressFor(element, jobStatusUrl) {
22
22
  }
23
23
 
24
24
  document.documentElement.addEventListener('turbo:frame-load', function(e) {
25
- if (e.target.id != 'para_admin_modal') return;
25
+ if (e.target.id !== 'para_admin_modal') return;
26
26
 
27
27
  loadedElement = e.target.childNodes[0];
28
28
 
29
- var jobStatusUrl = loadedElement && loadedElement.dataset.jobStatusUrl;
29
+ var jobStatusUrl = loadedElement?.dataset?.jobStatusUrl;
30
30
  if (!jobStatusUrl) return;
31
31
 
32
32
  trackProgressFor(loadedElement, jobStatusUrl);
@@ -14,8 +14,6 @@ import "./vendor/jquery.sortable";
14
14
 
15
15
  import "./application";
16
16
 
17
- import "./lib/page-loading";
18
-
19
17
  import "./inputs/material-input";
20
18
  import "./inputs/multi-select-input";
21
19
  import "./inputs/nested_many";
@@ -56,6 +56,10 @@ module Para
56
56
 
57
57
  reference = model.reflect_on_all_associations.find do |association|
58
58
  association.foreign_key == name
59
+ rescue ArgumentError
60
+ # This can happen when the association is polymorphic and the foreign key can't
61
+ # be determined, in this case, we just ignore the association.
62
+ false
59
63
  end
60
64
 
61
65
  if reference
@@ -75,12 +79,11 @@ module Para
75
79
  true
76
80
  end
77
81
 
78
- #
79
82
  def searchable?
80
83
  options[:searchable] != false && (
81
- [:string, :text].include?(type.to_sym) && !name.match(/password/)
84
+ %i[string text].include?(type.to_sym) && !name.match(/password/)
82
85
  ) && (
83
- !model.respond_to?(:ransackable_attributes) ||
86
+ !model.respond_to?(:ransackable_attributes) ||
84
87
  model.ransackable_attributes.include?(name.to_s)
85
88
  )
86
89
  end
@@ -94,7 +97,7 @@ module Para
94
97
  def field_options
95
98
  self.class._field_options.each_with_object({}) do |params, hash|
96
99
  value = send(params[:method_name])
97
- hash[params[:key]] = value if value != nil || params[:options][:allow_nil]
100
+ hash[params[:key]] = value if !value.nil? || params[:options][:allow_nil]
98
101
  end
99
102
  end
100
103
 
@@ -42,8 +42,10 @@ module Para
42
42
  # attributes mappings above
43
43
  next if AttributeField::RelationField == fields_hash[name]
44
44
 
45
- # Remove foreign key, if existing, from fields
46
- fields_hash.delete(reflection.foreign_key.to_s)
45
+ unless through_polymorphic_reflection?(reflection)
46
+ # Remove foreign key, if existing, from fields
47
+ fields_hash.delete(reflection.foreign_key.to_s)
48
+ end
47
49
 
48
50
  # Do not process polymorphic belongs to for now ...
49
51
  if reflection.options[:polymorphic] == true
@@ -52,27 +54,25 @@ module Para
52
54
  end
53
55
 
54
56
  if model.nested_attributes_options[name]
55
- if reflection.collection?
56
- fields_hash[name] = AttributeField::NestedManyField.new(
57
- model, name: name, type: 'has_many', field_type: 'nested_many'
58
- )
59
- else
60
- fields_hash[name] = AttributeField::NestedOneField.new(
61
- model, name: name, type: 'belongs_to', field_type: 'nested_one'
62
- )
63
- end
64
- else
65
- if reflection.collection?
66
- remove_counter_cache_column!(name, reflection)
57
+ fields_hash[name] = if reflection.collection?
58
+ AttributeField::NestedManyField.new(
59
+ model, name: name, type: 'has_many', field_type: 'nested_many'
60
+ )
61
+ else
62
+ AttributeField::NestedOneField.new(
63
+ model, name: name, type: 'belongs_to', field_type: 'nested_one'
64
+ )
65
+ end
66
+ elsif reflection.collection?
67
+ remove_counter_cache_column!(name, reflection)
67
68
 
68
- fields_hash[name] = AttributeField::HasManyField.new(
69
- model, name: name, type: 'has_many', field_type: 'multi_select'
70
- )
71
- elsif !reflection.options[:through]
72
- fields_hash[name] = AttributeField::BelongsToField.new(
73
- model, name: name, type: 'belongs_to', field_type: 'selectize'
74
- )
75
- end
69
+ fields_hash[name] = AttributeField::HasManyField.new(
70
+ model, name: name, type: 'has_many', field_type: 'multi_select'
71
+ )
72
+ elsif !reflection.options[:through]
73
+ fields_hash[name] = AttributeField::BelongsToField.new(
74
+ model, name: name, type: 'belongs_to', field_type: 'selectize'
75
+ )
76
76
  end
77
77
  end
78
78
  end
@@ -84,14 +84,23 @@ module Para
84
84
  return unless (inverse_relation = reflection.inverse_of)
85
85
  return unless (counter_name = inverse_relation.options[:counter_cache])
86
86
 
87
- counter_name = if String === counter_name
88
- counter_name
89
- else
90
- "#{ name }_count"
91
- end
87
+ counter_name = if counter_name.is_a?(String)
88
+ counter_name
89
+ else
90
+ "#{name}_count"
91
+ end
92
92
 
93
93
  fields_hash.delete(counter_name)
94
94
  end
95
+
96
+ def through_polymorphic_reflection?(reflection)
97
+ reflection.through_reflection? && (
98
+ (
99
+ reflection.through_reflection.options[:polymorphic] &&
100
+ !reflection.through_reflection.options[:source_type]
101
+ ) || through_polymorphic_reflection?(reflection.through_reflection)
102
+ )
103
+ end
95
104
  end
96
105
  end
97
106
  end
data/lib/para/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Para
4
- VERSION = '0.12.1'
4
+ VERSION = '0.12.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: para
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 0.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valentin Ballestrino
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-06 00:00:00.000000000 Z
11
+ date: 2024-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_decorator
@@ -487,7 +487,6 @@ files:
487
487
  - app/javascripts/para/inputs/multi-select-input.js
488
488
  - app/javascripts/para/inputs/nested_many.js
489
489
  - app/javascripts/para/lib/fetch.js
490
- - app/javascripts/para/lib/page-loading.js
491
490
  - app/javascripts/para/plugins-includes.js.erb
492
491
  - app/javascripts/para/simple_form_extension/colorpicker.js
493
492
  - app/javascripts/para/simple_form_extension/datetimepicker.js
@@ -1,42 +0,0 @@
1
- Para.PageLoading = class PageLoading {
2
- constructor() {
3
- this.start = this.start.bind(this);
4
- this.stop = this.stop.bind(this);
5
- }
6
-
7
- start() {
8
- return this.addLoadingMarkup();
9
- }
10
-
11
- stop() {
12
- return this.removeLoadingMarkup();
13
- }
14
-
15
- addLoadingMarkup() {
16
- $('<div/>', {
17
- class: 'loading-overlay',
18
- 'data-loading-overlay': true
19
- }).prependTo('body');
20
-
21
- $('<div/>', {
22
- class: 'loading-spinner',
23
- 'data-loading-spinner': true
24
- }).prependTo('body');
25
- }
26
-
27
- removeLoadingMarkup() {
28
- $('[data-loading-overlay]').remove();
29
- return $('[data-loading-spinner]').remove();
30
- }
31
-
32
- };
33
-
34
- // Global loading manager allowing to
35
- Para.loadingManager = new Para.PageLoading();
36
-
37
- $(document).on('turbo:before-fetch-request', Para.loadingManager.start);
38
-
39
- $(document).on('turbo:load turbo:frame-load turbo:before-stream-render turbo:frame-missing turbo:fetch-request-error', function() {
40
- Para.loadingManager.stop();
41
- return $('body').on('submit', '[data-para-form]:not([data-remote])', Para.loadingManager.start);
42
- });