base_editing_bootstrap 1.1.0 → 1.3.0

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: a1e80d543ff93c2a170069bb78b4f78488819804458f1e5a36c87fd7d0975476
4
- data.tar.gz: b65c0f800fe834ac24794e292c8e09c7e2910e2f5e1b0ba215aadd69ee7ff168
3
+ metadata.gz: 83d2f87db81cd1d75dc4da9b979b5ff497c90f098b9081536e066d3aa86836e1
4
+ data.tar.gz: b84fd68fe596b603d0a0f356e1e532e8b2f24c7a0b9f78712fd412e449c75663
5
5
  SHA512:
6
- metadata.gz: 776c45e8aab54bb0208bf9b0af8728a2467b9943dec257f6e55527be03c53cfd7996e7f370a63ef29d769fe318a4937435bb7759eabf130c08f070d88c8b0eb8
7
- data.tar.gz: 749586e54204dab5ad28c227d03fab252a79483e63a7f6cf07cb6ce84aca05aded2408f6092578ce3f39fca61ac4708b4c4692a3fb67c3722a1ca350dada2392
6
+ metadata.gz: 9592453e9d94965266b86a5704dc658e00236393d734d8c31eb10ec620fda2cc35de1f283268bed03a8937f7a842298d02a4da0442730e1c750df27e6b135b8a
7
+ data.tar.gz: 9e3677d9c11a2b5bcf60e173a864325ee6fdce0c746261c1aeab05a0ecfaacfbbd54150ccb2d24d763e24b32d3d2944724dce2566e1c2a058e97e8e9baf12ace
data/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
  All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.
3
3
 
4
4
  - - -
5
+ ## 1.3.0 - 2025-01-09
6
+ #### Documentation
7
+ - Aggiunta documentazione per override search field - (ba97155) - Marino Bonetti
8
+ #### Features
9
+ - Translated Namespaced button (#12) - (7e06c5f) - Marino Bonetti
10
+ #### Tests
11
+ - Add sub view for dummy posts - (0b25868) - Marino Bonetti
12
+
13
+ - - -
14
+
15
+ ## 1.2.0 - 2025-01-09
16
+ #### Features
17
+ - Add new method to get label from search field - (ace5fa0) - Marino Bonetti
18
+ #### Tests
19
+ - Add Menu for navigation in dummy - (2b2a9a6) - Marino Bonetti
20
+
21
+ - - -
22
+
5
23
  ## 1.1.0 - 2025-01-03
6
24
  #### Continuous Integration
7
25
  - Add ruby 3.4 - (5658bb0) - Marino Bonetti
data/README.md CHANGED
@@ -173,6 +173,12 @@ Utilizzo per modello base, in questo esempio prendiamo come modello Post come es
173
173
  #...
174
174
  ```
175
175
 
176
+ ### Translations
177
+ Traduzioni disponibili:
178
+ Per i bottoni della index, è possibile eseguire l'override del testo presente nel bottone.
179
+ Leggere la documentazione nel file `app/helpers/base_editing_helper.rb#translate_with_controller_scoped`
180
+
181
+
176
182
  ## Testing helpers
177
183
 
178
184
  ### Requirements(installed with generators)
@@ -5,5 +5,42 @@ module BaseEditingHelper
5
5
  include Utilities::FormHelper
6
6
  include Utilities::IconHelper
7
7
 
8
+ ##
9
+ # Estrapola la traduzione, andando ad includere la path del controller nella ricerca della chiave
10
+ # Viene tenuto conto anche del namespace del controller assieme ai suoi namespace
11
+ # ES:
12
+ # In un caso in cui abbiamo un controller di questo tipo: Customer::PostsController < PostsController
13
+ # la ricerca della chiave .destroy partendo dal partial app/views/base_editing/_search_result_buttons.html.erb
14
+ # sarà così composta:
15
+ #
16
+ # it.customer/posts.index.base_editing.search_result_buttons.destroy => nil
17
+ # it.customer/posts.base_editing.search_result_buttons.destroy => nil
18
+ # it.posts.index.base_editing.search_result_buttons.destroy => nil
19
+ # it.posts.base_editing.search_result_buttons.destroy => nil
20
+ # it.base_editing.index.base_editing.search_result_buttons.destroy => nil
21
+ # it.base_editing.base_editing.search_result_buttons.destroy => nil
22
+ # it.restricted_area.index.base_editing.search_result_buttons.destroy => nil
23
+ # it.restricted_area.base_editing.search_result_buttons.destroy => nil
24
+ # it.authentication.index.base_editing.search_result_buttons.destroy => nil
25
+ # it.authentication.base_editing.search_result_buttons.destroy => nil
26
+ # it.base_editing.search_result_buttons.destroy => nil
27
+ #
28
+ def translate_with_controller_scoped(key, **options)
29
+ if key&.start_with?(".")
30
+ inner_key = scope_key_by_partial(key)
31
+ defaults = []
32
+ paths = controller.class.ancestors.select { |c| c < ApplicationController }.collect(&:controller_path).uniq
33
+ paths.each do |path|
34
+ defaults << [:"#{path}.#{action_name}.#{inner_key}", :"#{path}.#{inner_key}"]
35
+ end
36
+ defaults << inner_key.to_sym
37
+ defaults << options[:default] if options.key?(:default)
38
+ key = nil
39
+ options[:default] = defaults.flatten
40
+ end
41
+
42
+ # dobbiamo eliminare possibili duplicati nello scope delle chiavi
43
+ t(key, **options)
44
+ end
8
45
 
9
46
  end
@@ -1,3 +1,9 @@
1
+ <%
2
+ ##
3
+ # Il campo search_field è un BaseEditingBootstrap::Searches::Field.
4
+ # Per strutturare in modo differente il campo di ricerca si ha a disposizione
5
+ # l'helper BaseEditingBootstrap::Searches::Field#label che stampa il contenuto della label
6
+ %>
1
7
  <div class="form-group col-xs-6 col-sm-4 col-md-3">
2
8
  <%= ransack_form_builder.label(search_field.name) %>
3
9
  <%= ransack_form_builder.search_field(search_field.name, class: "form-control form-control-sm") %>
@@ -1,15 +1,14 @@
1
1
  <%# locals: (obj:) -%>
2
- <%= link_to(icon("pencil-square"),
2
+ <%= link_to(icon("pencil-square", translate_with_controller_scoped(".edit", default: [:edit,""])),
3
3
  edit_custom_polymorphic_path(obj),
4
4
  class: "btn btn-sm btn-primary me-1") if policy(obj).edit? %>
5
5
 
6
-
7
- <%= link_to(icon(:eye),
6
+ <%= link_to(icon(:eye, translate_with_controller_scoped(".show", default: [:show,""])),
8
7
  show_custom_polymorphic_path(obj),
9
8
  class: "btn btn-sm btn-primary me-1") if policy(obj).show? %>
10
9
 
11
10
 
12
- <%= link_to(icon(:trash),
11
+ <%= link_to(icon(:trash, translate_with_controller_scoped(".destroy", default: [:destroy,""])),
13
12
  destroy_custom_polymorphic_path(obj),
14
13
  data: {
15
14
  turbo_method: :delete,
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.3.0
@@ -6,6 +6,8 @@ module BaseEditingBootstrap::Searches
6
6
  class Field
7
7
  attr_reader :search_base, :name
8
8
 
9
+ # @param [BaseEditingBootstrap::Searches::Base] search_base
10
+ # @param [Symbol] name
9
11
  def initialize(search_base, name)
10
12
  @search_base = search_base
11
13
  @name = name
@@ -14,5 +16,12 @@ module BaseEditingBootstrap::Searches
14
16
  def to_partial_path
15
17
  "search_field"
16
18
  end
19
+
20
+ ##
21
+ # Helper per estrapolare la label del campo
22
+ # @return [String]
23
+ def label
24
+ @search_base.ransack_query.translate(name)
25
+ end
17
26
  end
18
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: base_editing_bootstrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marino Bonetti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-03 00:00:00.000000000 Z
11
+ date: 2025-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails