-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 #16364 from opf/feature/48274-work-packages-export…
…-modal-with-settings [#48274] Work packages export modal with settings & Job status modal https://community.openproject.org/work_packages/48274
- Loading branch information
Showing
139 changed files
with
2,124 additions
and
2,186 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# 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 OpenProject | ||
module Common | ||
class DividerComponent < Primer::BaseComponent | ||
def initialize(**system_arguments) | ||
system_arguments[:tag] = :hr | ||
system_arguments[:mt] = system_arguments.fetch(:mt, 4) | ||
system_arguments[:mb] = system_arguments.fetch(:mb, 4) | ||
super(**system_arguments) # rubocop:disable Style/SuperArguments | ||
end | ||
end | ||
end | ||
end |
47 changes: 47 additions & 0 deletions
47
app/components/work_packages/exports/base_export_settings_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,47 @@ | ||
# 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 WorkPackages | ||
module Exports | ||
class BaseExportSettingsComponent < ApplicationComponent | ||
include OpPrimer::ComponentHelpers | ||
include OpTurbo::Streamable | ||
include WorkPackagesHelper | ||
|
||
attr_reader :query | ||
|
||
def initialize(query) | ||
super | ||
|
||
@query = query | ||
end | ||
end | ||
end | ||
end |
16 changes: 16 additions & 0 deletions
16
app/components/work_packages/exports/column_selection_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,16 @@ | ||
<%= helpers.angular_component_tag "opce-draggable-autocompleter", | ||
inputs: { | ||
id:, | ||
name: 'columns', | ||
dragAreaName: "#{id}_dragarea", | ||
formControlId: "#{id}_autocompleter", | ||
appendToComponent: true, | ||
options: available_columns, | ||
selected: selected_columns, | ||
protected: protected_options, | ||
inputCaption: caption, | ||
inputLabel: I18n.t(:"queries.configure_view.columns.input_label"), | ||
inputPlaceholder: I18n.t(:"queries.configure_view.columns.input_placeholder"), | ||
dragAreaLabel: I18n.t(:"queries.configure_view.columns.drag_area_label"), | ||
} | ||
%> |
64 changes: 64 additions & 0 deletions
64
app/components/work_packages/exports/column_selection_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,64 @@ | ||
# 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 WorkPackages | ||
module Exports | ||
class ColumnSelectionComponent < ApplicationComponent | ||
include WorkPackagesHelper | ||
|
||
attr_reader :query, :id, :caption | ||
|
||
def initialize(query, id, caption) | ||
super() | ||
|
||
@query = query | ||
@id = id | ||
@caption = caption | ||
end | ||
|
||
def available_columns | ||
query | ||
.displayable_columns | ||
.sort_by(&:caption) | ||
.map { |column| { id: column.name.to_s, name: column.caption } } | ||
end | ||
|
||
def protected_options | ||
[] | ||
end | ||
|
||
def selected_columns | ||
query | ||
.columns | ||
.map { |column| { id: column.name.to_s, name: column.caption } } | ||
end | ||
end | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
app/components/work_packages/exports/csv/export_settings_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,5 @@ | ||
<%= render WorkPackages::Exports::ColumnSelectionComponent.new( | ||
query, | ||
"columns-select-export-csv", | ||
I18n.t("export.dialog.columns.input_caption_table") | ||
) %> |
38 changes: 38 additions & 0 deletions
38
app/components/work_packages/exports/csv/export_settings_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,38 @@ | ||
# 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 WorkPackages | ||
module Exports | ||
module CSV | ||
class ExportSettingsComponent < BaseExportSettingsComponent | ||
end | ||
end | ||
end | ||
end |
59 changes: 59 additions & 0 deletions
59
app/components/work_packages/exports/modal_dialog_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,59 @@ | ||
<%= render(Primer::Alpha::Dialog.new( | ||
title: I18n.t('export.dialog.title'), | ||
size: :xlarge, | ||
id: MODAL_ID, | ||
data: { | ||
"application-target": "dynamic", | ||
controller: "work-packages--export--dialog" | ||
} | ||
)) do |dialog| %> | ||
<% dialog.with_header(variant: :large) %> | ||
<% dialog.with_body do %> | ||
<% flex_layout do |modal_body| %> | ||
<% modal_body.with_row do |_format| %> | ||
<%= render(Primer::Beta::Text.new(tag: "legend", font_size: :normal, mb: 2, font_weight: :bold)) { I18n.t('export.dialog.format.label') } %> | ||
<%= render(Primer::Alpha::SegmentedControl.new(ml: 0, "aria-label": I18n.t('export.dialog.format.label'), size: :medium)) do |component| | ||
export_formats_settings.each do |format| | ||
component.with_item( | ||
label: format[:label], icon: format[:icon], selected: format[:selected], | ||
data: { | ||
"work-packages--export--dialog-format-param": format[:id], | ||
action: "click:segmented-control#select click->work-packages--export--dialog#formatChanged" | ||
}) | ||
end | ||
end %> | ||
<%= render OpenProject::Common::DividerComponent.new %> | ||
<% end %> | ||
<% export_formats_settings.each do |format| %> | ||
<% modal_body.with_row( | ||
classes: format[:selected] ? nil : "d-none", | ||
data: { format: format[:id], "work-packages--export--dialog-target": "formatTab" } | ||
) do |_format_tabs| %> | ||
<%= primer_form_with( | ||
url: export_format_url(format[:id]), | ||
id: "#{EXPORT_FORM_ID}-#{format[:id]}", | ||
data: { | ||
"application-target": "dynamic", | ||
action: "submit->work-packages--export--form#submitForm", | ||
controller: "work-packages--export--form", | ||
"work-packages--export--form-job-status-dialog-url-value": job_status_dialog_path('_job_uuid_') | ||
} | ||
) do |form| %> | ||
<input type="hidden" name="query" value="<%= query_params %>"> | ||
<%= render(format[:component].new(query)) %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% dialog.with_footer do %> | ||
<%= render(Primer::ButtonComponent.new(data: { "close-dialog-id": MODAL_ID })) { I18n.t(:button_cancel) } %> | ||
<%= render(Primer::ButtonComponent.new( | ||
data: { | ||
"close-dialog-id": MODAL_ID, | ||
"work-packages--export--dialog-target": "submit" | ||
}, | ||
scheme: :primary, type: :submit, | ||
form: "#{EXPORT_FORM_ID}-#{export_formats_settings.find { |e| e[:selected] }[:id]}")) { I18n.t('export.dialog.submit') } %> | ||
<% end %> | ||
<% end %> |
69 changes: 69 additions & 0 deletions
69
app/components/work_packages/exports/modal_dialog_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,69 @@ | ||
# 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 WorkPackages | ||
module Exports | ||
class ModalDialogComponent < ApplicationComponent | ||
MODAL_ID = "op-work-packages-export-dialog" | ||
EXPORT_FORM_ID = "op-work-packages-export-dialog-form" | ||
include OpTurbo::Streamable | ||
include OpPrimer::ComponentHelpers | ||
|
||
attr_reader :query, :project, :query_params | ||
|
||
def initialize(query:, project:) | ||
super | ||
|
||
@query = query | ||
@project = project | ||
@query_params = ::API::V3::Queries::QueryParamsRepresenter.new(query).to_url_query(merge_params: { columns: [] }) | ||
end | ||
|
||
def export_format_url(format) | ||
@project.nil? ? index_work_packages_path(format:) : project_work_packages_path(project, format:) | ||
end | ||
|
||
def export_formats_settings | ||
[ | ||
{ id: "pdf", icon: :"op-pdf", | ||
label: I18n.t("export.dialog.format.options.pdf.label"), | ||
component: WorkPackages::Exports::PDF::ExportSettingsComponent, | ||
selected: true }, | ||
{ id: "xls", icon: :"op-xls", | ||
label: I18n.t("export.dialog.format.options.xls.label"), | ||
component: WorkPackages::Exports::XLS::ExportSettingsComponent }, | ||
{ id: "csv", icon: :"op-file-csv", | ||
label: I18n.t("export.dialog.format.options.csv.label"), | ||
component: WorkPackages::Exports::CSV::ExportSettingsComponent } | ||
] | ||
end | ||
end | ||
end | ||
end |
35 changes: 35 additions & 0 deletions
35
app/components/work_packages/exports/pdf/export_settings_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,35 @@ | ||
<%= | ||
flex_layout(data: { | ||
"application-target": "dynamic", | ||
controller: "work-packages--export--pdf--settings" | ||
}) do |container| %> | ||
<%= container.with_row do %> | ||
<%= render(Primer::Alpha::RadioButtonGroup.new( | ||
full_width: true, | ||
name: "pdf_export_type", | ||
label: I18n.t("export.dialog.pdf.export_type.label"))) do |component| | ||
pdf_export_types.each do |entry| | ||
component.radio_button(label: entry[:label], | ||
value: entry[:value], | ||
checked: current_pdf_export_type == entry[:value], | ||
disabled: entry[:disabled] ? true : nil, | ||
data: { | ||
"work-packages--export--pdf--settings-name-param": entry[:value], | ||
action: "work-packages--export--pdf--settings#typeChanged" | ||
}, | ||
caption: entry[:caption]) | ||
end | ||
end %> | ||
<%= render OpenProject::Common::DividerComponent.new %> | ||
<% end %> | ||
<% pdf_export_types.reject { |entry| entry[:disabled] }.each do |entry| %> | ||
<%= container.with_row( | ||
classes: current_pdf_export_type == entry[:value] ? nil : "d-none", | ||
data: { | ||
"pdf-export-type": entry[:value], | ||
"work-packages--export--pdf--settings-target": "fields" | ||
}) do |_pdf_export_type| %> | ||
<%= render(entry[:component].new(query)) %> | ||
<% end %> | ||
<% end %> | ||
<% end %> |
Oops, something went wrong.