Files
alfresco-community-repo/source/web/scripts/ajax/mytasks.js
Dave Ward 36ed2b0785 Merged V4.0-BUG-FIX to HEAD
36152: ALF-13904: Can we code round the malformed Lock-Token reported in OOo/LibreOffice in ALF-7916
   36169: ALF-8755: After renaming content / space by Contributor via WebDAV new items are created
   36174: Reversed revisions 35090 and 35107. Reinstating Kofax in service packs for now until universal build is ready.
   36191: Fixed inconsistencies in the application of index control aspect and guessMimetype in ADMRemoteStore and AVMToADMRemoteStorePath since hidden aspect additions.
   Tested with large site migration.
   36193: Pull out the Thread-local HttpClient creation from RemoteClient, and expose. Will go back into Surf at some point
   36194: Convert to using the ThreadLocal HttpClient instances, and some extra steps to ensure we always tidy up after ourselves now the instance is shared
   36196: ALF-13915: Inline edit is possible on someone else's working copy in Share - possible data loss with no warning
   - Fix by MF
   36197: Chinese: First files translated into Chinese
   36202: ALF-13483: Japanese: Incorrect date handle in a date Input filed
   - Reviewed by DWe
   36203: ALF-11463: Corrected localized email template naming format
   - Fix by Pavel, reviewed by DWe
   36204: Fixes: ALF-13777, adjusts the sort order so that the calendar entries are displayed in a consistent order
   36223: Remove old module code from core
     * removed DOD module code (now found in separate RM archive)
     * removed proff of concept RM module (long since deprecated)
     * removed blog integration module (migrated into the core product many moons past)
     * updated build scripts, removing all DOD module related tasks and properties
   36226: ALF-5285: Workflow: Setting default value to data type <default>0</default>, value is not retained.
   - Customer bug from 2008! Reviewed by Frederik
   36228: ALF-12742: Fix Websphere classpath to allow OpenCMIS to work!
   - Changes researched by Dmitry
   - ALF-14023 logged for doc impact
   36235: More for ALF-13723 SOLR does not include the same query unit tests as lucene
   - first half of embedded CMIS tests
   36236: Fixes: ALF-13777. Fix tweaked for aesthetics.
   36245: ALF-13244 SOLR Multi-threaded tracking is required for performance - simultaneous document transformations
   - multi-threaded tracking is now the default
   36248: Fixed ALF-13705 "Could not load properties"/InvalidQNameException while trying to open/edit rule in Share
   36255: ALF-13088: Upgrade to OpenCMIS 0.7.0 to solve Alfresco CMIS extension issues
   36256: ALF-13088: Fix compilation error
   36259: ALF-13933 Alfresco needs to be able to support LibreOffice for transformations
      << Developed on Windows 7. Might need more work on Linux to get LibreOffice to shut down, but should be
         okay with OpenOffice 3.2 which was used in the previous release. >> 
      - Updated jodconverter to latest version jodconverter-core-3.0-SNAPSHOT-patched.jar 28/4/2012 which is newer
        than 3.0 beta-4
      - Applied patch for http://code.google.com/p/jodconverter/issues/detail?id=103 to handle setting the env
        for LibreOffice 3.5
      - Modified code to use partial GNU style options (not used for -env!) when using LibreOffice
      - Added OpenOfficeCommandLine to dynamically supply OpenOffice or LibreOffice command line args for OOoDirect
      - Tested to work with OpenOffice 3.4 and 3.2 on Windows 7
   36263: Merged V4.0 to V4.0-BUG-FIX
      36247: ALF-11027: temporarily remove import of maven.xml, since it makes ant calls fail from enterpriseprojects
   36264: ALF-13933 Alfresco needs to be able to support LibreOffice for transformations
      - remove old jodconverter-core-3.0-beta-3.diff
   36265: ALF-14025: Updated Surf libs to stop application context being added to non-checksum requested dependencies to allow relative paths to be requested.
   36266: Merged V3.4-BUG-FIX to V4.0-BUG-FIX
      36147: Removed nonsense comments from method information
      36187: Merged DEV to V3.4-BUG-FIX
         36121: ALF-234: There is no field restriction at the New Rule form in Share
            'maxlength="1024"' parameter has been added to title and description fields in 'rule-edit.get.html.ftl'
      36229: Merged DEV to V3.4-BUG-FIX
         35115: ALF-13181:Stack Specific: Script error occurs when try to exute Task Done/Approve/Reject action on My Tasks (My Tasks WebScript) dashlet
            Dellay for 500 miliseconds was added to MyTasks.transitionTask() method.
      36242: Fixed ALF-12287 "Share - metadataRefresh event removes version history"
      - The javascript component was listening to "metaDataRefresh" which made it refresh itself. However it also listened to dopcumentDetailsAvailable to enhance its dom (i.e. show itself). Meaning that if timing was bad and the "documentDetailsAvailable" was fired before the refresh had been performed it nwever showed itself.   
      36260: ALF-13936: Enabling IMAP can interfere with folder versioning
      36262: ALF-13718: Reverting ORDER BY changes to child assoc query as they had more impact than expected and we turned out to be compensating for out of date SQL Server statistics
   36269: Merged V3.4-BUG-FIX to V4.0-BUG-FIX
      36268: ALF-14031: Merged PATCHES/V3.4.6 to V3.4-BUG-FIX
         36176: ALF-13981: Fix registerReferenceCountingIndexReader() so that it works in a doWithFileLock() retry loop (whatever that means!)
   36273: ALF-13933 Alfresco needs to be able to support LibreOffice for transformations
      - Return a dummy OpenOffice command even when there is no OpenOffice/LibreOffice installed or on the path. 
   36275: ALF-14029: Updating single-valued association (no List<NodeRef>) fixed.
   36283: Translation updates to: DE, ES, FR, IT, JA, NL. Based on EN rev36165.
   36284: ALF-13723 SOLR does not include the same query unit tests as lucene 
   - InTree, InFolder, FTS, Access, DateFormatting, AspectJoin, FTSConnectives, LikeEscaping
   36306: ALF-13672: Workflow Notification Emails are partially localized into other languages


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@36324 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2012-05-12 08:23:46 +00:00

472 lines
15 KiB
JavaScript

var MyTasks = {
ANIM_LENGTH: 300,
Filter: null,
ServiceContext: null,
start: function()
{
if ($('taskPanel'))
{
var messagePanel = $("taskMessagePanel");
messagePanel.setStyle('opacity', 0);
messagePanel.setStyle('display', 'block');
// fire off the ajax request to populate the task panel - the 'mytaskspanel' webscript
// is responsible for rendering just the contents of the main panel div
YAHOO.util.Connect.asyncRequest(
"GET",
MyTasks.ServiceContext + '/ui/mytaskspanel?f='+MyTasks.Filter,
{
success: function(response)
{
// push the response into the task panel div
$('taskPanel').setHTML(response.responseText);
// extract the count value from a hidden div and display it
$('taskCount').setHTML($('taskCountValue').innerHTML);
// wire up all the events and animations
MyTasks.init();
},
failure: function(response)
{
// display the error
$('taskPanel').setHTML($('displayTheError').innerHTML);
// hide the ajax wait panel and show the main task panel
$('taskPanelOverlay').setStyle('visibility', 'hidden');
$('taskPanel').setStyle('visibility', 'visible');
}
}
);
}
},
init: function()
{
MyTasks.sortTasks();
MyTasks.parseTaskPanels();
// hide the ajax wait panel and show the main task panel
$('taskPanelOverlay').setStyle('visibility', 'hidden');
$('taskPanel').setStyle('visibility', 'visible');
if (MyTasks.postInit)
{
MyTasks.postInit();
MyTasks.postInit = null;
}
},
parseTaskPanels: function()
{
var tasks = $$('#taskPanel .taskRow');
var items = $$('#taskPanel .taskItem');
var infos = $$('#taskPanel .taskInfo');
var details = $$('#taskPanel .taskDetail');
var resources = $$('#taskPanel .taskResources');
var fxInfo = new Fx.Elements(infos, {wait: false, duration: MyTasks.ANIM_LENGTH, transition: Fx.Transitions.sineInOut});
var fxDetail = new Fx.Elements(details, {wait: false, duration: MyTasks.ANIM_LENGTH, transition: Fx.Transitions.sineInOut,
onComplete: function()
{
// event handler to ensure scrollable area style is set
this.elements.each(function(detail, i)
{
if (detail.parentNode.isOpen == true)
{
$E('.taskResources', detail).setStyle('overflow', 'auto');
}
});
}
});
tasks.each(function(task, i)
{
var item = items[i];
var info = infos[i];
var detail = details[i];
var resource = resources[i];
// animated elements defaults
task.isOpen = false;
task.loadingResources = false;
item.defBColor = (item.getStyle('background-color') == 'transparent') ? '' : item.getStyle('background-color');
detail.defHeight = detail.offsetHeight + 3; // Add some extra spacing for the button
detail.setStyle('opacity', 0);
detail.setStyle('display', 'block');
detail.setStyle('height', 1);
info.setStyle('opacity', 0);
// register 'mouseenter' event for each task
task.addEvent('mouseenter', function(e)
{
if (task.isOpen)
return;
// highlight the item title
task.addClass('taskItemSelected');
// fade in info button
var animInfo = {};
var infoOpacity = info.getStyle('opacity');
if (infoOpacity != 1)
{
animInfo[i] = {'opacity': [infoOpacity, 1]};
}
// reset styles on all closed tasks
tasks.each(function(otherTask, j)
{
var otherInfo = infos[j];
if ((otherTask != task) && (!otherTask.isOpen))
{
// reset selected class
otherTask.removeClass('taskItemSelected');
// does the info button need fading out
var otherOpacity = otherInfo.getStyle('opacity');
if (otherOpacity != 0)
{
animInfo[j] = {'opacity': [otherOpacity, 0]};
}
}
});
fxInfo.start(animInfo);
});
// register 'mouseleave' event for each task
task.addEvent('mouseleave', function(e)
{
if (task.isOpen)
return;
// unhighlight the item title
task.removeClass('taskItemSelected');
// fade out info button
var animInfo = {};
var infoOpacity = info.getStyle('opacity');
if (infoOpacity != 0)
{
animInfo[i] = {'opacity': [infoOpacity, 0]};
}
// reset styles on all closed tasks - needed in case any element is mid-animation
tasks.each(function(otherTask, j)
{
var otherInfo = infos[j];
if ((otherTask != task) && (!otherTask.isOpen))
{
// does the info button need fading out
var otherOpacity = otherInfo.getStyle('opacity');
if (otherOpacity != 0)
{
animInfo[j] = {'opacity': [otherOpacity, 0]};
}
}
});
fxInfo.start(animInfo);
});
// register 'click' event for each task
task.addEvent('click', function(e)
{
var animInfo = {},
animDetail = {},
infoOpacity = info.getStyle('opacity');
if (!task.isOpen)
{
// open up this task
// flag this task as open
task.isOpen = true;
task.addClass("taskItemSelected");
task.addClass("taskItemSelectedOpen");
if (task.loadingResources == false)
{
// ajax call to populate the task resource list
task.loadingResources = true;
YAHOO.util.Connect.asyncRequest(
"POST",
getContextPath() + '/ajax/invoke/TaskInfoBean.sendTaskResources',
{
success: function(response)
{
// set the resource list panel html
var resource = response.argument[0];
resource.innerHTML = response.responseText;
},
failure: handleErrorYahoo, // global error handler
argument: [resource]
},
"taskId=" + task.id);
}
// fade in info button
animInfo[i] = {'opacity': [infoOpacity, 1]};
// slide and fade in the details panel
animDetail[i] = {
'height': [1, detail.defHeight],
'opacity': [detail.getStyle('opacity'), 1]};
// close other open tasks and toggle this one if it's already open
tasks.each(function(otherTask, j)
{
var otherInfo = infos[j],
otherDetail = details[j];
if (otherTask != task)
{
// close any other open tasks
otherTask.isOpen = false;
// unhighlight the item title
otherTask.removeClass('taskItemSelected');
otherTask.removeClass("taskItemSelectedOpen");
// does this task detail panel need resetting back to it's default height?
var otherHeight = otherDetail.offsetHeight;
if (otherHeight != 1)
{
animDetail[j] = {
'height': [otherHeight, 1],
'opacity': [otherDetail.getStyle('opacity'), 0]};
}
// does the info button need fading out?
var otherOpacity = otherInfo.getStyle('opacity');
if (otherOpacity != 0)
{
animInfo[j] = {'opacity': [otherOpacity, 0]};
}
$E('.taskResources', otherDetail).setStyle('overflow', 'hidden');
}
});
}
else
{
// close this task
// flag this task as closed
task.isOpen = false;
task.removeClass("taskItemSelectedOpen");
// fade in info button
animInfo[i] = {'opacity': [infoOpacity, 1]};
// reset task back to it's default height
animDetail[i] = {
'height': [detail.defHeight, 1],
'opacity': [detail.getStyle('opacity'), 0]};
$E('.taskResources', detail).setStyle('overflow', 'hidden');
}
fxInfo.start(animInfo);
fxDetail.start(animDetail);
});
});
$('taskPanel').addEvent('mouseleave', function(e)
{
var animInfo = {};
// handler for mouse leaving the entire task panel
tasks.each(function(task, i)
{
if (!task.isOpen)
{
task.removeClass('taskItemSelected');
animInfo[i] = {'opacity': [infos[i].getStyle('opacity'), 0]};
}
else
{
animInfo[i] = {'opacity': [infos[i].getStyle('opacity'), 1]};
}
});
fxInfo.start(animInfo);
});
},
transitionTask: function(commandUrl, successMessage)
{
YAHOO.util.Connect.asyncRequest(
"GET",
getContextPath() + commandUrl,
{
success: function(response)
{
MyTasks.displayMessage(successMessage);
MyTasks.refreshList();
}.delay(500),
failure: function(e)
{
alert(e.status + " : ERROR failed to transition task.");
}
}
);
},
/**
* Refresh the main data list contents within the taskPanel container
*/
refreshList: function(reopenActive)
{
// do we want to remember which panel was open?
if (reopenActive)
{
// do we have an open panel?
var openPanel = $E('#taskPanel .taskItemSelected');
var openPanelId = null;
if (openPanel != null)
{
openPanelId = openPanel.id;
// Re-open the panel if the id still exists
MyTasks.postInit = function()
{
if ($(openPanelId))
{
$(openPanelId).fireEvent("click");
// scroll the open panel into view
var fxScroll = new Fx.Scroll($('taskPanel'),
{
duration: MyTasks.ANIM_LENGTH,
transition: Fx.Transitions.linear
});
fxScroll.toElement($(openPanelId));
}
}
}
}
// empty the main panel div and restart by reloading the panel contents
var taskPanel = $('taskPanel');
taskPanel.setStyle('visibility', 'hidden');
// show the ajax wait panel
$('taskPanelOverlay').setStyle('visibility', 'visible');
taskPanel.empty();
taskPanel.removeEvents('mouseleave');
MyTasks.start();
},
/**
* Update the view filter
*/
filter: function(filter)
{
$$('#taskFilterBar li').each(function(filterLink, i)
{
if (i == filter)
{
filterLink.addClass("taskCurrent");
}
else
{
filterLink.removeClass("taskCurrent");
}
});
MyTasks.Filter = filter;
MyTasks.refreshList();
},
sortTasks: function()
{
var taskArray = new Array();
$$('#taskPanel .taskRow').each(function(taskDiv, i)
{
taskArray[i] = {dueDate: taskDiv.getProperty('rel'), theDiv: taskDiv.clone()};
});
taskArray.sort(MyTasks.sortByDueDate);
var taskPanel = $('taskPanel');
taskPanel.empty();
taskPanel.removeEvents('mouseleave');
for(var i = 0; i < taskArray.length; i++)
{
taskArray[i].theDiv.injectInside(taskPanel);
}
},
sortByDueDate: function(a, b)
{
var x = a.dueDate;
var y = b.dueDate;
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
},
/**
* Called when the Manage Task dialog returns
*/
manageTaskCallback: function()
{
// The manage task dialog window has closed
MyTasks.refreshList(true);
},
/**
* Display a message bubble of helpful info to the user. Calling this function in quick
* succession will cause previous message to be lost as the new ones are displayed.
*
* @param message Message text to display
*/
displayMessage: function(message)
{
var panel = $("taskMessagePanel");
if ($defined(panel.timeout))
{
clearTimeout(panel.timeout);
panel.timeout = null;
}
panel.setStyle("opacity", 0);
panel.setStyle("margin-top", -90);
panel.getChildren()[1].setHTML(message);
// reset the close box animation by refreshing the image source
$("taskMessagePanelCloseImage").src = getContextPath() + "/images/icons/close_portlet_animation.gif";
panel.fxMessage = new Fx.Styles(panel,
{
duration: 1000,
transition: Fx.Transitions.sineInOut
});
panel.fxMessage.start({'margin-top': -70, 'opacity': [0, 0.75]});
panel.timeout = window.setTimeout(this.fadeOutMessage, 9000);
},
/**
* Timer callback function to fade out the message panel
*/
fadeOutMessage: function()
{
var panel = $("taskMessagePanel");
panel.timeout = null;
var fxMessage = new Fx.Styles(panel,
{
duration: 1000,
transition: Fx.Transitions.sineInOut
});
fxMessage.start({'margin-top': -90, 'opacity': [0]});
},
/**
* Close the message panel immediately when the user clicks the close icon
*/
closeMessage: function()
{
var panel = $("taskMessagePanel");
if ($defined(panel.timeout))
{
clearTimeout(panel.timeout);
panel.timeout = null;
}
panel.fxMessage.stop();
panel.setStyle("opacity", 0);
}
};
window.addEvent('load', MyTasks.start);