Removed json part from preview autocomplete. Now the complete userlist is loaded in the page directly.
This commit is contained in:
parent
e53193b638
commit
0221e48476
1 changed files with 32 additions and 37 deletions
|
|
@ -403,11 +403,14 @@ sub www_previewEmail {
|
||||||
my $subject = $asset->getSubject( $self->get('configuration') );
|
my $subject = $asset->getSubject( $self->get('configuration') );
|
||||||
|
|
||||||
my $userSelection =
|
my $userSelection =
|
||||||
'<div id="ac">
|
qq{
|
||||||
Kies een gebruiker:
|
<p><a href="$manageUrl">Terug naar de mailing manager.</a></p>
|
||||||
<input id="acElem" type="text" />
|
<label for="acElem">Kies een gebruiker:</label>
|
||||||
<div id="acCont"></div>
|
<div id="ac">
|
||||||
</div>';
|
<input id="acElem" type="text" />
|
||||||
|
<div id="acCont"></div>
|
||||||
|
</div>
|
||||||
|
};
|
||||||
|
|
||||||
my $js = $self->getAutoCompleteJS;
|
my $js = $self->getAutoCompleteJS;
|
||||||
|
|
||||||
|
|
@ -427,8 +430,6 @@ sub www_previewEmail {
|
||||||
<script type="text/javascript" src="/extras/yui/build/yahoo-dom-event/yahoo-dom-event.js"></script>
|
<script type="text/javascript" src="/extras/yui/build/yahoo-dom-event/yahoo-dom-event.js"></script>
|
||||||
<script type="text/javascript" src="/extras/yui/build/datasource/datasource-min.js"></script>
|
<script type="text/javascript" src="/extras/yui/build/datasource/datasource-min.js"></script>
|
||||||
<script type="text/javascript" src="/extras/yui/build/autocomplete/autocomplete-min.js"></script>
|
<script type="text/javascript" src="/extras/yui/build/autocomplete/autocomplete-min.js"></script>
|
||||||
<script type="text/javascript" src="/extras/yui/build/connection/connection-min.js"></script>
|
|
||||||
<script type="text/javascript" src="/extras/yui/build/json/json-min.js"></script>
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$js
|
$js
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -445,36 +446,49 @@ EOHTML
|
||||||
|
|
||||||
sub getAutoCompleteJS {
|
sub getAutoCompleteJS {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
my $session = $self->session;
|
||||||
my $url = $self->session->url;
|
my $url = $self->session->url;
|
||||||
my $jsonUrl = $url->page( 'newsletter=mailing;func=getRecipientsList;id='.$self->getId .';');
|
my $jsonUrl = $url->page( 'newsletter=mailing;func=getRecipientsList;id='.$self->getId .';');
|
||||||
my $contentBase = $url->page( "newsletter=mailing;func=previewContent;id=".$self->getId );
|
my $contentBase = $url->page( "newsletter=mailing;func=previewContent;id=".$self->getId );
|
||||||
|
|
||||||
|
my $data = to_json( [
|
||||||
|
map { {
|
||||||
|
id => $_->getId,
|
||||||
|
name => $_->username . " (" . $_->get('email') . ")",
|
||||||
|
} }
|
||||||
|
grep { defined $_ }
|
||||||
|
map { WebGUI::User->new( $session, $_ ) }
|
||||||
|
@{ $self->getAsset->getRecipients }
|
||||||
|
] );
|
||||||
|
|
||||||
return <<EOJS;
|
return <<EOJS;
|
||||||
YAHOO.util.Event.onDOMReady( function() {
|
YAHOO.util.Event.onDOMReady( function() {
|
||||||
|
var data = $data;
|
||||||
|
|
||||||
var jsonUrl = '$jsonUrl';
|
var jsonUrl = '$jsonUrl';
|
||||||
var contentBase = '$contentBase';
|
var contentBase = '$contentBase';
|
||||||
var contentFrame = YAHOO.util.Dom.get('previewFrame');
|
var contentFrame = YAHOO.util.Dom.get('previewFrame');
|
||||||
|
|
||||||
var dataSource = new YAHOO.util.XHRDataSource("$jsonUrl");
|
var dataSource = new YAHOO.util.LocalDataSource( data );
|
||||||
dataSource.responseType = YAHOO.util.XHRDataSource.TYPE_JSON;
|
|
||||||
dataSource.responseSchema = {
|
dataSource.responseSchema = {
|
||||||
resultsList : 'recipients',
|
|
||||||
fields : [ 'name', 'id' ]
|
fields : [ 'name', 'id' ]
|
||||||
};
|
};
|
||||||
|
|
||||||
// Instantiate the AutoComplete
|
// Instantiate the AutoComplete
|
||||||
var autoComplete = new YAHOO.widget.AutoComplete("acElem", "acCont", dataSource);
|
var autoComplete = new YAHOO.widget.AutoComplete("acElem", "acCont", dataSource);
|
||||||
autoComplete.resultTypeList = false;
|
autoComplete.resultTypeList = false;
|
||||||
autoComplete.queryQuestionMark = false;
|
autoComplete.queryMatchContains = true;
|
||||||
|
|
||||||
// Define an event handler to populate a hidden form field
|
var updateFrameSrc = function(type, args) {
|
||||||
// when an item gets selected
|
|
||||||
var myHiddenField = YAHOO.util.Dom.get("autoCompleteHiddenField");
|
|
||||||
var myHandler = function(type, args) {
|
|
||||||
// myHiddenField.value = args[2].id
|
|
||||||
contentFrame.src = contentBase + ';userId=' + args[2].id;
|
contentFrame.src = contentBase + ';userId=' + args[2].id;
|
||||||
};
|
};
|
||||||
autoComplete.itemSelectEvent.subscribe(myHandler);
|
|
||||||
|
autoComplete.itemSelectEvent.subscribe(updateFrameSrc);
|
||||||
|
|
||||||
|
YAHOO.util.Event.addListener( 'acElem', 'focus', function ( e ) {
|
||||||
|
this.focus();
|
||||||
|
this.select();
|
||||||
|
} );
|
||||||
} );
|
} );
|
||||||
EOJS
|
EOJS
|
||||||
}
|
}
|
||||||
|
|
@ -631,24 +645,5 @@ sub www_sendTestEmailsConfirm {
|
||||||
return WebGUI::Mailing::Admin->new( $session )->www_view;
|
return WebGUI::Mailing::Admin->new( $session )->www_view;
|
||||||
}
|
}
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
|
||||||
sub www_getRecipientsList {
|
|
||||||
my $self = shift;
|
|
||||||
my $session = $self->session;
|
|
||||||
|
|
||||||
my $query = $session->form->get( 'query' );
|
|
||||||
my @users =
|
|
||||||
map { {
|
|
||||||
id => $_->getId,
|
|
||||||
name => $_->username . " (" . $_->get('email') . ")",
|
|
||||||
} }
|
|
||||||
grep { defined $_ && ( $_->username =~ m{$query}i || $_->get('email') =~ m{$query}i ) }
|
|
||||||
map { WebGUI::User->new( $session, $_ ) }
|
|
||||||
@{ $self->getAsset->getRecipients };
|
|
||||||
|
|
||||||
$session->http->setMimeType('application/json');
|
|
||||||
return to_json( { recipients => \@users } );
|
|
||||||
}
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue