Skip to content

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

Allowing adding multiple tags to multipe files Tag button created in files view

uggrock3516d227d429
diff --git a/data/ext/view.basic.js b/data/ext/view.basic.js
index 9850c78c9..c608cc7d0 100644
--- a/data/ext/view.basic.js
+++ b/data/ext/view.basic.js
@@ -97,6 +97,13 @@ exports.init = function init() {
viewMode = "files"
exports.load();
})
+
+ viewToolbar.append($("<button>", {
+ text: "Tag",
+ disabled: true,
+ title: "TagSelectedFiles",
+ id: exports.ID+"TagButton",
+ }));
viewToolbar.append($("<span>", {
style: "float: right; margin: 0px; padding: 0px;",
@@ -176,6 +183,7 @@ exports.init = function init() {
var rowData = fileTable.fnGetData( this );
// Add the filename which is located in the first column to the list of selected filenames
UIAPI.selectedFiles.push(UIAPI.currentPath + UIAPI.TagUtils.DIR_SEPARATOR + rowData[0]);
+ handleElementActivation();
});
console.debug("Selected files: "+UIAPI.selectedFiles);
}
@@ -226,8 +234,9 @@ exports.load = function load() {
exports.clearSelectedFiles();
UIAPI.selectedFiles.push(targetFilePath);
+ handleElementActivation();
- UIAPI.TagUtils.addTag(UIAPI.selectedFiles, tagName);
+ UIAPI.TagUtils.addTag(UIAPI.selectedFiles, [tagName]);
IOAPI.listDirectory(UIAPI.currentPath);
}
@@ -311,6 +320,8 @@ exports.load = function load() {
$('#'+exports.ID+"FileTable_wrapper").show();
$( "#"+exports.ID+"CreateFileButton" ).button( "enable" );
+
+ $( "#"+exports.ID+"TagButton" ).button( "disable" );
UIAPI.hideLoadingAnimation();
}
@@ -331,6 +342,7 @@ var selectFile = function(tagButton, filePath) {
exports.clearSelectedFiles();
$(tagButton).parent().parent().toggleClass("ui-selected");
UIAPI.selectedFiles.push(filePath);
+ handleElementActivation();
}
var initButtons = function() {
@@ -346,6 +358,16 @@ var initButtons = function() {
$( "#dialog-filecreate" ).dialog( "open" );
});
+ $( "#"+exports.ID+"TagButton" ).button({
+ text: true,
+ icons: {
+ primary: "ui-icon-document"
+ }
+ })
+ .click(function() {
+ $( "#dialogAddTags" ).dialog( "open" );
+ });
+
$( "#clearFilterButton" ).button({
text: false,
disabled: false,
@@ -359,25 +381,15 @@ var initButtons = function() {
});
}
-// currently not used
var handleElementActivation = function() {
console.debug("Entering element activation handler...");
if (UIAPI.selectedFiles.length > 1) {
- $( "#openFileButton" ).button( "disable" );
- $( "#editFileButton" ).button( "disable" );
- $( "#deleteFileButton" ).button( "disable" );
- $( "#renameFileButton" ).button( "disable" );
+ $( "#"+exports.ID+"TagButton" ).button( "enable" );
} else if (UIAPI.selectedFiles.length == 1) {
- $( "#openFileButton" ).button( "enable" );
- $( "#editFileButton" ).button( "enable" );
- $( "#deleteFileButton" ).button( "enable" );
- $( "#renameFileButton" ).button( "enable" );
+ $( "#"+exports.ID+"TagButton" ).button( "enable" );
} else {
- $( "#openFileButton" ).button( "disable" );
- $( "#editFileButton" ).button( "disable" );
- $( "#deleteFileButton" ).button( "disable" );
- $( "#renameFileButton" ).button( "disable" );
+ $( "#"+exports.ID+"TagButton" ).button( "disable" );
}
}
diff --git a/data/js/core.ui.js b/data/js/core.ui.js
index e203f8b97..135565bae 100644
--- a/data/js/core.ui.js
+++ b/data/js/core.ui.js
@@ -217,10 +217,7 @@ var initDialogs = function() {
buttons: {
"Add tags": function() {
var tags = $("#tags").val().split(",");
- UIAPI.TagUtils.writeTagsToFile(UIAPI.selectedFiles[0], tags);
-
- // TODO ? search
- IOAPI.listDirectory(UIAPI.currentPath);
+ UIAPI.TagUtils.addTag(UIAPI.selectedFiles, tags);
$( this ).dialog( "close" );
},
Cancel: function() {
diff --git a/data/js/fileopener.js b/data/js/fileopener.js
index 248568787..2e480980a 100644
--- a/data/js/fileopener.js
+++ b/data/js/fileopener.js
@@ -117,7 +117,7 @@ console.debug("Loading FileViewer...");
drop: function( event, ui ) {
var tagName = ui.draggable.attr("tag");
console.log("Tagging file: "+tagName+" to "+filePath);
- UIAPI.TagUtils.addTag([filePath], tagName);
+ UIAPI.TagUtils.addTag([filePath], [tagName]);
}
})
diff --git a/data/js/tags.ui.js b/data/js/tags.ui.js
index a7103ee81..bb0ef458b 100644
--- a/data/js/tags.ui.js
+++ b/data/js/tags.ui.js
@@ -67,7 +67,7 @@ TagsUI.initContextMenus = function() {
console.debug("Tag menu action: "+ui.item.attr( "action" )+" for tag: "+UIAPI.selectedTag);
switch (ui.item.attr( "action" )) {
case "addTagToFile":
- UIAPI.TagUtils.addTag(UIAPI.selectedFiles, UIAPI.selectedTag);
+ UIAPI.TagUtils.addTag(UIAPI.selectedFiles, [UIAPI.selectedTag]);
break;
case "addTagAsFilter":
$("#filterBox").val(UIAPI.selectedTag);
@@ -345,11 +345,21 @@ TagsUI.generateTagGroups = function() {
$("#tagGroups").append($("<h3>", {
class: "ui-accordion-header ui-helper-reset ui-state-default ui-corner-top ui-corner-bottom"
})
+ /* .droppable({
+ accept: ".tagButton",
+ hoverClass: "activeRow",
+ drop: function( event, ui ) {
+ var tagName = ui.draggable.attr("tag");
+ TSSETTINGS.createTag(UIAPI.selectedTagData, tagName );
+ TSSETTINGS.deleteTag(UIAPI.selectedTagData);
+ TagsUI.generateTagGroups();
+ }
+ }) */
.hover(function() { $(this).toggleClass("ui-state-hover"); })
.append($("<span>", {
class: "tagGroupTitle",
text: TSSETTINGS.Settings["tagGroups"][i].title,
- })
+ })
.click(function() {
$(this)
.parent().toggleClass("ui-accordion-header-active ui-state-active ui-state-default ui-corner-bottom").end()
diff --git a/data/js/tagutils.js b/data/js/tagutils.js
index 0bdd0cd62..9737f364f 100644
--- a/data/js/tagutils.js
+++ b/data/js/tagutils.js
@@ -198,6 +198,14 @@ define([
IOAPI.renameFile(filePath, containingDirectoryPath+DIR_SEPARATOR+newFileName);
}
+ function addTag(filePathArray, tagArray) {
+ console.debug("Adding tags to files");
+
+ for (var i=0; i < filePathArray.length; i++) {
+ writeTagsToFile(filePathArray[i], tagArray);
+ };
+ }
+
function renameTag(filePath, oldTag, newTag) {
console.debug("Rename tag for file: "+filePath);
@@ -242,14 +250,6 @@ define([
IOAPI.renameFile(filePath, containingDirectoryPath+DIR_SEPARATOR+newFileName);
}
- function addTag(filePathArray, tagName) {
- console.debug("Adding tag: "+tagName+" to the files, first file: "+filePathArray[0]);
-
- for (var i=0; i < filePathArray.length; i++) {
- writeTagsToFile(filePathArray[i], [tagName]);
- };
- }
-
// Public API definition
exports.DIR_SEPARATOR = DIR_SEPARATOR;
exports.isWindows = isWindows;