Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions app/components/admin/enumerations/item_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def wrapper_uniq_by
def build_enumeration_menu(menu)
with_item_group(menu) do
edit_enumeration(menu)
move_enumeration(menu)
with_move_submenu(menu)
end
with_item_group(menu) { deletion_enumeration(menu) }
end
Expand All @@ -67,20 +67,6 @@ def edit_enumeration(menu)
end
end

def move_enumeration(menu)
menu.with_item(
component_klass: Primer::Alpha::ActionMenu::SubMenuItem,
label: I18n.t(:button_move),
select_variant: :none,
form_arguments: {},
data: { sortable_lists__item_target: "moveMenu" }
) do |submenu|
submenu.with_leading_visual_icon(icon: :"op-arrow-in")

with_move_items(submenu)
end
end

def deletion_enumeration(menu)
menu.with_item(label: I18n.t(:button_delete),
tag: :button,
Expand Down
16 changes: 1 addition & 15 deletions app/components/roles/row_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def action_menu
)

edit_action(menu)
move_action(menu) if movable?
with_move_submenu(menu) if movable?

if deletable?
menu.with_divider
Expand All @@ -126,20 +126,6 @@ def edit_action(menu)
end
end

def move_action(menu)
menu.with_item(
component_klass: Primer::Alpha::ActionMenu::SubMenuItem,
label: t(:button_move),
select_variant: :none,
form_arguments: {},
data: { sortable_lists__item_target: "moveMenu" }
) do |submenu|
submenu.with_leading_visual_icon(icon: :"op-arrow-in")

with_move_items(submenu)
end
end

def delete_action(menu)
menu.with_item(
label: t(:button_delete),
Expand Down
14 changes: 14 additions & 0 deletions app/components/sortable_lists/move_menu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ def item_data

private

def with_move_submenu(menu)
menu.with_item(
component_klass: Primer::Alpha::ActionMenu::SubMenuItem,
label: I18n.t(:button_move),
select_variant: :none,
form_arguments: {},
data: { sortable_lists__item_target: "moveMenu" }
) do |submenu|
submenu.with_leading_visual_icon(icon: :"op-arrow-in")

with_move_items(submenu)
end
end

# The `data:` hash must live on the item level so Primer renders it on the ActionList
# `<li>`, which is what the item controller targets to compute availability and to
# handle the bubbled click.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,35 @@
#++

require "spec_helper"
require_relative "../../../support/pages/admin/time_entry_activities"

RSpec.describe "Time entry activities admin", :js do
include Flash::Expectations
include EnumerationAdminHelpers

current_user { create(:admin) }

let!(:alpha) { create(:time_entry_activity, name: "Alpha") }
let!(:beta) { create(:time_entry_activity, name: "Beta") }
let!(:gamma) { create(:time_entry_activity, name: "Gamma") }
let(:list_page) { Pages::Admin::TimeEntryActivities.new }

before do
gamma.move_to_top
beta.move_to_top
alpha.move_to_top
end

def enumeration_list_selector = "#admin-enumerations-index-component"
def enumeration_actions_label = "Actions"

it "reorders through the move menu" do
visit admin_settings_time_entry_activities_path
list_page.visit!

expect_enumeration_order("Alpha", "Beta", "Gamma")
list_page.expect_order("Alpha", "Beta", "Gamma")

move_enumeration(gamma, I18n.t(:label_sort_highest))
list_page.move(gamma, I18n.t(:label_sort_highest))

expect_enumeration_move_settled("Gamma", "Alpha", "Beta")
list_page.expect_move_settled("Gamma", "Alpha", "Beta")

refresh

expect_enumeration_order("Gamma", "Alpha", "Beta")
list_page.expect_order("Gamma", "Alpha", "Beta")
end
end
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

# -- copyright
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2010-2024 the OpenProject GmbH
# Copyright (C) the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
Expand All @@ -26,32 +26,18 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See COPYRIGHT and LICENSE files for more details.
# ++
#++

module Documents
require "support/pages/admin/enumeration_list"

module Pages
module Admin
module DocumentTypes
class ItemComponent < ::Admin::Enumerations::ItemComponent
alias_method :document_type, :enumeration
class TimeEntryActivities < EnumerationList
def path = admin_settings_time_entry_activities_path

def deletion_enumeration(menu)
menu.with_item(
label: I18n.t(:button_delete),
scheme: :danger,
tag: :a,
content_arguments: {
data: { controller: "async-dialog" }
},
href: delete_dialog_admin_settings_document_type_path(document_type)
) do |item|
item.with_leading_visual_icon(icon: :trash)
end
end
def list_selector = "#admin-enumerations-index-component"

def colored?
false
end
end
def actions_label = "Actions"
end
end
end
1 change: 0 additions & 1 deletion modules/documents/app/components/_index.sass
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
@import "documents/admin/document_types/index_component"
@import "documents/show_edit_view/block_note_editor_component"
@import "documents/show_edit_view/page_layout_component"
Original file line number Diff line number Diff line change
Expand Up @@ -48,31 +48,7 @@
end

flex.with_row do
render(border_box_container(data: list_data)) do |component|
component.with_header(font_weight: :bold) do
grid_layout("op-documents-types-list--header", tag: :div, align_items: :center) do |grid|
grid.with_area(:name, tag: :div, mr: 3) do
render(Primer::Beta::Text.new(font_weight: :semibold)) { I18n.t("documents.index_page.type") }
end

grid.with_area(:"documents-count", tag: :div, hide: :sm) do
render(Primer::Beta::Text.new(font_weight: :semibold)) { I18n.t("label_documents") }
end
end
end

if document_types.empty?
component.with_row do
render(Primer::Beta::Text.new(color: :subtle)) { t(:no_results_title_text) }
end
else
document_types.each do |document_type|
component.with_row(test_selector: "document-type-row-#{document_type.id}", data: item_data(document_type)) do
render(item_component_class.new(enumeration: document_type))
end
end
end
end
render(::Documents::Admin::DocumentTypes::TableComponent.new(rows: document_types))
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,35 @@
module Documents
module Admin
module DocumentTypes
class IndexComponent < ::Admin::Enumerations::IndexComponent
class IndexComponent < ApplicationComponent
include OpPrimer::ComponentHelpers
include OpTurbo::Streamable

def initialize(enumerations:)
super()
@enumerations = enumerations
end

private

attr_reader :enumerations

alias_method :document_types, :enumerations

def item_component_class
::Documents::Admin::DocumentTypes::ItemComponent
def wrapper_data_attributes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍊 This root wiring and the move URL template are now a copy of Admin::Enumerations::IndexComponent, comment included, so a new outlet or renamed value has to land in both. Worth a small shared module that both include, with each defining its own move_url_template? Fine as a follow-up.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to handle this as a follow-up. It could be done as part of #24669 (DREAM 805) / DREAM-838. / @HDinger

{
controller: "sortable-lists",
sortable_lists_move_url_template_value: move_url_template,
sortable_lists_sortable_lists__list_outlet: "##{wrapper_key} [data-controller~='sortable-lists--list']",
sortable_lists_sortable_lists__item_outlet: "##{wrapper_key} [data-controller~='sortable-lists--item']"
}
end

# Built from the route helper with a sentinel so relative-URL-root
# installations keep working; {id} is expanded client-side.
def move_url_template
id_placeholder = "__id__"
move_admin_settings_document_type_path(id_placeholder).sub(id_placeholder, "{id}")
end
end
end
Expand Down

This file was deleted.

This file was deleted.

Loading
Loading