mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
mimick id on non existent model
That way change detection can pick up setting an association with such a value
This commit is contained in:
@@ -320,7 +320,7 @@ module WorkPackages
|
||||
def validate_people_visible(attribute, id_attribute, list)
|
||||
id = model[id_attribute]
|
||||
|
||||
return if id.nil? || model.changed.exclude?(id_attribute)
|
||||
return if id.nil? || id == 0 || model.changed.exclude?(id_attribute)
|
||||
|
||||
unless principal_visible?(id, list)
|
||||
errors.add attribute,
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
# --copyright
|
||||
# OpenProject is an open source project management software.
|
||||
# Copyright (C) 2010-2022 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 InexistentModel
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
# Set an id so that e.g. change detection (dirty) on associations
|
||||
# is picked up whenever such a model is assigned.
|
||||
after_initialize do
|
||||
self.id = 0
|
||||
end
|
||||
|
||||
_validators.clear
|
||||
end
|
||||
end
|
||||
@@ -26,4 +26,6 @@
|
||||
# See COPYRIGHT and LICENSE files for more details.
|
||||
#++
|
||||
|
||||
class Priority::InexistentPriority < IssuePriority; end
|
||||
class Priority::InexistentPriority < IssuePriority
|
||||
include InexistentModel
|
||||
end
|
||||
|
||||
@@ -26,4 +26,6 @@
|
||||
# See COPYRIGHT and LICENSE files for more details.
|
||||
#++
|
||||
|
||||
class Status::InexistentStatus < Status; end
|
||||
class Status::InexistentStatus < Status
|
||||
include InexistentModel
|
||||
end
|
||||
|
||||
@@ -27,4 +27,5 @@
|
||||
#++
|
||||
|
||||
class Type::InexistentType < Type
|
||||
include InexistentModel
|
||||
end
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#++
|
||||
|
||||
class Users::InexistentUser < User
|
||||
include InexistentModel
|
||||
|
||||
def self.sti_name
|
||||
nil
|
||||
end
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#++
|
||||
|
||||
class WorkPackage::InexistentWorkPackage < WorkPackage
|
||||
_validators.clear
|
||||
include InexistentModel
|
||||
|
||||
def does_not_exist
|
||||
errors.add :base, :does_not_exist
|
||||
|
||||
@@ -27,5 +27,5 @@
|
||||
#++
|
||||
|
||||
class Storages::Storage::InexistentStorage < Storages::Storage
|
||||
_validators.clear
|
||||
include InexistentModel
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user