tabs mostly working
This commit is contained in:
parent
5f8888fcc9
commit
55ae893c93
4 changed files with 127 additions and 72 deletions
|
|
@ -228,11 +228,19 @@ sub drawLocationField {
|
|||
my ($self, $params) = @_;
|
||||
my $ems = $self->ems;
|
||||
my $options = { map { $_ => $_ } ( @{ $ems->getSubmissionLocations || [ $ems->getLocations ] } ) } ;
|
||||
return WebGUI::Form::combo($self->session, {
|
||||
name => 'location',
|
||||
value => $self->get('location'),
|
||||
options => $options,
|
||||
});
|
||||
if( $ems->isRegistrationStaff ) {
|
||||
return WebGUI::Form::combo($self->session, {
|
||||
name => 'location',
|
||||
value => $self->get('location'),
|
||||
options => $options,
|
||||
});
|
||||
} else {
|
||||
return WebGUI::Form::selectBox($self->session, {
|
||||
name => 'location',
|
||||
value => $self->get('location'),
|
||||
options => $options,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -492,13 +500,13 @@ sub getEditTabs {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
=head2 getUrl
|
||||
=head2 getQueueUrl
|
||||
|
||||
returns the URL for the submission queue page with the submisison id in the hash part
|
||||
|
||||
=cut
|
||||
|
||||
sub getUrl {
|
||||
sub getQueueUrl {
|
||||
my $self = shift;
|
||||
return $self->ems->getUrl('func=viewSubmissionQueue#' . $self->get('submissionId') );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ sub definition {
|
|||
nextSubmissionId => {
|
||||
tab => "properties",
|
||||
fieldType => "integer",
|
||||
defaultValue => 0,
|
||||
defaultValue => 1,
|
||||
label => $i18n->get("next submission id label"),
|
||||
hoverHelp => $i18n->get("next submission id label help")
|
||||
},
|
||||
|
|
@ -1275,7 +1275,7 @@ sub www_getAllSubmissions {
|
|||
|
||||
my %fields = (
|
||||
submissionId => $asset->get("submissionId"),
|
||||
url => $asset->getUrl,
|
||||
url => $asset->getQueueUrl,
|
||||
title => $asset->get( "title" ),
|
||||
createdBy => WebGUI::User->new($session,$asset->get( "createdBy" ))->username,
|
||||
creationDate => $datetime->epochToSet($asset->get( "creationDate" )),
|
||||
|
|
@ -1329,6 +1329,35 @@ sub www_getBadgesAsJson {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_getSubmissionById
|
||||
|
||||
returns a JSON dataset with info about the requested submission
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
sub www_getSubmissionById {
|
||||
my $self = shift;
|
||||
my $submissionId = $self->session->form->get('submissionId');
|
||||
my $result;
|
||||
my $res = $self->getLineage(['descendants'],{ limit => 1, returnObjects=>1,
|
||||
includeOnlyClasses => ['WebGUI::Asset::EMSSubmission'],
|
||||
joinClass => "WebGUI::Asset::EMSSubmission",
|
||||
whereClause => q{submissionId='} . $submissionId . q/'/,
|
||||
} );
|
||||
if( scalar(@$res) == 0 ) {
|
||||
$result->{hasError} = 1;
|
||||
$result->{errors} = [ 'failed to load submission' ];
|
||||
} else {
|
||||
$result->{itemText} = $res->[0]->www_editSubmission;
|
||||
$result->{submissionId} = $submissionId;
|
||||
}
|
||||
$self->session->http->setMimeType('application/json');
|
||||
return JSON->new->encode($result);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_getRegistrantAsJson ( )
|
||||
|
||||
Retrieves the properties of a specific badge and the items attached to it. Expects badgeId to be one of the form params.
|
||||
|
|
@ -2519,7 +2548,8 @@ sub www_viewSubmissionQueue {
|
|||
$self->processTemplate({
|
||||
backUrl => $self->getUrl,
|
||||
isRegistrationStaff => $isRegistrationStaff,
|
||||
canEdit => $canEdit,
|
||||
canEdit => $canEdit,
|
||||
mainUrl => $self->getUrl,
|
||||
canSubmit => $canSubmit,
|
||||
hasSubmissionForms => $self->hasSubmissionForms,
|
||||
getSubmissionQueueDataUrl => $self->getUrl('func=getAllSubmissions'),
|
||||
|
|
@ -2528,8 +2558,8 @@ sub www_viewSubmissionQueue {
|
|||
addSubmissionUrl => $self->getUrl('func=addSubmission'),
|
||||
},$self->get('eventSubmissionQueueTemplateId'));
|
||||
|
||||
return $self->processStyle(
|
||||
$self->processTemplate({
|
||||
return $self->processStyle(
|
||||
$self->processTemplate({
|
||||
queueTabTitle => $isRegistrationStaff ? $i18n->get('submission queue') : $i18n->get('my submissions'),
|
||||
queueTabData => $QueueTabData,
|
||||
backUrl => $self->getUrl,
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ my @cleanup = ();
|
|||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 50; # Increment this number for each test you create
|
||||
plan tests => 60; # Increment this number for each test you create
|
||||
|
||||
(my $submitGroupA = WebGUI::Group->new($session,'new'))->name('groupA');
|
||||
(my $submitGroupB = WebGUI::Group->new($session,'new'))->name('groupB');
|
||||
|
|
@ -248,10 +248,10 @@ cmp_deeply( from_json($ems->www_getAllSubmissions), {
|
|||
records => [
|
||||
{
|
||||
lastReplyDate => '',
|
||||
submissionId => '4',
|
||||
submissionId => '5',
|
||||
creationDate => ignore(),
|
||||
createdBy => 'userA',
|
||||
url => '/test-ems?func=viewSubmissionQueue#4',
|
||||
url => '/test-ems?func=viewSubmissionQueue#5',
|
||||
submissionStatus => $i18n->get('pending'),
|
||||
title => 'my favorite thing to talk about',
|
||||
lastReplyBy => ''
|
||||
|
|
@ -262,6 +262,12 @@ cmp_deeply( from_json($ems->www_getAllSubmissions), {
|
|||
dir => 'DESC',
|
||||
}, 'test getAllSubmissions for UserA' );
|
||||
|
||||
$session->request->setup_body({submissionId => 5});
|
||||
cmp_deeply( from_json($ems->www_getSubmissionById), {
|
||||
submissionId => 5,
|
||||
itemText => ignore(),
|
||||
}, 'test getSubmissionById');
|
||||
|
||||
loginUserC;
|
||||
cmp_deeply( from_json($ems->www_getAllSubmissions), {
|
||||
sort => undef,
|
||||
|
|
@ -281,20 +287,20 @@ cmp_deeply( from_json($ems->www_getAllSubmissions), {
|
|||
records => [
|
||||
{
|
||||
lastReplyDate => '',
|
||||
submissionId => '5',
|
||||
submissionId => '6',
|
||||
creationDate => ignore(),
|
||||
createdBy => 'userB',
|
||||
url => '/test-ems?func=viewSubmissionQueue#5',
|
||||
url => '/test-ems?func=viewSubmissionQueue#6',
|
||||
submissionStatus => $i18n->get('pending'),
|
||||
title => 'why i like to be important',
|
||||
lastReplyBy => ''
|
||||
},
|
||||
{
|
||||
lastReplyDate => '',
|
||||
submissionId => '4',
|
||||
submissionId => '5',
|
||||
creationDate => ignore(),
|
||||
createdBy => 'userA',
|
||||
url => '/test-ems?func=viewSubmissionQueue#4',
|
||||
url => '/test-ems?func=viewSubmissionQueue#5',
|
||||
submissionStatus => $i18n->get('pending'),
|
||||
title => 'my favorite thing to talk about',
|
||||
lastReplyBy => ''
|
||||
|
|
|
|||
|
|
@ -37,10 +37,12 @@ WebGUI.EMS = function (configs) {
|
|||
if(configs) {
|
||||
this._configs = configs;
|
||||
}
|
||||
this.url = this._configs.url;
|
||||
|
||||
if(!this._configs.initRequestString) {
|
||||
this._configs.initRequestString = ';startIndex=0';
|
||||
}
|
||||
WebGUI.EMS.Items = new Object();
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Internationalization
|
||||
|
|
@ -77,21 +79,22 @@ WebGUI.EMS = function (configs) {
|
|||
var index;
|
||||
if( typeof(e) == "string" || typeof(e) == "number" ) {
|
||||
index = e;
|
||||
myTab = WebGUI.EMS.Tickets[index].Tab;
|
||||
myTab = WebGUI.EMS.Items[index].Tab;
|
||||
} else {
|
||||
if( typeof(e) != "undefined" ) {
|
||||
YAHOO.util.Event.preventDefault(e);
|
||||
}
|
||||
if( typeof(myTab) == "undefined" ) {
|
||||
myTab = tabView.get('activeTab');
|
||||
myTab = WebGUI.EMS.Tabs.get('activeTab');
|
||||
}
|
||||
index = parseInt( myTab.get('label') );
|
||||
}
|
||||
delete WebGUI.EMS.Tickets[index];
|
||||
delete WebGUI.EMS.Items[index];
|
||||
WebGUI.EMS.Tabs.removeTab(myTab);
|
||||
if( WebGUI.EMS.lastTab ) {
|
||||
WebGUI.EMS.Tabs.set('activeTab',WebGUI.EMS.lastTab);
|
||||
}
|
||||
window.location.hash = '';
|
||||
};
|
||||
|
||||
//***********************************************************************************
|
||||
|
|
@ -171,47 +174,26 @@ WebGUI.EMS = function (configs) {
|
|||
}
|
||||
|
||||
//***********************************************************************************
|
||||
// This method is subscribed to by the DataTable and thus becomes a member of the DataTable
|
||||
// class even though it is a member of the EMS Class. For this reason, a EMS instance
|
||||
// is actually passed to the method as it's second parameter.
|
||||
// This method does the actual work of loading an item into a tab
|
||||
//
|
||||
WebGUI.EMS.loadTicket = function ( evt, obj ) {
|
||||
// if the user pressed a modifier key we want to default
|
||||
if( eventModifiers( evt ) ) { return }
|
||||
var target = evt.target;
|
||||
if( typeof(WebGUI.EMS.Tickets) == "undefined" ) {
|
||||
WebGUI.EMS.Tickets = new Object();
|
||||
}
|
||||
|
||||
//let the default action happen if the user clicks the last reply column
|
||||
var links = YAHOO.util.Dom.getElementsByClassName ("profile_link","a",target);
|
||||
|
||||
WebGUI.EMS.loadItem = function ( submissionId, pathname ) {
|
||||
// the 'loading' 'indicator'
|
||||
if( typeof(WebGUI.EMS.ticketLoadingIndicator) == "undefined" ) {
|
||||
WebGUI.EMS.ticketLoadingIndicator = new YAHOO.widget.Overlay( "ticketLoadingIndicator", {
|
||||
if( typeof(WebGUI.EMS.loadingIndicator) == "undefined" ) {
|
||||
WebGUI.EMS.loadingIndicator = new YAHOO.widget.Overlay( "loadingIndicator", {
|
||||
fixedcenter : true,
|
||||
visible : false
|
||||
} );
|
||||
WebGUI.EMS.ticketLoadingIndicator.setBody( "Loading Ticket ..." +
|
||||
"<img id='ticketLoadingIndicator' title='loading' src='/extras/wobject/EMS/indicator.gif'/>"
|
||||
WebGUI.EMS.loadingIndicator.setBody( "Loading ..." +
|
||||
"<img id='loadingIndicator' title='Loading' src='/extras/wobject/EMS/indicator.gif'/>"
|
||||
);
|
||||
WebGUI.EMS.ticketLoadingIndicator.render(document.body);
|
||||
}
|
||||
WebGUI.EMS.ticketLoadingIndicator.show();
|
||||
|
||||
if (links.length == 0) {
|
||||
YAHOO.util.Event.stopEvent(evt.event);
|
||||
WebGUI.EMS.loadingIndicator.render(document.body);
|
||||
}
|
||||
WebGUI.EMS.loadingIndicator.show();
|
||||
|
||||
var elCell = this.getTdEl(target);
|
||||
if(elCell) {
|
||||
var oRecord = this.getRecord(elCell);
|
||||
|
||||
if( typeof( WebGUI.EMS.Tickets[oRecord.ticketId] ) != "undefined" ) {
|
||||
WebGUI.EMS.Tabs.set('activeTab',WebGUI.EMS.Tickets[oRecord.ticketId].Tab);
|
||||
WebGUI.EMS.ticketLoadingIndicator.hide();
|
||||
} else {
|
||||
var url = oRecord.getData('url') + "?func=view;caller=ticketMgr;view=" + obj._configs.view;
|
||||
if( typeof(pathname) == "undefined" ) {
|
||||
pathname = WebGUI.EMS.url ;
|
||||
}
|
||||
var url = pathname + "?func=getSubmissionById;submissionId=" + submissionId;
|
||||
|
||||
// Create callback object for the request
|
||||
var oCallback = {
|
||||
|
|
@ -225,42 +207,71 @@ WebGUI.EMS = function (configs) {
|
|||
}
|
||||
alert(message);
|
||||
return;
|
||||
} else if( typeof(WebGUI.EMS.Tickets[response.ticketId]) == "undefined"
|
||||
|| WebGUI.EMS.Tickets[response.ticketId] == null ) {
|
||||
} else if( typeof(WebGUI.EMS.Items[response.submissionId]) == "undefined"
|
||||
|| WebGUI.EMS.Items[response.submissionId] == null ) {
|
||||
// if there is a tab .. close it,
|
||||
// at least until I can get the JS/HTML re-written to handle multiple tabs
|
||||
// there should only be one
|
||||
for( var ticketId in WebGUI.EMS.Tickets ) { WebGUI.EMS.closeTab(ticketId) }
|
||||
var myContent = document.createElement("div");
|
||||
myContent.innerHTML = response.ticketText;
|
||||
myContent.innerHTML = response.itemText;
|
||||
myTab = new YAHOO.widget.Tab({
|
||||
label: response.ticketId + '<span class="close"><img src="/extras/wobject/EMS/close12_1.gif" alt="X" title="' +
|
||||
label: response.submissionId + '<span class="close"><img src="/extras/wobject/EMS/close12_1.gif" alt="X" title="' +
|
||||
WebGUI.EMS.i18n.get('Asset_EMSSubmission','close tab') + '" /></span>',
|
||||
contentEl: myContent
|
||||
});
|
||||
WebGUI.EMS.Tabs.addTab( myTab );
|
||||
YAHOO.util.Event.on(myTab.getElementsByClassName('close')[0], 'click', WebGUI.EMS.closeTab , myTab);
|
||||
WebGUI.EMS.Tickets[response.ticketId] = new Object();
|
||||
WebGUI.EMS.Tickets[response.ticketId].Tab = myTab;
|
||||
WebGUI.EMS.Items[response.submissionId] = new Object();
|
||||
WebGUI.EMS.Items[response.submissionId].Tab = myTab;
|
||||
} else {
|
||||
myTab = WebGUI.EMS.Tickets[response.ticketId].Tab;
|
||||
myTab.set('content', response.ticketText);
|
||||
myTab = WebGUI.EMS.Tickets[response.submissionId].Tab;
|
||||
myTab.set('content', response.itemText);
|
||||
}
|
||||
// make sure the script on the ticket has run
|
||||
if( typeof( WebGUI.ticketJScriptRun ) == "undefined" ) {
|
||||
eval( document.getElementById("ticketJScript").innerHTML );
|
||||
}
|
||||
delete WebGUI.ticketJScriptRun;
|
||||
WebGUI.EMS.ticketLoadingIndicator.hide();
|
||||
WebGUI.EMS.lastTab = tabView.get('activeTab');
|
||||
// if( typeof( WebGUI.ticketJScriptRun ) == "undefined" ) {
|
||||
// eval( document.getElementById("ticketJScript").innerHTML );
|
||||
// }
|
||||
// delete WebGUI.ticketJScriptRun;
|
||||
WebGUI.EMS.loadingIndicator.hide();
|
||||
WebGUI.EMS.lastTab = WebGUI.EMS.Tabs.get('activeTab');
|
||||
WebGUI.EMS.Tabs.set('activeTab',myTab);
|
||||
},
|
||||
failure: function(o) {
|
||||
WebGUI.EMS.ticketLoadingIndicator.hide();
|
||||
WebGUI.EMS.loadingIndicator.hide();
|
||||
alert("AJAX call failed");
|
||||
}
|
||||
};
|
||||
var request = YAHOO.util.Connect.asyncRequest('GET', url, oCallback);
|
||||
}
|
||||
};
|
||||
|
||||
//***********************************************************************************
|
||||
// This method is subscribed to by the DataTable and thus becomes a member of the DataTable
|
||||
// class even though it is a member of the EMS Class. For this reason, a EMS instance
|
||||
// is actually passed to the method as it's second parameter.
|
||||
//
|
||||
WebGUI.EMS.loadItemFromTable = function ( evt, obj ) {
|
||||
// if the user pressed a modifier key we want to default
|
||||
if( eventModifiers( evt ) ) { return }
|
||||
var target = evt.target;
|
||||
|
||||
//let the default action happen if the user clicks the last reply column
|
||||
var links = YAHOO.util.Dom.getElementsByClassName ("profile_link","a",target);
|
||||
|
||||
if (links.length == 0) {
|
||||
YAHOO.util.Event.stopEvent(evt.event);
|
||||
}
|
||||
|
||||
var elCell = this.getTdEl(target);
|
||||
if(elCell) {
|
||||
var oRecord = this.getRecord(elCell);
|
||||
|
||||
if( typeof( WebGUI.EMS.Items[oRecord.submissionId] ) != "undefined" ) {
|
||||
WebGUI.EMS.Tabs.set('activeTab',WebGUI.EMS.Items[oRecord.submissionId].Tab);
|
||||
WebGUI.EMS.loadingIndicator.hide();
|
||||
} else {
|
||||
WebGUI.EMS.loadItem( oRecord.submissionId );
|
||||
}
|
||||
} else {
|
||||
alert("Could not get table cell for " + target);
|
||||
}
|
||||
|
|
@ -327,7 +338,7 @@ WebGUI.EMS = function (configs) {
|
|||
);
|
||||
this.EMSQ.subscribe("rowMouseoverEvent", this.EMSQ.onEventHighlightRow);
|
||||
this.EMSQ.subscribe("rowMouseoutEvent", this.EMSQ.onEventUnhighlightRow);
|
||||
this.EMSQ.subscribe("cellClickEvent",WebGUI.EMS.loadTicket,this);
|
||||
this.EMSQ.subscribe("cellClickEvent",WebGUI.EMS.loadItemFromTable,this);
|
||||
// Override function for custom server-side sorting
|
||||
this.EMSQ.sortColumn = WebGUI.EMS.sortColumn;
|
||||
this.EMSQ.handleDataReturnPayload = function (oReq, oRes, oPayload ) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue