Skip to content
Draft
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
5 changes: 4 additions & 1 deletion app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class Project < ApplicationRecord
}, dependent: :destroy
has_many :time_entries, dependent: :delete_all
has_many :time_entry_activities_projects, dependent: :delete_all
has_many :cost_types_projects, dependent: :delete_all
has_many :cost_types, through: :cost_types_projects
has_many :queries, dependent: :destroy
has_many :news, -> { includes(:author) }, dependent: :destroy
has_many :categories, -> { order("#{Category.table_name}.name") }, dependent: :delete_all
Expand Down Expand Up @@ -193,7 +195,8 @@ class Project < ApplicationRecord
scope :templated, -> { where(templated: true) }

scopes :activated_time_activity,
:visible_with_activated_time_activity
:visible_with_activated_time_activity,
:available_cost_types

enum :status_code, {
on_track: 0,
Expand Down
12 changes: 9 additions & 3 deletions config/initializers/menus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -784,15 +784,21 @@
},
versions: { caption: :label_version_plural },
repository: { caption: :label_repository },
time_entry_activities: { caption: :enumeration_activities },
time_and_costs: {
caption: :"cost_types.settings.time_and_costs",
controller: "/projects/settings/time_entry_activities"
},
storage: { caption: :label_required_disk_storage }
}

project_menu_items.each do |key, options|
menu.push :"settings_#{key}",
{ controller: "/projects/settings/#{key}", action: "show" }.merge(options.slice(:action)),
{
controller: options[:controller] || "/projects/settings/#{key}",
action: options[:action] || "show"
},
parent: :settings,
**options.except(:action)
**options.except(:action, :controller)
end
end

Expand Down
43 changes: 43 additions & 0 deletions db/migrate/20260513120000_add_project_scoping_to_cost_types.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# 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 AddProjectScopingToCostTypes < ActiveRecord::Migration[8.0]
def change
add_column :cost_types, :is_for_all, :boolean, default: true, null: false

create_table :cost_types_projects do |t|
t.references :cost_type, null: false, foreign_key: true
t.references :project, null: false, foreign_key: true
t.timestamps
end

add_index :cost_types_projects, %i[cost_type_id project_id], unique: true
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<%#-- 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
primer_form_with(
model: @cost_type_project_mapping,
url:,
data: { turbo: true },
method: :post
) do |form|
concat(
render(
Primer::Alpha::Dialog::Body.new(
id: dialog_body_id, test_selector: dialog_body_id, aria: { label: title },
classes: "Overlay-body_autocomplete_height"
)
) do
render(::CostTypes::CostTypeProjects::CostTypeMappingForm.new(form, project_mapping: @cost_type_project_mapping))
end
)

concat(
render(Primer::Alpha::Dialog::Footer.new(show_divider: false)) do
concat(render(Primer::Beta::Button.new(data: { "close-dialog-id": dialog_id })) { cancel_button_text })
concat(render(Primer::Beta::Button.new(scheme: :primary, type: :submit)) { submit_button_text })
end
)
end
end
%>
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# 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 CostTypes
module CostTypeProjects
class NewCostTypeProjectsFormModalComponent < ApplicationComponent
include OpTurbo::Streamable

DIALOG_ID = "new-cost-type-projects-modal"
DIALOG_BODY_ID = "new-cost-type-projects-modal-body"

def initialize(cost_type_project_mapping:, cost_type:, **)
@cost_type_project_mapping = cost_type_project_mapping
@cost_type = cost_type
super(@cost_type_project_mapping, **)
end

private

def url
url_helpers.admin_cost_type_projects_path(@cost_type)
end

def dialog_id = DIALOG_ID
def dialog_body_id = DIALOG_BODY_ID

attr_reader :cost_type_project_mapping, :cost_type

def title
I18n.t(:label_add_projects)
end

def cancel_button_text
I18n.t("button_cancel")
end

def submit_button_text
I18n.t("button_add")
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<%#-- 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.
++#%>

<%=
render(
Primer::Alpha::Dialog.new(
id: dialog_id,
title:,
test_selector: dialog_id,
size: :large
)
) do |dialog|
dialog.with_header(
show_divider: false,
visually_hide_title: false,
variant: :large
)

render(form_modal_component)
end
%>
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# 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 CostTypes
module CostTypeProjects
class NewCostTypeProjectsModalComponent < ApplicationComponent
include OpTurbo::Streamable

def initialize(cost_type_project_mapping:, cost_type:, **)
@cost_type_project_mapping = cost_type_project_mapping
@cost_type = cost_type
super(@cost_type_project_mapping, **)
end

def render?
!cost_type.is_for_all?
end

private

attr_reader :cost_type_project_mapping, :cost_type

def dialog_id = NewCostTypeProjectsFormModalComponent::DIALOG_ID
def dialog_body_id = NewCostTypeProjectsFormModalComponent::DIALOG_BODY_ID

def title
I18n.t(:label_add_projects)
end

def form_modal_component
Admin::CostTypes::CostTypeProjects::NewCostTypeProjectsFormModalComponent.new(
cost_type_project_mapping:, cost_type:
)
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<%#-- 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: "tr", class: row_css_class, data: { turbo: true }) do %>
<% columns.each do |column| %>
<td class="<%= column_css_class(column) %>">
<%= column_value(column) %>
</td>
<% end %>

<td class="buttons">
<% button_links.each do |link| %>
<%= link %>
<% end %>
</td>
<% end %>
Loading
Loading