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: 6ae778a1b16f9e589fe5d85bc0cf643d83c6c4a86ef20e5280fa3cce218a9dca
4
- data.tar.gz: 541dd2e07470a6d6498d6ff5a106f0b05d8a83434a3038ca4add643d5d44af96
3
+ metadata.gz: ac0873581beb3d88c2497f3b13cded83ad12869dee3f6db47531fa5e558e195d
4
+ data.tar.gz: d3f5a63a8f467cfe80146a4eddb8c23bd2d24df93bf6a8b1572bcd59313349f8
5
5
  SHA512:
6
- metadata.gz: 76d4ec81c0b78de510676e498edc48befe7ce2a882ef62b0e4442dd38c30bbee28060cceac6bca145c086af3d39c1bec0fdd3b798b2aff823df69122ff3c3348
7
- data.tar.gz: 530deba6cce227ff8764dd1c0458c904677ef984f147abda260b6ff039f7fef23802cacc3068851356583029cc0490b60f100b7d3378d30bf58c721dfee73cf7
6
+ metadata.gz: c7e15482eb122f6577cb76dcc9f2049444ddef7995ff6c69cb2e30f09bfa6bf276b0fd9be2d95a1a747214b99d7fe1617eeb0e28b34fe7250136fe2bf3a507aa
7
+ data.tar.gz: 82200cedb539476e04092bbb9dc1b3c374b2f7bdf67710c86edea7f133e4e6c863256ec8596788f71cc56e67fa9ea4b0464f7a4ec99e2c403fd16fef72220f5b
@@ -20,6 +20,10 @@ module NtqTools
20
20
  render json: { data: true }, status: 200
21
21
  end
22
22
 
23
+ def refresh
24
+ system("bundle exec rake react_on_rails:locale") if defined?(ReactOnRails)
25
+ end
26
+
23
27
  private
24
28
 
25
29
  def check_presence_of_key
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
- class_name = asso.options.dig(:class_name) || asso.name.to_s.singularize.camelcase
63
- associations << "field :#{asso.name}, Types::#{class_name.downcase.pluralize.camelcase}::#{class_name}Type"
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
- class_name = asso.options.dig(:class_name) || asso.name.to_s.singularize.camelcase
69
- next if class_name == 'PaperTrail::Version'
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::#{class_name.downcase.pluralize.camelcase}::#{class_name}Type]"
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
@@ -1,3 +1,3 @@
1
1
  module NtqTools
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.2"
3
3
  end
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.0
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-01 00:00:00.000000000 Z
11
+ date: 2023-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails