Show
Ignore:
Timestamp:
05.06.2014 09:57:40 (5 years ago)
Author:
kjdon
Message:

sortfield option. will now display even when there is only one option. this allows user to choose ascending/descending for that one sortfield. add code to use _textsortbynone_ macro for 'none' option.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/runtime-src/src/recpt/queryaction.cpp

    r28956 r29087  
    604604                       displayclass &disp) { 
    605605 
    606   // we need at least two options here to continue 
    607   if (option.validValues.size() < 2) { 
     606  // we need at one sort option here to continue 
     607  if (option.validValues.size() < 1) { 
    608608    return; 
    609609  } 
    610  
     610  if (option.validValues.size() == 1) { 
     611    // we don't need a drop down list, just the value 
     612    text_t value = option.defaultValue; 
     613    text_t macrovalue = ""; 
     614    if (value == "rank") { 
     615      macrovalue = "_query:textsortbyrank_"; 
     616    } else if (value == "none") { 
     617      return; // no sorting is the only option, so don't display anything 
     618    } else { 
     619      macrovalue = "_"+value+"_"; 
     620    } 
     621    disp.setmacro ("sfselection", displayclass::defaultpackage, macrovalue); 
     622    return; 
     623  } 
     624  // if we have more than two options, make a drop down list 
    611625  text_t macrovalue = "<select name=\"sf\">\n"; 
    612626   
     
    618632  //  int valid_count = 0; 
    619633  while (thisvalue != endvalue) { 
     634    macrovalue += "<option value=\"" + *thisvalue + "\""; 
     635    if (current_value == *thisvalue) 
     636      macrovalue += " selected"; 
     637    macrovalue += ">"; 
    620638    if (*thisvalue == "rank") { 
    621        macrovalue += "<option value=\"rank\""; 
    622        if (current_value == "rank") { 
    623      macrovalue += " selected"; 
    624        } 
    625        macrovalue += ">_query:textsortbyrank_\n"; 
     639       macrovalue += "_query:textsortbyrank_"; 
     640    } else if (*thisvalue == "none") { 
     641      macrovalue += "_query:textsortbynone_"; 
    626642    } else { 
    627       macrovalue += "<option value=\"" + *thisvalue + "\""; 
    628       if (current_value == *thisvalue) 
    629     macrovalue += " selected"; 
    630       macrovalue += ">_" + *thisvalue + "_\n"; 
    631     } 
     643      macrovalue += "_" + *thisvalue + "_"; 
     644    } 
     645    macrovalue += "</option>/n"; 
    632646    ++thisvalue; 
    633647  }