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 options Hash to schema && add display class for right-to-left text

Henriette Dingerd4e5aa9c2dc9
diff --git a/app/assets/stylesheets/openproject/_generic.sass b/app/assets/stylesheets/openproject/_generic.sass
index 5582932d305..936c637e01c 100644
--- a/app/assets/stylesheets/openproject/_generic.sass
+++ b/app/assets/stylesheets/openproject/_generic.sass
@@ -86,6 +86,8 @@
font-style: italic
.-small-font
font-size: 12px
+.-rtl
+ direction: rtl
.drop-zone.-dragged-over
background-color: #eaeaea60
diff --git a/frontend/src/app/components/wp-edit-form/display-field-renderer.ts b/frontend/src/app/components/wp-edit-form/display-field-renderer.ts
index 36e67bbd51d..22b36655840 100644
--- a/frontend/src/app/components/wp-edit-form/display-field-renderer.ts
+++ b/frontend/src/app/components/wp-edit-form/display-field-renderer.ts
@@ -61,7 +61,7 @@ export class DisplayFieldRenderer<T extends HalResource = HalResource> {
}
const field = this.getField(resource, fieldSchema, schemaName, change);
- field.render(span, this.getText(field, fieldSchema, placeholder));
+ field.render(span, this.getText(field, fieldSchema, placeholder), fieldSchema.options);
const title = field.title;
if (title) {
diff --git a/frontend/src/app/modules/fields/display/display-field.module.ts b/frontend/src/app/modules/fields/display/display-field.module.ts
index b88458706cc..89f0ccee538 100644
--- a/frontend/src/app/modules/fields/display/display-field.module.ts
+++ b/frontend/src/app/modules/fields/display/display-field.module.ts
@@ -118,7 +118,7 @@ export class DisplayField<T extends HalResource = HalResource> extends Field {
return this.valueString;
}
- public render(element:HTMLElement, displayText:string):void {
+ public render(element:HTMLElement, displayText:string, options:any = {}):void {
element.textContent = displayText;
}
diff --git a/frontend/src/app/modules/fields/display/field-types/formattable-display-field.module.ts b/frontend/src/app/modules/fields/display/field-types/formattable-display-field.module.ts
index 6eb1a2d9bb3..e602231ab1c 100644
--- a/frontend/src/app/modules/fields/display/field-types/formattable-display-field.module.ts
+++ b/frontend/src/app/modules/fields/display/field-types/formattable-display-field.module.ts
@@ -35,9 +35,10 @@ export class FormattableDisplayField extends DisplayField {
private readonly appRef = this.$injector.get(ApplicationRef);
- public render(element:HTMLElement, displayText:string):void {
+ public render(element:HTMLElement, displayText:string, options:any = {}):void {
let div = document.createElement('div');
div.classList.add('read-value--html', 'wiki', 'highlight', '-multiline');
+ if (options.rtl) { div.classList.add('-rtl'); }
div.innerHTML = displayText;
element.innerHTML = '';
diff --git a/lib/api/decorators/property_schema_representer.rb b/lib/api/decorators/property_schema_representer.rb
index 388f2235e40..6249d6011d6 100644
--- a/lib/api/decorators/property_schema_representer.rb
+++ b/lib/api/decorators/property_schema_representer.rb
@@ -61,7 +61,8 @@ module API
:attribute_group,
:min_length,
:max_length,
- :regular_expression
+ :regular_expression,
+ :options
property :type, exec_context: :decorator
property :name, exec_context: :decorator
@@ -73,6 +74,7 @@ module API
property :min_length, exec_context: :decorator
property :max_length, exec_context: :decorator
property :regular_expression, exec_context: :decorator
+ property :options, exec_context: :decorator
private
diff --git a/lib/api/decorators/schema_representer.rb b/lib/api/decorators/schema_representer.rb
index 1b95e1a4aea..55712312054 100644
--- a/lib/api/decorators/schema_representer.rb
+++ b/lib/api/decorators/schema_representer.rb
@@ -63,6 +63,7 @@ module API
min_length: nil,
max_length: nil,
regular_expression: nil,
+ options: {},
show_if: true)
getter = ->(*) do
schema_property_getter(type,
@@ -74,7 +75,8 @@ module API
attribute_group,
min_length,
max_length,
- regular_expression)
+ regular_expression,
+ options)
end
schema_property(property,
@@ -286,7 +288,8 @@ module API
attribute_group,
min_length,
max_length,
- regular_expression)
+ regular_expression,
+ options)
name = call_or_translate(name_source)
schema = ::API::Decorators::PropertySchemaRepresenter
.new(type: call_or_use(type),
@@ -299,6 +302,7 @@ module API
schema.min_length = min_length
schema.max_length = max_length
schema.regular_expression = regular_expression
+ schema.options = options
schema
end
diff --git a/lib/api/v3/utilities/custom_field_injector.rb b/lib/api/v3/utilities/custom_field_injector.rb
index 1ce81b4f352..374d655b51e 100644
--- a/lib/api/v3/utilities/custom_field_injector.rb
+++ b/lib/api/v3/utilities/custom_field_injector.rb
@@ -188,7 +188,8 @@ module API
writable: writable,
min_length: cf_min_length(custom_field),
max_length: cf_max_length(custom_field),
- regular_expression: cf_regexp(custom_field)
+ regular_expression: cf_regexp(custom_field),
+ options: cf_options(custom_field)
end
def path_method_for(custom_field)
@@ -321,6 +322,12 @@ module API
custom_field.regexp unless custom_field.regexp.blank?
end
+ def cf_options(custom_field)
+ {
+ rtl: ("true" if custom_field.content_right_to_left)
+ }
+ end
+
def list_schemas_values_callback(custom_field)
->(*) { represented.assignable_custom_field_values(custom_field) }
end