Skip to content

Commit

Permalink
Custom text for add/delete block buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
jtilatti authored and nanego committed Oct 10, 2023
1 parent d9a79d9 commit eaf1ab4
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 7 deletions.
11 changes: 11 additions & 0 deletions app/views/issue_templates/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,14 @@
<div id="all_attributes">
<%= render :partial => 'issue_templates/form' %>
</div>

<%= javascript_tag do %>
// Display button title form if bloc is set as repeatable
$( document ).ready(function() {
$(".repeatable_checkbox").each(function(){
if($(this).is(':checked')){
$(this.parentElement.nextElementSibling).show();
}
});
});
<% end %>
20 changes: 19 additions & 1 deletion app/views/issue_templates/sections/_group_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@
</p>
<div class="collapsible">
<p>
<%= form.check_box :repeatable, label: "Bloc répétable" %>
<%= form.check_box :repeatable, label: "Bloc répétable", onclick: "displayRepeatableButtonField(event)", class: "repeatable_checkbox"%>
</p>
<div style="display: none;">
<p>
<%= form.text_field :add_button_title, :placeholder => t("add_repeatable_bloc"), :label => t("add_repeatable_bloc_label"), :size => 45, :required => false %>
</p>
<p>
<%= form.text_field :delete_button_title, :placeholder => t("delete_repeatable_bloc"), :label => t("delete_repeatable_bloc_label"), :size => 45, :required => false %>
</p>
</div>
<p>
<%= form.check_box :retracted, label: "Bloc escamoté par défaut" %>
</p>
Expand Down Expand Up @@ -46,3 +54,13 @@

</div>
<% end %>
<%= javascript_tag do %>
function displayRepeatableButtonField(){
if(event.target.checked) {
event.target.parentElement.nextElementSibling.style.display = "";
} else {
event.target.parentElement.nextElementSibling.style.display = "none";
}
}
<% end %>
7 changes: 3 additions & 4 deletions app/views/issues/_section_group_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,17 @@
<% end %>
<% if group_index.to_i > 0 %>

<p style="margin-top: 0.5em">
<%= link_to 'Supprimer ce bloc', '#',
<% remove_section_title_button = section_group.delete_button_title.present? ? section_group.delete_button_title : t("delete_repeatable_bloc") %>
<%= link_to remove_section_title_button, '#',
class: 'destroy_sections_group icon icon-del',
title: "Répéter ce groupe de sections",
title: remove_section_title_button,
data: {
group_id: section_group.id,
group_index: group_index
}
%>
</p>

<% end %>

</div>
Expand Down
5 changes: 3 additions & 2 deletions app/views/issues/_sections_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
<div class="section_group_repeater">
<%= render 'issues/sections/separator_form' %>
<p style="margin-top: -1.5em">
<%= link_to 'Répéter ce bloc', '#',
<% add_section_title_button = section_group.add_button_title.present? ? section_group.add_button_title : t("add_repeatable_bloc") %>
<%= link_to add_section_title_button, '#',
class: 'add_sections_group icon icon-add',
title: "Répéter ce groupe de sections",
title: add_section_title_button,
data: {
sections_group_id: section_group.id,
sections_group_type: section_group.class.name
Expand Down
4 changes: 4 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,7 @@ en:
display_mode: Display mode
projects_count: Number of projects
read_only: Read only
add_repeatable_bloc: Repeat this bloc
delete_repeatable_bloc: Delete this bloc
add_repeatable_bloc_label: Custom text for block add button (optional)
delete_repeatable_bloc_label: Custom text for block delete button (optional)
4 changes: 4 additions & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@ fr:
display_mode: Type de rendu
projects_count: Nombre de projets
read_only: Lecture seule
add_repeatable_bloc: Répéter ce bloc
delete_repeatable_bloc: Supprimer ce bloc
add_repeatable_bloc_label: Texte personnalisé pour le bouton d\'ajout du bloc (facultatif)
delete_repeatable_bloc_label: Texte personnalisé pour le bouton de suppression du bloc (facultatif)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddPersonalizedButtonTitleToIssueTemplateSectionGroups < ActiveRecord::Migration[5.2]
def change
add_column :issue_template_section_groups, :add_button_title, :string
add_column :issue_template_section_groups, :delete_button_title, :string
end
end

0 comments on commit eaf1ab4

Please sign in to comment.