Skip to content

Commit 16e4c4d

Browse files
authored
Merge branch 'dev' into dependabot/bundler/dev/googleauth-1.15.0
2 parents 5adfff4 + 142035c commit 16e4c4d

File tree

485 files changed

+7950
-3023
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

485 files changed

+7950
-3023
lines changed

.pkgr.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ license: "GPL"
77
targets:
88
debian-11: &debian
99
build_dependencies:
10+
- wget
1011
- libsqlite3-dev
1112
dependencies:
1213
- unzip
@@ -39,7 +40,7 @@ targets:
3940
before_precompile: "packaging/setup"
4041
after_precompile: "packaging/teardown"
4142
services:
42-
- postgres
43+
- postgres:17
4344
installer: https://github.com/pkgr/installer.git
4445
wizards:
4546
- https://github.com/pkgr/addon-legacy-installer.git

app/components/work_packages/info_line_component.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<%=
2-
flex_layout do |flex|
2+
flex_layout(flex_wrap: :wrap) do |flex|
33
flex.with_column(mr: 2) do
44
render(WorkPackages::HighlightedTypeComponent.new(work_package: @work_package, font_size: :small))
55
end

app/contracts/custom_fields/hierarchy/insert_item_contract.rb renamed to app/contracts/custom_fields/hierarchy/insert_list_item_contract.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
#
2424
# You should have received a copy of the GNU General Public License
2525
# along with this program; if not, write to the Free Software
26-
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2727
#
2828
# See COPYRIGHT and LICENSE files for more details.
2929
#++
3030

3131
module CustomFields
3232
module Hierarchy
33-
class InsertItemContract < Dry::Validation::Contract
33+
class InsertListItemContract < Dry::Validation::Contract
3434
config.messages.backend = :i18n
3535

3636
params do
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# frozen_string_literal: true
2+
3+
#-- copyright
4+
# OpenProject is an open source project management software.
5+
# Copyright (C) the OpenProject GmbH
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License version 3.
9+
#
10+
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
11+
# Copyright (C) 2006-2013 Jean-Philippe Lang
12+
# Copyright (C) 2010-2013 the ChiliProject Team
13+
#
14+
# This program is free software; you can redistribute it and/or
15+
# modify it under the terms of the GNU General Public License
16+
# as published by the Free Software Foundation; either version 2
17+
# of the License, or (at your option) any later version.
18+
#
19+
# This program is distributed in the hope that it will be useful,
20+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
# GNU General Public License for more details.
23+
#
24+
# You should have received a copy of the GNU General Public License
25+
# along with this program; if not, write to the Free Software
26+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27+
#
28+
# See COPYRIGHT and LICENSE files for more details.
29+
#++
30+
31+
module CustomFields
32+
module Hierarchy
33+
class InsertScoredItemContract < Dry::Validation::Contract
34+
config.messages.backend = :i18n
35+
36+
params do
37+
required(:parent).filled(type?: CustomField::Hierarchy::Item)
38+
required(:label).filled(:string)
39+
required(:score).filled(:decimal)
40+
end
41+
42+
rule(:parent) do
43+
next if schema_error?(:parent)
44+
45+
key.failure("must exist") unless value.persisted?
46+
end
47+
48+
rule(:label) do
49+
next if schema_error?(:parent)
50+
51+
key.failure(:not_unique) if values[:parent].children.exists?(label: value)
52+
end
53+
end
54+
end
55+
end

app/contracts/custom_fields/hierarchy/update_item_contract.rb renamed to app/contracts/custom_fields/hierarchy/update_list_item_contract.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
#
2424
# You should have received a copy of the GNU General Public License
2525
# along with this program; if not, write to the Free Software
26-
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2727
#
2828
# See COPYRIGHT and LICENSE files for more details.
2929
#++
3030

3131
module CustomFields
3232
module Hierarchy
33-
class UpdateItemContract < Dry::Validation::Contract
33+
class UpdateListItemContract < Dry::Validation::Contract
3434
config.messages.backend = :i18n
3535

3636
params do
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# frozen_string_literal: true
2+
3+
#-- copyright
4+
# OpenProject is an open source project management software.
5+
# Copyright (C) the OpenProject GmbH
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License version 3.
9+
#
10+
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
11+
# Copyright (C) 2006-2013 Jean-Philippe Lang
12+
# Copyright (C) 2010-2013 the ChiliProject Team
13+
#
14+
# This program is free software; you can redistribute it and/or
15+
# modify it under the terms of the GNU General Public License
16+
# as published by the Free Software Foundation; either version 2
17+
# of the License, or (at your option) any later version.
18+
#
19+
# This program is distributed in the hope that it will be useful,
20+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
# GNU General Public License for more details.
23+
#
24+
# You should have received a copy of the GNU General Public License
25+
# along with this program; if not, write to the Free Software
26+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27+
#
28+
# See COPYRIGHT and LICENSE files for more details.
29+
#++
30+
31+
module CustomFields
32+
module Hierarchy
33+
class UpdateScoredItemContract < Dry::Validation::Contract
34+
config.messages.backend = :i18n
35+
36+
params do
37+
required(:item).filled(type?: CustomField::Hierarchy::Item)
38+
optional(:label).filled(:string)
39+
optional(:score).filled(:decimal)
40+
end
41+
42+
rule(:item) do
43+
key.failure(:not_persisted) if value.new_record?
44+
key.failure(:root_item) if value.root?
45+
end
46+
47+
rule(:label) do
48+
next if schema_error?(:item)
49+
50+
key.failure(:not_unique) if values[:item].siblings.exists?(label: value)
51+
end
52+
end
53+
end
54+
end

app/controllers/admin/custom_fields/hierarchy/items_controller.rb

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#
2424
# You should have received a copy of the GNU General Public License
2525
# along with this program; if not, write to the Free Software
26-
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2727
#
2828
# See COPYRIGHT and LICENSE files for more details.
2929
#++
@@ -62,7 +62,7 @@ def edit; end
6262

6363
def create
6464
item_service
65-
.insert_item(**item_input)
65+
.insert_item(contract_class: create_contract, **item_input)
6666
.either(
6767
lambda do |item|
6868
redirect_to(
@@ -78,8 +78,13 @@ def create
7878
end
7979

8080
def update
81+
input = item_input
8182
item_service
82-
.update_item(item: @active_item, label: item_input[:label], short: item_input[:short])
83+
.update_item(contract_class: update_contract,
84+
item: @active_item,
85+
label: input[:label],
86+
short: input[:short],
87+
score: input[:score])
8388
.either(
8489
lambda do |_|
8590
redirect_to(custom_field_item_path(@custom_field, @active_item.parent), status: :see_other)
@@ -119,14 +124,37 @@ def item_service
119124
::CustomFields::Hierarchy::HierarchicalItemService.new
120125
end
121126

122-
def item_input
127+
def item_input # rubocop:disable Metrics/AbcSize
123128
input = { parent: @active_item, label: params[:label] }
124129
input[:short] = params[:short] if params[:short].present?
130+
input[:score] = params[:score] if params[:score].present?
125131
input[:sort_order] = params[:sort_order].to_i if params[:sort_order].present?
126132

127133
input
128134
end
129135

136+
def create_contract
137+
case @custom_field.field_format
138+
when "hierarchy"
139+
::CustomFields::Hierarchy::InsertListItemContract
140+
when "scored_list"
141+
::CustomFields::Hierarchy::InsertScoredItemContract
142+
else
143+
raise ArgumentError, "unsupported custom field format '#{@custom_field.field_format}'"
144+
end
145+
end
146+
147+
def update_contract
148+
case @custom_field.field_format
149+
when "hierarchy"
150+
::CustomFields::Hierarchy::UpdateListItemContract
151+
when "scored_list"
152+
::CustomFields::Hierarchy::UpdateScoredItemContract
153+
else
154+
raise ArgumentError, "unsupported custom field format '#{@custom_field.field_format}'"
155+
end
156+
end
157+
130158
def add_errors_to_form(validation_result)
131159
@new_item = ::CustomField::Hierarchy::Item.new(**item_input)
132160
validation_result.errors(full: true).to_h.each do |attribute, errors|
@@ -135,7 +163,7 @@ def add_errors_to_form(validation_result)
135163
end
136164

137165
def add_errors_to_edit_form(validation_result)
138-
@active_item.assign_attributes(**validation_result.to_h.slice(:label, :short))
166+
@active_item.assign_attributes(**validation_result.to_h.slice(:label, :short, :score))
139167

140168
validation_result.errors(full: true).to_h.each do |attribute, errors|
141169
@active_item.errors.add(attribute, errors.join(", "))

app/controllers/custom_styles_controller.rb

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ class CustomStylesController < ApplicationController
3535
menu_item :custom_style
3636

3737
UNGUARDED_ACTIONS = %i[logo_download
38-
export_logo_download
39-
export_cover_download
40-
export_footer_download
4138
favicon_download
4239
touch_icon_download].freeze
4340

@@ -76,6 +73,7 @@ def create
7673
end
7774

7875
def update
76+
flash.clear
7977
@custom_style = get_or_create_custom_style
8078
if @custom_style.update(custom_style_params)
8179
redirect_to custom_style_path
@@ -141,6 +139,22 @@ def favicon_delete
141139
file_delete(:remove_favicon)
142140
end
143141

142+
def export_font_regular_delete
143+
file_delete(:remove_export_font_regular)
144+
end
145+
146+
def export_font_bold_delete
147+
file_delete(:remove_export_font_bold)
148+
end
149+
150+
def export_font_italic_delete
151+
file_delete(:remove_export_font_italic)
152+
end
153+
154+
def export_font_bold_italic_delete
155+
file_delete(:remove_export_font_bold_italic)
156+
end
157+
144158
def touch_icon_delete
145159
file_delete(:remove_touch_icon)
146160
end
@@ -171,6 +185,19 @@ def update_themes
171185
redirect_to custom_style_path
172186
end
173187

188+
def export_demo_pdf_download
189+
result = ::Exports::PDF::DemoGenerator.new.export!
190+
expires_in 0, public: false
191+
send_data result.content,
192+
filename: result.title,
193+
type: "application/pdf",
194+
disposition: "inline"
195+
rescue StandardError => e
196+
Rails.logger.error "Failed to generate demo PDF: #{e.message}"
197+
flash[:error] = e.message
198+
redirect_to custom_style_path
199+
end
200+
174201
private
175202

176203
def theme_from_params
@@ -192,13 +219,19 @@ def get_or_create_custom_style
192219
end
193220

194221
def custom_style_params
195-
params.expect(custom_style: %i[logo remove_logo
196-
export_logo remove_export_logo
197-
export_cover remove_export_cover
198-
export_cover_text_color
199-
export_footer remove_export_footer
200-
favicon remove_favicon
201-
touch_icon remove_touch_icon])
222+
params.expect(custom_style: %i[
223+
logo remove_logo
224+
export_logo remove_export_logo
225+
export_cover remove_export_cover
226+
export_footer remove_export_footer
227+
favicon remove_favicon
228+
touch_icon remove_touch_icon
229+
export_font_regular remove_export_font_regular
230+
export_font_bold remove_export_font_bold
231+
export_font_italic remove_export_font_italic
232+
export_font_bold_italic remove_export_font_bold_italic
233+
export_cover_text_color
234+
])
202235
end
203236

204237
def file_download(path_method)

app/forms/custom_fields/hierarchy/item_form.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#
2424
# You should have received a copy of the GNU General Public License
2525
# along with this program; if not, write to the Free Software
26-
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2727
#
2828
# See COPYRIGHT and LICENSE files for more details.
2929
#++
@@ -98,6 +98,7 @@ def score_input_field(form_group)
9898
name: :score,
9999
label: I18n.t("custom_fields.admin.items.placeholder.score"),
100100
type: :number,
101+
step: :any,
101102
value: @target_item.score,
102103
visually_hide_label: true,
103104
full_width: false,

app/helpers/custom_styles_helper.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ def design_tabs
5656
path: custom_style_path(tab: :pdf_export_styles),
5757
label: t(:"admin.custom_styles.tab_pdf_export_styles"),
5858
pdf: true
59+
},
60+
{
61+
name: "pdf_export_font",
62+
partial: "custom_styles/pdf_export_font",
63+
path: custom_style_path(tab: :pdf_export_font),
64+
label: t(:"admin.custom_styles.tab_pdf_export_font"),
65+
pdf: true
5966
}
6067
]
6168
end
@@ -80,4 +87,19 @@ def apply_custom_favicon?
8087
def apply_custom_touch_icon?
8188
apply_custom_styles?(skip_ee_check: false) && CustomStyle.current.touch_icon.present?
8289
end
90+
91+
def export_fonts_fields(custom_style)
92+
%i[regular bold italic bold_italic].map do |variant|
93+
field = :"export_font_#{variant}"
94+
font = custom_style.public_send(field)
95+
{
96+
field: field,
97+
label: I18n.t("label_custom_export_font_#{variant}"),
98+
present: font.present?,
99+
filename: custom_style.id && font.present? ? File.basename(font.file.path) : nil,
100+
delete_path: public_send(:"custom_style_export_font_#{variant}_delete_path"),
101+
instructions: I18n.t("text_custom_export_font_#{variant}_instructions")
102+
}
103+
end
104+
end
83105
end

0 commit comments

Comments
 (0)