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: 6ae778a1b16f9e589fe5d85bc0cf643d83c6c4a86ef20e5280fa3cce218a9dca
4
- data.tar.gz: 541dd2e07470a6d6498d6ff5a106f0b05d8a83434a3038ca4add643d5d44af96
3
+ metadata.gz: 57781cd3327d2e0c9a4934e818210a94a5869680d6ca88f17920e627a8bcc49b
4
+ data.tar.gz: aef6ae2230214af398d8a60254430478841d5a83400fe9b80d57764209cdaaad
5
5
  SHA512:
6
- metadata.gz: 76d4ec81c0b78de510676e498edc48befe7ce2a882ef62b0e4442dd38c30bbee28060cceac6bca145c086af3d39c1bec0fdd3b798b2aff823df69122ff3c3348
7
- data.tar.gz: 530deba6cce227ff8764dd1c0458c904677ef984f147abda260b6ff039f7fef23802cacc3068851356583029cc0490b60f100b7d3378d30bf58c721dfee73cf7
6
+ metadata.gz: 23710b7d19138ae83c21ea05db99511ff32fd68fd9541d1442d06f926e392922731a2adccb17949920ec6f945d81e003bb09abd70c475d5a0b77d8c96251cfbb
7
+ data.tar.gz: 18c0103de806aaa82b170bf882c875647c18ac1e855913b0b3ae352a2dae3cf0db1a6b316776c2cfda2a5418128accc7b4fe2b23eea579cf2f70d2b85cc7a13f
@@ -20,6 +20,10 @@ module NtqTools
20
20
  render json: { data: true }, status: 200
21
21
  end
22
22
 
23
+ def refresh
24
+ if defined?(ReactOnRails) system "bundle exec rake react_on_rails:locale"
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.1"
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.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-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