Fix file drag and drop on step [SCI-9508]

This commit is contained in:
Anton 2023-10-18 12:03:12 +02:00
parent 88102673fe
commit 820d8294b9
2 changed files with 16 additions and 0 deletions

View file

@ -171,6 +171,7 @@
@reorder="startStepReorder" @reorder="startStepReorder"
:inRepository="inRepository" :inRepository="inRepository"
:stepToReload="stepToReload" :stepToReload="stepToReload"
:activeDragStep="activeDragStep"
@step:delete="updateStepsPosition" @step:delete="updateStepsPosition"
@step:update="updateStep" @step:update="updateStep"
@stepUpdated="refreshProtocolStatus" @stepUpdated="refreshProtocolStatus"
@ -179,6 +180,7 @@
@step:move_element="reloadStep" @step:move_element="reloadStep"
@step:attachemnts:loaded="stepToReload = null" @step:attachemnts:loaded="stepToReload = null"
@step:move_attachment="reloadStep" @step:move_attachment="reloadStep"
@step:drag_enter="dragEnter"
:reorderStepUrl="steps.length > 1 ? urls.reorder_steps_url : null" :reorderStepUrl="steps.length > 1 ? urls.reorder_steps_url : null"
:assignableMyModuleId="protocol.attributes.assignable_my_module_id" :assignableMyModuleId="protocol.attributes.assignable_my_module_id"
/> />
@ -256,6 +258,7 @@
reordering: false, reordering: false,
publishing: false, publishing: false,
stepToReload: null, stepToReload: null,
activeDragStep: null
} }
}, },
mounted() { mounted() {
@ -433,6 +436,9 @@
$('.my_module-name .view-mode').trigger('click'); $('.my_module-name .view-mode').trigger('click');
$('.my_module-name .input-field').focus(); $('.my_module-name .input-field').focus();
}, 300) }, 300)
},
dragEnter(id) {
this.activeDragStep = id;
} }
} }
} }

View file

@ -194,6 +194,10 @@
type: Number, type: Number,
required: false required: false
}, },
activeDragStep: {
type: Number,
required: false
}
}, },
data() { data() {
return { return {
@ -242,6 +246,11 @@
this.loadElements(); this.loadElements();
this.loadAttachments(); this.loadAttachments();
} }
},
activeDragStep() {
if (this.activeDragStep != this.step.id && this.dragingFile) {
this.dragingFile = false;
}
} }
}, },
mounted() { mounted() {
@ -349,6 +358,7 @@
let dt = e.dataTransfer; let dt = e.dataTransfer;
if (dt.types && (dt.types.indexOf ? dt.types.indexOf('Files') != -1 : dt.types.contains('Files'))) { if (dt.types && (dt.types.indexOf ? dt.types.indexOf('Files') != -1 : dt.types.contains('Files'))) {
this.dragingFile = true; this.dragingFile = true;
this.$emit('step:drag_enter', this.step.id);
} }
}, },
loadAttachments() { loadAttachments() {