mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
custom comment column in project list
This commit is contained in:
@@ -68,6 +68,7 @@ module Queries::Projects
|
||||
|
||||
select Selects::CreatedAt
|
||||
select Selects::CustomField
|
||||
select Selects::CustomComment
|
||||
select Selects::Default
|
||||
select Selects::Favorited
|
||||
select Selects::LatestActivityAt
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
# 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 Queries::Projects::Selects::CustomComment < Queries::Selects::Base
|
||||
include Queries::Selects::Shared::CustomFieldSelect
|
||||
|
||||
self.custom_field_context = Queries::Projects::CustomFieldContext
|
||||
|
||||
validates :custom_field, presence: { message: I18n.t(:"activerecord.errors.messages.does_not_exist") }
|
||||
|
||||
KEY = /\Acfc_(\d+)\z/
|
||||
|
||||
def self.key
|
||||
KEY
|
||||
end
|
||||
|
||||
def self.all_available
|
||||
return [] unless available?
|
||||
|
||||
custom_field_context
|
||||
.custom_fields
|
||||
.where(has_comment: true)
|
||||
.pluck(:id)
|
||||
.map { |id| new(:"cfc_#{id}") }
|
||||
end
|
||||
|
||||
def caption
|
||||
I18n.t(:label_custom_comment, name: custom_field.name)
|
||||
end
|
||||
|
||||
def custom_field
|
||||
return @custom_field if defined?(@custom_field)
|
||||
|
||||
@custom_field = custom_field_context.find_custom_field(attribute[KEY, 1])
|
||||
end
|
||||
|
||||
def available?
|
||||
custom_field&.has_comment?
|
||||
end
|
||||
end
|
||||
@@ -3528,6 +3528,7 @@ en:
|
||||
label_lock_user: "Lock user"
|
||||
label_logged_as: "Logged in as"
|
||||
label_login: "Sign in"
|
||||
label_custom_comment: "%{name} comment"
|
||||
label_custom_logo: "Custom logo desktop"
|
||||
label_custom_logo_mobile: "Custom logo mobile"
|
||||
label_custom_export_logo: "Custom export logo"
|
||||
|
||||
@@ -116,15 +116,14 @@ RSpec.describe ProjectQuery do
|
||||
|
||||
describe ".available_selects" do
|
||||
before do
|
||||
scope = instance_double(ActiveRecord::Relation)
|
||||
all_scope = instance_double(ActiveRecord::Relation)
|
||||
commentable = instance_double(ActiveRecord::Relation)
|
||||
|
||||
allow(ProjectCustomField)
|
||||
.to receive(:visible)
|
||||
.and_return(scope)
|
||||
allow(ProjectCustomField).to receive(:visible).and_return(all_scope)
|
||||
allow(all_scope).to receive(:pluck).with(:id).and_return([23, 42])
|
||||
|
||||
allow(scope)
|
||||
.to receive(:pluck)
|
||||
.and_return([23, 42])
|
||||
allow(all_scope).to receive(:where).with(has_comment: true).and_return(commentable)
|
||||
allow(commentable).to receive(:pluck).with(:id).and_return([42])
|
||||
end
|
||||
|
||||
# rubocop:disable Naming/VariableNumber
|
||||
@@ -146,6 +145,7 @@ RSpec.describe ProjectQuery do
|
||||
created_at
|
||||
cf_23
|
||||
cf_42
|
||||
cfc_42
|
||||
budget_available
|
||||
budget_planned
|
||||
budget_spent
|
||||
@@ -175,6 +175,7 @@ RSpec.describe ProjectQuery do
|
||||
required_disk_space
|
||||
cf_23
|
||||
cf_42
|
||||
cfc_42
|
||||
budget_available
|
||||
budget_planned
|
||||
budget_spent
|
||||
|
||||
Reference in New Issue
Block a user