Skip to content

Commit 35aa0e5

Browse files
committed
Simplier version of the check condition
1 parent aabcd72 commit 35aa0e5

1 file changed

Lines changed: 12 additions & 34 deletions

File tree

src/Pyramid-Bloc/PyramidEditElementTreeDragAndDropPlugin.class.st

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ Class {
1010
'editor',
1111
'navigationPlugin',
1212
'navigationSelectionPanel',
13-
'navigationPresenter',
14-
'canMoveCollection'
13+
'navigationPresenter'
1514
],
1615
#category : #'Pyramid-Bloc-plugin-edit-element-tree'
1716
}
@@ -44,33 +43,18 @@ PyramidEditElementTreeDragAndDropPlugin >> addEditElementTreeDragAndDrop [
4443

4544
{ #category : #testing }
4645
PyramidEditElementTreeDragAndDropPlugin >> canMoveSelectedElement: anArrayOfElementDragged target: aElementTarget [
47-
48-
| canMove |
49-
canMove := true.
50-
51-
canMoveCollection removeAll.
52-
53-
anArrayOfElementDragged do: [ :element |
54-
aElementTarget = element ifTrue: [ ^ canMove := false ] ].
55-
56-
self checkParentOfTarget: aElementTarget
57-
draggedBlElement: anArrayOfElementDragged.
58-
59-
canMoveCollection do: [ :boolean | boolean ifFalse: [ canMove := false ] ].
60-
61-
^ canMove
62-
]
63-
64-
{ #category : #testing }
65-
PyramidEditElementTreeDragAndDropPlugin >> checkParentOfTarget: aElementTarget draggedBlElement: anArrayOfElementDragged [
66-
67-
aElementTarget hasParent
68-
ifTrue: [ anArrayOfElementDragged do: [ :element | (aElementTarget parent = element)
69-
ifTrue: [ canMoveCollection add: false ]
70-
ifFalse: [ self checkParentOfTarget: (aElementTarget parent)
71-
draggedBlElement: anArrayOfElementDragged ] ] ]
72-
ifFalse: [ canMoveCollection add: true ]
46+
"
47+
anArrayOfElementDragged = Tous les élements en train d'être drag (candidat déplacement)
48+
aElementTarget = l'élément cible qui recevra les auters (cible)
7349
50+
Conditions pour valider le déplacement:
51+
1) Aucun candidat dépacement n'est la cible (on ne se rajoute pas sur sois même)
52+
2) La cible n'est l'enfant d'aucun candidat déplacement. ()
53+
"
54+
55+
^ anArrayOfElementDragged allSatisfy: [ :elementDrag |
56+
elementDrag ~= aElementTarget and: [
57+
(aElementTarget allParentsInclude: elementDrag) not ] ]
7458
]
7559

7660
{ #category : #connecting }
@@ -91,12 +75,6 @@ PyramidEditElementTreeDragAndDropPlugin >> editor [
9175
^ editor
9276
]
9377

94-
{ #category : #initialization }
95-
PyramidEditElementTreeDragAndDropPlugin >> initialize [
96-
97-
canMoveCollection := OrderedCollection new
98-
]
99-
10078
{ #category : #actions }
10179
PyramidEditElementTreeDragAndDropPlugin >> moveElementDragToChild: arrayOfElementDragged target: aElementTarget [
10280

0 commit comments

Comments
 (0)