mirror of
https://github.com/opf/openproject.git
synced 2026-06-13 19:20:00 +00:00
Simplify project export
Instead of showing a huge dialog that then just shows three links with huge icons and no further description, we just use a submenu, that immediately shows the export options as menu items.
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
<%= render(
|
||||
Primer::Alpha::Dialog.new(
|
||||
title: t("js.label_export"),
|
||||
id: MODAL_ID
|
||||
)
|
||||
) do |d| %>
|
||||
<% d.with_header(variant: :large) %>
|
||||
<% d.with_body do %>
|
||||
<ul class="op-export-options">
|
||||
<% helpers.supported_export_formats.each do |key| %>
|
||||
<li class="op-export-options--option">
|
||||
<%= link_to projects_path(format: key, **helpers.projects_query_params.except(:page, :per_page)),
|
||||
"data-controller": "job-dialog",
|
||||
"data-job-dialog-close-dialog-id-value": MODAL_ID,
|
||||
class: "op-export-options--option-link" do %>
|
||||
<%= helpers.op_icon("icon-big icon-export-#{key}") %>
|
||||
<span class="op-export-options--option-label"><%= t("export.format.#{key}") %></span>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% end %>
|
||||
@@ -1,36 +0,0 @@
|
||||
# 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.
|
||||
# ++
|
||||
|
||||
class Projects::ExportListModalComponent < ApplicationComponent
|
||||
include OpTurbo::Streamable
|
||||
MODAL_ID = "op-project-list-export-dialog"
|
||||
|
||||
options :query
|
||||
end
|
||||
@@ -126,13 +126,18 @@
|
||||
end
|
||||
|
||||
if can_export?
|
||||
menu.with_item(
|
||||
tag: :a,
|
||||
label: t("js.label_export"),
|
||||
href: export_list_modal_projects_path(projects_query_params),
|
||||
content_arguments: { data: { controller: "async-dialog" }, rel: "nofollow" }
|
||||
) do |item|
|
||||
item.with_leading_visual_icon(icon: "sign-out")
|
||||
menu.with_sub_menu_item(label: t("js.label_export")) do |submenu|
|
||||
submenu.with_leading_visual_icon(icon: "sign-out")
|
||||
helpers.supported_export_formats.each do |key|
|
||||
submenu.with_item(
|
||||
label: t("export.format.#{key}"),
|
||||
tag: :a,
|
||||
href: projects_path(format: key, **helpers.projects_query_params.except(:page, :per_page)),
|
||||
content_arguments: { data: { controller: "job-dialog" }, rel: "nofollow" }
|
||||
) do |item|
|
||||
item.with_leading_visual_icon(icon: "op-#{key == "csv" ? "file-csv" : key}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -34,10 +34,10 @@ class ProjectsController < ApplicationController
|
||||
menu_item :overview
|
||||
menu_item :roadmap, only: :roadmap
|
||||
|
||||
before_action :find_project, except: %i[index new create export_list_modal]
|
||||
before_action :load_query_or_deny_access, only: %i[index export_list_modal]
|
||||
before_action :find_project, except: %i[index new create]
|
||||
before_action :load_query_or_deny_access, only: %i[index]
|
||||
before_action :authorize,
|
||||
only: %i[copy_form copy deactivate_work_package_attachments export_list_modal export_project_initiation_pdf]
|
||||
only: %i[copy_form copy deactivate_work_package_attachments export_project_initiation_pdf]
|
||||
before_action :authorize_global, only: %i[new create]
|
||||
before_action :require_admin, only: %i[destroy destroy_info]
|
||||
before_action :find_optional_parent, only: :new
|
||||
@@ -172,10 +172,6 @@ class ProjectsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def export_list_modal
|
||||
respond_with_dialog Projects::ExportListModalComponent.new(query: @query)
|
||||
end
|
||||
|
||||
def export_project_initiation_pdf
|
||||
export = Project::PDFExport::ProjectInitiation.new(@project).export!
|
||||
send_data(export.content, type: export.mime_type, filename: export.title)
|
||||
|
||||
@@ -47,7 +47,7 @@ class Project < ApplicationRecord
|
||||
IDENTIFIER_MAX_LENGTH = 100
|
||||
|
||||
# reserved identifiers
|
||||
RESERVED_IDENTIFIERS = %w[new menu queries filters export_list_modal].freeze
|
||||
RESERVED_IDENTIFIERS = %w[new menu queries filters].freeze
|
||||
|
||||
enum :workspace_type, {
|
||||
project: "project",
|
||||
|
||||
@@ -39,7 +39,6 @@ Disallow: <%= activities_path %>
|
||||
Disallow: /activity
|
||||
Disallow: <%= search_path %>
|
||||
Disallow: /project_queries/configure_view_modal
|
||||
Disallow: /projects/export_list_modal
|
||||
<%# Generally allow /projects but disallow those links that change columns, sort order or per page settings %>
|
||||
Disallow: /projects?*columns=
|
||||
Disallow: /projects?*sortBy=
|
||||
|
||||
@@ -158,7 +158,7 @@ Rails.application.reloader.to_prepare do
|
||||
|
||||
map.permission :export_projects,
|
||||
{
|
||||
projects: %i[export_list_modal export_project_initiation_pdf]
|
||||
projects: %i[export_project_initiation_pdf]
|
||||
},
|
||||
permissible_on: :project,
|
||||
dependencies: :view_project
|
||||
|
||||
@@ -372,10 +372,6 @@ Rails.application.routes.draw do
|
||||
post :deactivate_work_package_attachments
|
||||
end
|
||||
|
||||
collection do
|
||||
get :export_list_modal
|
||||
end
|
||||
|
||||
resources :versions, only: %i[new create] do
|
||||
collection do
|
||||
put :close_completed
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
.op-export-options
|
||||
display: flex
|
||||
flex-wrap: wrap
|
||||
margin: 0
|
||||
padding: 20px 0
|
||||
list-style-type: none
|
||||
|
||||
&--option
|
||||
flex: 1 1 calc(33% - 40px) // line break after third element
|
||||
margin: 20px
|
||||
text-align: center
|
||||
|
||||
&-link
|
||||
cursor: pointer
|
||||
text-decoration: none
|
||||
color: var(--body-font-color)
|
||||
font-weight: normal
|
||||
overflow-wrap: break-word
|
||||
word-wrap: break-word
|
||||
&:hover, &:active
|
||||
text-decoration: none
|
||||
color: var(--body-font-color)
|
||||
|
||||
&-label
|
||||
display: block
|
||||
padding: 10px 0 0 0
|
||||
@@ -6,6 +6,5 @@
|
||||
@import '../../app/shared/components/option-list/option-list'
|
||||
@import '../../app/shared/components/table/table'
|
||||
@import '../../app/shared/components/table/scrollable-table'
|
||||
@import 'export-options/export-options'
|
||||
@import 'select/select'
|
||||
@import 'wide-autocomplete-wrapper/wide-autocomplete-wrapper'
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
<div class="spot-modal-overlay spot-modal-overlay_active">
|
||||
<div class="spot-modal">
|
||||
<div class="spot-modal--header">
|
||||
Export
|
||||
</div>
|
||||
<div class="spot-divider"></div>
|
||||
<div class="spot-modal--body spot-container">
|
||||
<ul class="op-export-options">
|
||||
<li class="op-export-options--option">
|
||||
<a class="op-export-options--option-link">
|
||||
<i class="icon-export-atom icon-big"></i>
|
||||
<span class="op-export-options--option-label">ATOM</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="op-export-options--option">
|
||||
<a class="op-export-options--option-link">
|
||||
<i class="icon-export-xls icon-big"></i>
|
||||
<span class="op-export-options--option-label">XLS</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="op-export-options--option">
|
||||
<a class="op-export-options--option-link">
|
||||
<i class="icon-export-xls-with-descriptions icon-big"></i>
|
||||
<span class="op-export-options--option-label">XLS with description</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="op-export-options--option">
|
||||
<a class="op-export-options--option-link">
|
||||
<i class="icon-export-pdf icon-big"></i>
|
||||
<span class="op-export-options--option-label">PDF</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="op-export-options--option">
|
||||
<a class="op-export-options--option-link">
|
||||
<i class="icon-export-pdf-descr icon-big"></i>
|
||||
<span class="op-export-options--option-label">PDF with description</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="op-export-options--option">
|
||||
<a class="op-export-options--option-link">
|
||||
<i class="icon-export-csv icon-big"></i>
|
||||
<span class="op-export-options--option-label">CSV</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="spot-action-bar">
|
||||
<div class="spot-action-bar--right">
|
||||
<button
|
||||
type="button"
|
||||
class="spot-modal--cancel-button button button_no-margin spot-action-bar--action">Cancel
|
||||
</button>
|
||||
<button name="button" type="submit" class="button button_no-margin spot-action-bar--action">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -105,14 +105,6 @@ RSpec.describe ProjectsController do
|
||||
end
|
||||
end
|
||||
|
||||
describe "export_list_modal" do
|
||||
it do
|
||||
expect(get("/projects/export_list_modal")).to route_to(
|
||||
controller: "projects", action: "export_list_modal"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
describe "templated" do
|
||||
it do
|
||||
expect(delete("/projects/123/templated"))
|
||||
|
||||
Reference in New Issue
Block a user