🚸 Make drag and drop an optional feature (enabled by default) (#4853)
* add option to allow enabling/disabling drag and drop upload, #4843 * ♻️ Slight refactoring & earlier bail --------- Co-authored-by: Gina Häußge <gina@octoprint.org>
This commit is contained in:
1 parent
ac5b3206f0
commit
4302769aad
5 files changed
+22
-1
No files matched your search
@@ -43,3 +43,6 @@ class FeatureConfig(BaseModel):
|
||||
|
||||
enforceReallyUniversalFilenames: bool = False
|
||||
"""Replace all special characters and spaces with text equivalent to make them universally compatible. Most OS filesystems work fine with unicode characters, but just in case you can revert to the older behaviour by setting this to true."""
|
||||
|
||||
enableDragDropUpload: bool = True
|
||||
"""Enable drag and drop upload overlay"""
|
||||
@@ -148,6 +148,7 @@ def getSettings():
|
||||
),
|
||||
"g90InfluencesExtruder": s.getBoolean(["feature", "g90InfluencesExtruder"]),
|
||||
"autoUppercaseBlacklist": s.get(["feature", "autoUppercaseBlacklist"]),
|
||||
"enableDragDropUpload": s.getBoolean(["feature", "enableDragDropUpload"]),
|
||||
},
|
||||
"gcodeAnalysis": {
|
||||
"runAt": s.get(["gcodeAnalysis", "runAt"]),
|
||||
@@ -709,6 +710,11 @@ def _saveSettings(data):
|
||||
["feature", "autoUppercaseBlacklist"],
|
||||
data["feature"]["autoUppercaseBlacklist"],
|
||||
)
|
||||
if "enableDragDropUpload" in data["feature"]:
|
||||
s.setBoolean(
|
||||
["feature", "enableDragDropUpload"],
|
||||
data["feature"]["enableDragDropUpload"],
|
||||
)
|
||||
|
||||
if "gcodeAnalysis" in data:
|
||||
if "runAt" in data["gcodeAnalysis"]:
|
||||
|
||||
@@ -1633,7 +1633,7 @@ $(function () {
|
||||
};
|
||||
|
||||
self._enableDragNDrop = function (enable) {
|
||||
if (enable) {
|
||||
if (enable && self.settingsViewModel.feature_enableDragDropUpload()) {
|
||||
$(document).bind("dragenter", self._handleDragEnter);
|
||||
$(document).bind("dragleave", self._handleDragLeave);
|
||||
log.debug("Enabled drag-n-drop");
|
||||
@@ -1930,6 +1930,10 @@ $(function () {
|
||||
};
|
||||
|
||||
self._handleDragEnter = function (e) {
|
||||
if (!self.settingsViewModel.feature_enableDragDropUpload()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const draggedFiles = Array.from(e.originalEvent.dataTransfer.items).filter(
|
||||
(item) => item.kind === "file"
|
||||
);
|
||||
|
||||
@@ -164,6 +164,7 @@ $(function () {
|
||||
self.feature_uploadOverwriteConfirmation = ko.observable(undefined);
|
||||
self.feature_g90InfluencesExtruder = ko.observable(undefined);
|
||||
self.feature_autoUppercaseBlacklist = ko.observable(undefined);
|
||||
self.feature_enableDragDropUpload = ko.observable(undefined);
|
||||
|
||||
self.gcodeAnalysis_runAt = ko.observable(undefined);
|
||||
|
||||
|
||||
@@ -42,6 +42,13 @@
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: feature_enableDragDropUpload" id="settings-enableDragDropUpload"> {{ _('Enable drag and drop upload overlay') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
|
||||
Reference in new issue
Block a user