From 468c1514889f70fa32be14bc0c206699d9ab4ccf Mon Sep 17 00:00:00 2001 From: Mike Hatfield Date: Tue, 4 Dec 2007 12:13:30 +0000 Subject: [PATCH] Office add-in tagging: bug fixes and UI clean-up git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@7522 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../org/alfresco/office/docActions.get.js | 26 +-- .../office/documentDetails.get.html.ftl | 183 +++++++++--------- .../office/searchResults.get.html.ftl | 2 +- .../org/alfresco/office/tags.get.html.ftl | 2 +- source/web/css/office.css | 9 +- source/web/scripts/office/doc_details.js | 32 +-- source/web/scripts/office/navigation.js | 20 +- source/web/scripts/office/office_addin.js | 2 +- source/web/scripts/office/tags.js | 32 ++- 9 files changed, 158 insertions(+), 150 deletions(-) diff --git a/config/alfresco/templates/webscripts/org/alfresco/office/docActions.get.js b/config/alfresco/templates/webscripts/org/alfresco/office/docActions.get.js index 8c9daa6b96..fd2c99cdf1 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/office/docActions.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/office/docActions.get.js @@ -8,19 +8,19 @@ var resultString = "Action failed", resultCode = false; // Is this action targetting a document? -var nodeId = args.n; -if ((nodeId != "") && (nodeId != null)) +var docNodeId = args.n; +if ((docNodeId != "") && (docNodeId != null)) { - var node = search.findNode("workspace://SpacesStore/" + nodeId); + var docNode = search.findNode("workspace://SpacesStore/" + docNodeId); - if (node != null && node.isDocument) + if (docNode != null && docNode.isDocument) { try { if (runAction == "makepdf") { resultString = "Could not convert document"; - var nodeTrans = node.transformDocument("application/pdf"); + var nodeTrans = docNode.transformDocument("application/pdf"); if (nodeTrans != null) { resultString = "Document converted"; @@ -30,7 +30,7 @@ if ((nodeId != "") && (nodeId != null)) else if (runAction == "delete") { resultString = "Could not delete document"; - if (node.remove()) + if (docNode.remove()) { resultString = "Document deleted"; resultCode = true; @@ -38,7 +38,7 @@ if ((nodeId != "") && (nodeId != null)) } else if (runAction == "checkout") { - var workingCopy = node.checkout(); + var workingCopy = docNode.checkout(); if (workingCopy != null) { resultString = "Document checked out"; @@ -47,7 +47,7 @@ if ((nodeId != "") && (nodeId != null)) } else if (runAction == "checkin") { - var originalDoc = node.checkin(); + var originalDoc = docNode.checkin(); if (originalDoc != null) { resultString = "Document checked in"; @@ -57,7 +57,7 @@ if ((nodeId != "") && (nodeId != null)) else if (runAction == "makeversion") { resultString = "Could not version document"; - if (node.addAspect("cm:versionable")) + if (docNode.addAspect("cm:versionable")) { resultString = "Document versioned"; resultCode = true; @@ -78,13 +78,13 @@ if ((nodeId != "") && (nodeId != null)) { workflow.parameters["bpm:workflowDueDate"] = dueDate; } - workflow.execute(node); + workflow.execute(docNode); resultString = "New workflow started"; resultCode = true; } else if (runAction == "test") { - resultString = "Test complete."; + resultString = "Tested ok."; resultCode = true; } else @@ -105,7 +105,7 @@ else // Non document-based actions if (runAction == "newspace") { resultString = "Could not create space"; - var nodeId = args.n, + var parentNodeId = args.p, spaceName = args.sn, spaceTitle = (args.st == "undefined") ? "" : args.st, spaceDescription = (args.sd == "undefined") ? "" : args.sd, @@ -118,7 +118,7 @@ else // Non document-based actions } else { - var nodeParent = search.findNode("workspace://SpacesStore/" + nodeId); + var nodeParent = search.findNode("workspace://SpacesStore/" + parentNodeId); // Copy from template? if ((templateId != null) && (templateId != "")) { diff --git a/config/alfresco/templates/webscripts/org/alfresco/office/documentDetails.get.html.ftl b/config/alfresco/templates/webscripts/org/alfresco/office/documentDetails.get.html.ftl index b3054bd498..c40ffab43f 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/office/documentDetails.get.html.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/office/documentDetails.get.html.ftl @@ -1,5 +1,4 @@ <#assign doc_actions="${url.serviceContext}/office/docActions"> -<#assign tag_actions="${url.serviceContext}/collaboration/tagActions"> <#if args.p?exists><#assign path=args.p><#else><#assign path=""> <#if args.e?exists><#assign extn=args.e><#else><#assign extn="doc"><#assign extnx=extn+"x"> @@ -38,62 +37,65 @@
Current Document Details
- - - - - - -
+
+ + + + - + + +
<#if d.isDocument> - ${d.name} - - + ${d.name} + + <#if d.isLocked > - Locked + Locked - ${d.name} - -
- + ${d.name} + +
+
<#if d.properties.title?exists> - + <#else> - + <#if d.properties.description?exists> - + <#else> - + - - - - - - - + + + + + + - -
Title:${d.properties.title}
Title:${d.properties.title}
Title: 
Title: 
Description:${d.properties.description}
Description:${d.properties.description}
Description: 
Description: 
Creator:${d.properties.creator}
Created:${d.properties.created?datetime}
Modifier:${d.properties.modifier}
Modified:${d.properties.modified?datetime}
Size:${d.size / 1024} Kb
Categories: +
Creator:${d.properties.creator}
Created:${d.properties.created?datetime}
Modifier:${d.properties.modifier}
Modified:${d.properties.modified?datetime}
Size:${d.size / 1024} Kb
Categories: <#if d.properties.categories?exists> <#list d.properties.categories as category> - ${companyhome.nodeByReference[category].name}; + ${companyhome.nodeByReference[category].name}; <#else> - None. + None. -
+
<#else> - The current document is not managed by Alfresco. + The current document is not managed by Alfresco. -
+ + + + +
+
@@ -106,7 +108,7 @@ Add a tag
-
+ @@ -117,8 +119,8 @@ <#list d.properties["cm:taggable"]?sort_by("name") as tag> <#if tag?exists> @@ -169,7 +171,7 @@ The current document is not versioned.

@@ -190,65 +192,66 @@
Document Actions
-
-
- -
- +
+<#if args.version?exists> + + + diff --git a/config/alfresco/templates/webscripts/org/alfresco/office/searchResults.get.html.ftl b/config/alfresco/templates/webscripts/org/alfresco/office/searchResults.get.html.ftl index 9c07abff3b..688124cf4b 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/office/searchResults.get.html.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/office/searchResults.get.html.ftl @@ -16,7 +16,7 @@
<#else> <#assign totalResults = results?size> - <#list results as child> + <#list results?sort_by(["properties","cm:modified"])?reverse as child> <#assign resCount=resCount + 1> <#if child.isDocument> <#assign relativePath = (child.displayPath?substring(companyhome.name?length+1) + '/' + child.name)?url?replace('%2F', '/')?replace('\'', '\\\'') /> diff --git a/config/alfresco/templates/webscripts/org/alfresco/office/tags.get.html.ftl b/config/alfresco/templates/webscripts/org/alfresco/office/tags.get.html.ftl index 30d5220645..bc64772dd6 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/office/tags.get.html.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/office/tags.get.html.ftl @@ -54,7 +54,7 @@ <#if (args.tag?exists)> diff --git a/source/web/css/office.css b/source/web/css/office.css index ef57aae3e3..a37e42ef3e 100644 --- a/source/web/css/office.css +++ b/source/web/css/office.css @@ -765,12 +765,12 @@ ul.autocompleter-choices li.autocompleter-selected span.autocompleter-queried padding: 0px 4px; } -.tagDelete { +.tagListDelete { color: #ccc; font-size: 11px; } -.tagName { +.tagListName { } /* Tag cloud */ @@ -786,6 +786,11 @@ ul.autocompleter-choices li.autocompleter-selected span.autocompleter-queried #tagCloud a { cursor: pointer; + padding: 1px; +} + +#tagCloud a.tagSelected { + background-color: #ffff90; } #tagCloud .tagName0 { diff --git a/source/web/scripts/office/doc_details.js b/source/web/scripts/office/doc_details.js index 6a5adff75f..9358a84c06 100644 --- a/source/web/scripts/office/doc_details.js +++ b/source/web/scripts/office/doc_details.js @@ -70,38 +70,14 @@ var OfficeDocDetails = addTag: function(nodeId, tagName) { - OfficeAddin.postAction(window.serviceContextPath + "/collaboration/tagActions", "add", nodeId, null, "&t=" + tagName); + OfficeAddin.postAction(window.serviceContextPath + "/collaboration/tagActions", "add", nodeId, null, "t=" + tagName); return false; }, - tagAction: function(action, nodeId, tagName, msg) + removeTag: function(nodeId, tagName) { - if (msg != "" && !confirm(msg)) - { - return; - } - - OfficeAddin.showStatusText("Processing...", "ajax_anim.gif", false); - var actionURL = window.serviceContextPath + "/collaboration/tagActions?a=" + action + "&n=" + nodeId + "&t=" + tagName; - var myAjax = new Ajax(actionURL, { - method: 'post', - headers: {'If-Modified-Since': 'Sat, 1 Jan 2000 00:00:00 GMT'}, - onComplete: function(textResponse, xmlResponse) - { - // Optionally add a status string - if (textResponse != "") - { - var objResponse = Json.evaluate(textResponse); - var imgSuccess = (objResponse.statusCode ? "action_successful.gif" : "action_failed.gif"); - var colBackground = (objResponse.statusCode ? "#50ff50" : "#ff5050"); - OfficeAddin.showStatusText(objResponse.statusString, imgSuccess, true, colBackground); - } - }, - onFailure: function() - { - OfficeAddin.showStatusText("Action failed", "action_failed.gif", true); - } - }).request(); + OfficeAddin.postAction(window.serviceContextPath + "/collaboration/tagActions", "remove", nodeId , null, "t=" + tagName); + return false; } }; diff --git a/source/web/scripts/office/navigation.js b/source/web/scripts/office/navigation.js index 17072a91b4..16f0bfd7df 100644 --- a/source/web/scripts/office/navigation.js +++ b/source/web/scripts/office/navigation.js @@ -155,22 +155,22 @@ var OfficeNavigation = submitCreateSpace: function(commandURL, nodeId) { - var spcName = $('spaceName').value, - spcTitle = $('spaceTitle').value, - spcDescription = $('spaceDescription').value; + var spaceName = $('spaceName').value, + spaceTitle = $('spaceTitle').value, + spaceDescription = $('spaceDescription').value; - var spcTemplate; + var spaceTemplate; if ($('spaceTemplate')) { - spcTemplate = $('spaceTemplate').value; + spaceTemplate = $('spaceTemplate').value; } OfficeAddin.showStatusText("Creating space...", "ajax_anim.gif", false); - var actionURL = commandURL + "?a=newspace&n=" + nodeId; - actionURL += "&sn=" + encodeURI(spcName); - actionURL += "&st=" + encodeURI(spcTitle); - actionURL += "&sd=" + encodeURI(spcDescription); - actionURL += "&t=" + encodeURI(spcTemplate); + var actionURL = commandURL + "?a=newspace&p=" + nodeId; + actionURL += "&sn=" + encodeURI(spaceName); + actionURL += "&st=" + encodeURI(spaceTitle); + actionURL += "&sd=" + encodeURI(spaceDescription); + actionURL += "&t=" + encodeURI(spaceTemplate); var myAjax = new Ajax(actionURL, { method: 'get', headers: {'If-Modified-Since': 'Sat, 1 Jan 2000 00:00:00 GMT'}, diff --git a/source/web/scripts/office/office_addin.js b/source/web/scripts/office/office_addin.js index 3ab108d439..c91a70fa65 100644 --- a/source/web/scripts/office/office_addin.js +++ b/source/web/scripts/office/office_addin.js @@ -123,7 +123,7 @@ var OfficeAddin = // Remove any trailing hash var href = window.location.href.replace("#", "") // Remove any previous "st" parameters - href = OfficeAddin.removeParameters(href, "st"); + href = OfficeAddin.removeParameters(href, "st|version"); // Optionally add a status string if (textResponse != "") { diff --git a/source/web/scripts/office/tags.js b/source/web/scripts/office/tags.js index 140543d281..5cb0ae8706 100644 --- a/source/web/scripts/office/tags.js +++ b/source/web/scripts/office/tags.js @@ -10,6 +10,9 @@ var OfficeTags = /* Manadatory params for searchResults component */ searchParams: "", + /* Set to preselect a tag after the tag cloud populated */ + preselectedTag: "", + init: function() { OfficeTags.getTagCloud(); @@ -48,8 +51,12 @@ var OfficeTags = tagCloud.empty(); tagQuery.tags.each(function(tag, i) { - tagNameClass = "tagName" + Math.round((tag.count - tagQuery.countMin) / scale); - tagName = new Element("a", {"class": tagNameClass}); + tagNameClass = "tagName" + Math.round((tag.count - tagQuery.countMin) / scale); + if (OfficeTags.preselectedTag == tag.name) + { + tagNameClass += " tagSelected"; + } + tagName = new Element("a", {"class": tagNameClass, "rel": tag.name}); tagName.appendText(tag.name); tagName.injectInside(tagCloud); tagName.addEvent('click', function(e) @@ -62,8 +69,6 @@ var OfficeTags = tagCount.appendText("(" + tag.count + ")"); tagCount.injectInside(tagName); }); - - // $("tagCloud").innerHTML = Json.toString(tagQuery); }, /* AJAX call to perform server-side tag search */ @@ -87,6 +92,25 @@ var OfficeTags = $('taggedHeader').innerHTML = "Tagged with \"" + tagName + "\""; } }).request(); + + var tags = $$("#tagCloud a"); + tags.each(function(tag, i) + { + if (tag.rel == tagName) + { + tag.addClass("tagSelected"); + } + else + { + tag.removeClass("tagSelected"); + } + }); + }, + + preselectTag: function(tagName) + { + OfficeTags.preselectedTag = tagName; + OfficeTags.selectTag(tagName); } };