Skip to content

Commit

Permalink
Merge branch 'release/15.1' into task/59512-create-new-section-(contr…
Browse files Browse the repository at this point in the history
…ibution-guide)-how-to-give-back,-contribute-to-the-community
  • Loading branch information
MayaBerd authored Dec 2, 2024
2 parents fee9eed + 5b4f8ce commit 23e51aa
Show file tree
Hide file tree
Showing 171 changed files with 808 additions and 743 deletions.
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
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
Loading

0 comments on commit 23e51aa

Please sign in to comment.