Files
alfresco-community-repo/source/web/scripts/office/my_tasks.js
Kevin Roast 189422edce Merged V3.2E to HEAD
17495: Changed xforms-samples name to wcm-sample
   17496: Minor fixes for day and week views when rendering new events
   17497: *RECORD ONLY* Added Enterprise logo local copy.
   17498: ETHREEOH-2933 - User can see contents of the moderated site if user is not a member of the site
          - Site containers are now private and non member's can't see content.
          - fix only applies to new moderated sites.
   17499: ETHREEOH-2322 - Office Plugin: filename overlaps the plugin UI if longer than 40 characters without spaces
   17500: Temorary build fix for site visibility
   17508: ETHREEOH-1268 - Pages and Components show varying degrees of success handling "site not found" errors.
   17509: Fix for ETHREEOH1733 - Wrong display of multi day events in Share
   17514: View In Browser action for document list and document details actions.
   17515: Merged DEV-TEMPORARY to V3.2
      17471: ETHREEOH-3193: 'capitalize' in output path pattern works differently for templates (vs. XSDs)
   17516: Missing css file from Edit Offline changes. Also "Checked out on/by" text changed to "Editing started on/by". Tags now comma separated
   17517: Merged DEV-TEMPORARY to V3.2
      17474: ETHREEOH-1211: Can't See Images in TinyMCE
   17518: Office add-in: ETHREEOH-3361 - Workflow name is visible only before symbol &, ETHREEOH-2735 - Total number of founded items is not shown
   17519: 3.2E help links
   17520: 3.2E help links, plus ETHREEOH-1536 - Incorrect "insert into current document" function work for unsupported files in MS Office Addin
   17522: Fix for ETHREEOH-3257 - Event becomes All day again after editing it to not All day
   17526: Fix for unreported issue when rendering an edited event after the view is filtered via tag component causes an script error
   17528: Fixed ETHREEOH-3364 " Admin Console - Group Search needs to show searching message and disable further requests while search is running"
          - Disabling search button & message displaying "Searching..." after 2 seconds for long searches for the following components:
             * Admin Console: Users - search user, add group
             * Admin Console: Groups - search group, add group, add user
             * Site: Members: People - search members, add people
             * Site: Members: Groups - search membergroups, add group
             * Site: Members: Pending invites - search invites
             * Site: Doclib: Assign Workflow - add users
             * People Finder 
             * Site Finder
          - All component listed above uses max search result except the following where webscript services lacks support for it:
             * Admin Console: Users - add group
             * Admin Console: Groups - search group, add group
             * Site: Members: Pending invites - search invites
          - Bugfix: When minSearchTermLength is set to 0:
             * Group Admin Console: switched to browse view
             * User Admin Console: didnt do a search
          - Bugfix: For some components minSearchTermLength & maxSearchResults were brought in as strings causing the global search's max result to be 1001 instead of 101

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@18126 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2010-01-19 11:50:05 +00:00

295 lines
8.9 KiB
JavaScript

/*
* Prerequisites: mootools.v1.11.js
* autocompleter.js
* office_addin.js
*/
var OfficeMyTasks =
{
MAX_DESCRIPTION: 100,
init: function()
{
OfficeAddin.sortTasks($('taskList'));
OfficeMyTasks.setupEventHandlers();
if (window.queryObject.t)
{
OfficeMyTasks.openTask(window.queryObject.t);
}
if ($('wrkAssignTo'))
{
var autoAssignTo = new Autocompleter.Ajax.Json($('wrkAssignTo'), window.serviceContextPath + '/office/getUsers',
{
postVar: 's',
minLength: 2,
useSelection: false,
markQuery: false,
ajaxOptions:
{
method: 'get',
headers: {'If-Modified-Since': 'Sat, 1 Jan 2000 00:00:00 GMT'}
},
onRequest: function(el)
{
$('ajxAssignTo').setStyle('display', '');
},
onComplete: function(el)
{
$('ajxAssignTo').setStyle('display', 'none');
}
});
}
if ($('wrkDueDate'))
{
var dueDate = new DatePicker($('wrkDueDate'),
{
readOnly: false,
dateFormat: "dd MMMM yyyy"
});
}
if ($('wrkDescription'))
{
var desc = $('wrkDescription');
desc.onkeyup = desc.onchange = desc.onblur = function(event)
{
if (this.value.length > OfficeMyTasks.MAX_DESCRIPTION)
{
this.setProperty('value', this.getProperty('value').substr(0, OfficeMyTasks.MAX_DESCRIPTION));
}
};
}
},
setupEventHandlers: function()
{
var tasks = $$('#taskList .taskItem');
tasks.each(function(task, i)
{
task.isOpen = false;
// register 'mouseenter' event for each task
task.addEvent('mouseenter', function(e)
{
if (task.isOpen)
{
return;
}
// highlight the item title
task.addClass('taskItemSelected');
// reset styles on all closed tasks
tasks.each(function(otherTask, j)
{
if ((otherTask != task) && (!otherTask.isOpen))
{
// reset selected class
otherTask.removeClass('taskItemSelected');
}
});
});
// register 'mouseleave' event for each task
task.addEvent('mouseleave', function(e)
{
if (task.isOpen)
{
return;
}
// unhighlight the item title
task.removeClass('taskItemSelected');
});
// register 'click' event for each task
task.addEvent('click', function(e)
{
if (!task.isOpen)
{
// open up this task
// flag this task as open
task.isOpen = true;
// highlight the item title
task.addClass('taskItemSelected');
if (!window.queryObject.st)
{
OfficeAddin.showStatusText("Loading task...", "ajax_anim.gif", false);
}
// ajax call to load task details
var actionURL = window.serviceContextPath + "/office/myTasksDetail" + OfficeAddin.defaultQuery + "&t=" + task.id.replace(/\./, "$");
var myAjax = new Ajax(actionURL,
{
method: 'get',
headers: {'If-Modified-Since': 'Sat, 1 Jan 2000 00:00:00 GMT'},
onComplete: function(textResponse, xmlResponse)
{
if (!window.queryObject.st)
{
OfficeAddin.hideStatusText();
}
$("taskDetails").innerHTML = textResponse;
}
}).request();
// close other open tasks
tasks.each(function(otherTask, j)
{
if (otherTask != task)
{
// close any other open tasks
otherTask.isOpen = false;
// unhighlight the item title
otherTask.removeClass('taskItemSelected');
}
});
}
});
});
$('taskList').addEvent('mouseleave', function(e)
{
// handler for mouse leaving the entire task list
tasks.each(function(task, i)
{
if (!task.isOpen)
{
task.removeClass('taskItemSelected');
}
});
});
},
openTask: function(taskId)
{
if ($(taskId))
{
$(taskId).fireEvent("click");
}
},
transitionTask: function(taskId, commandURL, successMessage)
{
OfficeAddin.showStatusText("Running workflow...", "ajax_anim.gif", false);
// ajax call to run workflow
var myAjax = new Ajax(commandURL,
{
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 "st" and "w" parameters
href = OfficeAddin.removeParameters(href, "st|w");
// Optionally add a status string
if (successMessage !== "")
{
var json = "{\"statusString\":\"" + successMessage + "\",\"statusCode\":true}";
href += (href.indexOf("?") == -1) ? "?" : "&";
href += "st=" + encodeURIComponent(json);
}
window.location.href = href;
},
onFailure: function()
{
OfficeAddin.showStatusText("Couldn't run workflow", "action_failed.gif", true);
}
}).request();
},
startWorkflow: function(commandURL, Doc)
{
var wrkType = $('wrkType').value,
wrkAssignTo = $('wrkAssignTo').value,
wrkDueDate = $('wrkDueDate').value,
wrkDescription=$('wrkDescription').value;
if (wrkAssignTo.test(/(?:\(([^\)]+)\))/))
{
// Extract the Username - should be "First Last (Username)"
wrkAssignTo = wrkAssignTo.match(/(?:\(([^\)]+)\))/)[1];
}
if (wrkAssignTo === "")
{
OfficeAddin.showStatusText("Assign to cannot be empty", "info.gif", true);
return;
}
OfficeAddin.showStatusText("Starting workflow...", "ajax_anim.gif", false);
var actionURL = commandURL + "?a=workflow&n=" + encodeURIComponent(Doc);
actionURL += "&wt=" + encodeURIComponent(wrkType);
actionURL += "&at=" + encodeURIComponent(wrkAssignTo);
// Date supplied?
if (wrkDueDate !== "")
{
actionURL += "&dd=" + encodeURIComponent(wrkDueDate);
}
actionURL += "&desc=" + encodeURIComponent(wrkDescription);
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", "w" or "wd" parameters
href = OfficeAddin.removeParameters(href, "st|w|wd");
// Optionally add a status string
if (textResponse !== "")
{
href += (href.indexOf("?") == -1) ? "?" : "&";
href += "st=" + encodeURIComponent(textResponse);
}
window.location.href = href;
}
});
myAjax.request();
},
/* AJAX call to perform server-side actions */
runTaskAction: function(useTemplate, action, nodeId, confirmMsg)
{
// Re-select a selected task after reload
var taskSel = $E('#taskList .taskItemSelected'),
outParams = null;
if (taskSel !== null)
{
var taskId = taskSel.id;
outParams = "t=" + encodeURIComponent(taskId);
}
return OfficeAddin.getAction(useTemplate, action, nodeId, confirmMsg, null, outParams);
},
refreshPage: function()
{
// Remove any trailing hash
var href = window.location.href.replace("#", "");
// Remove any previous "st", "w", "wd" or "t" parameters
href = OfficeAddin.removeParameters(href, "st|w|wd|t");
// Re-select a selected task after reload
var taskSel = $E('#taskList .taskItemSelected');
if (taskSel !== null)
{
var taskId = taskSel.id;
href += (href.indexOf("?") == -1) ? "?" : "&";
href += "t=" + encodeURIComponent(taskId);
}
window.location.href = href;
}
};
window.addEvent('domready', OfficeMyTasks.init);