Skip to content

Commit

Permalink
Merge branch 'dev' into implementation/59433-define-database-model-fo…
Browse files Browse the repository at this point in the history
…r-reminders
  • Loading branch information
akabiru authored Dec 2, 2024
2 parents 220ca16 + bc48a8a commit 5079bf7
Show file tree
Hide file tree
Showing 114 changed files with 890 additions and 1,079 deletions.
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ GEM
awesome_nested_set (3.7.0)
activerecord (>= 4.0.0, < 8.0)
aws-eventstream (1.3.0)
aws-partitions (1.1013.0)
aws-partitions (1.1015.0)
aws-sdk-core (3.214.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.992.0)
Expand All @@ -353,7 +353,7 @@ GEM
aws-sdk-kms (1.96.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.174.0)
aws-sdk-s3 (1.175.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
Expand Down Expand Up @@ -652,7 +652,7 @@ GEM
http-2 (1.0.2)
http_parser.rb (0.6.0)
httpclient (2.8.3)
httpx (1.3.3)
httpx (1.3.4)
http-2 (>= 1.0.0)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
Expand Down Expand Up @@ -962,7 +962,7 @@ GEM
rbtree3 (0.7.1)
rdoc (6.8.1)
psych (>= 4.0.0)
recaptcha (5.17.0)
recaptcha (5.17.1)
redcarpet (3.6.0)
redis (5.3.0)
redis-client (>= 0.22.0)
Expand Down Expand Up @@ -1067,7 +1067,7 @@ GEM
securerandom (0.3.2)
selenium-devtools (0.131.0)
selenium-webdriver (~> 4.2)
selenium-webdriver (4.26.0)
selenium-webdriver (4.27.0)
base64 (~> 0.2)
logger (~> 1.4)
rexml (~> 3.2, >= 3.2.5)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ See COPYRIGHT and LICENSE files for more details.
) do |form|
concat(render(Primer::Alpha::Dialog::Body.new(
id: dialog_body_id, test_selector: dialog_body_id, aria: { label: title },
style: "min-height: 300px"
classes: "Overlay-body_autocomplete_height"
)) do
render(Projects::CustomFields::CustomFieldMappingForm.new(form, project_mapping: @custom_field_project_mapping))
end)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
resource: 'work_packages',
searchKey: 'subjectOrId',
openDirectly: false,
focusDirectly: false,
focusDirectly: true,
dropdownPosition: 'bottom',
appendTo: "##{DIALOG_ID}",
data: { test_selector: ID_FIELD_TEST_SELECTOR }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<%= component_wrapper(tag: "turbo-frame") do %>
<%=
if should_render_create_button?
flex_layout(justify_content: :space_between, mb: 4) do |action_bar|
action_bar.with_column do
flex_layout(justify_content: :space_between, align_items: :center, mb: 4) do |action_bar|
action_bar.with_column(pr: 1) do
render(Primer::Beta::Text.new(color: :muted)) do
t("#{I18N_NAMESPACE}.index.action_bar_title")
end
end

# Prevent the menu from overflowing on Safari
action_bar.with_column(flex_shrink: 0) do
action_bar.with_column(flex_shrink: 0, ml: 2) do
render(Primer::Alpha::ActionMenu.new(test_selector: NEW_RELATION_ACTION_MENU,
menu_id: NEW_RELATION_ACTION_MENU)) do |menu|
menu.with_show_button do |button|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def render_relation_group(title:, relation_type:, items:, &_block)
end

items.each do |item|
border_box.with_row(py: 3, test_selector: row_test_selector(item)) do
border_box.with_row(test_selector: row_test_selector(item)) do
yield(item)
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// We reference an ID as one is required to be specified for the action menu list.
// It can't be nested inside the BEM model as it's placed as a #top-layer element.
#new-relation-action-menu-list
max-height: 380px
max-height: 450px
max-width: 280px
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
<%=
flex_layout do |flex|
flex.with_row do
render(WorkPackages::InfoLineComponent.new(work_package: related_work_package))
end

flex.with_row(flex_layout: true, justify_content: :space_between, align_items: :flex_start) do |subject_line_row|
subject_line_row.with_column(py: 2) do
render(Primer::Beta::Link.new(href: work_package_path(related_work_package),
color: :default,
underline: false,
font_size: :normal,
font_weight: :bold,
target: "_blank")) { related_work_package.subject }
flex.with_row(flex_layout: true, justify_content: :space_between, align_items: :center) do |row|
row.with_column do
render(WorkPackages::InfoLineComponent.new(work_package: related_work_package))
end

if should_render_action_menu?
subject_line_row.with_column do
row.with_column do
render(Primer::Alpha::ActionMenu.new(test_selector: action_menu_test_selector)) do |menu|
menu.with_show_button(icon: "kebab-horizontal",
"aria-label": I18n.t(:label_relation_actions),
Expand Down Expand Up @@ -52,16 +43,23 @@ flex_layout do |flex|
end
end

flex.with_row(mb: 2) do
render(Primer::Beta::Link.new(href: work_package_path(related_work_package),
color: :default,
underline: false,
font_size: :normal,
font_weight: :bold,
target: "_blank")) { related_work_package.subject }
end

if should_display_description?
flex.with_row(flex_layout: true, mb: 2) do |description_row|
description_row.with_column do
render(Primer::Beta::Text.new(font_size: :small, color: :muted)) { format_text(relation, :description) }
end
flex.with_row(mb: 2) do
render(Primer::Beta::Text.new(font_size: :small, color: :muted)) { format_text(relation, :description) }
end
end

if should_display_start_and_end_dates?
flex.with_row(flex_layout: true, align_items: :center) do |start_and_end_dates_row|
flex.with_row(flex_layout: true, align_items: :center, mb: 2) do |start_and_end_dates_row|
start_and_end_dates_row.with_column(mr: 1) do
icon = if follows?
:calendar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
url:,
relations: true, # Activates relations fetch mode in the autocomplete
openDirectly: false,
focusDirectly: false,
focusDirectly: true,
dropdownPosition: 'bottom',
appendTo: "##{DIALOG_ID}",
data: { test_selector: TO_ID_FIELD_TEST_SELECTOR}
Expand All @@ -56,6 +56,7 @@
my_form.text_field(
name: :description,
label: Relation.human_attribute_name(:description),
autofocus: relation.persisted?
)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ def initialize(work_package:, relation:, base_errors: nil)
end

def related_work_package
@related_work_package ||= @relation.to
@related_work_package ||= begin
related = @relation.to
# We cannot rely on the related WorkPackage being the "to",
# depending on the relation it can also be "from"
related.id == @work_package.id ? @relation.from : related
end
end

def submit_url_options
Expand Down
1 change: 1 addition & 0 deletions app/forms/custom_fields/hierarchy/item_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class ItemForm < ApplicationForm
value: @target_item.label,
visually_hide_label: true,
required: true,
autofocus: true,
placeholder: I18n.t("custom_fields.admin.items.placeholder.label"),
validation_message: validation_message_for(:label)
)
Expand Down
6 changes: 2 additions & 4 deletions app/forms/projects/custom_fields/custom_field_mapping_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ class CustomFieldMappingForm < ApplicationForm
include OpPrimer::ComponentHelpers

form do |form|
form.group(layout: :vertical) do |group|
group.project_autocompleter(
form.project_autocompleter(
name: :id,
label: Project.model_name.human,
visually_hide_label: true,
Expand All @@ -48,13 +47,12 @@ class CustomFieldMappingForm < ApplicationForm
}
)

group.check_box(
form.check_box(
name: :include_sub_projects,
label: I18n.t(:label_include_sub_projects),
checked: false,
label_arguments: { class: "no-wrap" }
)
end
end

def initialize(project_mapping:)
Expand Down
13 changes: 13 additions & 0 deletions app/helpers/custom_fields_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,19 @@ def custom_field_tag_for_bulk_edit(name, custom_field, project = nil) # rubocop:
options_for_select(base_options + custom_field.possible_values_options(project)),
id: field_id,
multiple: custom_field.multi_value?)
when "hierarchy"
base_options = [[I18n.t(:label_no_change_option), ""]]
result = CustomFields::Hierarchy::HierarchicalItemService.new
.get_descendants(item: custom_field.hierarchy_root, include_self: false)
.either(
->(items) { items },
->(_) { [] }
)
options = base_options + result.map do |item|
label = item.short.present? ? "#{item.label} (#{item.short})" : item.label
[label, item.id]
end
styled_select_tag(field_name, options_for_select(options), id: field_id, multiple: custom_field.multi_value?)
else
styled_text_field_tag(field_name, "", id: field_id)
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/custom_actions/actions/custom_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def apply(work_package)

def self.all
WorkPackageCustomField
.order(:name)
.usable_as_custom_action
.map do |cf|
create_subclass(cf)
end
Expand Down
9 changes: 8 additions & 1 deletion app/models/custom_field/order_statements.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module CustomField::OrderStatements
# value of the custom field.
def order_statement
case field_format
when "string", "date", "bool", "link", "int", "float", "list", "user", "version"
when "string", "date", "bool", "link", "int", "float", "list", "user", "version", "hierarchy"
"cf_order_#{id}.value"
end
end
Expand All @@ -52,6 +52,8 @@ def order_join_statement
join_for_order_by_user_sql
when "version"
join_for_order_by_version_sql
when "hierarchy"
join_for_order_by_hierarchy_sql
end
end

Expand Down Expand Up @@ -167,4 +169,9 @@ def join_for_order_by_version_sql
multi_value:
)
end

def join_for_order_by_hierarchy_sql
table_name = CustomField::Hierarchy::Item.quoted_table_name
join_for_order_sql(value: "item.label", join: "INNER JOIN #{table_name} item ON item.id = cv.value::bigint")
end
end
5 changes: 5 additions & 0 deletions app/models/work_package_custom_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ class WorkPackageCustomField < CustomField
end
}

scope :usable_as_custom_action, -> {
where.not(field_format: %w[hierarchy])
order(:name)
}

def self.summable
where(field_format: %w[int float])
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,14 @@ def get_branch(item:)

# Gets all descendant nodes in a tree starting from the item/node.
# @param item [CustomField::Hierarchy::Item] the node
# @param include_self [Boolean] flag
# @return [Success(Array<CustomField::Hierarchy::Item>)]
def get_descendants(item:)
Success(item.self_and_descendants)
def get_descendants(item:, include_self: true)
if include_self
Success(item.self_and_descendants)
else
Success(item.descendants)
end
end

# Move an item/node to a new parent item/node
Expand Down
22 changes: 11 additions & 11 deletions config/locales/crowdin/de.seeders.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ de:
item_0:
name: PM2 Orange
item_1:
name: PM2 Purple
name: PM2 Lila
item_2:
name: PM2 Red
name: PM2 Rot
item_3:
name: PM2 Magenta
name: PM2 Rosa
item_4:
name: PM2 Green Yellow
name: PM2 Grüngelb
document_categories:
item_0:
name: Dokumentation
Expand Down Expand Up @@ -83,19 +83,19 @@ de:
standard:
life_cycles:
item_0:
name: Initiating
name: Initiierung
item_1:
name: Ready for Planning
name: Bereit für Planung
item_2:
name: Planning
name: Planung
item_3:
name: Ready for Executing
name: Bereit für Durchführung
item_4:
name: Executing
name: Durchführung
item_5:
name: Ready for Closing
name: Bereit für Abschluss
item_6:
name: Closing
name: Abschluss
priorities:
item_0:
name: Niedrig
Expand Down
Loading

0 comments on commit 5079bf7

Please sign in to comment.