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;
// 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 != ""))
{

View File

@@ -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>
<#if args.e?exists><#assign extn=args.e><#else><#assign extn="doc"></#if><#assign extnx=extn+"x">
@@ -38,62 +37,65 @@
<div class="header">Current Document Details</div>
<div class="containerMedium">
<table width="265">
<tbody>
<tr>
<td valign="top">
<div id="nonStatusText">
<table width="265">
<tbody>
<tr>
<td valign="top">
<#if d.isDocument>
<img src="${url.context}${d.icon32}" alt="${d.name}" />
</td>
<td style="padding-top: 4px;">
<span style="font-weight:bold; vertical-align: top;">
<img src="${url.context}${d.icon32}" alt="${d.name}" />
</td>
<td style="padding-top: 4px;">
<span style="font-weight:bold; vertical-align: top;">
<#if d.isLocked >
<img src="${url.context}/images/office/lock.gif" alt="Locked" title="Locked" style="margin: -2px 0px;" />
<img src="${url.context}/images/office/lock.gif" alt="Locked" title="Locked" style="margin: -2px 0px;" />
</#if>
${d.name}
</span>
<br />
<table style="margin-top: 4px;">
${d.name}
</span>
<br />
<table style="margin-top: 4px;">
<#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>
<tr><td>Title:</td><td>&nbsp;</td></tr>
<tr><td valign="top">Title:</td><td>&nbsp;</td></tr>
</#if>
<#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>
<tr><td valign="top">Description:</td><td>&nbsp;</td></tr>
<tr><td valign="top">Description:</td><td>&nbsp;</td></tr>
</#if>
<tr><td>Creator:</td><td>${d.properties.creator}</td></tr>
<tr><td>Created:</td><td>${d.properties.created?datetime}</td></tr>
<tr><td>Modifier:</td><td>${d.properties.modifier}</td></tr>
<tr><td>Modified:</td><td>${d.properties.modified?datetime}</td></tr>
<tr><td>Size:</td><td>${d.size / 1024} Kb</td></tr>
<tr><td valign="top">Categories:</td>
<td>
<tr><td>Creator:</td><td>${d.properties.creator}</td></tr>
<tr><td>Created:</td><td>${d.properties.created?datetime}</td></tr>
<tr><td>Modifier:</td><td>${d.properties.modifier}</td></tr>
<tr><td>Modified:</td><td>${d.properties.modified?datetime}</td></tr>
<tr><td>Size:</td><td>${d.size / 1024} Kb</td></tr>
<tr><td valign="top">Categories:</td>
<td>
<#if d.properties.categories?exists>
<#list d.properties.categories as category>
${companyhome.nodeByReference[category].name};
${companyhome.nodeByReference[category].name};
</#list>
<#else>
None.
None.
</#if>
</td>
</tr>
</table>
</td>
</tr>
</table>
<#else>
The current document is not managed by Alfresco.
The current document is not managed by Alfresco.
</#if>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
<div id="statusText"></div>
</div>
<div class="tabBarInline">
<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><a title="Version History" href="#"><span><img src="${url.context}/images/office/version.gif" alt="Version History")}" /></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 id="tabLinkVersion" title="Version History" href="#"><span><img src="${url.context}/images/office/version.gif" alt="Version History")}" /></span></a></li>
</ul>
</div>
@@ -106,7 +108,7 @@
<a href="#" onclick="OfficeDocDetails.showAddTagForm(); return false;">Add a tag</a>
</div>
<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 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();">
@@ -117,8 +119,8 @@
<#list d.properties["cm:taggable"]?sort_by("name") as tag>
<#if tag?exists>
<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="tagName" href="${url.serviceContext}/office/tags?p=${path?url}&amp;e=${extn}&amp;n=${nav}">${tag.name}</a>
<a class="tagListDelete" href="#" title="Remove tag &quot;${tag.name}&quot;" onclick="OfficeDocDetails.removeTag('${d.id}', '${tag.name}');">[x]</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>
</#if>
</#list>
@@ -169,7 +171,7 @@
The current document is not versioned.<br />
<br />
<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
</a></li>
</ul>
@@ -190,65 +192,66 @@
<div class="header">Document Actions</div>
<div id="documentActions" class="actionsPanel">
<div id="nonStatusText">
<ul>
<ul>
<#if d.isDocument>
<#if d.isLocked >
<#elseif d.hasAspect("cm:workingcopy")>
<li>
<a href="#" onclick="OfficeAddin.getAction('${doc_actions}','checkin','${d.id}');">
<img src="${url.context}/images/office/checkin.gif" alt="Check In">
Check In
</a>
<br />Check in the current document.
</li>
<li>
<a href="#" onclick="OfficeAddin.getAction('${doc_actions}','checkin','${d.id}');">
<img src="${url.context}/images/office/checkin.gif" alt="Check In">
Check In
</a>
<br />Check in the current document.
</li>
<#else>
<li>
<a href="#" onclick="OfficeAddin.getAction('${doc_actions}','checkout','${d.id}');">
<img src="${url.context}/images/office/checkout.gif" alt="Check Out">
Check Out
</a>
<br />Check out the current document to a working copy.
</li>
<li>
<a href="#" onclick="OfficeAddin.getAction('${doc_actions}','checkout','${d.id}');">
<img src="${url.context}/images/office/checkout.gif" alt="Check Out">
Check Out
</a>
<br />Check out the current document to a working copy.
</li>
</#if>
<li>
<a href="${url.serviceContext}/office/myTasks?p=${path?url}&amp;w=new">
<img src="${url.context}/images/office/new_workflow.gif" alt="Start Workflow" />
Start Workflow
</a>
<br />Start Advanced Workflow for the current document.
</li>
<li>
<a href="${url.serviceContext}/office/myTasks?p=${path?url}&amp;w=new">
<img src="${url.context}/images/office/new_workflow.gif" alt="Start Workflow" />
Start Workflow
</a>
<br />Start Advanced Workflow for the current document.
</li>
<#if d.name?ends_with(extn) || d.name?ends_with(extnx)>
<li>
<a href="#" onclick="OfficeAddin.getAction('${doc_actions}','makepdf','${d.id}');">
<img src="${url.context}/images/office/makepdf.gif" alt="Transform to PDF" />
Transform to PDF
</a>
<br />Transform the current document to Adobe PDF format.
</li>
<li>
<a href="#" onclick="OfficeAddin.getAction('${doc_actions}','makepdf','${d.id}');">
<img src="${url.context}/images/office/makepdf.gif" alt="Transform to PDF" />
Transform to PDF
</a>
<br />Transform the current document to Adobe PDF format.
</li>
</#if>
<li>
<a href="${url.context}/navigate/showDocDetails/workspace/SpacesStore/${d.id}?ticket=${session.ticket}" rel="_blank">
<img src="${url.context}/images/office/document_details.gif" alt="Open Full Details" />
Open Full Details
</a>
<br />Open the document details in the Alfresco Web Client.
</li>
<li>
<a href="${url.context}/navigate/showDocDetails/workspace/SpacesStore/${d.id}?ticket=${session.ticket}" rel="_blank">
<img src="${url.context}/images/office/document_details.gif" alt="Open Full Details" />
Open Full Details
</a>
<br />Open the document details in the Alfresco Web Client.
</li>
<#else>
<li>
<a title="Save to Alfresco" href="${url.serviceContext}/office/navigation?p=${path?url}">
<img src="${url.context}/images/office/save_to_alfresco.gif" alt="Save to Alfresco" />
Save to Alfresco
</a>
<br />Allows you to place the current document under Alfresco management.
</li>
<li>
<a title="Save to Alfresco" href="${url.serviceContext}/office/navigation?p=${path?url}">
<img src="${url.context}/images/office/save_to_alfresco.gif" alt="Save to Alfresco" />
Save to Alfresco
</a>
<br />Allows you to place the current document under Alfresco management.
</li>
</#if>
</ul>
</div>
<div id="statusText"></div>
</ul>
</div>
<#if args.version?exists>
<script>
window.addEvent("domready", function(){$('tabLinkVersion').fireEvent('click');});
</script>
</#if>
</body>
</html>

View File

@@ -16,7 +16,7 @@
</div>
<#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('\'', '\\\'') />

View File

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

View File

@@ -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 {

View File

@@ -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;
}
};

View File

@@ -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'},

View File

@@ -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 != "")
{

View File

@@ -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);
}
};