Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add DB field and checkbox for long text field CFs to save text orientation

Henriette Dingerc3f9f1c7c311
diff --git a/app/assets/javascripts/custom-fields.js b/app/assets/javascripts/custom-fields.js
index 9cb07500c70..5c13acb2f44 100644
--- a/app/assets/javascripts/custom-fields.js
+++ b/app/assets/javascripts/custom-fields.js
@@ -44,7 +44,8 @@
possibleValues = $('#custom_field_possible_values_attributes'),
defaultValueFields = $('#custom_field_default_value_attributes'),
spanDefaultText = $('#default_value_text'),
- spanDefaultBool = $('#default_value_bool');
+ spanDefaultBool = $('#default_value_bool'),
+ textOrientationField = $('#custom_field_text_orientation');
var deactivate = function(element) {
element.hide().find('input, textarea').not('.destroy_flag,.-cf-ignore-disabled').attr('disabled', true);
@@ -65,7 +66,7 @@
unsearchable = function() { searchable.attr('checked', false).hide(); };
// defaults (reset these fields before doing anything else)
- $.each([spanDefaultBool, spanDefaultText, multiSelect], function(idx, element) {
+ $.each([spanDefaultBool, spanDefaultText, multiSelect, textOrientationField], function(idx, element) {
deactivate(element);
});
show(defaultValueFields);
@@ -107,6 +108,11 @@
hide(lengthField, regexpField, defaultValueFields);
unsearchable();
break;
+ case 'text':
+ show(lengthField, regexpField, searchable, textOrientationField);
+ deactivate(possibleValues);
+ activate(textOrientationField);
+ break;
default:
show(lengthField, regexpField, searchable);
deactivate(possibleValues);
diff --git a/app/models/permitted_params.rb b/app/models/permitted_params.rb
index d32e6abb519..b25500f4dd0 100644
--- a/app/models/permitted_params.rb
+++ b/app/models/permitted_params.rb
@@ -480,6 +480,7 @@ class PermittedParams
:default_value,
:possible_values,
:multi_value,
+ :content_right_to_left,
{ custom_options_attributes: %i(id value default_value position) },
type_ids: []
],
diff --git a/app/views/custom_fields/_form.html.erb b/app/views/custom_fields/_form.html.erb
index fa2bf08d37d..18f59d2afa9 100644
--- a/app/views/custom_fields/_form.html.erb
+++ b/app/views/custom_fields/_form.html.erb
@@ -107,6 +107,7 @@ See docs/COPYRIGHT.rdoc for more details.
<div class="form--field"><%= f.check_box :is_for_all %></div>
<div class="form--field"><%= f.check_box :is_filter %></div>
<div class="form--field" id="searchable_container"><%= f.check_box :searchable %></div>
+ <div class="form--field" id="custom_field_text_orientation"><%= f.check_box :content_right_to_left %></div>
<% when "UserCustomField" %>
<div class="form--field"><%= f.check_box :is_required %></div>
<div class="form--field"><%= f.check_box :visible %></div>
diff --git a/db/migrate/20191115141154_add_content_orientation_to_custom_fields.rb b/db/migrate/20191115141154_add_content_orientation_to_custom_fields.rb
new file mode 100644
index 00000000000..7fbfb7b5fd3
--- /dev/null
+++ b/db/migrate/20191115141154_add_content_orientation_to_custom_fields.rb
@@ -0,0 +1,5 @@
+class AddContentOrientationToCustomFields < ActiveRecord::Migration[6.0]
+ def change
+ add_column :custom_fields, :content_right_to_left, :boolean, default: false
+ end
+end