Revize 1472
Přidáno uživatelem Ondřej Fibich před asi 12 roky(ů)
freenetis/branches/network/application/controllers/devices.php | ||
---|---|---|
|
||
// filter connect devices form
|
||
$filter_form = new Filter_form();
|
||
|
||
$filter_form->add('subnet')
|
||
->type('select')
|
||
->values(ORM::factory('subnet')->select_list_by_net())
|
||
->css_class('filter_field_subnet');
|
||
|
||
$filter_form->add('type')
|
||
->type('select')
|
||
... | ... | |
'id', 'CONCAT(surname, \' \', name, \' - \', login)',
|
||
'surname'
|
||
));
|
||
|
||
$filter_form->add('subnet')
|
||
->type('select')
|
||
->values(ORM::factory('subnet')->select_list_by_net());
|
||
|
||
// validates form and saves data
|
||
if($form->validate())
|
freenetis/branches/network/application/libraries/Filter_form.php | ||
---|---|---|
$js_data[$filter->name]["callback"] = $filter->callback;
|
||
|
||
$js_data[$filter->name]["classes"] = (is_array($filter->class)) ? $filter->class : array('all' => $filter->class);
|
||
|
||
$js_data[$filter->name]["css_classes"] = $filter->css_class;
|
||
}
|
||
|
||
foreach ($this->opers as $i => $operation)
|
||
... | ... | |
$this->template->tables = $tables;
|
||
$this->template->default = $default;
|
||
$this->template->keys = $keys;
|
||
$this->template->classes = $filter->css_class;
|
||
|
||
$this->template->js_data = $js_data;
|
||
|
freenetis/branches/network/application/libraries/Filter.php | ||
---|---|---|
*
|
||
* @author Michal Kliment
|
||
* @version 1.0
|
||
*
|
||
* @method Filter type(string $type)
|
||
* @method Filter table(string $sql_table_name)
|
||
* @method Filter callback(string $url_autocomplete)
|
||
* @method Filter values(array $select_type_values)
|
||
* @method Filter default(array $select_type_values_selected_by_default)
|
||
* @method Filter css_class(string $class_name) CSS class of value field of form
|
||
*/
|
||
class Filter
|
||
{
|
||
... | ... | |
(
|
||
'type' => 'text',
|
||
'default' => array(),
|
||
'class' => array()
|
||
'class' => array(),
|
||
'css_class' => array()
|
||
);
|
||
|
||
/**
|
||
... | ... | |
// cannot modify name
|
||
if ($method == 'name')
|
||
{
|
||
// do nothing
|
||
// do nothing
|
||
}
|
||
// stores default values
|
||
else if ($method == 'default')
|
||
{
|
||
$this->data[$method][] = array('oper' => $args[0], 'value' => $args[1]);
|
||
$this->data[$method][] = array('oper' => $args[0], 'value' => $args[1]);
|
||
}
|
||
else if ($method == 'css_class')
|
||
{
|
||
$this->data[$method] = array_merge($this->data[$method], array($args[0]));
|
||
}
|
||
else
|
||
{
|
||
$this->data[$method] = $args[0];
|
||
$this->data[$method] = $args[0];
|
||
}
|
||
|
||
if ($method == 'type')
|
||
{
|
||
$this->data['class'] = array_merge($this->data['class'], array($args[0]));
|
||
$this->data['class'] = array_merge($this->data['class'], array($args[0]));
|
||
}
|
||
|
||
return $this;
|
freenetis/branches/network/application/views/js/devices_add.php | ||
---|---|---|
$('#filter_form').unbind('submit').submit(function ()
|
||
{
|
||
var $i = $tr.find('input[name^="_device_filter["]');
|
||
$i.val($(this).serialize());
|
||
$i.val($(this).serialize()).trigger('change');
|
||
$('#dialog_filter_devices').dialog('close');
|
||
$i.trigger('change');
|
||
return false;
|
||
});
|
||
|
||
// filter field subnet
|
||
var subnet_id = $tr.find('select[name^="subnet["]').val();
|
||
$('.filter_field_subnet').val(subnet_id);
|
||
|
||
// open dialog
|
||
$('#dialog_filter_devices').dialog({
|
||
title: '<?php echo __('Filter devices') ?>',
|
||
... | ... | |
*/
|
||
function change_ip_address()
|
||
{
|
||
var $subnet = $(this).parent().find('input[name="subnet["]');
|
||
var $subnet = $(this).parent().find('select[name="subnet["]');
|
||
|
||
if ($(this).val().length)
|
||
{
|
||
... | ... | |
html_buffer.push('<label class="device_add_label"><?php echo __('Subnet') ?>: </label>');
|
||
html_buffer.push('<select name="subnet[');
|
||
html_buffer.push(i);
|
||
html_buffer.push(']" style="width: 11em" onchange="subnets_options()">');
|
||
html_buffer.push(']" style="width: 11em">');
|
||
html_buffer.push(subnets_options);
|
||
html_buffer.push('</select>');
|
||
html_buffer.push('</td>');
|
freenetis/branches/network/application/views/filter_form_template.php | ||
---|---|---|
* @author Michal Kliment
|
||
*/
|
||
$(".t").die("change").live("change", function (){
|
||
|
||
// css classes
|
||
var classes = [];
|
||
|
||
// remove all items from operation's select
|
||
$(this).next().html("");
|
||
|
||
... | ... | |
});
|
||
}
|
||
else
|
||
$(this).next().next().autocomplete("destroy");
|
||
{
|
||
$(this).next().next().autocomplete("destroy");
|
||
}
|
||
|
||
$(this).next().next().datepicker("destroy");
|
||
|
||
... | ... | |
$(this).next().next().addClass(types[$(this).val()]['classes'][i]);
|
||
}
|
||
|
||
// add CSS classes
|
||
for (var i in types[$(this).val()]['css_classes'])
|
||
{
|
||
$(this).next().next().addClass(types[$(this).val()]['css_classes'][i]);
|
||
classes.push(types[$(this).val()]['css_classes'][i]);
|
||
}
|
||
|
||
// type returns key (not value), change value input to select
|
||
if (types[$(this).val()]['returns'] == 'key')
|
||
{
|
||
... | ... | |
$(this).next().next().after("<img src='<?php echo url::base() ?>media/images/icons/ico_add.gif' class='expand-button' title='<?php echo __("Multiple choice") ?>'>");
|
||
}
|
||
|
||
$(this).next().next().replaceWith("<select class='v' name='"+$(this).next().next().attr("name")+"'></select>");
|
||
classes.push('v');
|
||
$(this).next().next().replaceWith("<select class='" + classes.join(' ') + "' name='"+$(this).next().next().attr("name")+"'></select>");
|
||
|
||
b = [];
|
||
for (var i in types[$(this).val()]['values'])
|
||
... | ... | |
{
|
||
if (!$(this).next().next().is("input"))
|
||
{
|
||
$(this).next().next().replaceWith("<input class='v' name='"+$(this).next().next().attr("name")+"'>");
|
||
classes.push('v');
|
||
$(this).next().next().replaceWith("<input class='" + classes.join(' ') + "' name='"+$(this).next().next().attr("name")+"'>");
|
||
$(this).next().next().next().remove();
|
||
}
|
||
}
|
||
... | ... | |
|
||
$(".v").die('blur').live('blur', function (){
|
||
var is_multiple = ($(this).attr("multiple") == 'multiple');
|
||
|
||
var length = $(this).children("option").length;
|
||
|
||
if (is_multiple)
|
||
... | ... | |
$(".filter_div:last .t").trigger("change");
|
||
$("#add_button").click();
|
||
$(".filter_div:first .n").removeAttr("checked");
|
||
|
||
return false;
|
||
});
|
||
|
||
... | ... | |
<?php echo form::checkbox ('on['.$i.']', 1, $states[$i], " class='n'") ?>
|
||
<?php echo form::dropdown ('types['.$i.']', $type_options, $type, " class='t'") ?>
|
||
<?php echo form::dropdown ('opers['.$i.']', $operation_options, $operations[$i], " class='o'") ?>
|
||
<?php echo form::input(array('name' => 'values['.$i.'][]', 'value' => $values[$i][0], 'class' => 'v')) ?>
|
||
<?php echo form::input(array('name' => 'values['.$i.'][]', 'value' => $values[$i][0], 'class' => implode(' ', array_merge(array('v'), $classes)))) ?>
|
||
</div>
|
||
<?php endforeach ?>
|
||
|
Také k dispozici: Unified diff
Novinky:
- hodnoty filtru lze opatrit CSS tridami
Upravy:
- predvyplneny subnet u filtru zarizeni