Difference between revisions of "Widget:RAPIDFilter"

From Open Energy Information

(adding hydro project types)
(update hydro type functionality)
Line 21: Line 21:
 
               <p id="hydro-type-toggle" style="margin-left:20px; font-size:x-small; color:#337AB7; cursor:pointer;">narrow by hydropower project type <i class="fa fa-chevron-down"></i></p>
 
               <p id="hydro-type-toggle" style="margin-left:20px; font-size:x-small; color:#337AB7; cursor:pointer;">narrow by hydropower project type <i class="fa fa-chevron-down"></i></p>
 
               <div class="hydro-group hidden" style="margin-left:20px;">
 
               <div class="hydro-group hidden" style="margin-left:20px;">
                 <li><input id="hydro1" class="hydro-filter" type="checkbox" value="conduit"/><label for="hydro1">conduit</label><a href="javascript:void(0);" class="filterOptionOnly">only</a></li>
+
                 <li><input id="hydro0" class="hydro-filter" type="radio" value="unfiltered" name="hydroType" checked/><label for="hydro0">all hydropower</label></li>
                 <li><input id="hydro2" class="hydro-filter" type="checkbox" value="conventional"/><label for="hydro2">conventional</label><a href="javascript:void(0);" class="filterOptionOnly">only</a></li>
+
                <li><input id="hydro1" class="hydro-filter" type="radio" value="conduit" name="hydroType"/><label for="hydro1">conduit</label></li>
                 <li><input id="hydro3" class="hydro-filter" type="checkbox" value="non-powered dam"/><label for="hydro3">non-powered dam</label><a href="javascript:void(0);" class="filterOptionOnly">only</a></li>
+
                 <li><input id="hydro2" class="hydro-filter" type="radio" value="conventional" name="hydroType"/><label for="hydro2">conventional</label></li>
                 <li><input id="hydro4" class="hydro-filter" type="checkbox" value="pumped storage"/><label for="hydro4">pumped storage</label><a href="javascript:void(0);" class="filterOptionOnly">only</a></li>
+
                 <li><input id="hydro3" class="hydro-filter" type="radio" value="non-powered dam" name="hydroType"/><label for="hydro3">non-powered dam</label></li>
 +
                 <li><input id="hydro4" class="hydro-filter" type="radio" value="pumped storage" name="hydroType"/><label for="hydro4">pumped storage</label></li>
 
               </div>
 
               </div>
 
             </div>
 
             </div>
Line 188: Line 189:
 
       $('.hydro-filter:checked').each(function(){
 
       $('.hydro-filter:checked').each(function(){
 
         hydroProjectTypeValues.push(this.value);
 
         hydroProjectTypeValues.push(this.value);
 +
        hydroProjectTypeValues.push('noHydroType');
 
       });
 
       });
  
Line 259: Line 261:
  
 
         $('#RRFilter input:checkbox').prop('checked',true);
 
         $('#RRFilter input:checkbox').prop('checked',true);
        $('#RRFilter .hydro-filter').prop('checked',false);
 
 
         //clear all function
 
         //clear all function
 
         $('#clearAll').click(function(){$('input:checkbox').attr('checked',false);$('.rapid-results').css('display','none');});
 
         $('#clearAll').click(function(){$('input:checkbox').attr('checked',false);$('.rapid-results').css('display','none');});
Line 421: Line 422:
 
             $('.hydro-filter').attr('checked',false).attr('disabled', true);
 
             $('.hydro-filter').attr('checked',false).attr('disabled', true);
 
             $('.hydro-group label').addClass('text-muted');
 
             $('.hydro-group label').addClass('text-muted');
             $('#RRFilter .hydro-group .filterOptionOnly').addClass('hidden');
+
             //$('#RRFilter .hydro-group .filterOptionOnly').addClass('hidden');
 
           }else{
 
           }else{
 
             $('.hydro-filter').attr('disabled',false);
 
             $('.hydro-filter').attr('disabled',false);
 
             $('.hydro-group label').removeClass('text-muted');
 
             $('.hydro-group label').removeClass('text-muted');
             $('#RRFilter .hydro-group .filterOptionOnly').removeClass('hidden');
+
             //$('#RRFilter .hydro-group .filterOptionOnly').removeClass('hidden');
 
           }
 
           }
 
         });
 
         });
Line 503: Line 504:
 
     in_array(techValues[i], techCategory) && in_array($(el).data('topic'),showVals) && in_array($(el).data('sectionCode'),showVals) && in_array(agencyValue, resultAgencies)
 
     in_array(techValues[i], techCategory) && in_array($(el).data('topic'),showVals) && in_array($(el).data('sectionCode'),showVals) && in_array(agencyValue, resultAgencies)
 
   ){
 
   ){
     if(hydroProjectTypeValues.length>=1){
+
     if(hydroProjectTypeValues.length >= 1){
 +
      if(hydroProjectTypeValues[0] === "unfiltered"){
 +
        return true;
 +
      }
 +
      showVals.push('noHydroType');
 
       foo = $(el).data('hydroType').split(', ');
 
       foo = $(el).data('hydroType').split(', ');
      console.log(foo);
 
 
       for(h=0;h<foo.length;h++)
 
       for(h=0;h<foo.length;h++)
 
         if(in_array(foo[h], showVals)){
 
         if(in_array(foo[h], showVals)){

Revision as of 14:38, 19 July 2019

This widget is used to filter regulatory roadmap sections for the RAPID Regulatory Roadmap page.