advanced search ajax callback for dynamic form building are almost working + started css
This commit is contained in:
parent
bf5f1a63ff
commit
1ee4e95491
BIN
sites/all/modules/gui/materiobasemod/images/addfilter.png
Normal file
BIN
sites/all/modules/gui/materiobasemod/images/addfilter.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 290 B |
129
sites/all/modules/gui/materiobasemod/images/addfilter.svg
Normal file
129
sites/all/modules/gui/materiobasemod/images/addfilter.svg
Normal file
@ -0,0 +1,129 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
id="svg2"
|
||||
xml:space="preserve"
|
||||
width="20"
|
||||
height="20"
|
||||
viewBox="0 0 20 20"
|
||||
sodipodi:docname="addcriteria.svg"
|
||||
inkscape:version="0.92.2 5c3e80d, 2017-08-06"
|
||||
inkscape:export-filename="/home/bach/Sites/materio/base_d7/sites/all/modules/gui/materiobasemod/images/addcriteria.png"
|
||||
inkscape:export-xdpi="72"
|
||||
inkscape:export-ydpi="72"><metadata
|
||||
id="metadata8"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs6"><clipPath
|
||||
clipPathUnits="userSpaceOnUse"
|
||||
id="clipPath22"><path
|
||||
d="M 1.148,0.842 H 13.853 V 14.158 H 1.148 Z"
|
||||
id="path20"
|
||||
inkscape:connector-curvature="0" /></clipPath></defs><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1912"
|
||||
inkscape:window-height="1021"
|
||||
id="namedview4"
|
||||
showgrid="false"
|
||||
inkscape:zoom="23.6"
|
||||
inkscape:cx="11.241365"
|
||||
inkscape:cy="14.13105"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="28"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="g4568-6" /><g
|
||||
id="g10"
|
||||
inkscape:groupmode="layer"
|
||||
inkscape:label="search"
|
||||
transform="matrix(1.3333333,0,0,-1.3333333,0,20)"><g
|
||||
id="g12"
|
||||
transform="translate(-16.966507,1.8164)"><path
|
||||
d="M 0,0 0.975,-0.975 5.188,3.238 4.213,4.213 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
id="path14"
|
||||
inkscape:connector-curvature="0" /></g><g
|
||||
id="g16"
|
||||
transform="translate(-18.114407)"><g
|
||||
id="g18"
|
||||
clip-path="url(#clipPath22)"><g
|
||||
id="g24"
|
||||
transform="translate(8.7549,14.1582)"><path
|
||||
d="M 0,0 C -0.688,0 -1.35,-0.119 -1.967,-0.351 -2.581,-0.583 -3.13,-0.935 -3.599,-1.398 -4.067,-1.862 -4.443,-2.442 -4.716,-3.125 -4.99,-3.809 -5.128,-4.614 -5.128,-5.52 c 0,-0.904 0.138,-1.712 0.412,-2.402 0.273,-0.687 0.644,-1.268 1.102,-1.725 0.458,-0.459 1.005,-0.809 1.623,-1.041 0.623,-0.232 1.292,-0.35 1.991,-0.35 0.698,0 1.365,0.118 1.982,0.35 0.615,0.232 1.159,0.582 1.617,1.041 0.458,0.457 0.826,1.038 1.094,1.724 0.268,0.691 0.405,1.499 0.405,2.403 0,0.906 -0.139,1.711 -0.412,2.395 C 4.413,-2.442 4.041,-1.861 3.583,-1.397 3.124,-0.934 2.581,-0.582 1.968,-0.351 1.351,-0.119 0.688,0 0,0 m -0.016,-9.571 c -0.517,0 -0.988,0.099 -1.399,0.294 -0.412,0.195 -0.766,0.472 -1.054,0.825 -0.285,0.349 -0.506,0.779 -0.656,1.278 -0.148,0.494 -0.225,1.05 -0.225,1.654 0,0.605 0.077,1.159 0.225,1.647 0.15,0.493 0.371,0.924 0.656,1.279 0.287,0.358 0.642,0.638 1.054,0.833 0.411,0.196 0.882,0.293 1.399,0.293 0.507,0 0.973,-0.097 1.384,-0.293 0.411,-0.195 0.766,-0.472 1.054,-0.825 0.285,-0.35 0.506,-0.78 0.657,-1.278 0.149,-0.495 0.224,-1.052 0.224,-1.656 0,-0.602 -0.075,-1.159 -0.224,-1.654 C 2.928,-7.672 2.707,-8.103 2.422,-8.453 2.135,-8.805 1.78,-9.082 1.368,-9.277 0.957,-9.472 0.491,-9.571 -0.016,-9.571"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
id="path26"
|
||||
inkscape:connector-curvature="0" /></g><g
|
||||
id="g28"
|
||||
transform="translate(9.4307,8.6182)"><path
|
||||
d="m 0,0 c 0,-0.259 -0.084,-0.464 -0.251,-0.615 -0.167,-0.153 -0.364,-0.229 -0.592,-0.229 -0.235,0 -0.436,0.076 -0.603,0.229 -0.167,0.151 -0.251,0.356 -0.251,0.615 0,0.265 0.084,0.474 0.251,0.626 0.167,0.151 0.368,0.228 0.603,0.228 0.228,0 0.425,-0.077 0.592,-0.228 C -0.084,0.474 0,0.265 0,0"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
id="path30"
|
||||
inkscape:connector-curvature="0" /></g></g></g><g
|
||||
transform="matrix(-0.93526845,-0.63921764,0.93526845,-0.63921764,8.902391,13.772511)"
|
||||
id="g4568-7"
|
||||
style="stroke-width:0.91451848" /><g
|
||||
transform="matrix(-0.6316744,0.70710678,-0.6316744,-0.70710678,6.0298881,6.3370541)"
|
||||
id="g4568-6"
|
||||
style="stroke-width:1.05802488"><g
|
||||
id="g4641"><g
|
||||
style="stroke-width:0.79386932"
|
||||
id="g4568"
|
||||
transform="matrix(1.3881038,0.3881038,0.3881038,1.3881038,-3.1094674,19.762142)"><path
|
||||
d="M 0,0 0.975,-0.975 5.188,3.238 4.213,4.213 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.79386932"
|
||||
id="path4566"
|
||||
inkscape:connector-curvature="0" /></g><path
|
||||
d="m 3.6069436,26.478553 0.9749999,-0.975 4.2130001,4.213 -0.975,0.975 z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.05802488"
|
||||
id="path4566-2"
|
||||
inkscape:connector-curvature="0" /></g><rect
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#000001;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.79351866;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
id="rect4658"
|
||||
width="2.9882731"
|
||||
height="12.457628"
|
||||
x="0.2938301"
|
||||
y="-7.3917599"
|
||||
transform="matrix(-0.70710676,-0.70710676,-0.70710678,0.70710678,-1.3605447e-7,1.3487158e-7)"
|
||||
ry="1.3029661"
|
||||
rx="1.4585619" /><rect
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#000001;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.79351866;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
id="rect4658-7"
|
||||
width="2.2245762"
|
||||
height="13.945275"
|
||||
x="0.05065766"
|
||||
y="-5.1846709"
|
||||
ry="1.4585619"
|
||||
rx="1.0858051"
|
||||
transform="matrix(0.70710678,-0.70710678,-0.70710678,-0.70710678,0,0)" /></g><g
|
||||
id="g4634"
|
||||
transform="translate(-19.369704,-16.144068)"><path
|
||||
d="M 8.8885816,13.772511 H 7.0648081 V 4.8907006 h 1.8237735 z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1"
|
||||
id="path4566-5"
|
||||
inkscape:connector-curvature="0" /><g
|
||||
style="stroke-width:0.91451848"
|
||||
id="g4568-7-9"
|
||||
transform="matrix(-0.93526847,-0.63921764,0.93526847,-0.63921764,8.888582,5.6093)"><path
|
||||
d="M 0,0 0.975,-0.975 5.188,3.238 4.213,4.213 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.91451848"
|
||||
id="path4566-5-1"
|
||||
inkscape:connector-curvature="0" /></g></g><path
|
||||
d="m -10.544509,-9.1411866 c 0,0.259 -0.084,0.464 -0.251,0.615 -0.167,0.153 -0.364,0.229 -0.592,0.229 -0.235,0 -0.436,-0.076 -0.603,-0.229 -0.167,-0.151 -0.251,-0.356 -0.251,-0.615 0,-0.265 0.084,-0.474 0.251,-0.626 0.167,-0.151 0.368,-0.228 0.603,-0.228 0.228,0 0.425,0.077 0.592,0.228 0.167,0.152 0.251,0.361 0.251,0.626"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.99999994"
|
||||
id="path30-2"
|
||||
inkscape:connector-curvature="0" /></g></svg>
|
After Width: | Height: | Size: 8.2 KiB |
@ -613,7 +613,7 @@ function materio_search_api_search_form($form, &$form_state){
|
||||
$args = arg();
|
||||
$path = array_shift($args);
|
||||
// dsm($args, 'args');
|
||||
if($args[0] == "advanced"){
|
||||
if(isset($args[0]) && $args[0] == "advanced"){
|
||||
$advanced = true;
|
||||
array_shift($args);
|
||||
// dsm($args, 'shifted arsg');
|
||||
@ -734,44 +734,145 @@ function materio_search_api_search_form_submit($form, &$form_state){
|
||||
function materio_search_api_advanced_search_form($form, &$form_state){
|
||||
// dsm($form_state, 'form_state');
|
||||
// dsm($form, 'form');
|
||||
global $user;
|
||||
// global $user;
|
||||
$form = array();
|
||||
|
||||
// add a back to search/base home bouton if on explore/foo
|
||||
$args = arg();
|
||||
$path = array_shift($args);
|
||||
|
||||
// add a back to search/base home bouton if on explore/foo
|
||||
if ($path == 'explore' || $path == 'bookmarks' || $path == 'lists' ) {
|
||||
$link = l('<i class="fi-home"></i>', base_path().'actuality', array(
|
||||
'html'=>true,
|
||||
'attributes'=>array('class'=>'back-search-home')
|
||||
));
|
||||
|
||||
$form['actu'] = array(
|
||||
'#type' => 'markup',
|
||||
'#markup' => $link,
|
||||
);
|
||||
}
|
||||
|
||||
$form['searchfield'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => $path == 'explore' ? $keys : $default_value, // TODO: set the search page path global or a variable in settings
|
||||
// '#autocomplete_path' => 'materiosearchapi/autocomplete/searchapi',
|
||||
//'#autocomplete_path' => 'materiosearchapi/autocomplete/dbselect',
|
||||
'#size' => 30,
|
||||
'#maxlength' => 1024,
|
||||
'#attributes' => array("default"=>$default_value),
|
||||
// filters
|
||||
$form['filters'] = array(
|
||||
'#type' => 'container',
|
||||
'#prefix' => '<div id="advancedsearch-filters">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
// building first level texonomy tree
|
||||
$taxotree = taxonomy_get_tree(15, 0, 1, false);
|
||||
// dsm($taxotree, "taxotree");
|
||||
$level_0_ops = array(0=>t("Choose a filter"));
|
||||
foreach ($taxotree as $index => $term) {
|
||||
$level_0_ops[$term->tid] = $term->name;
|
||||
}
|
||||
|
||||
$form['create'] = array(
|
||||
$filterlines = isset($form_state['values']['filterlines']) ? $form_state['values']['filterlines'] : 1;
|
||||
|
||||
if (!empty($form_state['triggering_element'])) {
|
||||
dsm($form_state['values'], 'form state values');
|
||||
}
|
||||
|
||||
if(isset($form_state['triggering_element']['#name']) && $form_state['triggering_element']['#name'] == 'addfilters'){
|
||||
$filterlines = $filterlines + 1;
|
||||
}
|
||||
|
||||
$form['filterlines'] = array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => $filterlines,
|
||||
);
|
||||
|
||||
// build filters lines (ajax enabled)
|
||||
for ($i=0; $i < $filterlines; $i++) {
|
||||
|
||||
$form['filters']['filterline-'.$i] = array(
|
||||
'#type' => 'container',
|
||||
'#attributes' => array(
|
||||
'class' => array("filter-line")
|
||||
)
|
||||
);
|
||||
|
||||
$form['filters']['filterline-'.$i]['filter-'.$i.'-0'] = array(
|
||||
'#type' => 'select',
|
||||
'#options' => $level_0_ops,
|
||||
'#ajax' => array(
|
||||
'callback' => 'materio_search_api_advanced_search_callback',
|
||||
'wrapper' => 'advancedsearch-filters',
|
||||
// 'methode' => 'replace',
|
||||
// 'effect' => 'fade',
|
||||
),
|
||||
);
|
||||
|
||||
// add level 1 filter if level 0 chosen
|
||||
if(isset($form_state["values"]['filter-'.$i.'-0'])
|
||||
& $form_state["values"]['filter-'.$i.'-0']
|
||||
){
|
||||
|
||||
$value = $form_state["values"]['filter-'.$i.'-0'];
|
||||
|
||||
$taxotree1 = taxonomy_get_tree(15, $value, 1, false);
|
||||
dsm($taxotree1, "taxotree1");
|
||||
$level_1_ops = array(
|
||||
0=>t("Choose a filter")
|
||||
);
|
||||
foreach ($taxotree1 as $index => $term) {
|
||||
$level_1_ops[$term->tid] = $term->name;
|
||||
}
|
||||
|
||||
$form['filters']['filterline-'.$i]['filter-'.$i.'-1'] = array(
|
||||
'#type' => 'select',
|
||||
'#options' => $level_1_ops,
|
||||
'#ajax' => array(
|
||||
'callback' => 'materio_search_api_advanced_search_callback',
|
||||
'wrapper' => 'advancedsearch-filters',
|
||||
'methode' => 'replace',
|
||||
// 'effect' => 'fade',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// add a new line of criterias
|
||||
$form['addfilters'] = array(
|
||||
'#type' => 'image_button',
|
||||
'#src' => drupal_get_path('module', 'materio_search_api') . '/images/search.png',
|
||||
'#value' => t('Search'),
|
||||
'#src' => drupal_get_path('module', 'materio_search_api') . '/images/addfilter.png',
|
||||
'#title' => t('Add a filter line'),
|
||||
'#default_value' => 0,
|
||||
'#return_value' => 1,
|
||||
'#name' => "addfilters",
|
||||
'#executes_submit_callback' => false,
|
||||
'#ajax' => array(
|
||||
'callback' => 'materio_search_api_advanced_search_callback',
|
||||
'wrapper' => 'advancedsearch-filters',
|
||||
'trigger_as' => array("name"=>"addfilters"),
|
||||
// 'methode' => 'replacewith',
|
||||
// 'speed' => 5000,
|
||||
// 'effect' => 'slide',
|
||||
),
|
||||
);
|
||||
|
||||
// submit
|
||||
// $form['create'] = array(
|
||||
// '#type' => 'image_button',
|
||||
// '#src' => drupal_get_path('module', 'materio_search_api') . '/images/search.png',
|
||||
// '#value' => t('Search'),
|
||||
// '#name' => "search",
|
||||
// '#executes_submit_callback' => false,
|
||||
// );
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
function materio_search_api_advanced_search_callback($form, $form_state) {
|
||||
// dsm($form_state, "callback form state");
|
||||
// $form["filters"]['test']= array(
|
||||
// "#markup" => "test",
|
||||
// );
|
||||
return $form['filters'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* viewmode
|
||||
*/
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1086,8 +1086,33 @@ $headerouterheight:$headerheight+$headerpaddingtop+$headerpaddingbottom;
|
||||
#edit-bundles-filter{display:none;}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#block-materio-search-api-mo-searchapi-advanced-search{
|
||||
// @include inlineblock(); vertical-align: middle ;
|
||||
// position:absolute; top:10px; right:0;
|
||||
float:right;
|
||||
>.inner{
|
||||
@include inlineblock(); margin:0 0 0 10px;
|
||||
padding: 3px 10px; background-color:#fff; @include rounded(3px);
|
||||
@include shadowBtn(); text-align: right;
|
||||
}
|
||||
}
|
||||
|
||||
#materio-search-api-advanced-search-form{
|
||||
.filter-line{
|
||||
.form-item.form-type-select{
|
||||
display:inline-block;
|
||||
vertical-align: middle;
|
||||
@include fs12; line-height:1;
|
||||
padding-right:3em;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#center{
|
||||
// background-color: #e6e6e6;
|
||||
@include rounded(10px);
|
||||
|
Loading…
x
Reference in New Issue
Block a user