-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16930 from opf/implementation/57816-enable-item-c…
…reation [#57816] create hierarchy items
- Loading branch information
Showing
16 changed files
with
399 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
app/components/admin/custom_fields/hierarchy/items_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<%#-- 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(tag: 'turbo-frame') do | ||
flex_layout do |container| | ||
if items.empty? && !show_new_item_form? | ||
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 | ||
else | ||
container.with_row(mb: 3) do | ||
render(Primer::Beta::BorderBox.new) do |item_box| | ||
item_box.with_header { @custom_field.name } | ||
|
||
items.each do |item| | ||
item_box.with_row { render Admin::CustomFields::Hierarchy::ItemComponent.new(hierarchy_item: item) } | ||
end | ||
|
||
if show_new_item_form? | ||
item_box.with_footer do | ||
render Admin::CustomFields::Hierarchy::NewItemFormComponent.new(custom_field: @custom_field, | ||
label: @new_item_form_data[:label], | ||
short: @new_item_form_data[:short]) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
container.with_row do | ||
render Primer::Beta::Button.new(scheme: :primary, | ||
tag: :a, | ||
data: { turbo_stream: true }, | ||
href: new_custom_field_item_path(@custom_field)) do |button| | ||
button.with_leading_visual_icon(icon: :plus) | ||
I18n.t(:label_item) | ||
end | ||
end | ||
end | ||
end | ||
%> |
53 changes: 53 additions & 0 deletions
53
app/components/admin/custom_fields/hierarchy/items_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#-- 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 ItemsComponent < ApplicationComponent | ||
include OpTurbo::Streamable | ||
include OpPrimer::ComponentHelpers | ||
|
||
def initialize(custom_field:, new_item_form_data: { show: false }) | ||
super | ||
@custom_field = custom_field | ||
@new_item_form_data = new_item_form_data | ||
end | ||
|
||
def items | ||
# TODO: This must be context aware (breadcrumbs) | ||
@custom_field.hierarchy_root.children | ||
end | ||
|
||
def show_new_item_form? | ||
@new_item_form_data[:show] || false | ||
end | ||
end | ||
end | ||
end | ||
end |
37 changes: 37 additions & 0 deletions
37
app/components/admin/custom_fields/hierarchy/new_item_form_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<%#-- 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. | ||
++#%> | ||
|
||
<%= | ||
primer_form_with( | ||
url: custom_field_items_path(@custom_field), | ||
method: :post, | ||
) do |f| | ||
render(CustomFields::Hierarchy::NewItemForm.new(f, custom_field: @custom_field, label: @label, short: @short)) | ||
end | ||
%> |
48 changes: 48 additions & 0 deletions
48
app/components/admin/custom_fields/hierarchy/new_item_form_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#-- 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 NewItemFormComponent < ApplicationComponent | ||
include OpTurbo::Streamable | ||
|
||
def initialize(custom_field:, label: nil, short: nil) | ||
super | ||
@custom_field = custom_field | ||
@label = label | ||
@short = short | ||
end | ||
|
||
def items_path | ||
custom_field_items_path(@custom_field) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.