Skip to content

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

Test search queries save

miroopfdee0f453b75
diff --git a/data/index.html b/data/index.html
index 342470a70..d7208df8c 100644
--- a/data/index.html
+++ b/data/index.html
@@ -889,18 +889,20 @@
<option value="t:archive">Archives (ZIP,RAR,TGZ,7Z,...)</option>
</select>
</div>
- <!--div class="form-group">
+ <div class="form-group">
<label for="searchHistory" class="control-label">History of your last searches</label>
<select id="searchHistory" class="form-control searchFormElements disabled" disabled title="TagSpaces PRO feature">
<option value="">You can find here your last search queries</option>
+ <!--
<option value="t:pictures +topsy">t:pictures +topsy</option>
<option value="t:pictures +danny">t:pictures +danny</option>
<option value="t:docs +work">t:docs +work</option>
<option value="t:archives +client1">t:archives +client1</option>
<option value="t:audio u2">t:audio u2</option>
<option value="clear">Clear search history</option>
+ -->
</select>
- </div-->
+ </div>
<div class="checkbox">
<label>
<input type="checkbox" id="searchRecursive" checked>&nbsp;<span>Search in subfolders</span>
diff --git a/data/js/search.ui.js b/data/js/search.ui.js
index b0d591ddd..c43fa9360 100644
--- a/data/js/search.ui.js
+++ b/data/js/search.ui.js
@@ -147,12 +147,32 @@ define(function(require, exports, module) {
$("#searchOptions").show();
}
+ //var searchArryQueries = [];
function startSearch() {
if (TSCORE.IO.stopWatchingDirectories) {
TSCORE.IO.stopWatchingDirectories();
}
if (!$('#searchRecursive').prop('checked') && $('#searchBox').val().length > 0) {
+ var origSearchVal = $('#searchBox').val();
$('#searchBox').val(TSCORE.Search.recursiveSymbol + " " + $('#searchBox').val());
+ if (!$('#searchHistory').prop('disabled')) {
+ console.warn("add search query : " + $('#searchBox').val());
+ TSCORE.Config.addSearchQuery(origSearchVal);
+ var sh = document.getElementById("searchHistory");
+ for(var inxo = sh.options.length-1; inxo>0; inxo--){
+ console.warn("opt["+inxo+"] remove:" + sh.options[inxo]);
+ sh.removeChild(sh.options[inxo]);
+ }
+ //TSCORE.Config.removeAllSearchQueries();
+ var arrSearchQueries = TSCORE.Config.getSearchQueries();
+ for(var item in arrSearchQueries) {
+ console.warn("search query add: " + item);
+ $('#searchHistory').append($('<option>', {
+ value: item,
+ text : item
+ }));
+ };
+ }
TSCORE.Search.nextQuery = $('#searchBox').val();
}
diff --git a/data/js/settings.api.js b/data/js/settings.api.js
index 96ff3993e..220dca14c 100644
--- a/data/js/settings.api.js
+++ b/data/js/settings.api.js
@@ -1120,6 +1120,26 @@ define(function(require, exports, module) {
saveSettings();
}
+ function addSearchQuery(query) {
+ if(!exports.Settings.searchQueryList) {
+ exports.Settings.searchQueryList = [];
+ }
+ exports.Settings.searchQueryList[query] = query;
+ saveSettings();
+ }
+
+ function getSearchQueries() {
+ if(!exports.Settings.searchQueryList) {
+ exports.Settings.searchQueryList = [];
+ }
+ return exports.Settings.searchQueryList;
+ }
+
+ function removeAllSearchQueries() {
+ exports.Settings.searchQueryList = [];
+ saveSettings();
+ }
+
function updateSettingMozillaPreferences(settings) {
var tmpSettings = JSON.parse(settings);
if (tmpSettings !== null) {
@@ -1142,6 +1162,8 @@ define(function(require, exports, module) {
function loadSettingsLocalStorage() {
try {
var tmpSettings = JSON.parse(localStorage.getItem('tagSpacesSettings'));
+ console.warn("tmpSettings: " + tmpSettings.searchQueryList);
+
//Cordova try to load saved setting in app storage
if (isCordova) {
var appStorageSettings = JSON.parse(TSCORE.IO.loadSettings());
@@ -1314,4 +1336,8 @@ define(function(require, exports, module) {
exports.getWriteMetaToSidecarFile = getWriteMetaToSidecarFile;
exports.getUseDefaultLocation = getUseDefaultLocation;
exports.setUseDefaultLocation = setUseDefaultLocation;
+ exports.addSearchQuery = addSearchQuery;
+ exports.getSearchQueries = getSearchQueries;
+ exports.removeAllSearchQueries = removeAllSearchQueries;
+
});
diff --git a/data/js/settings.default.js b/data/js/settings.default.js
index e64ed3d84..84b037a66 100644
--- a/data/js/settings.default.js
+++ b/data/js/settings.default.js
@@ -18,6 +18,7 @@ define(function (require, exports, module) {
"firstRun": true,
"lastOpenedDirectory": "",
"tagspacesList": [], // [{"name":"Demo","path":"/owncloud/remote.php/webdav/Demo","perspective":"perspectiveList"}],
+ "searchQueryList": [],
"extensionsPath": "ext",
"showWarningRecursiveScan": true,
"prefixTagContainer": "",