mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-02 18:04:29 +08:00
Merge pull request #3097 from urbanrotnik/ur-sci-5422-valdiation-for-moving-folder
Add parent_folder validation [SCI-5422]
This commit is contained in:
commit
4c4b315864
2 changed files with 6 additions and 3 deletions
|
@ -105,9 +105,11 @@ class ProjectFolder < ApplicationRecord
|
|||
end
|
||||
|
||||
def parent_folder_validation
|
||||
return if parent_folder.id != id
|
||||
|
||||
errors.add(:parent_folder, I18n.t('activerecord.errors.models.project_folder.attributes.parent_folder'))
|
||||
if parent_folder.id == id
|
||||
errors.add(:parent_folder, I18n.t('activerecord.errors.models.project_folder.attributes.parent_folder'))
|
||||
elsif ProjectFolder.inner_folders(team, self).where(id: parent_folder_id).exists?
|
||||
errors.add(:parent_folder, I18n.t('activerecord.errors.models.project_folder.attributes.parent_folder_child'))
|
||||
end
|
||||
end
|
||||
|
||||
def ensure_uniqueness_name_on_moving
|
||||
|
|
|
@ -102,6 +102,7 @@ en:
|
|||
attributes:
|
||||
parent_folder_team: "Parent folder and folder should belongs to the same team"
|
||||
parent_folder: "Folder cannot be parent to itself"
|
||||
parent_folder_child: "Folder cannot be moved to it's child"
|
||||
view_state:
|
||||
attributes:
|
||||
viewable_id:
|
||||
|
|
Loading…
Add table
Reference in a new issue