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
This commit is contained in:
Mike Hatfield
2007-12-04 12:13:30 +00:00
parent acb05d7043
commit 468c151488
9 changed files with 158 additions and 150 deletions

View File

@@ -8,19 +8,19 @@ var resultString = "Action failed",
resultCode = false; resultCode = false;
// Is this action targetting a document? // Is this action targetting a document?
var nodeId = args.n; var docNodeId = args.n;
if ((nodeId != "") && (nodeId != null)) 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 try
{ {
if (runAction == "makepdf") if (runAction == "makepdf")
{ {
resultString = "Could not convert document"; resultString = "Could not convert document";
var nodeTrans = node.transformDocument("application/pdf"); var nodeTrans = docNode.transformDocument("application/pdf");
if (nodeTrans != null) if (nodeTrans != null)
{ {
resultString = "Document converted"; resultString = "Document converted";
@@ -30,7 +30,7 @@ if ((nodeId != "") && (nodeId != null))
else if (runAction == "delete") else if (runAction == "delete")
{ {
resultString = "Could not delete document"; resultString = "Could not delete document";
if (node.remove()) if (docNode.remove())
{ {
resultString = "Document deleted"; resultString = "Document deleted";
resultCode = true; resultCode = true;
@@ -38,7 +38,7 @@ if ((nodeId != "") && (nodeId != null))
} }
else if (runAction == "checkout") else if (runAction == "checkout")
{ {
var workingCopy = node.checkout(); var workingCopy = docNode.checkout();
if (workingCopy != null) if (workingCopy != null)
{ {
resultString = "Document checked out"; resultString = "Document checked out";
@@ -47,7 +47,7 @@ if ((nodeId != "") && (nodeId != null))
} }
else if (runAction == "checkin") else if (runAction == "checkin")
{ {
var originalDoc = node.checkin(); var originalDoc = docNode.checkin();
if (originalDoc != null) if (originalDoc != null)
{ {
resultString = "Document checked in"; resultString = "Document checked in";
@@ -57,7 +57,7 @@ if ((nodeId != "") && (nodeId != null))
else if (runAction == "makeversion") else if (runAction == "makeversion")
{ {
resultString = "Could not version document"; resultString = "Could not version document";
if (node.addAspect("cm:versionable")) if (docNode.addAspect("cm:versionable"))
{ {
resultString = "Document versioned"; resultString = "Document versioned";
resultCode = true; resultCode = true;
@@ -78,13 +78,13 @@ if ((nodeId != "") && (nodeId != null))
{ {
workflow.parameters["bpm:workflowDueDate"] = dueDate; workflow.parameters["bpm:workflowDueDate"] = dueDate;
} }
workflow.execute(node); workflow.execute(docNode);
resultString = "New workflow started"; resultString = "New workflow started";
resultCode = true; resultCode = true;
} }
else if (runAction == "test") else if (runAction == "test")
{ {
resultString = "Test complete."; resultString = "Tested ok.";
resultCode = true; resultCode = true;
} }
else else
@@ -105,7 +105,7 @@ else // Non document-based actions
if (runAction == "newspace") if (runAction == "newspace")
{ {
resultString = "Could not create space"; resultString = "Could not create space";
var nodeId = args.n, var parentNodeId = args.p,
spaceName = args.sn, spaceName = args.sn,
spaceTitle = (args.st == "undefined") ? "" : args.st, spaceTitle = (args.st == "undefined") ? "" : args.st,
spaceDescription = (args.sd == "undefined") ? "" : args.sd, spaceDescription = (args.sd == "undefined") ? "" : args.sd,
@@ -118,7 +118,7 @@ else // Non document-based actions
} }
else else
{ {
var nodeParent = search.findNode("workspace://SpacesStore/" + nodeId); var nodeParent = search.findNode("workspace://SpacesStore/" + parentNodeId);
// Copy from template? // Copy from template?
if ((templateId != null) && (templateId != "")) if ((templateId != null) && (templateId != ""))
{ {

View File

@@ -1,5 +1,4 @@
<#assign doc_actions="${url.serviceContext}/office/docActions"> <#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> <#if args.p?exists><#assign path=args.p><#else><#assign path=""></#if>
<#if args.e?exists><#assign extn=args.e><#else><#assign extn="doc"></#if><#assign extnx=extn+"x"> <#if args.e?exists><#assign extn=args.e><#else><#assign extn="doc"></#if><#assign extnx=extn+"x">
@@ -38,6 +37,7 @@
<div class="header">Current Document Details</div> <div class="header">Current Document Details</div>
<div class="containerMedium"> <div class="containerMedium">
<div id="nonStatusText">
<table width="265"> <table width="265">
<tbody> <tbody>
<tr> <tr>
@@ -55,12 +55,12 @@
<br /> <br />
<table style="margin-top: 4px;"> <table style="margin-top: 4px;">
<#if d.properties.title?exists> <#if d.properties.title?exists>
<tr><td>Title:</td><td>${d.properties.title}</td></tr> <tr><td valign="top">Title:</td><td>${d.properties.title}</td></tr>
<#else> <#else>
<tr><td>Title:</td><td>&nbsp;</td></tr> <tr><td valign="top">Title:</td><td>&nbsp;</td></tr>
</#if> </#if>
<#if d.properties.description?exists> <#if d.properties.description?exists>
<tr><td>Description:</td><td>${d.properties.description}</td></tr> <tr><td valign="top">Description:</td><td>${d.properties.description}</td></tr>
<#else> <#else>
<tr><td valign="top">Description:</td><td>&nbsp;</td></tr> <tr><td valign="top">Description:</td><td>&nbsp;</td></tr>
</#if> </#if>
@@ -88,12 +88,14 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div>
<div id="statusText"></div>
</div> </div>
<div class="tabBarInline"> <div class="tabBarInline">
<ul> <ul>
<li class="current"><a title="Document Tags" href="#"><span><img src="${url.context}/images/office/document_tag.gif" alt="Document Tags" /></span></a></li> <li class="current"><a id="tabLinkTags" title="Document Tags" href="#"><span><img src="${url.context}/images/office/document_tag.gif" alt="Document Tags" /></span></a></li>
<li><a title="Version History" href="#"><span><img src="${url.context}/images/office/version.gif" alt="Version History")}" /></span></a></li> <li><a id="tabLinkVersion" title="Version History" href="#"><span><img src="${url.context}/images/office/version.gif" alt="Version History")}" /></span></a></li>
</ul> </ul>
</div> </div>
@@ -106,7 +108,7 @@
<a href="#" onclick="OfficeDocDetails.showAddTagForm(); return false;">Add a tag</a> <a href="#" onclick="OfficeDocDetails.showAddTagForm(); return false;">Add a tag</a>
</div> </div>
<div id="addTagFormContainer"> <div id="addTagFormContainer">
<form id="addTagForm" name="addTagForm" method="get" action="#" onsubmit="return OfficeDocDetails.addTag('${d.id}', this.tag.value);"> <form id="addTagForm" name="addTagForm" onsubmit="return OfficeDocDetails.addTag('${d.id}', this.tag.value);">
<input id="addTagBox" name="tag" type="text"> <input id="addTagBox" name="tag" type="text">
<input class="addTagImage" type="image" src="${url.context}/images/office/action_successful.gif" onclick="return (document.addTagForm.tag.value.length > 0);"> <input class="addTagImage" type="image" src="${url.context}/images/office/action_successful.gif" onclick="return (document.addTagForm.tag.value.length > 0);">
<input class="addTagImage" type="image" src="${url.context}/images/office/action_failed.gif" onclick="return OfficeDocDetails.hideAddTagForm();"> <input class="addTagImage" type="image" src="${url.context}/images/office/action_failed.gif" onclick="return OfficeDocDetails.hideAddTagForm();">
@@ -117,8 +119,8 @@
<#list d.properties["cm:taggable"]?sort_by("name") as tag> <#list d.properties["cm:taggable"]?sort_by("name") as tag>
<#if tag?exists> <#if tag?exists>
<div class="tagListEntry"> <div class="tagListEntry">
<a class="tagDelete" href="#" title="Delete this tag" onclick="OfficeAddin.postAction('${tag_actions}','remove','${d.id}','', '&t=${tag.name}');">[x]</a> <a class="tagListDelete" href="#" title="Remove tag &quot;${tag.name}&quot;" onclick="OfficeDocDetails.removeTag('${d.id}', '${tag.name}');">[x]</a>
<a class="tagName" href="${url.serviceContext}/office/tags?p=${path?url}&amp;e=${extn}&amp;n=${nav}">${tag.name}</a> <a class="tagListName" href="${url.serviceContext}/office/tags?p=${path?url}&amp;e=${extn}&amp;n=${nav}&amp;tag=${tag.name}">${tag.name}</a>
</div> </div>
</#if> </#if>
</#list> </#list>
@@ -169,7 +171,7 @@
The current document is not versioned.<br /> The current document is not versioned.<br />
<br /> <br />
<ul> <ul>
<li><a title="Make Versionable" href="#" onclick="OfficeAddin.getAction('${doc_actions}','makeversion','${d.id}',null,null,'tab=v');"> <li><a title="Make Versionable" href="#" onclick="OfficeAddin.getAction('${doc_actions}','makeversion','${d.id}',null,null,'version=1');">
<img src="${url.context}/images/office/make_versionable.gif" alt="Make Versionable" /> Make Versionable <img src="${url.context}/images/office/make_versionable.gif" alt="Make Versionable" /> Make Versionable
</a></li> </a></li>
</ul> </ul>
@@ -190,7 +192,6 @@
<div class="header">Document Actions</div> <div class="header">Document Actions</div>
<div id="documentActions" class="actionsPanel"> <div id="documentActions" class="actionsPanel">
<div id="nonStatusText">
<ul> <ul>
<#if d.isDocument> <#if d.isDocument>
<#if d.isLocked > <#if d.isLocked >
@@ -244,11 +245,13 @@
</li> </li>
</#if> </#if>
</ul> </ul>
</div>
<div id="statusText"></div>
</div> </div>
<#if args.version?exists>
<script>
window.addEvent("domready", function(){$('tabLinkVersion').fireEvent('click');});
</script>
</#if>
</body> </body>
</html> </html>

View File

@@ -16,7 +16,7 @@
</div> </div>
<#else> <#else>
<#assign totalResults = results?size> <#assign totalResults = results?size>
<#list results as child> <#list results?sort_by(["properties","cm:modified"])?reverse as child>
<#assign resCount=resCount + 1> <#assign resCount=resCount + 1>
<#if child.isDocument> <#if child.isDocument>
<#assign relativePath = (child.displayPath?substring(companyhome.name?length+1) + '/' + child.name)?url?replace('%2F', '/')?replace('\'', '\\\'') /> <#assign relativePath = (child.displayPath?substring(companyhome.name?length+1) + '/' + child.name)?url?replace('%2F', '/')?replace('\'', '\\\'') />

View File

@@ -54,7 +54,7 @@
</script> </script>
<#if (args.tag?exists)> <#if (args.tag?exists)>
<script type="text/javascript"> <script type="text/javascript">
window.addEvent('domready', function(){OfficeTags.selectTag("${args.tag}")}); window.addEvent("domready", function(){OfficeTags.preselectTag("${args.tag}")});
</script> </script>
</#if> </#if>
</body> </body>

View File

@@ -765,12 +765,12 @@ ul.autocompleter-choices li.autocompleter-selected span.autocompleter-queried
padding: 0px 4px; padding: 0px 4px;
} }
.tagDelete { .tagListDelete {
color: #ccc; color: #ccc;
font-size: 11px; font-size: 11px;
} }
.tagName { .tagListName {
} }
/* Tag cloud */ /* Tag cloud */
@@ -786,6 +786,11 @@ ul.autocompleter-choices li.autocompleter-selected span.autocompleter-queried
#tagCloud a { #tagCloud a {
cursor: pointer; cursor: pointer;
padding: 1px;
}
#tagCloud a.tagSelected {
background-color: #ffff90;
} }
#tagCloud .tagName0 { #tagCloud .tagName0 {

View File

@@ -70,38 +70,14 @@ var OfficeDocDetails =
addTag: function(nodeId, tagName) 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; return false;
}, },
tagAction: function(action, nodeId, tagName, msg) removeTag: function(nodeId, tagName)
{ {
if (msg != "" && !confirm(msg)) OfficeAddin.postAction(window.serviceContextPath + "/collaboration/tagActions", "remove", nodeId , null, "t=" + tagName);
{ return false;
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();
} }
}; };

View File

@@ -155,22 +155,22 @@ var OfficeNavigation =
submitCreateSpace: function(commandURL, nodeId) submitCreateSpace: function(commandURL, nodeId)
{ {
var spcName = $('spaceName').value, var spaceName = $('spaceName').value,
spcTitle = $('spaceTitle').value, spaceTitle = $('spaceTitle').value,
spcDescription = $('spaceDescription').value; spaceDescription = $('spaceDescription').value;
var spcTemplate; var spaceTemplate;
if ($('spaceTemplate')) if ($('spaceTemplate'))
{ {
spcTemplate = $('spaceTemplate').value; spaceTemplate = $('spaceTemplate').value;
} }
OfficeAddin.showStatusText("Creating space...", "ajax_anim.gif", false); OfficeAddin.showStatusText("Creating space...", "ajax_anim.gif", false);
var actionURL = commandURL + "?a=newspace&n=" + nodeId; var actionURL = commandURL + "?a=newspace&p=" + nodeId;
actionURL += "&sn=" + encodeURI(spcName); actionURL += "&sn=" + encodeURI(spaceName);
actionURL += "&st=" + encodeURI(spcTitle); actionURL += "&st=" + encodeURI(spaceTitle);
actionURL += "&sd=" + encodeURI(spcDescription); actionURL += "&sd=" + encodeURI(spaceDescription);
actionURL += "&t=" + encodeURI(spcTemplate); actionURL += "&t=" + encodeURI(spaceTemplate);
var myAjax = new Ajax(actionURL, { var myAjax = new Ajax(actionURL, {
method: 'get', method: 'get',
headers: {'If-Modified-Since': 'Sat, 1 Jan 2000 00:00:00 GMT'}, headers: {'If-Modified-Since': 'Sat, 1 Jan 2000 00:00:00 GMT'},

View File

@@ -123,7 +123,7 @@ var OfficeAddin =
// Remove any trailing hash // Remove any trailing hash
var href = window.location.href.replace("#", "") var href = window.location.href.replace("#", "")
// Remove any previous "st" parameters // Remove any previous "st" parameters
href = OfficeAddin.removeParameters(href, "st"); href = OfficeAddin.removeParameters(href, "st|version");
// Optionally add a status string // Optionally add a status string
if (textResponse != "") if (textResponse != "")
{ {

View File

@@ -10,6 +10,9 @@ var OfficeTags =
/* Manadatory params for searchResults component */ /* Manadatory params for searchResults component */
searchParams: "", searchParams: "",
/* Set to preselect a tag after the tag cloud populated */
preselectedTag: "",
init: function() init: function()
{ {
OfficeTags.getTagCloud(); OfficeTags.getTagCloud();
@@ -49,7 +52,11 @@ var OfficeTags =
tagQuery.tags.each(function(tag, i) tagQuery.tags.each(function(tag, i)
{ {
tagNameClass = "tagName" + Math.round((tag.count - tagQuery.countMin) / scale); tagNameClass = "tagName" + Math.round((tag.count - tagQuery.countMin) / scale);
tagName = new Element("a", {"class": tagNameClass}); if (OfficeTags.preselectedTag == tag.name)
{
tagNameClass += " tagSelected";
}
tagName = new Element("a", {"class": tagNameClass, "rel": tag.name});
tagName.appendText(tag.name); tagName.appendText(tag.name);
tagName.injectInside(tagCloud); tagName.injectInside(tagCloud);
tagName.addEvent('click', function(e) tagName.addEvent('click', function(e)
@@ -62,8 +69,6 @@ var OfficeTags =
tagCount.appendText("(" + tag.count + ")"); tagCount.appendText("(" + tag.count + ")");
tagCount.injectInside(tagName); tagCount.injectInside(tagName);
}); });
// $("tagCloud").innerHTML = Json.toString(tagQuery);
}, },
/* AJAX call to perform server-side tag search */ /* AJAX call to perform server-side tag search */
@@ -87,6 +92,25 @@ var OfficeTags =
$('taggedHeader').innerHTML = "Tagged with \"" + tagName + "\""; $('taggedHeader').innerHTML = "Tagged with \"" + tagName + "\"";
} }
}).request(); }).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);
} }
}; };