mirror of
				https://github.com/scinote-eln/scinote-web.git
				synced 2025-11-04 12:07:23 +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
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def parent_folder_validation
 | 
					  def parent_folder_validation
 | 
				
			||||||
    return if parent_folder.id != id
 | 
					    if parent_folder.id == id
 | 
				
			||||||
 | 
					      errors.add(:parent_folder, I18n.t('activerecord.errors.models.project_folder.attributes.parent_folder'))
 | 
				
			||||||
    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
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def ensure_uniqueness_name_on_moving
 | 
					  def ensure_uniqueness_name_on_moving
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -102,6 +102,7 @@ en:
 | 
				
			||||||
          attributes:
 | 
					          attributes:
 | 
				
			||||||
            parent_folder_team: "Parent folder and folder should belongs to the same team"
 | 
					            parent_folder_team: "Parent folder and folder should belongs to the same team"
 | 
				
			||||||
            parent_folder: "Folder cannot be parent to itself"
 | 
					            parent_folder: "Folder cannot be parent to itself"
 | 
				
			||||||
 | 
					            parent_folder_child: "Folder cannot be moved to it's child"
 | 
				
			||||||
        view_state:
 | 
					        view_state:
 | 
				
			||||||
          attributes:
 | 
					          attributes:
 | 
				
			||||||
            viewable_id:
 | 
					            viewable_id:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue