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

4.0 KB
Raw Blame
<%=
  component_wrapper(class: "op-project-custom-field-section-container", data: { test_selector: "project-custom-field-section-container-#{@project_custom_field_section.id}" }) do
    render(border_box_container(mt: 3, data: drag_and_drop_target_config)) do |component|
      component.with_header(font_weight: :bold) do
        flex_layout(justify_content: :space_between, align_items: :center) do |section_header_container|
          section_header_container.with_column(flex_layout: true, align_items: :center) do |content_container|
            content_container.with_column(mr: 2) do
              render(Primer::OpenProject::DragHandle.new(classes: "handle"))
            end
            content_container.with_column do
              render(Primer::Beta::Text.new(font_weight: :bold)) do
                @project_custom_field_section.name
              end
            end
          end
          section_header_container.with_column(flex_layout: true, justify_content: :flex_end) do |actions_container|
            actions_container.with_column do
              render(Primer::Alpha::ActionMenu.new(data: { test_selector: "project-custom-field-section-action-menu" })) do |menu|
                menu.with_show_button(icon: "kebab-horizontal", "aria-label": t("settings.project_attributes.label_section_actions"), scheme: :invisible)
                edit_action_item(menu)
                move_actions(menu)
                if @project_custom_fields.empty?
                  delete_action_item(menu)
                else
                  disabled_delete_action_item(menu)
                end
              end
            end
            actions_container.with_column do
              render(
                Primer::Alpha::Dialog.new(
                  id: "project-custom-field-section-dialog#{@project_custom_field_section.id}", title: t("settings.project_attributes.label_new_section"),
                  size: :medium_portrait
                )
              ) do |_dialog|
                render(Settings::ProjectCustomFieldSections::DialogBodyFormComponent.new(project_custom_field_section: @project_custom_field_section))
              end
            end
          end
        end
      end
      if @project_custom_fields.empty?
        component.with_row(data: { "empty-list-item": true }) do
          flex_layout(align_items: :center, justify_content: :space_between) do |empty_list_container|
            empty_list_container.with_column(ml: 4, mr: 2) do
              render(Primer::Beta::Text.new(color: :subtle)) { t("settings.project_attributes.label_no_project_custom_fields") }
            end
            empty_list_container.with_column do
              render(Primer::Alpha::ActionMenu.new(data: { test_selector: "new-project-custom-field-in-section-button" })) do |menu|
                menu.with_show_button(
                  scheme: :secondary,
                  "aria-label": t("settings.project_attributes.label_new_attribute")
                ) do |btn|
                  btn.with_leading_visual_icon(icon: :plus)
                  btn.with_trailing_visual_icon(icon: :"triangle-down")

                  t("settings.project_attributes.label_new_attribute")
                end

                OpenProject::CustomFieldFormat.available_for_class_name("Project")
                                              .sort_by(&:name)
                                              .map do |format|
                  action_menu_item_for_custom_field_format(menu, format)
                end
              end
            end
          end
        end
      else
        first_and_last = [@project_custom_fields.first, @project_custom_fields.last]
        @project_custom_fields.each do |project_custom_field|
          component.with_row(
            data: draggable_item_config(project_custom_field)
          ) do
            render(
              ::Settings::ProjectCustomFieldSections::CustomFieldRowComponent.new(
                project_custom_field:,
                first_and_last:
              )
            )
          end
        end
      end
    end
  end
%>