Skip to content

Commit bd9de01

Browse files
committed
Merge branch 'improvement/IsProtected-reordering' into develop
Updated the drag-and-drop validation logic within the `DraggableTreeView` JavaScript component to allow notes marked as `IsProtected` or assigned to a `ContentTypeDescriptor` marked with `DisableDelete` to be _reordered_ but not _moved_. As part of this, I renamed the property on the `QueryResultTopicViewModel` from `IsDraggable` (`draggable`) to `IsMovable` (`movable`). This completes the implementation of #45.
2 parents bfbce59 + d5d1730 commit bd9de01

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

OnTopic.Editor.AspNetCore/Models/Queryable/QueryResultTopicViewModel.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public QueryResultTopicViewModel(
3636
string uniqueKey,
3737
string webPath,
3838
bool? isChecked = null,
39-
bool isDraggable = true,
39+
bool isMovable = true,
4040
bool isExpanded = false
4141
) {
4242

@@ -48,7 +48,7 @@ public QueryResultTopicViewModel(
4848
Title = title;
4949
UniqueKey = uniqueKey;
5050
WebPath = webPath;
51-
IsDraggable = isDraggable;
51+
IsMovable = isMovable;
5252
IsExpanded = isExpanded;
5353

5454
if (isChecked.HasValue) {
@@ -121,14 +121,14 @@ public bool? IsChecked {
121121
}
122122

123123
/*==========================================================================================================================
124-
| IS DRAGGABLE?
124+
| IS MOVABLE?
125125
\-------------------------------------------------------------------------------------------------------------------------*/
126126
/// <summary>
127-
/// Determines whether the current topic is intended to be draggable or not.
127+
/// Determines whether the current topic is permitted to be movable or not.
128128
/// </summary>
129-
[JsonPropertyName("draggable")]
129+
[JsonPropertyName("isMovable")]
130130
[DefaultValue(true)]
131-
public bool IsDraggable {
131+
public bool IsMovable {
132132
get;
133133
}
134134

OnTopic.Editor.AspNetCore/Shared/Scripts/DraggableTreeView.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ OnTopic.DraggableTreeView = Ext.extend(Ext.tree.TreePanel, {
2929
/*============================================================================================================================
3030
| METHOD: VALIDATE SOURCE TOPIC
3131
\---------------------------------------------------------------------------------------------------------------------------*/
32-
validateSourceTopic : function(tree, node, event) {
33-
node.draggable = (node.attributes.draggable == 'false');
32+
validateSourceTopic: function (e) {
33+
if (!e.dropNode.attributes.isMovable && e.dropNode.parentNode.attributes.path !== e.target.parentNode.attributes.path) {
34+
e.cancel = true;
35+
}
3436
},
3537

3638
/*============================================================================================================================
@@ -124,7 +126,7 @@ OnTopic.DraggableTreeView = Ext.extend(Ext.tree.TreePanel, {
124126
\-------------------------------------------------------------------------------------------------------------------------*/
125127
var me = this;
126128

127-
me.on('startdrag', me.validateSourceTopic, this);
129+
me.on('nodedragover', me.validateSourceTopic, this);
128130
me.on('movenode', me.moveTopic, this);
129131

130132
}

0 commit comments

Comments
 (0)