auto complete box for hosts.

This commit is contained in:
Naomi 2010-12-17 15:52:44 -05:00
parent ace30e9766
commit 3d952eb1bd
4 changed files with 32 additions and 7 deletions

View File

@ -86,6 +86,7 @@ class ScheduleController extends Zend_Controller_Action
}
}
$this->view->form = $form->__toString();
$this->view->hosts = User::getHosts();
}
public function moveShowAction()

View File

@ -91,6 +91,12 @@ class Application_Form_AddShow extends Zend_Form
'required' => false,
));
// Add end date element
$this->addElement('text', 'hosts_autocomplete', array(
'label' => 'Type a Host:',
'required' => false
));
$options = array();
$hosts = User::getHosts();
@ -98,7 +104,7 @@ class Application_Form_AddShow extends Zend_Form
$options[$host['id']] = $host['login'];
}
$hosts = new Zend_Form_Element_Multiselect('hosts');
$hosts = new Zend_Form_Element_MultiCheckbox('hosts');
$hosts->setLabel('Hosts:')
->setMultiOptions($options)
->setRequired(true);

View File

@ -11,11 +11,11 @@ class User {
$this->_userId = $userId;
}
public function getType(){
public function getType() {
return $this->userRole;
}
public function getId(){
public function getId() {
return $this->_userId;
}
@ -32,7 +32,7 @@ class User {
$sql;
$sql_gen = "SELECT id, login, type FROM cc_subjs";
$sql_gen = "SELECT id, login, type FROM cc_subjs ";
$sql = $sql_gen;
@ -50,6 +50,8 @@ class User {
$sql = $sql_gen ." WHERE ". $sql_type;
}
$sql = $sql . " ORDER BY login";
return $CC_DBC->GetAll($sql);
}

View File

@ -131,14 +131,20 @@ function schedulePlaylist() {
}
function makeShowDialog(html) {
function autoSelect(event, ui) {
$("#hosts-"+ui.item.value).attr("checked", "checked");
event.preventDefault();
}
function makeShowDialog(json) {
var dialog;
//main jqueryUI dialog
dialog = $('<div id="schedule_add_event_dialog" />');
dialog.append(html);
dialog.append(json.form);
var start = dialog.find("#start_date");
var end = dialog.find("#end_date");
@ -146,6 +152,16 @@ function makeShowDialog(html) {
createDateInput(start, startDpSelect);
createDateInput(end, endDpSelect);
var auto = json.hosts.map(function(el) {
return {value: el.id, label: el.login};
});
dialog.find("#hosts_autocomplete").autocomplete({
source: auto,
select: autoSelect
});
dialog.dialog({
autoOpen: false,
title: 'Add Show',
@ -203,7 +219,7 @@ function openShowDialog() {
url = '/Schedule/add-show-dialog/format/json';
$.get(url, function(json){
var dialog = makeShowDialog(json.form);
var dialog = makeShowDialog(json);
dialog.dialog('open');
});
}