Skip to content

TagSpaces is an offline, open source, document manager with tagging support

Added default location functionality

Borislav Sapundzhiev9c247ebb5faa
diff --git a/data/js/directories.ui.js b/data/js/directories.ui.js
index a8826e3c0..1ea7504da 100644
--- a/data/js/directories.ui.js
+++ b/data/js/directories.ui.js
@@ -98,6 +98,13 @@ define(function(require, exports, module) {
TSCORE.PerspectiveManager.changePerspective(defaultPerspective);
// Saving the last opened location path in the settings
TSCORE.Config.setLastOpenedLocation(path);
+ if($('#defaultLocation').prop('checked') === true
+ || $('#defaultLocationEdit').prop('checked') === true) {
+ console.log("set default path " + path);
+ TSCORE.Config.setDefaultLocation(path);
+ $('#defaultLocation').prop('checked', false);
+ $('#defaultLocationEdit').prop('checked', false);
+ }
TSCORE.Config.saveSettings();
}
// Clear search query
@@ -513,6 +520,10 @@ define(function(require, exports, module) {
} else if (isWeb) {
$('#folderLocation').attr('placeholder', 'e.g.: /owncloud/remote.php/webdav/');
}
+ var enableDefaultlocation = (TSCORE.Config.getDefaultLocation() === "");
+ $('#defaultLocation').attr('checked', enableDefaultlocation);
+ $('#defaultLocation').attr('disabled', enableDefaultlocation);
+
$('#formLocationCreate').validator();
$('#formLocationCreate').submit(function(e) {
e.preventDefault();
@@ -602,12 +613,16 @@ define(function(require, exports, module) {
function deleteLocation(name) {
console.log('Deleting folder connection..');
TSCORE.Config.deleteLocation(name);
+ alert("del " + name + " list "+ JSON.stringify(TSCORE.Config.Settings.tagspacesList));
initLocations();
//Opens the first location in the settings after deleting a location
if (TSCORE.Config.Settings.tagspacesList.length > 0) {
openLocation(TSCORE.Config.Settings.tagspacesList[0].path);
} else {
closeCurrentLocation();
+ TSCORE.Config.setLastOpenedLocation("");
+ TSCORE.Config.setDefaultLocation("");
+ TSCORE.Config.saveSettings();
}
}
diff --git a/data/js/settings.api.js b/data/js/settings.api.js
index 7933212b4..bea354c60 100644
--- a/data/js/settings.api.js
+++ b/data/js/settings.api.js
@@ -307,6 +307,12 @@ define(function(require, exports, module) {
var setLastOpenedLocation = function(value) {
exports.Settings.lastOpenedLocation = value;
};
+ var getDefaultLocation = function() {
+ return exports.Settings.defaultLocation || "";
+ };
+ var setDefaultLocation = function(value) {
+ exports.Settings.defaultLocation = value;
+ };
var getSupportedLanguages = function() {
return exports.DefaultSettings.supportedLanguages;
};
@@ -985,7 +991,8 @@ define(function(require, exports, module) {
exports.getShowTagLibraryKeyBinding = getShowTagLibraryKeyBinding;
exports.setShowFolderNavigatorKeyBinding = setShowFolderNavigatorKeyBinding;
exports.getShowFolderNavigatorBinding = getShowFolderNavigatorBinding;
-
+ exports.getDefaultLocation = getDefaultLocation;
+ exports.setDefaultLocation = setDefaultLocation;
exports.getPerspectiveExtensions = getPerspectiveExtensions;
exports.getActivatedPerspectiveExtensions = getActivatedPerspectiveExtensions;
exports.getViewerExtensions = getViewerExtensions;
diff --git a/data/templates/LocationCreateDialog.html b/data/templates/LocationCreateDialog.html
index 623065e46..95189d869 100644
--- a/data/templates/LocationCreateDialog.html
+++ b/data/templates/LocationCreateDialog.html
@@ -27,6 +27,16 @@
<label class="control-label" for="locationPerspective" data-i18n="ns.dialogs:createLocationDefaultPerspective">Default Perspective</label>
<select class="form-control" name="locationPerspective" id="locationPerspective" ></select>
</div>
+ <div class="form-group">
+ <label class="control-label" for="defaultLocation">Deault location</label>
+ <div class="onoffswitch">
+ <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="defaultLocation">
+ <label class="onoffswitch-label" for="defaultLocation">
+ <span class="onoffswitch-inner"></span>
+ <span class="onoffswitch-switch"></span>
+ </label>
+ </div>
+ </div>
</form>
</div>
<div class="modal-footer">
diff --git a/data/templates/LocationEditDialog.html b/data/templates/LocationEditDialog.html
index 7d6be63b2..4f1dd6133 100644
--- a/data/templates/LocationEditDialog.html
+++ b/data/templates/LocationEditDialog.html
@@ -27,6 +27,16 @@
<label class="control-label" for="locationPerspective2" data-i18n="ns.dialogs:editLocationDefaultPerspective">Default Perspective</label>
<select class="form-control" name="locationPerspective2" id="locationPerspective2" ></select>
</div>
+ <div class="form-group">
+ <label class="control-label" for="defaultLocationEdit">Deault location</label>
+ <div class="onoffswitch">
+ <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="defaultLocationEdit">
+ <label class="onoffswitch-label" for="defaultLocationEdit">
+ <span class="onoffswitch-inner"></span>
+ <span class="onoffswitch-switch"></span>
+ </label>
+ </div>
+ </div>
<!--/form-->
</div>
<div class="modal-footer">