Skip to content

Commit 60703c9

Browse files
committed
Merge branch 'release/16.5' into dev
2 parents 8e3d11f + 8108de9 commit 60703c9

File tree

11 files changed

+100
-21
lines changed

11 files changed

+100
-21
lines changed

app/components/enterprise_edition/plan_for_feature.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def plan
8181
end
8282

8383
def plan_text
84-
plan_name = render(Primer::Beta::Text.new(font_weight: :bold, classes: "upsell-colored")) do
84+
plan_name = render(Primer::Beta::Text.new(font_weight: :bold, classes: "upsell-colored-text")) do
8585
I18n.t("ee.upsell.plan_name", plan: plan.capitalize)
8686
end
8787

app/components/enterprise_edition/trial_teaser_component.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def description
6969
end
7070

7171
def plan_name
72-
render(Primer::Beta::Text.new(font_weight: :bold, classes: "upsell-colored")) do
72+
render(Primer::Beta::Text.new(font_weight: :bold, classes: "upsell-colored-text")) do
7373
I18n.t("ee.upsell.plan_name", plan: token.plan.capitalize)
7474
end
7575
end

app/models/custom_value/calculated_value_strategy.rb

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,26 @@ def typed_value
3838
end
3939

4040
def formatted_value
41-
integer_value? ? value.to_s : number_with_delimiter(value.to_s)
41+
return "" if value.blank?
42+
43+
if integer_value?
44+
number_with_delimiter(value.to_i)
45+
else
46+
delimiter = I18n.t("number.format.delimiter")
47+
separator = I18n.t("number.format.separator")
48+
formatted = number_with_precision(value.to_f,
49+
precision: 3,
50+
strip_insignificant_zeros: true,
51+
delimiter:,
52+
separator:)
53+
54+
# Ensure at least one decimal place for floats
55+
if formatted.exclude?(separator)
56+
"#{formatted}#{separator}0"
57+
else
58+
formatted
59+
end
60+
end
4261
end
4362

4463
def validate_type_of_value
@@ -51,6 +70,6 @@ def validate_type_of_value
5170
private
5271

5372
def integer_value?
54-
value && value =~ /\A\d+\z/
73+
value =~ /\A[-+]?\d+\z/
5574
end
5675
end

app/models/custom_value/float_strategy.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ def typed_value
3838
end
3939

4040
def formatted_value
41+
return "" if value.blank?
42+
4143
number_with_delimiter(value.to_s)
4244
end
4345

app/models/custom_value/int_strategy.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,16 @@
2929
#++
3030

3131
class CustomValue::IntStrategy < CustomValue::FormatStrategy
32+
include ActionView::Helpers::NumberHelper
33+
3234
def typed_value
33-
if value.present?
34-
value.to_i
35-
end
35+
value.to_i if value.present?
36+
end
37+
38+
def formatted_value
39+
return "" if value.blank?
40+
41+
number_with_delimiter(value.to_s)
3642
end
3743

3844
def validate_type_of_value

app/views/custom_styles/_primer_color_mapping.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
--ck-color-button-on-disabled-background: var(--button-default-bgColor-disabled);
9292
--ck-color-labeled-field-label-background: var(--overlay-bgColor);
9393
--ck-color-input-disabled-background: var(--bgColor-disabled);
94+
--enterprise-upsell-text-color: var(--enterprise-upsell-color);
9495
}
9596

9697
[data-dark-theme=dark_high_contrast] {

frontend/src/global_styles/content/_enterprise.sass

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
.upsell-colored
4141
color: var(--enterprise-upsell-color) !important
4242

43+
.upsell-colored-text
44+
color: var(--enterprise-upsell-text-color) !important
45+
4346
.upsell-colored-background
4447
background: var(--enterprise-upsell-color) !important
4548
color: white !important

frontend/src/global_styles/openproject/_variable_defaults.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,6 @@
133133
--full-view-split-right-width: 550px;
134134
--gantt-split-width: 50%;
135135
--enterprise-upsell-color: #FB8F44;
136+
--enterprise-upsell-text-color: #CE4C00;
136137
--enterprise-upsell-border-color: #fb8f4466;
137138
}

spec/features/admin/scim_clients/index_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
visit admin_scim_clients_path
4141

4242
expect(page).to be_axe_clean.within("#content")
43-
.skipping("color-contrast") # https://community.openproject.org/wp/65507
4443

4544
expect(page).to have_enterprise_banner(:corporate)
4645
expect(page).to have_no_test_selector("Admin::ScimClients::TableComponent")

spec/models/custom_value/calculated_value_strategy_spec.rb

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,24 +66,54 @@
6666
subject { instance.formatted_value }
6767

6868
context "when value is a float string" do
69-
let(:value) { "3.14" }
69+
let(:value) { "32400.14" }
7070

71-
it "is the float string" do
72-
expect(subject).to eql value
71+
it "is the float string with delimiters" do
72+
expect(subject).to eql "32,400.14"
7373
end
7474

75-
it "is localized" do
75+
it "is localized with delimiters" do
7676
I18n.with_locale(:de) do
77-
expect(subject).to eql "3,14"
77+
expect(subject).to eql "32.400,14"
7878
end
7979
end
8080
end
8181

82+
context "when value is a float string with many zeroed decimals" do
83+
let(:value) { "3.0000000000000000000000000000009" }
84+
85+
it "is formatted as a float with a minimum precision" do
86+
expect(subject).to eql "3.0"
87+
end
88+
end
89+
90+
context "when value is a float string with some zeroed decimals" do
91+
let(:value) { "3.000" }
92+
93+
it "is formatted as a float with a minimum precision" do
94+
expect(subject).to eql "3.0"
95+
end
96+
end
97+
98+
context "when value is a float string with digits after the decimal point" do
99+
let(:value) { "42.87391" }
100+
101+
it "is formatted as a float with a precision of 3 while rounding decimal places" do
102+
expect(subject).to eql "42.874"
103+
end
104+
end
105+
82106
context "when value is an int string" do
83-
let(:value) { "42" }
107+
let(:value) { "42312" }
84108

85-
it "is the int string" do
86-
expect(subject).to eql value
109+
it "is the int string with delimiters" do
110+
expect(subject).to eql "42,312"
111+
end
112+
113+
it "is localized with delimiters" do
114+
I18n.with_locale(:de) do
115+
expect(subject).to eql "42.312"
116+
end
87117
end
88118
end
89119

0 commit comments

Comments
 (0)