Fix for ETHREEOH-8.

Fix to client-side js error when clicking on a calendar event (recent YUI changes?)
Fix to issue where user calendar webscript was supressing remote errors then trying to interpret an HTML error page result as JSON.
Code and performance improvements to repo-side calendar web-scripts.
Code improvements and cleanup to repo-side sites webscripts.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@11941 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2008-11-17 13:16:53 +00:00
parent dde3f451b6
commit e53443521a
4 changed files with 99 additions and 118 deletions

View File

@@ -21,11 +21,10 @@ function main()
{ {
var size = parseInt(sizeString); var size = parseInt(sizeString);
if (size != NaN && size < sites.length) if (size < sites.length)
{ {
// TODO this is a tempory implementaion to support preview client
// Only return the first n sites based on the passed page size // Only return the first n sites based on the passed page size
var pagedSites = Array(); var pagedSites = new Array(size);
for (var index = 0; index < size; index++) for (var index = 0; index < size; index++)
{ {
pagedSites[index] = sites[index]; pagedSites[index] = sites[index];
@@ -35,7 +34,6 @@ function main()
} }
} }
// Pass the queried sites to the template
model.sites = sites; model.sites = sites;
} }

View File

@@ -12,11 +12,10 @@ function main()
{ {
var size = parseInt(sizeString); var size = parseInt(sizeString);
if (size != NaN && size < sites.length) if (size < sites.length)
{ {
// TODO this is a tempory implementaion to support preview client
// Only return the first n sites based on the passed page size // Only return the first n sites based on the passed page size
var pagedSites = Array(); var pagedSites = new Array(size);
for (var index = 0; index < size; index++) for (var index = 0; index < size; index++)
{ {
pagedSites[index] = sites[index]; pagedSites[index] = sites[index];
@@ -26,7 +25,6 @@ function main()
} }
} }
// Add the sites to the model
model.sites = sites; model.sites = sites;
} }

View File

@@ -18,31 +18,17 @@ model.events = getUserEvents(username, range);
function getUserEvents(user, range) function getUserEvents(user, range)
{ {
if (!user)
{
return [];
}
var paths = []; var paths = [];
/**
* This part is inefficient as it looks through all of the sites var sites = siteService.listUserSites(user);
* and tries to determine if the user is a member or not; however, until something like for (var j=0; j < sites.length; j++)
* /people/{userid}/sites is exposed through the JavaScript API, it will have to do.
*
*/
var availableSites = siteService.listSites(null, null);
for (var j=0; j < availableSites.length; j++)
{ {
var site = availableSites[j]; paths.push("PATH:\"/app:company_home/st:sites/cm:" + search.ISO9075Encode(sites[j].shortName) + "/cm:calendar/*\"");
if (site.isMember(user))
{
paths.push("PATH:\"/app:company_home/st:sites/cm:" + search.ISO9075Encode(site.shortName) + "/cm:calendar/*\"");
}
} }
var results = []; var results = [];
if (paths.length > 0) if (paths.length != 0)
{ {
var luceneQuery = "+(" + paths.join(" OR ") + ") +TYPE:\"{http\://www.alfresco.org/model/calendar}calendarEvent\""; var luceneQuery = "+(" + paths.join(" OR ") + ") +TYPE:\"{http\://www.alfresco.org/model/calendar}calendarEvent\"";
if (range.fromdate) if (range.fromdate)
@@ -57,4 +43,3 @@ function getUserEvents(user, range)
return results; return results;
} }