Page 1 of 1

Title drop-down list

PostPosted: Thu Dec 10, 2009 1:44 am
by andperry
I notice that the title drop-down list on the edit screen for a record always shows the first record in the table. This raises the following two issues:-

1. It is not possible to use this list to actually go to the first record in the table.

2. The back and forward arrows either side of the list are confusing because they operate in relation to the current record which is not necessarily what is displayed in the list.

Is there any way that the list can be made to display the current record rather than the first record? If this is not practically possible, then would it be possible to place a dummy entry at the start of the list with words such as "Please select record . . ."?

Regards,

Andrew.

PostPosted: Fri Dec 11, 2009 10:04 am
by shannah
This is a bug that has been with Xataface for a while. The title menu is generated by the jumpMenu() method in the ResultController.php class. You can try poking around in there if you want to try to fix it.

Re: Title drop-down list

PostPosted: Wed Jan 13, 2010 7:11 pm
by kevinwen
Hi, Steve

I fixed this bug already. Please take a look at 2 functions modified in ResultController:

Code: Select all
      function getContentsList(){
         
      $selected_url = '';
         
         if (! isset( $this->_contentsList) ){
            
         $this->_contentsList = array();
         if ( $this->getTotalRecords() > 100 ){
            // there are over 100 records in this found set.  It is unfeasible
            // to list them all in the jump menu, so instead we will list ranges
            // of records
            //$totalRecords = $this->getTotalRecords();
            //for ( $i=0; $i<$totalRecords; $i+=$this->_query['-limit']){
            //   $query = array_merge($this->_query, array("-skip"=>$i, "-action"=>"list"));
            //   $link = $this->_buildLink($query);
            //   $this->_contentsList[$link] = ($i+1)." to ".($i+$this->_query['-limit']);
            //   
            //   if ( $this->_resultSet->start() >= $i and $this->_resultSet->start() < ($i+$this->_query['-limit'])){
            //      $selected_url = $link;
            //   }
            //}
            
         
         } else {
            // There are less than 100 records.. Just list them individually
            //$sql = $this->_queryBuilder->select(
            //      array($this->_titleColumn),
            //      array('-skip'=>null, '-limit'=>null)
            //   );
            
            //$res = mysql_query(
            //   $sql,
            //   $this->_db
            //);
            $selected_url = '';
            $titles =& $this->_resultSet->getTitles(false, true,true);
            $index = 0;
            //while ( $row = mysql_fetch_array($res) ){
            $len = count($titles);
            
            for ($index =0 ; $index < $len; $index++){
               //$query = array( "-cursor"=>$index++, "-action"=>'browse');
               $query = array( "-cursor"=>$index, "-action"=>'browse');
               $query = array_merge( $this->_query, $query);
               foreach ($query as $key=>$value) {
                  if ( $value === null ){
                     unset($query[$key]);
                  }
               }
               $link = $this->_buildSetLink($query) ;
         
               //$this->_contentsList[ $link ] = $row[0];
               $this->_contentsList[ $link ] = $titles[$index];
               
               //if ( $index-1 == $this->_query['-cursor'] ){
               if ( $index == $this->_query['-cursor'] ){
                  $selected_url = $link;
               }
            }
         }
      }
      
         
         return array($this->_contentsList, $selected_url);
            
      
      }
      
      function jumpMenu(){
         list($contents, $selected_url) = $this->getContentsList();
         if ( $contents ){
         $html = '<select name="controller" class="jumpMenu" onchange="javascript:window.location=this.options[this.selectedIndex].value;">
            
            ';
         $currentLink = Dataface_LinkTool::buildLink(array());
         $currentLink = preg_replace('/&?-limit=\d+/', '', $currentLink);
            // link sans limit for use in field to specify number of records to be displayed per page
         
         foreach ($contents as $key=>$value){
            
            $selected = $key==$selected_url ? "selected" : '';
            $html .= '
                  <option value="'.$key.'" '.$selected.'>'.$value.'</option>';
         }
         $html .= '</select>';
      } else {
         $html = '';
      }
         return $html;
      
      }


Let me know your thought.

Re: Title drop-down list

PostPosted: Wed Aug 24, 2011 4:01 pm
by thesnowsnake
Wow that looks really impressive and is well documented..

Thanks for the effort

Re: Title drop-down list

PostPosted: Thu Aug 25, 2011 12:04 am
by fantomasdm
Very Very good!!

Re: Title drop-down list

PostPosted: Wed Aug 31, 2011 9:24 am
by andperry
Many thanks for the solution. I've given it a quick try and it seems to work OK.

When might it be incorporated into a release of Xataface?

Thanks,

Andrew Perry.