2012-03-26 19:56:44 +02:00
|
|
|
<div class="attributes form">
|
|
|
|
<?php echo $this->Form->create('Attribute');?>
|
2011-11-26 10:45:31 +01:00
|
|
|
<fieldset>
|
2012-03-21 21:25:16 +01:00
|
|
|
<legend><?php echo __('Search Attribute'); ?></legend>
|
2011-11-26 10:45:31 +01:00
|
|
|
<?php
|
2013-02-27 17:15:09 +01:00
|
|
|
echo $this->Form->input('keyword', array('type' => 'textarea', 'label' => 'Containing the following expressions'));
|
|
|
|
echo $this->Form->input('keyword2', array('type' => 'textarea', 'label' => 'Excluding the following events'));
|
2013-03-19 11:54:14 +01:00
|
|
|
echo $this->Form->input('org', array('type' => 'text', 'label' => 'From the following organisation'));
|
2012-09-18 15:30:32 +02:00
|
|
|
echo $this->Form->input('type', array('between' => $this->Html->div('forminfo', '', array('id' => 'AttributeTypeDiv'))));
|
|
|
|
echo $this->Form->input('category', array('between' => $this->Html->div('forminfo', '', array('id' => 'AttributeCategoryDiv'))));
|
2011-11-26 10:45:31 +01:00
|
|
|
?>
|
|
|
|
</fieldset>
|
|
|
|
<?php echo $this->Form->end(__('Search', true));?>
|
|
|
|
</div>
|
2012-05-29 16:50:45 +02:00
|
|
|
<script type="text/javascript">
|
2012-11-02 11:51:10 +01:00
|
|
|
//
|
|
|
|
//Generate Category / Type filtering array
|
|
|
|
//
|
|
|
|
var category_type_mapping = new Array();
|
|
|
|
|
|
|
|
<?php
|
|
|
|
// all types for Categorie ALL
|
|
|
|
echo "category_type_mapping['ALL'] = {";
|
|
|
|
$first = true;
|
|
|
|
foreach ($typeDefinitions as $type => $def) {
|
|
|
|
if ($first) $first = false;
|
|
|
|
else echo ', ';
|
|
|
|
echo "'" . addslashes($type) . "' : '" . addslashes($type) . "'";
|
|
|
|
}
|
|
|
|
echo "}; \n";
|
|
|
|
|
|
|
|
//all types for empty Categorie
|
|
|
|
echo "category_type_mapping[''] = {";
|
|
|
|
$first = true;
|
|
|
|
foreach ($typeDefinitions as $type => $def) {
|
|
|
|
if ($first) $first = false;
|
|
|
|
else echo ', ';
|
|
|
|
echo "'" . addslashes($type) . "' : '" . addslashes($type) . "'";
|
|
|
|
}
|
|
|
|
echo "}; \n";
|
|
|
|
|
|
|
|
// Types per Categorie
|
|
|
|
foreach ($categoryDefinitions as $category => $def) {
|
|
|
|
echo "category_type_mapping['" . addslashes($category) . "'] = {";
|
|
|
|
$first = true;
|
|
|
|
foreach ($def['types'] as $type) {
|
|
|
|
if ($first) $first = false;
|
|
|
|
else echo ', ';
|
|
|
|
echo "'" . addslashes($type) . "' : '" . addslashes($type) . "'";
|
|
|
|
}
|
|
|
|
echo "}; \n";
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
|
|
//
|
|
|
|
//Generate Type / Category filtering array
|
|
|
|
//
|
|
|
|
var type_category_mapping = new Array();
|
|
|
|
|
|
|
|
<?php
|
|
|
|
// all categories for Type ALL
|
|
|
|
echo "type_category_mapping['ALL'] = {";
|
|
|
|
$first = true;
|
|
|
|
foreach ($categoryDefinitions as $type => $def) {
|
|
|
|
if ($first) $first = false;
|
|
|
|
else echo ', ';
|
|
|
|
echo "'" . addslashes($type) . "' : '" . addslashes($type) . "'";
|
|
|
|
}
|
|
|
|
echo "}; \n";
|
|
|
|
|
|
|
|
// Categories per Type
|
|
|
|
foreach ($typeDefinitions as $type => $def) {
|
|
|
|
echo "type_category_mapping['" . addslashes($type) . "'] = {";
|
|
|
|
$first = true;
|
|
|
|
foreach ($categoryDefinitions as $category => $def) {
|
|
|
|
if ( in_array ( $type , $def['types'])) {
|
|
|
|
if ($first) $first = false;
|
|
|
|
else echo ', ';
|
|
|
|
echo "'" . addslashes($category) . "' : '" . addslashes($category) . "'";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo "}; \n";
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
|
|
function formCategoryChanged(id) {
|
|
|
|
var alreadySelected = $('#AttributeType').val();
|
|
|
|
showFormInfo(id); // display the tooltip
|
|
|
|
// empty the types
|
|
|
|
document.getElementById("AttributeType").options.length = 1;
|
|
|
|
// add new items to options
|
|
|
|
var options = $('#AttributeType').prop('options');
|
|
|
|
$.each(category_type_mapping[$('#AttributeCategory').val()], function(val, text) {
|
|
|
|
options[options.length] = new Option(text, val);
|
|
|
|
if (val == alreadySelected) {
|
|
|
|
options[options.length-1].selected = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
// enable the form element
|
|
|
|
$('#AttributeType').prop('disabled', false);
|
|
|
|
if ("ALL" == $('#AttributeCategory').val()) {
|
|
|
|
//alert($('#AttributeCategory').val());
|
|
|
|
$('#AttributeCategoryDiv').hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function formTypeChanged(id) {
|
|
|
|
var alreadySelected = $('#AttributeCategory').val();
|
|
|
|
showFormInfo(id); // display the tooltip
|
|
|
|
// empty the categories
|
|
|
|
document.getElementById("AttributeCategory").options.length = 2;
|
|
|
|
// add new items to options
|
|
|
|
var options = $('#AttributeCategory').prop('options');
|
|
|
|
$.each(type_category_mapping[$('#AttributeType').val()], function(val, text) {
|
|
|
|
options[options.length] = new Option(text, val);
|
|
|
|
if (val == alreadySelected) {
|
|
|
|
options[options.length-1].selected = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
// enable the form element
|
|
|
|
$('#AttributeCategory').prop('disabled', false);
|
|
|
|
if ("ALL" == $('#AttributeType').val()) {
|
|
|
|
//alert($('#AttributeType').val());
|
|
|
|
$('#AttributeTypeDiv').hide();
|
|
|
|
}
|
|
|
|
}
|
2012-05-29 16:50:45 +02:00
|
|
|
|
|
|
|
var formInfoValues = new Array();
|
2012-09-18 15:30:32 +02:00
|
|
|
<?php
|
2012-09-19 11:05:10 +02:00
|
|
|
foreach ($typeDefinitions as $type => $def) {
|
2012-09-18 15:30:32 +02:00
|
|
|
$info = isset($def['formdesc']) ? $def['formdesc'] : $def['desc'];
|
|
|
|
echo "formInfoValues['$type'] = \"$info\";\n";
|
|
|
|
}
|
|
|
|
|
2012-09-19 11:05:10 +02:00
|
|
|
foreach ($categoryDefinitions as $category => $def) {
|
2012-09-18 15:30:32 +02:00
|
|
|
$info = isset($def['formdesc']) ? $def['formdesc'] : $def['desc'];
|
|
|
|
echo "formInfoValues['$category'] = \"$info\";\n";
|
|
|
|
}
|
2012-11-02 11:51:10 +01:00
|
|
|
$this->Js->get('#AttributeCategory')->event('change', 'formCategoryChanged("#AttributeCategory")');
|
2012-09-18 15:30:32 +02:00
|
|
|
$this->Js->get('#AttributeCategory')->event('change', 'showFormInfo("#AttributeCategory")');
|
2012-11-02 11:51:10 +01:00
|
|
|
$this->Js->get('#AttributeType')->event('change', 'formTypeChanged("#AttributeType")');
|
|
|
|
$this->Js->get('#AttributeType')->event('change', 'showFormInfo("#AttributeType")');
|
2012-05-29 16:50:45 +02:00
|
|
|
?>
|
|
|
|
|
|
|
|
formInfoValues['ALL'] = '';
|
2012-11-02 11:51:10 +01:00
|
|
|
formInfoValues[''] = '';
|
2012-05-29 16:50:45 +02:00
|
|
|
|
|
|
|
function showFormInfo(id) {
|
|
|
|
idDiv = id+'Div';
|
2012-11-02 11:51:10 +01:00
|
|
|
if (("ALL" != $(id).val()) && ("" != $(id).val())) {
|
2012-05-29 16:50:45 +02:00
|
|
|
// LATER use nice animations
|
|
|
|
//$(idDiv).hide('fast');
|
|
|
|
// change the content
|
|
|
|
var value = $(id).val(); // get the selected value
|
|
|
|
$(idDiv).html(formInfoValues[value]); // search in a lookup table
|
|
|
|
|
|
|
|
// show it again
|
|
|
|
$(idDiv).fadeIn('slow');
|
2012-11-02 11:51:10 +01:00
|
|
|
} else {
|
|
|
|
$(idDiv).hide();
|
|
|
|
}
|
2012-05-29 16:50:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// hide the formInfo things
|
|
|
|
$('#AttributeTypeDiv').hide();
|
|
|
|
$('#AttributeCategoryDiv').hide();
|
|
|
|
|
|
|
|
</script>
|
2012-09-18 15:30:32 +02:00
|
|
|
<?php echo $this->Js->writeBuffer(); // Write cached scripts
|