ntq_tools 0.4.0 → 0.4.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57781cd3327d2e0c9a4934e818210a94a5869680d6ca88f17920e627a8bcc49b
|
4
|
+
data.tar.gz: aef6ae2230214af398d8a60254430478841d5a83400fe9b80d57764209cdaaad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23710b7d19138ae83c21ea05db99511ff32fd68fd9541d1442d06f926e392922731a2adccb17949920ec6f945d81e003bb09abd70c475d5a0b77d8c96251cfbb
|
7
|
+
data.tar.gz: 18c0103de806aaa82b170bf882c875647c18ac1e855913b0b3ae352a2dae3cf0db1a6b316776c2cfda2a5418128accc7b4fe2b23eea579cf2f70d2b85cc7a13f
|
data/config/routes.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
NtqTools::Engine.routes.draw do
|
2
2
|
resource :translation, only: [:update, :show]
|
3
|
+
get '/translation/refresh' => "translations#refresh"
|
3
4
|
|
4
5
|
if NtqTools.impersonation_enabled && NtqTools.impersonation_user_models.any? && defined?(Devise)
|
5
6
|
get '/impersonation/users' => "impersonation#index"
|
@@ -6,6 +6,8 @@ module NtqTools
|
|
6
6
|
|
7
7
|
def create_type_file
|
8
8
|
singular_name = plural_name.singularize
|
9
|
+
context_name = plural_name.camelcase
|
10
|
+
class_name = singular_name.camelcase
|
9
11
|
return unless defined?(class_name.constantize) && class_name.constantize.respond_to?(:columns_hash)
|
10
12
|
|
11
13
|
definition = []
|
@@ -59,16 +61,16 @@ module NtqTools
|
|
59
61
|
associations = []
|
60
62
|
%i[belongs_to has_one].each do |association_type|
|
61
63
|
class_name.constantize.reflect_on_all_associations(association_type).each do |asso|
|
62
|
-
|
63
|
-
associations << "field :#{asso.name}, Types::#{
|
64
|
+
asso_class_name = asso.options.dig(:class_name) || asso.name.to_s.singularize.camelcase
|
65
|
+
associations << "field :#{asso.name}, Types::#{asso_class_name.downcase.pluralize.camelcase}::#{asso_class_name}Type"
|
64
66
|
end
|
65
67
|
end
|
66
68
|
[:has_many].each do |association_type|
|
67
69
|
class_name.constantize.reflect_on_all_associations(association_type).each do |asso|
|
68
|
-
|
69
|
-
next if
|
70
|
+
asso_class_name = asso.options.dig(:class_name) || asso.name.to_s.singularize.camelcase
|
71
|
+
next if asso_class_name == 'PaperTrail::Version'
|
70
72
|
|
71
|
-
associations << "field :#{asso.name}, [Types::#{
|
73
|
+
associations << "field :#{asso.name}, [Types::#{asso_class_name.downcase.pluralize.camelcase}::#{asso_class_name}Type]"
|
72
74
|
end
|
73
75
|
end
|
74
76
|
|
@@ -230,6 +232,32 @@ FILE
|
|
230
232
|
end
|
231
233
|
FILE
|
232
234
|
|
235
|
+
if defined?(Interactor)
|
236
|
+
create_file "app/interactors/#{plural_name}/search_#{singular_name}.rb", <<-FILE
|
237
|
+
module #{context_name}
|
238
|
+
class Search#{class_name}
|
239
|
+
include Interactor::Organizer
|
240
|
+
|
241
|
+
organize Get#{class_name}, PaginateRecords
|
242
|
+
end
|
243
|
+
end
|
244
|
+
FILE
|
245
|
+
|
246
|
+
create_file "app/interactors/#{plural_name}/get_#{singular_name}.rb", <<-FILE
|
247
|
+
module #{context_name}
|
248
|
+
class Get#{class_name}
|
249
|
+
include Interactor
|
250
|
+
|
251
|
+
def call
|
252
|
+
search = context.search || {}
|
253
|
+
records = ::#{class_name}.ransack(search).result
|
254
|
+
context.records = records
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
258
|
+
FILE
|
259
|
+
end
|
260
|
+
|
233
261
|
inject_into_file 'app/graphql/types/query_type.rb', after: "# Fields\n" do <<-FILE
|
234
262
|
field :#{plural_name}, Types::#{plural_name.camelcase}::#{singular_name.camelcase}ListPayload do
|
235
263
|
argument :search, InputObject::Search#{plural_name.camelcase}Attributes, required: false
|
data/lib/ntq_tools/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ntq_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|