Office Addin - web scripts updated to support "Create new space"

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5988 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mike Hatfield
2007-06-15 17:05:36 +00:00
parent a557d4abf3
commit 2d878e8273
11 changed files with 409 additions and 124 deletions

View File

@@ -1,17 +1,20 @@
// Client has requested certain actions on the current document
// Client has requested server-side action
/* Inputs */
var docId = args.d,
runAction = args.a;
var runAction = args.a;
/* Outputs */
var resultString = "Action failed.",
var resultString = "Action failed",
resultCode = false;
var doc = search.findNode("workspace://SpacesStore/" + docId);
if (doc != null && doc.isDocument)
// Is this action targetting a document?
var docId = args.d;
if ((docId != "") && (docId != null))
{
var doc = search.findNode("workspace://SpacesStore/" + docId);
if (doc != null && doc.isDocument)
{
try
{
if (runAction == "makepdf")
@@ -76,7 +79,7 @@ if (doc != null && doc.isDocument)
workflow.parameters["bpm:workflowDueDate"] = dueDate;
}
workflow.execute(doc);
resultString = "New workflow started.";
resultString = "New workflow started";
resultCode = true;
}
else if (runAction == "test")
@@ -86,13 +89,71 @@ if (doc != null && doc.isDocument)
}
else
{
resultString = "Unknown action.";
resultString = "Unknown action";
}
}
catch(e)
{
resultString = "Action failed due to exception";
}
}
}
else // Non document-based actions
{
try
{
if (runAction == "newspace")
{
resultString = "Could not create space";
var nodeId = args.n,
spaceName = args.sn,
spaceTitle = (args.st == "undefined") ? "" : args.st,
spaceDescription = (args.sd == "undefined") ? "" : args.sd,
templateId = args.t;
var nodeNew;
if ((spaceName == null) || (spaceName == ""))
{
resultString = "Space must have a Name";
}
else
{
var nodeParent = search.findNode("workspace://SpacesStore/" + nodeId);
// Copy from template?
if ((templateId != null) && (templateId != ""))
{
nodeTemplate = search.findNode("workspace://SpacesStore/" + templateId);
nodeNew = nodeTemplate.copy(nodeParent, true);
nodeNew.name = spaceName;
}
else
{
nodeNew = nodeParent.createFolder(spaceName);
}
// Always add title & description, default icon
nodeNew.properties["cm:title"] = spaceTitle;
nodeNew.properties["cm:description"] = spaceDescription;
nodeNew.properties["app:icon"] = "space-icon-default";
nodeNew.save();
// Add uifacets aspect for the web client
nodeNew.addAspect("app:uifacets");
if (nodeNew != null)
{
resultString = "New space created";
resultCode = true;
}
}
}
else
{
resultString = "Unknown action";
}
}
catch(e)
{
resultString = "Action failed due to exception";
resultString = e.toString();
}
}
model.resultString = resultString;
model.resultCode = resultCode;

View File

@@ -43,10 +43,11 @@
<img src="${url.context}${d.icon32}" alt="${d.name}" />
</td>
<td style="padding-top: 4px;">
<span style="font-weight:bold; vertical-align: top;">${d.name}
<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;" />
</#if>
${d.name}
</span>
<br />
<table style="margin-top: 4px;">

View File

@@ -21,7 +21,6 @@
<script type="text/javascript" src="${url.context}/scripts/ajax/mootools.v1.1.js"></script>
<script type="text/javascript" src="${url.context}/scripts/office/office_addin.js"></script>
<script type="text/javascript" src="${url.context}/scripts/office/my_alfresco.js"></script>
<script type="text/javascript" src="/firebug.js"></script>
</head>
<body>
@@ -38,7 +37,7 @@
<div class="header">My Checked Out Documents<span class="headerExtra"><span class="toggle">&nbsp;</span></span></div>
<div id="checkedoutList" class="containerMedium togglePanel">
<table>
<table width="265">
<#assign rowNum=0>
<#assign query="@cm\\:workingCopyOwner:${person.properties.userName}">
<#list companyhome.childrenByLuceneSearch[query] as child>
@@ -65,6 +64,11 @@
</tr>
</#if>
</#list>
<#if rowNum = 0>
<tr>
<td class="noItems">(No documents)</td>
</tr>
</#if>
</table>
</div>
@@ -101,14 +105,20 @@
</td>
</tr>
</#list>
<#if taskNum = 0>
<tr>
<td class="noItems">(No tasks)</td>
</tr>
</#if>
</table>
</div>
<div class="header">Other Actions</div>
<div class="header">Actions</div>
<div id="documentActions">
<div id="nonStatusText">
<ul>
<#if d.isDocument>
<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" />
@@ -116,19 +126,13 @@
</a>
<br />Allows you to place the current document under Alfresco management.
</li>
</#if>
<li>
<a title="Browse Alfresco" href="${url.serviceContext}/office/navigation?p=${path?url}">
<img src="${url.context}/images/office/navigator.gif" alt="Browse Alfresco" />
Browse Alfresco
<a title="Create Collaboration Space" href="${url.serviceContext}/office/navigation?p=${path?url}&amp;n=${d.id}&amp;cc=true">
<img src="${url.context}/images/office/create_space.gif" alt="Create Collaboration Space" />
Create Collaboration Space
</a>
<br />Navigate around the Alfresco repository for documents.
</li>
<li>
<a title="Search" href="${url.serviceContext}/office/search?p=${path?url}">
<img src="${url.context}/images/office/search.gif" alt="Search" />
Find Documents
</a>
<br />Search Alfresco for documents by name and content.
<br />Create a new Collaboration Space in the Alfresco Repository
</li>
<li>
<a title="Launch Alfresco" href="${url.context}/navigate/browse?ticket=${session.ticket}" rel="_blank">

View File

@@ -71,7 +71,7 @@
</#list>
<#if taskNum = 0>
<tr>
<td>(No tasks)</td>
<td class="noItems">(No tasks)</td>
</tr>
</#if>
</table>

View File

@@ -12,6 +12,7 @@
<script type="text/javascript" src="${url.context}/scripts/ajax/mootools.v1.1.js"></script>
<script type="text/javascript" src="${url.context}/scripts/office/office_addin.js"></script>
<script type="text/javascript" src="${url.context}/scripts/office/navigation.js"></script>
<script type="text/javascript" src="/firebug.js"></script>
</head>
<body>
@@ -53,63 +54,99 @@
<div class="header">Spaces in ${thisSpace.name}<span class="headerExtra"><span class="toggle">&nbsp;</span></span></div>
<div id="spaceList" class="containerMedium togglePanel">
<table width="265">
<div id="createSpaceContainer">
<div id="createSpace" onclick="OfficeNavigation.showCreateSpace();">
<img src="${url.context}/images/office/create_space.gif" alt="Create new space" />
<span style="vertical-align: top;">Create New <#if args.cc?exists>Collaboration </#if>Space...</span>
</div>
<div id="createSpacePanel">
<div id="createSpaceParameters">
<div class="spaceParam">Name:</div>
<div class="spaceValue">
<input id="spaceName" type="text" value="" />
</div>
<div class="spaceParam">Title:</div>
<div class="spaceValue">
<input id="spacetitle" type="text" value="" />
</div>
<div class="spaceParam">Description:</div>
<div class="spaceValue">
<input id="spaceDescription" type="text" value="" />
</div>
<#assign xpath="app:dictionary/app:space_templates/*">
<#assign templates = companyhome.childrenByXPath[xpath]>
<#if (templates?size > 0)>
<div class="spaceParam">Template:</div>
<div class="spaceValue">
<select id="spaceTemplate" style="width: 172px;">
<option selected="selected" value="">(None)</option>
<#list templates as template>
<option value="${template.id}">${template.name}</option>
</#list>
</select>
</div>
</#if>
<div class="spaceParam">&nbsp;</div>
<div class="spaceValue">
<a class="spaceAction" href="#" onclick="OfficeNavigation.submitCreateSpace('${url.serviceContext}/office/docActions', '${thisSpace.id}');">
Submit
</a>
<a class="spaceAction" href="#" onclick="OfficeNavigation.hideCreateSpace();">
Cancel
</a>
</div>
</div>
</div>
</div>
<#assign spacesFound = 0>
<#list thisSpace.children as child>
<#if child.isContainer>
<#assign spacesFound = spacesFound + 1>
<tr class="${(spacesFound % 2 = 0)?string("odd", "even")}">
<td style="width: 32px;">
<div class="spaceItem ${(spacesFound % 2 = 0)?string("even", "odd")}">
<span style="float: left; width: 36px;">
<a href="${url.serviceContext}/office/navigation?p=${path?url}&amp;n=${child.id}"><img src="${url.context}${child.icon32}" alt="Open ${child.name}" /></a>
</td>
<td>
</span>
<span>
<a href="${url.serviceContext}/office/navigation?p=${path?url}&amp;n=${child.id}" title="Open ${child.name}">
<span class="bold">${child.name}</span>
</a>
<#if child.properties.description?exists>
<br/>${child.properties.description}
</#if>
</td>
</tr>
</span>
</div>
</#if>
</#list>
<#if spacesFound = 0>
<tr>
<td>(No subspaces)</td>
</tr>
<div class="noItems">(No subspaces)</div>
</#if>
</table>
</div>
<div class="header">Documents in ${thisSpace.name}<span class="headerExtra"><span class="toggle">&nbsp;</span></span></div>
<div id="documentList" class="containerMedium togglePanel">
<table width="265">
<#assign documentsFound = 0>
<#list thisSpace.children as child>
<#if child.isDocument>
<#assign documentsFound = documentsFound + 1>
<#assign webdavPath = (child.displayPath?substring(13) + '/' + child.name)?url('ISO-8859-1')?replace('%2F', '/')?replace('\'', '\\\'') />
<tr class="${(documentsFound % 2 = 0)?string("odd", "even")}">
<td valign="top" style="width: 32px;">
<div class="documentItem ${(documentsFound % 2 = 0)?string("even", "odd")}">
<span style="float: left; width: 36px;">
<#if child.name?ends_with(".doc")>
<a href="#" onclick="window.external.openDocument('${webdavPath}')"><img src="${url.context}${child.icon32}" alt="Open ${child.name}" /></a>
<#else>
<a href="${url.context}${child.url}?ticket=${session.ticket}" rel="_blank"><img src="${url.context}${child.icon32}" alt="Open ${child.name}" /></a>
</#if>
</td>
<td>
</span>
<span>
<#if child.name?ends_with(".doc")>
<a href="#" onclick="window.external.openDocument('${webdavPath}')" title="Open ${child.name}">
<span class="bold">${child.name}</span>
</a><br/>
<a href="#" onclick="window.external.openDocument('${webdavPath}')"><span class="bold">${child.name}</span></a>
<#else>
<a href="${url.context}${child.url}?ticket=${session.ticket}" rel="_blank" title="Open ${child.name}">
<span class="bold">${child.name}</span>
</a><br/>
<a href="${url.context}${child.url}?ticket=${session.ticket}" rel="_blank"><span class="bold">${child.name}</span></a>
</#if>
<br />
<#if child.properties.description?exists>
${child.properties.description}<br/>
${child.properties.description}<br />
</#if>
Modified: ${child.properties.modified?datetime}, Size: ${(child.size / 1024)?int}Kb<br/>
<#if child.isLocked >
@@ -123,25 +160,23 @@
<#if !child.isLocked >
<a href="#" onclick="OfficeAddin.runAction('${doc_actions}','delete','${child.id}', 'Are you sure you want to delete this document?');"><img src="${url.context}/images/office/delete.gif" style="padding:3px 6px 2px 0px;" alt="Delete..." title="Delete" /></a>
</#if>
</td>
</tr>
</span>
</div>
</#if>
</#list>
<#if documentsFound = 0>
<tr>
<td>(No documents)</td>
</tr>
<div class="noItems">(No documents)</div>
</#if>
</table>
</div>
<div class="header">Document Actions</div>
<div class="header">Actions</div>
<#assign currentPath = thisSpace.displayPath + '/' + thisSpace.name />
<#assign webdavPath = currentPath?substring(13)?url('ISO-8859-1')?replace('%2F', '/')?replace('\'', '\\\'') />
<div id="documentActionsNavigation">
<div id="nonStatusText">
<ul>
<#if node.isDocument>
<li>
<a href="#" onclick="window.external.saveToAlfresco('${webdavPath}')">
<img src="${url.context}/images/office/save_to_alfresco.gif" alt="Save to Alfresco" />
@@ -149,7 +184,8 @@
</a>
<br />Allows you to place the current document under Alfresco management.
</li>
<#if args.search?exists>
</#if>
<#if args.search?exists>
<li>
<a href="${url.serviceContext}/office/search?p=${path?url}&amp;searchagain=${args.search?url}&amp;maxresults=${args.maxresults}">
<img src="${url.context}/images/office/search_again.gif" alt="Back to results" />
@@ -157,7 +193,7 @@
</a>
<br />Return to the search tab.
</li>
</#if>
</#if>
</ul>
</div>

View File

@@ -48,6 +48,7 @@ input.button {
.bold {
font-weight: bold;
overflow-x: hidden;
}
#tabBar {
@@ -186,6 +187,14 @@ input.button {
.even {
background-color: #ffffff !important;
}
.new {
background-color: #ffffcc !important;
cursor: pointer;
}
.noItems {
text-align: center;
padding-top: 20px;
}
#currentSpaceInfo {
background: #fff;
@@ -199,6 +208,77 @@ input.button {
padding: 2px 0px 2px 2px;
}
#createSpaceContainer {
border-bottom: 1px dashed #ccc;
overflow: hidden;
padding: 2px 2px 0px;
width: 261px;
}
#createSpace {
cursor: pointer;
}
#createSpacePanel {
display: none;
overflow: hidden;
}
#createSpaceParameters {
background-color: #ffffcc;
border: 1px solid #ccc;
margin: 2px;
padding: 2px 0px 4px 0px;
overflow: hidden;
}
.spaceParam {
clear: both;
float: left;
padding: 4px 4px 0px 0px;
text-align: right;
width: 64px;
}
.spaceValue {
float: left;
padding: 2px 0px 0px 0px;
width: 180px;
}
.spaceValue select, .spaceValue input, .spaceValue textarea {
font-family: tahoma, sans-serif;
font-size: 8pt;
margin: 0px 1px 1px 1px;
padding: 0px 0px 0px 0px;
width: 168px;
}
.spaceAction {
background-color: #cce6ff;
border: 1px solid #0073e6;
color: #0073e6;
float: left;
font-size: 11px;
font-weight: bold;
cursor: pointer;
margin: 0px 4px 0px 2px;
padding: 4px;
filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#ffffff', EndColorStr='#cce6ff');
}
.spaceItem {
border-bottom: 1px solid #eee;
padding: 2px 0px 6px 0px;
height: 26px;
width: 265px;
}
.documentItem {
border-bottom: 1px solid #eee;
padding: 2px 0px 6px 0px;
width: 265px;
}
#documentActions {
clear: both;
background-color: #ffffcc;

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -46,7 +46,7 @@ var OfficeMyAlfresco =
// register 'click' event for each task
task.addEvent('click', function(e)
{
window.location.href = window.serviceContextPath + "/office/myTasks?p=" + window.queryObject.p + "&t=" + task.id.replace(/\./, "$");
window.location.href = window.serviceContextPath + "/office/myTasks?p=" + window.queryObject.p + "&t=" + task.id;
});
});

View File

@@ -179,10 +179,8 @@ var OfficeMyTasks =
myAjax.request();
},
startWorkflow: function(useTemplate, Doc)
startWorkflow: function(commandURL, Doc)
{
// OfficeAddin.runAction('${doc_actions}','makepdf','${d.id}', '');"
var wrkType=$('wrkType').value;
// wrkAssignTo should be "First Last (Username)"
var wrkAssignTo=$('wrkAssignTo').value;
@@ -195,7 +193,7 @@ var OfficeMyTasks =
var wrkDescription=$('wrkDescription').value;
OfficeAddin.showStatusText("Starting workflow...", "ajax_anim.gif", false);
var actionURL = useTemplate + "?a=workflow&d=" + Doc;
var actionURL = commandURL + "?a=workflow&d=" + Doc;
actionURL += "&wt=" + wrkType;
actionURL += "&at=" + wrkAssignTo;
// Date supplied?

View File

@@ -6,10 +6,20 @@ var OfficeNavigation =
{
TOGGLE_AMOUNT: 150,
ANIM_LENGTH: 800,
CREATE_SPACE_HEIGHT: 108,
CREATE_SPACE_TEMPLATE: 16,
init: function()
{
OfficeNavigation.setupToggles();
OfficeNavigation.setupCreateSpace();
// Did we arrive here from the "Create collaboration space" shortcut?
if (window.queryObject.cc)
{
OfficeNavigation.showCreateSpace();
}
},
setupToggles: function()
@@ -83,6 +93,101 @@ var OfficeNavigation =
fxPanel.start(animPanel);
});
});
},
setupCreateSpace: function()
{
var panel = $('createSpacePanel');
panel.defaultHeight = 0;
panel.setStyle('display', 'block');
panel.setStyle('height', panel.defaultHeight);
},
showCreateSpace: function()
{
var panel = $('createSpacePanel');
// Animation
var fxPanel = new Fx.Style(panel, 'height',
{
duration: OfficeNavigation.ANIM_LENGTH,
transition: Fx.Transitions.Back.easeOut,
onComplete: function()
{
$('spaceName').focus();
}
});
if (!panel.isOpen)
{
panel.isOpen = true;
var openHeight = OfficeNavigation.CREATE_SPACE_HEIGHT;
if ($('spaceTemplate'))
{
openHeight += OfficeNavigation.CREATE_SPACE_TEMPLATE;
}
fxPanel.start(panel.getStyle('height').toInt(), openHeight);
}
else
{
OfficeNavigation.hideCreateSpace();
}
},
hideCreateSpace: function()
{
var panel = $('createSpacePanel');
// Animation
var fxPanel = new Fx.Style(panel, 'height',
{
duration: OfficeNavigation.ANIM_LENGTH,
transition: Fx.Transitions.Back.easeIn,
onComplete: function()
{
panel.isOpen = false;
}
});
fxPanel.start(panel.getStyle('height').toInt(), panel.defaultHeight);
},
submitCreateSpace: function(commandURL, nodeId)
{
var spcName = $('spaceName').value,
spcTitle = $('spaceTitle').value,
spcDescription = $('spaceDescription').value;
var spcTemplate;
if ($('spaceTemplate'))
{
spcTemplate = $('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 myAjax = new Ajax(actionURL, {
method: 'get',
headers: {'If-Modified-Since': 'Sat, 1 Jan 2000 00:00:00 GMT'},
onComplete: function(textResponse, xmlResponse)
{
// Remove any trailing hash
var href = window.location.href.replace("#", "")
// Remove any previous "&st=" strings
href = href.replace(/[?&]st=([^&$]+)/g, "");
// Remove any previous "&cc=" strings
href = href.replace(/[?&]cc=([^&$]+)/g, "");
// Optionally add a status string
if (textResponse != "")
{
href += "&st=" + encodeURI(textResponse);
}
window.location.href = href;
}
});
myAjax.request();
}
};