para-i18n 0.4.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/.vscode/settings.json +5 -0
  4. data/README.md +1 -1
  5. data/app/controllers/para/admin/translations_controller.rb +7 -0
  6. data/app/helpers/para/i18n/form_helper.rb +13 -0
  7. data/app/helpers/para/i18n/urls_helper.rb +9 -0
  8. data/app/javascripts/para/admin/translation_locale_select_controller.js +20 -0
  9. data/app/javascripts/para/i18n.js +11 -0
  10. data/app/views/para/admin/resources/_translations_fields.html.haml +6 -0
  11. data/app/views/para/admin/resources/_translations_fields_container.html.haml +9 -0
  12. data/app/views/para/admin/resources/_translations_form.html.haml +5 -4
  13. data/app/views/para/admin/translations/_target_locale_select.html.erb +17 -0
  14. data/dist/index.js +19 -0
  15. data/dist/index.js.map +7 -0
  16. data/lib/generators/para/i18n/base_form_generator.rb +28 -0
  17. data/lib/generators/para/i18n/form/form_generator.rb +3 -14
  18. data/lib/generators/para/i18n/form/templates/_translations_form.html.haml +8 -2
  19. data/lib/generators/para/i18n/nested_fields/nested_fields_generator.rb +18 -0
  20. data/lib/generators/para/i18n/nested_fields/templates/_translations_fields.html.haml +11 -0
  21. data/lib/generators/para/i18n/translate/templates/model_migration.rb.erb +1 -1
  22. data/lib/para/i18n/form_builder/nested_form.rb +46 -0
  23. data/lib/para/i18n/form_builder/translations_form.rb +42 -0
  24. data/lib/para/i18n/form_builder.rb +10 -0
  25. data/lib/para/i18n/friendly_id.rb +2 -2
  26. data/lib/para/i18n/helpers/translations_helper.rb +9 -0
  27. data/lib/para/i18n/i18n_input.rb +5 -5
  28. data/lib/para/i18n/inputs/nested_many_input.rb +41 -0
  29. data/lib/para/i18n/inputs.rb +4 -0
  30. data/lib/para/i18n/model.rb +35 -0
  31. data/lib/para/i18n/resources_buttons.rb +7 -2
  32. data/lib/para/i18n/version.rb +1 -1
  33. data/lib/para/i18n.rb +3 -0
  34. data/package.json +27 -0
  35. data/para-i18n.gemspec +1 -1
  36. data/yarn.lock +161 -0
  37. metadata +36 -14
  38. data/app/assets/javascripts/para/admin/translation.coffee +0 -10
  39. data/app/assets/javascripts/para/i18n.coffee +0 -1
  40. data/app/views/para/admin/translations/_target_locale_select.html.haml +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: bffd454f68783dc4413fab9cff53b3c899b0f908
4
- data.tar.gz: 783928239cee302a6e963057cc8f68becd744c8c
2
+ SHA256:
3
+ metadata.gz: 7a0c2cb5b72d32e5b2f3004cf1058e38c2d8d6bfcd27b934209b14c34efb735c
4
+ data.tar.gz: b48b78e2882e346bfd623e82b2db83242e7fd646fc6f2004f9403c083016384a
5
5
  SHA512:
6
- metadata.gz: aa848897075a6d40a94d92451e3b660e1c18aade214e90ca0a394d066b58dd03f3d143f6457f29e469b805215f37e451f21a093443f67cc7298b2bd8a7a047de
7
- data.tar.gz: 3ce0e4a22d344090a9d98ba86fb505b778549e2a230d8e981b9288af8b0d16da180e8993d1b828c7d795d867092d01575c3a040e43e74f6f2c3c05ade9eaa975
6
+ metadata.gz: ac1aebbd243360b95d1cb944bdc76579448dad4c6161440ce1d12361536b46fc4a2b5eeb7ad135490c0462d77845d01d3e49363e325de88f27668c661a75aff7
7
+ data.tar.gz: 4de0c69944f80774d48a8e06fdc42eccf11232424c2f89941887ad6f3617597c03dffa02ac2a722dc439f8003b193033ae1a5060164952c3229e1c749a5b9a5a
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ node_modules/
@@ -0,0 +1,5 @@
1
+ {
2
+ "circleci.persistedProjectSelection": [
3
+ "gh/para-cms/para-i18n"
4
+ ]
5
+ }
data/README.md CHANGED
@@ -24,7 +24,7 @@ Or install it yourself as:
24
24
 
25
25
  $ gem install para-i18n
26
26
 
27
- Add the para-i18n javascript file to your app's admin manifest at `app/assets/javascripts/admin/app.(js|coffee)` :
27
+ Add the para-i18n javascript file to your app's admin manifest at `app/assets/javascripts/admin/app.js` :
28
28
 
29
29
  ```javascript
30
30
  //= require para/i18n
@@ -22,6 +22,13 @@ module Para
22
22
 
23
23
  private
24
24
 
25
+ def after_form_submit_path
26
+ path = super
27
+ return path unless params[:_save_and_edit]
28
+
29
+ path.merge(target_locale: @target_locale)
30
+ end
31
+
25
32
  def load_and_authorize_crud_resource
26
33
  options = { class: resource_model }
27
34
 
@@ -0,0 +1,13 @@
1
+ module Para
2
+ module I18n
3
+ module FormHelper
4
+ def para_translations_form_for(resource, options = {}, &block)
5
+ extended_options = options.reverse_merge(
6
+ Para::I18n::FormBuilder::TranslationsForm::TRANSLATIONS_FORM_PARAM_KEY => true
7
+ )
8
+
9
+ para_form_for(resource, extended_options, &block)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ module Para
2
+ module I18n
3
+ module UrlsHelper
4
+ def translations_form_locale_path_for(resource, target_locale)
5
+ @component.relation_path(resource, :translation, action: :edit, target_locale:)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,20 @@
1
+ import { Controller } from "@hotwired/stimulus";
2
+ import TomSelect from "tom-select";
3
+
4
+ export default class extends Controller {
5
+ static values = { pathTemplate: String };
6
+
7
+ connect() {
8
+ this.localeSelect = new TomSelect(this.element);
9
+ }
10
+
11
+ disconnect() {
12
+ this.localeSelect.destroy();
13
+ }
14
+
15
+ switchLocale() {
16
+ const url = this.pathTemplateValue.replace("__locale__", this.element.value);
17
+
18
+ Turbo.visit(url);
19
+ }
20
+ }
@@ -0,0 +1,11 @@
1
+ const application = window.Stimulus;
2
+
3
+ if (!application) {
4
+ throw new Error(
5
+ "Stimulus is not available in the global scope. Make sure to require Para and / " +
6
+ "or initialize Stimulus in your application before loading this file."
7
+ );
8
+ }
9
+
10
+ import TranslationLocaleSelectController from "./admin/translation_locale_select_controller";
11
+ application.register("translations-locale-select", TranslationLocaleSelectController);
@@ -0,0 +1,6 @@
1
+ = form.fieldset do
2
+ - translated_model_fields_for(form.object.class).each do |field|
3
+ = form.input field.field_name, as: :i18n
4
+
5
+ - nested_relations_attributes_for(form.object.class).each do |field|
6
+ = form.input field.field_name, as: field.field_type
@@ -0,0 +1,9 @@
1
+ - if form.object.class.translates? && form.options["locale"]
2
+ -# Process the label value here while we're in the locale of the UI, and not in the
3
+ -# target translation locale
4
+ - label = t("para.i18n.disabled_for_locale")
5
+
6
+ - I18n.with_locale(form.options["locale"]) do
7
+ = form.input :_disabled_for_locale, as: :boolean, label:
8
+
9
+ = render partial: find_partial_for(form.object.class, "translations_fields"), locals: local_assigns
@@ -1,10 +1,11 @@
1
- = para_form_for(resource, url: @component.relation_path(resource, :translation)) do |form|
1
+ = para_translations_form_for(resource, url: @component.relation_path(resource, :translation), locale: @target_locale) do |form|
2
2
  = target_locale_select
3
3
 
4
4
  = form.fieldset do
5
- = I18n.with_locale(@target_locale) { form.input :_disabled_for_locale, as: :boolean, label: t("para.i18n.disabled_for_locale") }
6
-
7
5
  - translated_model_fields_for(resource.class).each do |field|
8
- = form.input field.field_name, as: :i18n, locale: @target_locale
6
+ = form.input field.field_name, as: :i18n
7
+
8
+ - nested_relations_attributes_for(resource.class).each do |field|
9
+ = form.input field.field_name, as: field.field_type
9
10
 
10
11
  = form.actions(except: :submit_and_add_another)
@@ -0,0 +1,17 @@
1
+ <div class="block form-inputs">
2
+ <div class="form-group">
3
+ <%= label :target_locale, t('para.i18n.choose_locale'), class: 'control-label col-md-3 pull-left' %>
4
+
5
+ <div class="col-md-9">
6
+ <%= select_tag :target_locale,
7
+ options_for_select(
8
+ locales.map { |locale| [locale, locale] }, target_locale),
9
+ data: {
10
+ controller: "translations-locale-select",
11
+ action: "change->translations-locale-select#switchLocale",
12
+ "translations-locale-select-path-template-value": translations_form_locale_path_for(resource, "__locale__"),
13
+ }
14
+ %>
15
+ </div>
16
+ </div>
17
+ </div>
data/dist/index.js ADDED
@@ -0,0 +1,19 @@
1
+ (() => {
2
+ // app/javascripts/para/admin/translation.js
3
+ var TranslationLocaleSelect;
4
+ TranslationLocaleSelect = class TranslationLocaleSelect2 {
5
+ static onChange($field) {
6
+ var targetLocale, targetURL;
7
+ targetURL = $field.data("locale-select-target-url");
8
+ targetLocale = $field.val();
9
+ targetURL = targetURL.replace("target_locale=_", ["target_locale", targetLocale].join("="));
10
+ return Turbolinks.visit(targetURL.replace(":locale", targetLocale));
11
+ }
12
+ };
13
+ $(document).on("turbo:load turbo:frame-load", function() {
14
+ return $("body").on("change", "[data-locale-select]", function(e) {
15
+ return TranslationLocaleSelect.onChange($(e.currentTarget));
16
+ });
17
+ });
18
+ })();
19
+ //# sourceMappingURL=index.js.map
data/dist/index.js.map ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../app/javascripts/para/admin/translation.js"],
4
+ "sourcesContent": ["var TranslationLocaleSelect;\n\nTranslationLocaleSelect = class TranslationLocaleSelect {\n static onChange($field) {\n var targetLocale, targetURL;\n targetURL = $field.data('locale-select-target-url');\n targetLocale = $field.val();\n targetURL = targetURL.replace('target_locale=_', ['target_locale', targetLocale].join('='));\n return Turbolinks.visit(targetURL.replace(':locale', targetLocale));\n }\n\n};\n\n$(document).on('turbo:load turbo:frame-load', function() {\n return $('body').on('change', '[data-locale-select]', function(e) {\n return TranslationLocaleSelect.onChange($(e.currentTarget));\n });\n});\n"],
5
+ "mappings": ";;AAAA,MAAI;AAEJ,4BAA0B,MAAMA,yBAAwB;AAAA,IACtD,OAAO,SAAS,QAAQ;AACtB,UAAI,cAAc;AAClB,kBAAY,OAAO,KAAK,0BAA0B;AAClD,qBAAe,OAAO,IAAI;AAC1B,kBAAY,UAAU,QAAQ,mBAAmB,CAAC,iBAAiB,YAAY,EAAE,KAAK,GAAG,CAAC;AAC1F,aAAO,WAAW,MAAM,UAAU,QAAQ,WAAW,YAAY,CAAC;AAAA,IACpE;AAAA,EAEF;AAEA,IAAE,QAAQ,EAAE,GAAG,+BAA+B,WAAW;AACvD,WAAO,EAAE,MAAM,EAAE,GAAG,UAAU,wBAAwB,SAAS,GAAG;AAChE,aAAO,wBAAwB,SAAS,EAAE,EAAE,aAAa,CAAC;AAAA,IAC5D,CAAC;AAAA,EACH,CAAC;",
6
+ "names": ["TranslationLocaleSelect"]
7
+ }
@@ -0,0 +1,28 @@
1
+ module Para
2
+ module I18n
3
+ module FormGeneratorConcern
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ include Para::Admin::BaseHelper
8
+ include Para::Generators::FieldHelpers
9
+ include Para::ModelHelper
10
+ include Para::I18n::Helpers::TranslationsHelper
11
+ end
12
+
13
+ private
14
+
15
+ def translated_attributes
16
+ translated_model_fields_for(model)
17
+ end
18
+
19
+ def nested_relations_attributes
20
+ nested_relations_attributes_for(model)
21
+ end
22
+
23
+ def model
24
+ @model ||= class_name.constantize
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,10 +1,9 @@
1
+ require "generators/para/i18n/base_form_generator"
2
+
1
3
  module Para
2
4
  module I18n
3
5
  class FormGenerator < Para::Generators::NamedBase
4
- include Para::Admin::BaseHelper
5
- include Para::Generators::FieldHelpers
6
- include Para::ModelHelper
7
- include Para::I18n::Helpers::TranslationsHelper
6
+ include Para::I18n::FormGeneratorConcern
8
7
 
9
8
  source_root File.expand_path("../templates", __FILE__)
10
9
 
@@ -14,16 +13,6 @@ module Para
14
13
  "app/views/admin/#{ plural_namespaced_path }/_translations_form.html.haml"
15
14
  )
16
15
  end
17
-
18
- private
19
-
20
- def translated_attributes
21
- translated_model_fields_for(model)
22
- end
23
-
24
- def model
25
- @model ||= class_name.constantize
26
- end
27
16
  end
28
17
  end
29
18
  end
@@ -1,9 +1,15 @@
1
- = para_form_for(resource, url: @component.relation_path(resource, :translation)) do |form|
1
+ = para_translations_form_for(resource, url: @component.relation_path(resource, :translation), locale: @target_locale) do |form|
2
2
  = target_locale_select
3
3
 
4
4
  = form.fieldset do
5
+ - I18n.with_locale(@target_locale) do
6
+ = form.input :_disabled_for_locale, as: :boolean, label: t("para.i18n.disabled_for_locale")
7
+
5
8
  <%- translated_attributes.each do |field| -%>
6
- = form.input :<%= field.field_name %>, as: :i18n, locale: @target_locale
9
+ = form.input :<%= field.field_name %>, as: :i18n
10
+ <%- end -%>
11
+ <%- nested_relations_attributes.each do |field| -%>
12
+ = form.input :<%= field.field_name %>, as: :<%= field.field_type %>
7
13
  <%- end -%>
8
14
 
9
15
  = form.actions(except: :submit_and_add_another)
@@ -0,0 +1,18 @@
1
+ require "generators/para/i18n/base_form_generator"
2
+
3
+ module Para
4
+ module I18n
5
+ class NestedFieldsGenerator < Para::Generators::NamedBase
6
+ include Para::I18n::FormGeneratorConcern
7
+
8
+ source_root File.expand_path("../templates", __FILE__)
9
+
10
+ def generate_nested_fields
11
+ template(
12
+ "_translations_fields.html.haml",
13
+ "app/views/admin/#{ plural_namespaced_path }/_translations_fields.html.haml"
14
+ )
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,11 @@
1
+ = form.fieldset do
2
+ - I18n.with_locale(@target_locale) do
3
+ = form.input :_disabled_for_locale, as: :boolean, label: t("para.i18n.disabled_for_locale")
4
+
5
+ <%- translated_attributes.each do |field| -%>
6
+ = form.input :<%= field.field_name %>, as: :i18n
7
+ <%- end -%>
8
+ <%- nested_relations_attributes.each do |field| -%>
9
+ = form.input :<%= field.field_name %>, as: :<%= field.field_type %>
10
+ <%- end -%>
11
+
@@ -1,4 +1,4 @@
1
- class Translate<%= table_name.camelize %> < ActiveRecord::Migration
1
+ class Translate<%= table_name.camelize %> < ActiveRecord::Migration<%= "[#{Rails.version.to_f}]" if Rails.version.to_i >= 5 %>
2
2
  def change
3
3
  add_column :<%= table_name %>, :_translations, :jsonb
4
4
  end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literals: true
2
+
3
+ module Para
4
+ module I18n
5
+ module FormBuilder
6
+ # Thid module provides methods to extend the para's nested form functionality by
7
+ # extending the SimpleForm::FormBuilder.
8
+ #
9
+ module NestedForm
10
+ # Traverses the parent_builder chain until the top of the builder chain returning
11
+ # the top-most form builder which represents the one created through the
12
+ # `form_for` like helper.
13
+ #
14
+ # Note that this could go into the Para::FormBuilder::NestedForm module, but it's
15
+ # not used inside Para, so we keep it here for now.
16
+ #
17
+ def top_level_form_builder
18
+ parent_builder = options[:parent_builder]
19
+
20
+ while parent_builder && parent_builder.options[:parent_builder]
21
+ parent_builder = parent_builder.options[:parent_builder]
22
+ end
23
+
24
+ parent_builder || self
25
+ end
26
+
27
+ # Don't allow nested fields destruction if we're in a translations form as this is
28
+ # the method used by the FormBuilder#remove_association_button method to check
29
+ # whether it's allowed to render the remove button or not.
30
+ #
31
+ def allow_destroy?
32
+ return false if translations_form?
33
+
34
+ super
35
+ end
36
+
37
+ # Overrides the Para::FormBuilder::NestedForm#fields_partial_name method to render
38
+ # a different nested fields partial when the builder is a translations form
39
+ #
40
+ def nested_fields_partial_name
41
+ translations_form? ? :translations_fields_container : :fields
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literals: true
2
+
3
+ module Para
4
+ module I18n
5
+ module FormBuilder
6
+ # Thid module extends the Para overriden SimpleForm::FormBuilder to include some
7
+ # trnaslations form related methods and overrides, allowing a simple use of
8
+ # translations forms with the para-i18n gem.
9
+ #
10
+ module TranslationsForm
11
+ TRANSLATIONS_FORM_PARAM_KEY = :_translations_form
12
+
13
+ # Allows storing a gobal reference to the target locale of the translations form,
14
+ # which allows input objects to fetch it directly, without having to provide
15
+ # manually the :locale parameter for each input
16
+ #
17
+ # Example :
18
+ #
19
+ # = para_translations_form_for(resource, locale: @target_Locale) do |form|
20
+ # = form.input :title, as: :i18n # No need to pass `:locale` option here.
21
+ #
22
+ def target_locale
23
+ top_level_form_builder.options.with_indifferent_access[:locale]
24
+ end
25
+
26
+ # Allows checking if the current form builder is a translations form, depending
27
+ # on the passed TRANSLATIONS_FORM_PARAM_KEY option. This is automatically passed
28
+ # to the form builder when using the `para_translations_form_for` helper.
29
+ #
30
+ # Example :
31
+ #
32
+ # para_translations_form_for(resource)
33
+ # # OR
34
+ # para_form_for(resource, _translations_form: true)
35
+ #
36
+ def translations_form?
37
+ !!top_level_form_builder.options.with_indifferent_access[TRANSLATIONS_FORM_PARAM_KEY]
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,10 @@
1
+ require 'para/form_builder'
2
+
3
+ require 'para/i18n/form_builder/nested_form'
4
+ require 'para/i18n/form_builder/translations_form'
5
+
6
+ # Extend the para extended simple_form form builder to included translations related
7
+ # methods.
8
+ #
9
+ SimpleForm::FormBuilder.prepend(Para::I18n::FormBuilder::NestedForm)
10
+ SimpleForm::FormBuilder.prepend(Para::I18n::FormBuilder::TranslationsForm)
@@ -14,7 +14,7 @@ module FriendlyId
14
14
  # model. Example :
15
15
  model_class.instance_eval do
16
16
  relation.class.send(:include, ClassMethods)
17
- if (ActiveRecord::VERSION::MAJOR == 4 && ActiveRecord::VERSION::MINOR == 2) || ActiveRecord::VERSION::MAJOR == 5
17
+ if (ActiveRecord::VERSION::MAJOR == 4 && ActiveRecord::VERSION::MINOR == 2) || ActiveRecord::VERSION::MAJOR >= 5
18
18
  model_class.send(:extend, ClassMethods)
19
19
  end
20
20
  end
@@ -76,7 +76,7 @@ module FriendlyId
76
76
  where(friendly_id_config.query_field => id)
77
77
  else
78
78
  json_path = "{#{ locale },#{ friendly_id_config.query_field }}"
79
- where("_translations#>>'#{ json_path }' = ?", id)
79
+ where("#{table_name}._translations#>>'#{ json_path }' = ?", id)
80
80
  end
81
81
  end
82
82
  end
@@ -9,6 +9,15 @@ module Para
9
9
  model.translated_attribute_names.include?(field.name.to_sym)
10
10
  end
11
11
  end
12
+
13
+ def nested_relations_attributes_for(model)
14
+ model_field_mappings(model).fields.select do |field|
15
+ next unless field.field_type.in?(["nested_one", "nested_many"])
16
+
17
+ # This returns nil if the target model is not translated
18
+ model.reflect_on_association(field.name).klass.translatable?
19
+ end
20
+ end
12
21
  end
13
22
  end
14
23
  end
@@ -26,11 +26,11 @@ module Para
26
26
  private
27
27
 
28
28
  def locale
29
- if (locale = options[:locale])
30
- locale
31
- else
32
- raise 'Missing `:locale` option passed to :i18n input.'
33
- end
29
+ locale = options.fetch(:locale, @builder.target_locale)
30
+ return locale if locale.present?
31
+
32
+ raise 'No target locale for the current i18n input. Please provide a `:locale`' \
33
+ 'option to the :i18n input or the `para_translations_form_for` method'
34
34
  end
35
35
 
36
36
  def original_content
@@ -0,0 +1,41 @@
1
+ module Para
2
+ module I18n
3
+ module Inputs
4
+ module NestedManyInput
5
+ def input(_wrapper_options = nil)
6
+ # Disable the add button and orderable features of the input.
7
+ # Note : The remove button disabling is done by the
8
+ # Para::I18n::FormBuilder::TranslationsForm extension
9
+ if within_translations_form?
10
+ options[:add_button] = false
11
+ options[:orderable] = false
12
+ end
13
+
14
+ super
15
+ end
16
+ private
17
+
18
+ def within_translations_form?
19
+ @builder.translations_form?
20
+ end
21
+
22
+ # Extend remote partial params with the :_translations_form key if we're in the
23
+ # context of a translations form builder.
24
+ #
25
+ def remote_partial_params
26
+ super.tap do |remote_partial_params|
27
+ if within_translations_form?
28
+ remote_partial_params.deep_merge!(
29
+ builder_options: {
30
+ Para::I18n::FormBuilder::TranslationsForm::TRANSLATIONS_FORM_PARAM_KEY => true,
31
+ locale: @builder.target_locale
32
+ }
33
+ )
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+
@@ -0,0 +1,4 @@
1
+ require "para/inputs/nested_many_input"
2
+ require 'para/i18n/inputs/nested_many_input'
3
+
4
+ Para::Inputs::NestedManyInput.prepend(Para::I18n::Inputs::NestedManyInput)
@@ -6,6 +6,29 @@ module Para
6
6
  included do
7
7
  class_attribute :translated_attribute_names
8
8
  class_attribute :translatable
9
+
10
+ # Fetch all records of the current model that are not disabled for the provided
11
+ # locale, which also includes models that are not translatable and records of
12
+ # translatable models that are not translated for the current locale.
13
+ #
14
+ scope :enabled_for_locale, ->(locale = I18n.locale) {
15
+ # Models that are not translatable don't have the `_translations` column, so we
16
+ # avoid any query for them.
17
+ next all unless translates?
18
+
19
+ with_disabled_for_locale_state(disabled: false, locale: locale)
20
+ }
21
+
22
+ # Fetch all records of the current model that are explicitly disabled for the
23
+ # provided locale.
24
+ #
25
+ scope :disabled_for_locale, ->(locale = I18n.locale) {
26
+ # Models that are not translatable don't have the `_translations` column, so we
27
+ # avoid any query for them.
28
+ next none unless translates?
29
+
30
+ with_disabled_for_locale_state(disabled: true, locale: locale)
31
+ }
9
32
  end
10
33
 
11
34
  def read_translated_attribute(field, locale = ::I18n.locale)
@@ -103,6 +126,18 @@ module Para
103
126
  translatable
104
127
  end
105
128
 
129
+ # This methods is used by both the enabled_for_locale and disabled_for_locale
130
+ # scopes to filter the records based on the _disabled_for_locale attribute stored
131
+ # in the translations JSONB column for the provided locale.
132
+ def with_disabled_for_locale_state(disabled:, locale: I18n.locale)
133
+ predicate = disabled ? 'IN' : 'NOT IN'
134
+
135
+ where(<<-SQL.squish, locale, %w[1 t true])
136
+ COALESCE(#{table_name}._translations->?->>'_disabled_for_locale', '0')
137
+ #{predicate} (?)
138
+ SQL
139
+ end
140
+
106
141
  private
107
142
 
108
143
  def prepare_attribute_translation(attribute)
@@ -5,9 +5,14 @@ module Para
5
5
  return unless resource.class.translates? && view.can?(:translate, resource)
6
6
 
7
7
  path = component.relation_path(resource, :translation, action: :edit)
8
- options = { class: 'btn btn-default' }
9
8
 
10
- view.link_to(path, options) do
9
+ options = {
10
+ class: 'btn btn-sm btn-icon-info btn-shadow hint--left',
11
+ data: { 'turbo-frame': '_top' },
12
+ aria: { label: I18n.t('para.i18n.translate') }
13
+ }
14
+
15
+ view.link_to(path, **options) do
11
16
  content_tag(:i, '', class: 'fa fa-globe')
12
17
  end
13
18
  end
@@ -1,5 +1,5 @@
1
1
  module Para
2
2
  module I18n
3
- VERSION = "0.4.1"
3
+ VERSION = '0.5.2'.freeze
4
4
  end
5
5
  end
data/lib/para/i18n.rb CHANGED
@@ -13,6 +13,9 @@ require 'para/i18n/attribute_translation/base'
13
13
  require 'para/i18n/attribute_translation/simple_attribute'
14
14
  require 'para/i18n/attribute_translation/attachment'
15
15
 
16
+ require 'para/i18n/form_builder'
17
+ require 'para/i18n/inputs'
18
+
16
19
  require 'para/i18n/friendly_id'
17
20
 
18
21
  require 'para/i18n/i18n_input'
data/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@para/i18n",
3
+ "version": "1.0.2",
4
+ "description": "Javascript engine for Para's I18n Extension",
5
+ "main": "app/javascripts/para/i18n.js",
6
+ "files": [
7
+ "app/javascripts/para"
8
+ ],
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/respublica-conseil/simple_form_extension.git"
12
+ },
13
+ "author": "Valentin Ballestrino",
14
+ "license": "MIT",
15
+ "homepage": "https://github.com/respublica-conseil/simple_form_extension",
16
+ "dependencies": {
17
+ "tom-select": "^2.2.2"
18
+ },
19
+ "peerDependencies": {
20
+ "jquery": "^3.6.0",
21
+ "@hotwired/stimulus": "^3.2.2",
22
+ "@para/para": "^1.0.0"
23
+ },
24
+ "devDependencies": {
25
+ "esbuild": "^0.19.8"
26
+ }
27
+ }
data/para-i18n.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency "para", "~> 0.8"
22
+ spec.add_dependency "para", ">= 0.9.2", "<= 1.0"
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.11"
25
25
  spec.add_development_dependency "rake", "~> 10.0"
data/yarn.lock ADDED
@@ -0,0 +1,161 @@
1
+ # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
+ # yarn lockfile v1
3
+
4
+
5
+ "@esbuild/android-arm64@0.19.8":
6
+ version "0.19.8"
7
+ resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.19.8.tgz#fb7130103835b6d43ea499c3f30cfb2b2ed58456"
8
+ integrity sha512-B8JbS61bEunhfx8kasogFENgQfr/dIp+ggYXwTqdbMAgGDhRa3AaPpQMuQU0rNxDLECj6FhDzk1cF9WHMVwrtA==
9
+
10
+ "@esbuild/android-arm@0.19.8":
11
+ version "0.19.8"
12
+ resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.19.8.tgz#b46e4d9e984e6d6db6c4224d72c86b7757e35bcb"
13
+ integrity sha512-31E2lxlGM1KEfivQl8Yf5aYU/mflz9g06H6S15ITUFQueMFtFjESRMoDSkvMo8thYvLBax+VKTPlpnx+sPicOA==
14
+
15
+ "@esbuild/android-x64@0.19.8":
16
+ version "0.19.8"
17
+ resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.19.8.tgz#a13db9441b5a4f4e4fec4a6f8ffacfea07888db7"
18
+ integrity sha512-rdqqYfRIn4jWOp+lzQttYMa2Xar3OK9Yt2fhOhzFXqg0rVWEfSclJvZq5fZslnz6ypHvVf3CT7qyf0A5pM682A==
19
+
20
+ "@esbuild/darwin-arm64@0.19.8":
21
+ version "0.19.8"
22
+ resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.19.8.tgz#49f5718d36541f40dd62bfdf84da9c65168a0fc2"
23
+ integrity sha512-RQw9DemMbIq35Bprbboyf8SmOr4UXsRVxJ97LgB55VKKeJOOdvsIPy0nFyF2l8U+h4PtBx/1kRf0BelOYCiQcw==
24
+
25
+ "@esbuild/darwin-x64@0.19.8":
26
+ version "0.19.8"
27
+ resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.19.8.tgz#75c5c88371eea4bfc1f9ecfd0e75104c74a481ac"
28
+ integrity sha512-3sur80OT9YdeZwIVgERAysAbwncom7b4bCI2XKLjMfPymTud7e/oY4y+ci1XVp5TfQp/bppn7xLw1n/oSQY3/Q==
29
+
30
+ "@esbuild/freebsd-arm64@0.19.8":
31
+ version "0.19.8"
32
+ resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.8.tgz#9d7259fea4fd2b5f7437b52b542816e89d7c8575"
33
+ integrity sha512-WAnPJSDattvS/XtPCTj1tPoTxERjcTpH6HsMr6ujTT+X6rylVe8ggxk8pVxzf5U1wh5sPODpawNicF5ta/9Tmw==
34
+
35
+ "@esbuild/freebsd-x64@0.19.8":
36
+ version "0.19.8"
37
+ resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.19.8.tgz#abac03e1c4c7c75ee8add6d76ec592f46dbb39e3"
38
+ integrity sha512-ICvZyOplIjmmhjd6mxi+zxSdpPTKFfyPPQMQTK/w+8eNK6WV01AjIztJALDtwNNfFhfZLux0tZLC+U9nSyA5Zg==
39
+
40
+ "@esbuild/linux-arm64@0.19.8":
41
+ version "0.19.8"
42
+ resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.19.8.tgz#c577932cf4feeaa43cb9cec27b89cbe0df7d9098"
43
+ integrity sha512-z1zMZivxDLHWnyGOctT9JP70h0beY54xDDDJt4VpTX+iwA77IFsE1vCXWmprajJGa+ZYSqkSbRQ4eyLCpCmiCQ==
44
+
45
+ "@esbuild/linux-arm@0.19.8":
46
+ version "0.19.8"
47
+ resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.19.8.tgz#d6014d8b98b5cbc96b95dad3d14d75bb364fdc0f"
48
+ integrity sha512-H4vmI5PYqSvosPaTJuEppU9oz1dq2A7Mr2vyg5TF9Ga+3+MGgBdGzcyBP7qK9MrwFQZlvNyJrvz6GuCaj3OukQ==
49
+
50
+ "@esbuild/linux-ia32@0.19.8":
51
+ version "0.19.8"
52
+ resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.19.8.tgz#2379a0554307d19ac4a6cdc15b08f0ea28e7a40d"
53
+ integrity sha512-1a8suQiFJmZz1khm/rDglOc8lavtzEMRo0v6WhPgxkrjcU0LkHj+TwBrALwoz/OtMExvsqbbMI0ChyelKabSvQ==
54
+
55
+ "@esbuild/linux-loong64@0.19.8":
56
+ version "0.19.8"
57
+ resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.19.8.tgz#e2a5bbffe15748b49356a6cd7b2d5bf60c5a7123"
58
+ integrity sha512-fHZWS2JJxnXt1uYJsDv9+b60WCc2RlvVAy1F76qOLtXRO+H4mjt3Tr6MJ5l7Q78X8KgCFudnTuiQRBhULUyBKQ==
59
+
60
+ "@esbuild/linux-mips64el@0.19.8":
61
+ version "0.19.8"
62
+ resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.19.8.tgz#1359331e6f6214f26f4b08db9b9df661c57cfa24"
63
+ integrity sha512-Wy/z0EL5qZYLX66dVnEg9riiwls5IYnziwuju2oUiuxVc+/edvqXa04qNtbrs0Ukatg5HEzqT94Zs7J207dN5Q==
64
+
65
+ "@esbuild/linux-ppc64@0.19.8":
66
+ version "0.19.8"
67
+ resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.19.8.tgz#9ba436addc1646dc89dae48c62d3e951ffe70951"
68
+ integrity sha512-ETaW6245wK23YIEufhMQ3HSeHO7NgsLx8gygBVldRHKhOlD1oNeNy/P67mIh1zPn2Hr2HLieQrt6tWrVwuqrxg==
69
+
70
+ "@esbuild/linux-riscv64@0.19.8":
71
+ version "0.19.8"
72
+ resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.19.8.tgz#fbcf0c3a0b20f40b5fc31c3b7695f0769f9de66b"
73
+ integrity sha512-T2DRQk55SgoleTP+DtPlMrxi/5r9AeFgkhkZ/B0ap99zmxtxdOixOMI570VjdRCs9pE4Wdkz7JYrsPvsl7eESg==
74
+
75
+ "@esbuild/linux-s390x@0.19.8":
76
+ version "0.19.8"
77
+ resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.19.8.tgz#989e8a05f7792d139d5564ffa7ff898ac6f20a4a"
78
+ integrity sha512-NPxbdmmo3Bk7mbNeHmcCd7R7fptJaczPYBaELk6NcXxy7HLNyWwCyDJ/Xx+/YcNH7Im5dHdx9gZ5xIwyliQCbg==
79
+
80
+ "@esbuild/linux-x64@0.19.8":
81
+ version "0.19.8"
82
+ resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.19.8.tgz#b187295393a59323397fe5ff51e769ec4e72212b"
83
+ integrity sha512-lytMAVOM3b1gPypL2TRmZ5rnXl7+6IIk8uB3eLsV1JwcizuolblXRrc5ShPrO9ls/b+RTp+E6gbsuLWHWi2zGg==
84
+
85
+ "@esbuild/netbsd-x64@0.19.8":
86
+ version "0.19.8"
87
+ resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.19.8.tgz#c1ec0e24ea82313cb1c7bae176bd5acd5bde7137"
88
+ integrity sha512-hvWVo2VsXz/8NVt1UhLzxwAfo5sioj92uo0bCfLibB0xlOmimU/DeAEsQILlBQvkhrGjamP0/el5HU76HAitGw==
89
+
90
+ "@esbuild/openbsd-x64@0.19.8":
91
+ version "0.19.8"
92
+ resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.19.8.tgz#0c5b696ac66c6d70cf9ee17073a581a28af9e18d"
93
+ integrity sha512-/7Y7u77rdvmGTxR83PgaSvSBJCC2L3Kb1M/+dmSIvRvQPXXCuC97QAwMugBNG0yGcbEGfFBH7ojPzAOxfGNkwQ==
94
+
95
+ "@esbuild/sunos-x64@0.19.8":
96
+ version "0.19.8"
97
+ resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.19.8.tgz#2a697e1f77926ff09fcc457d8f29916d6cd48fb1"
98
+ integrity sha512-9Lc4s7Oi98GqFA4HzA/W2JHIYfnXbUYgekUP/Sm4BG9sfLjyv6GKKHKKVs83SMicBF2JwAX6A1PuOLMqpD001w==
99
+
100
+ "@esbuild/win32-arm64@0.19.8":
101
+ version "0.19.8"
102
+ resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.19.8.tgz#ec029e62a2fca8c071842ecb1bc5c2dd20b066f1"
103
+ integrity sha512-rq6WzBGjSzihI9deW3fC2Gqiak68+b7qo5/3kmB6Gvbh/NYPA0sJhrnp7wgV4bNwjqM+R2AApXGxMO7ZoGhIJg==
104
+
105
+ "@esbuild/win32-ia32@0.19.8":
106
+ version "0.19.8"
107
+ resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.19.8.tgz#cbb9a3146bde64dc15543e48afe418c7a3214851"
108
+ integrity sha512-AIAbverbg5jMvJznYiGhrd3sumfwWs8572mIJL5NQjJa06P8KfCPWZQ0NwZbPQnbQi9OWSZhFVSUWjjIrn4hSw==
109
+
110
+ "@esbuild/win32-x64@0.19.8":
111
+ version "0.19.8"
112
+ resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.19.8.tgz#c8285183dbdb17008578dbacb6e22748709b4822"
113
+ integrity sha512-bfZ0cQ1uZs2PqpulNL5j/3w+GDhP36k1K5c38QdQg+Swy51jFZWWeIkteNsufkQxp986wnqRRsb/bHbY1WQ7TA==
114
+
115
+ "@orchidjs/sifter@^1.0.3":
116
+ version "1.0.3"
117
+ resolved "https://registry.yarnpkg.com/@orchidjs/sifter/-/sifter-1.0.3.tgz#43f42519472282eb632d0a1589184f044d64129b"
118
+ integrity sha512-zCZbwKegHytfsPm8Amcfh7v/4vHqTAaOu6xFswBYcn8nznBOuseu6COB2ON7ez0tFV0mKL0nRNnCiZZA+lU9/g==
119
+ dependencies:
120
+ "@orchidjs/unicode-variants" "^1.0.4"
121
+
122
+ "@orchidjs/unicode-variants@^1.0.4":
123
+ version "1.0.4"
124
+ resolved "https://registry.yarnpkg.com/@orchidjs/unicode-variants/-/unicode-variants-1.0.4.tgz#6d2f812e3b19545bba2d81caffff1204de9a6a58"
125
+ integrity sha512-NvVBRnZNE+dugiXERFsET1JlKZfM5lJDEpSMilKW4bToYJ7pxf0Zne78xyXB2ny2c2aHfJ6WLnz1AaTNHAmQeQ==
126
+
127
+ esbuild@^0.19.8:
128
+ version "0.19.8"
129
+ resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.19.8.tgz#ad05b72281d84483fa6b5345bd246c27a207b8f1"
130
+ integrity sha512-l7iffQpT2OrZfH2rXIp7/FkmaeZM0vxbxN9KfiCwGYuZqzMg/JdvX26R31Zxn/Pxvsrg3Y9N6XTcnknqDyyv4w==
131
+ optionalDependencies:
132
+ "@esbuild/android-arm" "0.19.8"
133
+ "@esbuild/android-arm64" "0.19.8"
134
+ "@esbuild/android-x64" "0.19.8"
135
+ "@esbuild/darwin-arm64" "0.19.8"
136
+ "@esbuild/darwin-x64" "0.19.8"
137
+ "@esbuild/freebsd-arm64" "0.19.8"
138
+ "@esbuild/freebsd-x64" "0.19.8"
139
+ "@esbuild/linux-arm" "0.19.8"
140
+ "@esbuild/linux-arm64" "0.19.8"
141
+ "@esbuild/linux-ia32" "0.19.8"
142
+ "@esbuild/linux-loong64" "0.19.8"
143
+ "@esbuild/linux-mips64el" "0.19.8"
144
+ "@esbuild/linux-ppc64" "0.19.8"
145
+ "@esbuild/linux-riscv64" "0.19.8"
146
+ "@esbuild/linux-s390x" "0.19.8"
147
+ "@esbuild/linux-x64" "0.19.8"
148
+ "@esbuild/netbsd-x64" "0.19.8"
149
+ "@esbuild/openbsd-x64" "0.19.8"
150
+ "@esbuild/sunos-x64" "0.19.8"
151
+ "@esbuild/win32-arm64" "0.19.8"
152
+ "@esbuild/win32-ia32" "0.19.8"
153
+ "@esbuild/win32-x64" "0.19.8"
154
+
155
+ tom-select@^2.2.2:
156
+ version "2.3.1"
157
+ resolved "https://registry.yarnpkg.com/tom-select/-/tom-select-2.3.1.tgz#df338d9082874cd0bceb3bee87ed0184447c47f1"
158
+ integrity sha512-QS4vnOcB6StNGqX4sGboGXL2fkhBF2gIBB+8Hwv30FZXYPn0CyYO8kkdATRvwfCTThxiR4WcXwKJZ3cOmtI9eg==
159
+ dependencies:
160
+ "@orchidjs/sifter" "^1.0.3"
161
+ "@orchidjs/unicode-variants" "^1.0.4"
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: para-i18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valentin Ballestrino
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-22 00:00:00.000000000 Z
11
+ date: 2025-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: para
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.9.2
20
+ - - "<="
18
21
  - !ruby/object:Gem::Version
19
- version: '0.8'
22
+ version: '1.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 0.9.2
30
+ - - "<="
25
31
  - !ruby/object:Gem::Version
26
- version: '0.8'
32
+ version: '1.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: bundler
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -76,21 +82,31 @@ files:
76
82
  - ".gitignore"
77
83
  - ".rspec"
78
84
  - ".travis.yml"
85
+ - ".vscode/settings.json"
79
86
  - Gemfile
80
87
  - LICENSE.txt
81
88
  - README.md
82
89
  - Rakefile
83
- - app/assets/javascripts/para/admin/translation.coffee
84
- - app/assets/javascripts/para/i18n.coffee
85
90
  - app/controllers/para/admin/translations_controller.rb
91
+ - app/helpers/para/i18n/form_helper.rb
92
+ - app/helpers/para/i18n/urls_helper.rb
93
+ - app/javascripts/para/admin/translation_locale_select_controller.js
94
+ - app/javascripts/para/i18n.js
95
+ - app/views/para/admin/resources/_translations_fields.html.haml
96
+ - app/views/para/admin/resources/_translations_fields_container.html.haml
86
97
  - app/views/para/admin/resources/_translations_form.html.haml
87
- - app/views/para/admin/translations/_target_locale_select.html.haml
98
+ - app/views/para/admin/translations/_target_locale_select.html.erb
88
99
  - app/views/para/admin/translations/edit.html.haml
89
100
  - bin/console
90
101
  - bin/setup
91
102
  - config/locales/para-i18n.fr.yml
103
+ - dist/index.js
104
+ - dist/index.js.map
105
+ - lib/generators/para/i18n/base_form_generator.rb
92
106
  - lib/generators/para/i18n/form/form_generator.rb
93
107
  - lib/generators/para/i18n/form/templates/_translations_form.html.haml
108
+ - lib/generators/para/i18n/nested_fields/nested_fields_generator.rb
109
+ - lib/generators/para/i18n/nested_fields/templates/_translations_fields.html.haml
94
110
  - lib/generators/para/i18n/translate/templates/model_migration.rb.erb
95
111
  - lib/generators/para/i18n/translate/translate_generator.rb
96
112
  - lib/para/i18n.rb
@@ -100,21 +116,28 @@ files:
100
116
  - lib/para/i18n/attribute_translation/simple_attribute.rb
101
117
  - lib/para/i18n/engine.rb
102
118
  - lib/para/i18n/fallbacks.rb
119
+ - lib/para/i18n/form_builder.rb
120
+ - lib/para/i18n/form_builder/nested_form.rb
121
+ - lib/para/i18n/form_builder/translations_form.rb
103
122
  - lib/para/i18n/friendly_id.rb
104
123
  - lib/para/i18n/helpers.rb
105
124
  - lib/para/i18n/helpers/translations_form_helper.rb
106
125
  - lib/para/i18n/helpers/translations_helper.rb
107
126
  - lib/para/i18n/i18n_input.rb
127
+ - lib/para/i18n/inputs.rb
128
+ - lib/para/i18n/inputs/nested_many_input.rb
108
129
  - lib/para/i18n/model.rb
109
130
  - lib/para/i18n/resources_buttons.rb
110
131
  - lib/para/i18n/resources_table.rb
111
132
  - lib/para/i18n/version.rb
133
+ - package.json
112
134
  - para-i18n.gemspec
135
+ - yarn.lock
113
136
  homepage: https://github.com/para-cms/para-i18n
114
137
  licenses:
115
138
  - MIT
116
139
  metadata: {}
117
- post_install_message:
140
+ post_install_message:
118
141
  rdoc_options: []
119
142
  require_paths:
120
143
  - lib
@@ -129,9 +152,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
152
  - !ruby/object:Gem::Version
130
153
  version: '0'
131
154
  requirements: []
132
- rubyforge_project:
133
- rubygems_version: 2.6.11
134
- signing_key:
155
+ rubygems_version: 3.5.16
156
+ signing_key:
135
157
  specification_version: 4
136
158
  summary: Para CMS I18n admin module for models
137
159
  test_files: []
@@ -1,10 +0,0 @@
1
- class TranslationLocaleSelect
2
- @onChange = ($field) ->
3
- targetURL = $field.data('locale-select-target-url')
4
- targetLocale = $field.val()
5
- targetURL = targetURL.replace('target_locale=_', ['target_locale', targetLocale].join('='))
6
- Turbolinks.visit(targetURL.replace(':locale', targetLocale))
7
-
8
- $(document).on 'page:change turbolinks:load', ->
9
- $('body').on 'change', '[data-locale-select]', (e) ->
10
- TranslationLocaleSelect.onChange($(e.currentTarget))
@@ -1 +0,0 @@
1
- #= require ./admin/translation
@@ -1,5 +0,0 @@
1
- .block.form-inputs
2
- .form-group
3
- = label :target_locale, t('para.i18n.choose_locale'), class: 'control-label col-md-3 pull-left'
4
- .col-md-9
5
- = select_tag :target_locale, options_for_select(locales.map { |locale| [locale, locale] }, target_locale), data: { :'locale-select' => true, selectize: true, multi: false, value: { text: target_locale, value: target_locale }, :'locale-select-target-url' => @component.relation_path(resource, :translation, action: :edit, target_locale: '_') }