-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add feature to multilingualize item names defined in DB(draft) #2
- Loading branch information
1 parent
f4993cc
commit 0a75581
Showing
21 changed files
with
245 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<%= form_tag custom_message_settings_path, method: :post do %> | ||
<div id='edit-custom-messages'> | ||
<%= render 'custom_message_settings/messages', lang: @lang %> | ||
</div> | ||
<%= submit_tag l(:button_save) %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<div> | ||
<%= select_tag 'select-key', customizable_name_options(@setting, lang), id: 'customizable-name-selector', :include_blank => true %><br> | ||
<span class='icon icon-help'><%= l(:text_description_of_search_box) %></span> | ||
</div> | ||
<br> | ||
<div class='tabular'> | ||
<%= customizable_name_input_fields(@setting, lang) %> | ||
</div> | ||
<%= javascript_tag do %> | ||
$(document).ready(function() { | ||
setCustomNamesSelect2(); | ||
}); | ||
|
||
$('#customizable-name-selector').on('select2:select', function (e) { | ||
const key = e.params.data.id; | ||
const val = e.params.data.text; | ||
const category = key.replace(/[0-9]/g, '').slice(0, -1); | ||
const selector = '#edit-custom-names div#' + category; | ||
|
||
if($(selector + ' input[name="settings[custom_names[' + key + ']]"]').length === 0){ | ||
$(selector).prepend('<p></p>'); | ||
$('<label>' + val + '</label><br>').appendTo($(selector + ' p:first')); | ||
$('<input>').attr({ | ||
type: 'text', | ||
value: val, | ||
name: 'settings[custom_names[' + key + ']]', | ||
}).appendTo($(selector + ' p:first')); | ||
$('<a>').attr({ | ||
class: 'icon icon-del clear-key-link', | ||
href: '#', | ||
onclick: '$(this).closest("p").remove(); return false;' | ||
}).appendTo($(selector + ' p:first')); | ||
$('#customizable-name-selector').val('').change(); | ||
$('#customizable-name-selector option[value="' + key + '"]').prop("disabled", true).change(); | ||
setCustomNamesSelect2(); | ||
} | ||
}); | ||
|
||
function setCustomNamesSelect2(){ | ||
$("#customizable-name-selector").select2({ | ||
width: '100%', | ||
placeholder: '<%= l(:text_placeholder_choose_key) %>' | ||
}); | ||
} | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<%= form_tag custom_message_settings_path, method: :post do %> | ||
<div id='edit-custom-names'> | ||
<%= render 'custom_message_settings/names', lang: @lang %> | ||
</div> | ||
<%= submit_tag l(:button_save) %> | ||
<% end %> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
$('#edit-custom-messages').html("<%= j (render 'custom_message_settings/messages', lang: @lang) %>"); | ||
$('#edit-custom-names').html("<%= j (render 'custom_message_settings/names', lang: @lang) %>"); | ||
$('#ajax-indicator').hide(); |
1 change: 1 addition & 0 deletions
1
...ustom_message_settings/_yaml_tab.html.erb → ...ustom_message_settings/yaml_edit.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require_dependency 'custom_field' | ||
|
||
module CustomMessages | ||
module CustomFieldPatch | ||
def name | ||
l("custom_object_name.custom_field_#{self.id}", {default: super, fallback: false}) | ||
end | ||
end | ||
end | ||
|
||
unless CustomField.included_modules.include?(CustomMessages::CustomFieldPatch) | ||
CustomField.prepend(CustomMessages::CustomFieldPatch) | ||
end |
Oops, something went wrong.