Skip to content

Commit

Permalink
[#57815] add item page for hierarchies
Browse files Browse the repository at this point in the history
- https://community.openproject.org/work_packages/57815
- add new tab only for hierarchy custom fields
- show blank slate and non-functional button
  • Loading branch information
Kharonus committed Oct 1, 2024
1 parent 05a30db commit dc667cc
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ See COPYRIGHT and LICENSE files for more details.
tab.with_text { t(:label_details) }
end

if @custom_field.field_format_hierarchy?
tab_nav.with_tab(
selected: tab_selected?(:items),
href: custom_field_items_path(@custom_field)
) do |tab|
tab.with_text { t(:label_item_plural) }
end
end

tab_nav.with_tab(
selected: tab_selected?(:custom_field_projects),
href: custom_field_projects_path(@custom_field)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module CustomFields
class EditFormHeaderComponent < ApplicationComponent
TAB_NAVS = %i[
edit
items
custom_field_projects
].freeze

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<%#-- copyright
OpenProject is an open source project management software.
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.
OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2013 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See COPYRIGHT and LICENSE files for more details.
++#%>
<%=
component_wrapper do
flex_layout do |container|
container.with_row(mb: 3) do
render Primer::Beta::Blankslate.new(border: true) do |component|
component.with_visual_icon(icon: "list-ordered")
component.with_heading(tag: :h3).with_content(I18n.t("custom_fields.admin.items.blankslate.title"))
component.with_description { I18n.t("custom_fields.admin.items.blankslate.description") }
end
end

container.with_row do
render Primer::Beta::Button.new(scheme: :primary) do |button|
button.with_leading_visual_icon(icon: :plus)
I18n.t(:label_item)
end
end
end
end
%>
38 changes: 38 additions & 0 deletions app/components/admin/custom_fields/hierarchy/item_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#-- copyright
# OpenProject is an open source project management software.
# 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.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See COPYRIGHT and LICENSE files for more details.
#++

module Admin
module CustomFields
module Hierarchy
class ItemComponent < ApplicationComponent
include OpTurbo::Streamable
include OpPrimer::ComponentHelpers
end
end
end
end
55 changes: 55 additions & 0 deletions app/controllers/admin/custom_fields/hierarchy/items_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# 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.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See COPYRIGHT and LICENSE files for more details.
#++

module Admin
module CustomFields
module Hierarchy
class ItemsController < ApplicationController
layout "admin"

model_object CustomField

before_action :require_admin
before_action :find_model_object

menu_item :custom_fields

def index; end

private

def find_model_object(object_id = :custom_field_id)
super
@custom_field = @object
end
end
end
end
end
34 changes: 34 additions & 0 deletions app/views/admin/custom_fields/hierarchy/items/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<%#-- copyright
OpenProject is an open source project management software.
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.
OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2013 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See COPYRIGHT and LICENSE files for more details.
++#%>
<% html_title t(:label_administration), "#{CustomField.model_name.human} #{h @custom_field.name}", t(:label_item_plural) %>
<%= render(Admin::CustomFields::EditFormHeaderComponent.new(custom_field: @custom_field, selected: :items)) %>
<%= render(Admin::CustomFields::Hierarchy::ItemComponent.new(custom_field: @custom_field)) %>
6 changes: 6 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ en:
is_for_all_blank_slate:
heading: For all projects
description: This custom field is enabled in all projects since the "For all projects" option is checked. It cannot be deactivated for individual projects.
items:
blankslate:
title: "Your list of items is empty"
description: "Start by adding items to the custom field of type hierarchy. Each item can be used to create a hierarchy bellow it. To navigate and create sub-items inside a hierarchy click on the created item."
notice:
remember_items_and_projects: "Remember to set items and projects in the respective tabs for this custom field."

Expand Down Expand Up @@ -2294,6 +2298,8 @@ en:
label_internal: "Internal"
label_introduction_video: "Introduction video"
label_invite_user: "Invite user"
label_item: "Item"
label_item_plural: "Items"
label_share: "Share"
label_share_project_list: "Share project list"
label_share_work_package: "Share work package"
Expand Down
3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@
resource :project,
controller: "/admin/custom_fields/custom_field_projects",
only: :destroy
resources :items,
controller: "/admin/custom_fields/hierarchy/items",
only: :index
end
end
end
Expand Down

0 comments on commit dc667cc

Please sign in to comment.