ntq_tools 0.4.0 → 0.4.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac0873581beb3d88c2497f3b13cded83ad12869dee3f6db47531fa5e558e195d
|
4
|
+
data.tar.gz: d3f5a63a8f467cfe80146a4eddb8c23bd2d24df93bf6a8b1572bcd59313349f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7e15482eb122f6577cb76dcc9f2049444ddef7995ff6c69cb2e30f09bfa6bf276b0fd9be2d95a1a747214b99d7fe1617eeb0e28b34fe7250136fe2bf3a507aa
|
7
|
+
data.tar.gz: 82200cedb539476e04092bbb9dc1b3c374b2f7bdf67710c86edea7f133e4e6c863256ec8596788f71cc56e67fa9ea4b0464f7a4ec99e2c403fd16fef72220f5b
|
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.2
|
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
|