OSDN Git Service

Profile検索欄を動的に表示
authorCake <cake_67@users.sourceforge.jp>
Wed, 15 Dec 2010 06:53:15 +0000 (15:53 +0900)
committerCake <cake_67@users.sourceforge.jp>
Wed, 15 Dec 2010 06:53:15 +0000 (15:53 +0900)
app/views/elements/searchbox_detail.ctp
app/webroot/css/base.css

index 8dc8755..cfcaaee 100644 (file)
@@ -6,6 +6,73 @@ if (!isset($keyword)) {
 $search_models_num = count($search_cols);
 $m = 1;
 $isLast = false;
+
+$search_select_options = array();
+$search = array();
+
+$display_items = array('name', 'system_id', 'public_flag', 'status');
+
+foreach($search_cols as $model => $settings) {
+       $search_cols_num = 0;
+       $i = 1;
+       if ($m == $search_models_num) {
+               $isLast = true;
+               $search_cols_num = count($settings);
+       }
+
+       foreach ($settings as $field => $options) {
+               $fieldname = $model. '.'. 'keyword.'. $field;
+               $fieldClass = 'SearchColumn_'. $field;
+
+               $display_style = false;
+               if (!in_array($field, $display_items)) {
+                       $search_select_options[$field] = $options['name'];
+                       if (!isset($this->data[$model]['keyword'][$field]['value']) || empty($this->data[$model]['keyword'][$field]['value'])) {
+                               $display_style = 'display:none;';
+                       }
+               }
+
+               $search[$fieldname] = $html->tag('dt',
+                       $options['name'],
+                       array(
+                               'class' => $fieldClass,
+                               'style' => $display_style,
+                       )
+               );
+
+               unset($options['name']);
+               $options['label'] = false;
+               $options['legend'] = false;
+               $options['div'] = array(
+                       'class' => 'inline searchType',
+               );
+
+               $dd_contents = $form->input($fieldname.'.value', $options);
+
+               if (($field != 'public_flag' && $field != 'system_id' && $field != 'status') && (!$isLast || $i != $search_cols_num)) {
+                       $dd_contents .=  $form->input($fieldname.'.type', array_merge($options, array(
+                               'type' => 'radio',
+                               'options' => array(
+                                       'and' => 'AND',
+                                       'or' => 'OR',
+                               ),
+                               'default' => 'and'
+                       )));
+               }
+
+               $search[$fieldname] .= $html->tag('dd', 
+                       $dd_contents,
+                       array(
+                               'class' => $fieldClass,
+                               'style' => $display_style,
+                       )
+               );
+
+               $i++;
+       }
+
+       $m++;
+}
 ?>
 <div class="characters listview searchDetail">
 
@@ -27,55 +94,60 @@ echo $form->create('Character', array(
 ?>
 <p>
 <dl>
-<?php foreach($search_cols as $model => $settings): ?>
+<?php if (!empty($search_select_options)): ?>
+<dt><?php __('Search Target') ?></dt>
+<dd>
 <?php
-$search_cols_num = 0;
-$i = 1;
-if ($m == $search_models_num) {
-       $isLast = true;
-       $search_cols_num = count($settings);
-}
+       echo $form->input('searchSelect', array(
+               'type' => 'select',
+               'label' => false,
+               'id' => 'searchSelect',
+               'div' => array('class' => 'inline'),
+               'options' => $search_select_options,
+       ));
+
+       echo $form->button(sprintf('%s/%s', __('Add', true), __('Delete', true)), array(
+               'type' => 'button',
+               'label' => false,
+       ));
 ?>
-<?php foreach($settings as $field => $options): ?>
-<dt><?php echo $options['name'] ?></dt>
-<dd><?php
-       unset($options['name']);
-       $options['label'] = false;
-       $options['legend'] = false;
-       $options['div'] = array(
-               'class' => 'inline searchType',
-       );
-       $fieldname = $model. '.'. 'keyword.'. $field;
-
-       echo $form->input($fieldname.'.value', $options);
-
-       if (($field != 'public_flag' && $field != 'system_id' && $field != 'status') && (!$isLast || $i != $search_cols_num)) {
-
-               echo $form->input($fieldname.'.type', array_merge($options, array(
-                       'type' => 'radio',
-                       'options' => array(
-                               'and' => 'AND',
-                               'or' => 'OR',
-                       ),
-                       'default' => 'and'
-               )));
+</dd>
+<script language="JavaScript">
+<!--
+$("button").click(function(){
+       var target = $('#searchSelect').val();
+       $('.SearchColumn_'+target).toggle();
+       if ($('.SearchColumn_'+target).css('display') == 'none' && target != 'public_flag' && target != 'status' && target != 'system_id') {
+               $('dd.SearchColumn_'+target+' > div > input').attr('disabled', 'disabled');
+       } else {
+               $('dd.SearchColumn_'+target+' > div > input').attr('disabled', '');
        }
-       $i++;
-?></dd>
-<?php endforeach; ?>
-<?php
-       $m++;
-?>
+});
+//-->
+</script>
+<?php endif; ?>
+
+<?php 
+echo $form->create('Character', array(
+       'url' => array_merge(array(
+               'action' => $this->action), $this->passedArgs
+       ),
+       'id' => 'Search',
+));
+ ?>
+
+<?php foreach($search as $v): ?>
+<?php echo $v; ?>
 <?php endforeach; ?>
+
 </dl>
 </div>
-<?php echo
-       $form->end(__('Search' ,true), array(
-               'class' => 'inline',
-       )); 
-?>
+<?php
+echo $form->end(__('Search' ,true), array(
+       'class' => 'inline',
+)); 
+
 
-<?php 
 echo $form->create('Character', array(
        'url' => array_merge(array(
                'action' => 'index'), $this->passedArgs
index 05cea61..a711deb 100644 (file)
@@ -416,6 +416,7 @@ div.actions ul li a {
        clear: both;
 }
 input[type=submit],
+button[type=button],
 div.actions ul li a,
 td.actions a,
 form .submit input[type=submit] {
@@ -432,6 +433,7 @@ form .submit input[type=submit] {
        min-width: 0;
 }
 div.actions ul li a:hover,
+button[type=button]:hover,
 form .submit input[type=submit]:hover {
        text-decoration: none;
        background: #f0f09a;