Ignore:
Timestamp:
Jan 1, 2017, 5:03:41 PM (8 years ago)
Author:
chronos
Message:
  • Added: Show sub-lists in IS item view as multiple subtabs to avoid always loading all subtables at once.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/IS/IS.php

    r837 r843  
    358358    return($Output);
    359359  }
     360 
     361  function ShowTabs($Tabs, $QueryParamName, $TabContent)
     362  {
     363        $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
     364       
     365    if(array_key_exists($QueryParamName, $_GET)) $TabIndex = $_GET[$QueryParamName];
     366      else $TabIndex = 0;
     367
     368    $Output = '<div class="Tab">'.
     369      '<ul>';
     370    foreach($Tabs as $Index => $Tab)
     371    {
     372      $QueryItems[$QueryParamName] = $Index;
     373      if($Index == $TabIndex) $Selected = ' id="selected"';
     374        else $Selected = '';
     375      $Output .= '<li'.$Selected.'><a href="?'.SetQueryStringArray($QueryItems).'">'.$Tab.'</a></li>';
     376    }
     377    $Output .= '</ul></div><div class="TabContent">'.$TabContent.'</div>';
     378    return($Output);
     379  }
    360380
    361381  function ShowView($Table, $Id, $WithoutActions = false)
     
    379399    if($WithoutActions == false)
    380400    {
    381     $Actions = array(
    382       $this->ShowAction('Upravit', '?a=edit&amp;t='.$TableModify.'&amp;i='.$Id,
    383         $this->System->Link('/images/edit.png')),
    384       $this->ShowAction('Seznam', '?a=list&amp;t='.$Table,
    385         $this->System->Link('/images/list.png')),
    386       $this->ShowAction('Odstranit', '?a=delete&amp;t='.$Table.'&amp;i='.$Id,
    387         $this->System->Link('/images/delete.png'), 'Opravdu smazat položku?'),
    388       $this->ShowAction('Přidat', '?a=add&amp;t='.$TableModify,
    389         $this->System->Link('/images/add.png'))
    390     );
    391     if(array_key_exists('ItemActions', $FormClass))
    392     {
    393       foreach($FormClass['ItemActions'] as $Action)
    394       {
    395         $URL = str_replace('#RowId', $Id, $this->System->Link($Action['URL']));
    396         $Actions[] = $this->ShowAction($Action['Caption'], $URL,
    397           $this->System->Link('/images/action.png'));
    398       }
    399     }
    400     $Output .= '<ul class="ActionMenu">';
    401     foreach($Actions as $Action)
    402     {
    403       $Output .= '<li>'.$Action.'</li>';
    404     }
    405     $Output .= '</ul><br/>';
     401      $Actions = array(
     402        $this->ShowAction('Upravit', '?a=edit&amp;t='.$TableModify.'&amp;i='.$Id,
     403          $this->System->Link('/images/edit.png')),
     404        $this->ShowAction('Seznam', '?a=list&amp;t='.$Table,
     405          $this->System->Link('/images/list.png')),
     406        $this->ShowAction('Odstranit', '?a=delete&amp;t='.$Table.'&amp;i='.$Id,
     407          $this->System->Link('/images/delete.png'), 'Opravdu smazat položku?'),
     408        $this->ShowAction('Přidat', '?a=add&amp;t='.$TableModify,
     409          $this->System->Link('/images/add.png'))
     410      );
     411      if(array_key_exists('ItemActions', $FormClass))
     412      {
     413        foreach($FormClass['ItemActions'] as $Action)
     414        {
     415          $URL = str_replace('#RowId', $Id, $this->System->Link($Action['URL']));
     416          $Actions[] = $this->ShowAction($Action['Caption'], $URL,
     417            $this->System->Link('/images/action.png'));
     418        }
     419      }
     420      $Output .= '<ul class="ActionMenu">';
     421      foreach($Actions as $Action)
     422      {
     423        $Output .= '<li>'.$Action.'</li>';
     424      }
     425      $Output .= '</ul><br/>';
     426    }
    406427
    407428    // Show ManyToOne relations
     429    $Tabs = array();
    408430    foreach($Form->Definition['Items'] as $Index => $Item)
    409431    if((array_key_exists($Item['Type'], $this->System->FormManager->FormTypes) and
    410432    ($this->System->FormManager->FormTypes[$Item['Type']]['Type'] == 'ManyToOne')))
    411433    {
    412       $Output .= $this->ShowList($this->System->FormManager->FormTypes[$Item['Type']]['Table'], '`'.
    413         $this->System->FormManager->FormTypes[$Item['Type']]['Ref'].'`='.$Id, $Item['Caption'],
    414         $this->System->FormManager->FormTypes[$Item['Type']]['Ref'], $Id).'<br/>';
    415     }
    416     }
     434          $Tabs[] = $Item['Caption'];
     435    }
     436    $Tabs[] = 'Vše';
     437    if(array_key_exists('tab', $_GET)) $TabIndex = $_GET['tab'];
     438      else $TabIndex = 0;
     439   
     440    $TabContent = '';
     441    $I = 0;
     442    foreach($Form->Definition['Items'] as $Index => $Item)
     443    if((array_key_exists($Item['Type'], $this->System->FormManager->FormTypes) and
     444    ($this->System->FormManager->FormTypes[$Item['Type']]['Type'] == 'ManyToOne')))
     445    {
     446          $TypeItem = $this->System->FormManager->FormTypes[$Item['Type']];
     447      if (($TabIndex == $I) or ($TabIndex == (count($Tabs) - 1)))
     448      {
     449        $TabContent .= $this->ShowList($TypeItem['Table'], '`'.
     450          $TypeItem['Ref'].'`='.$Id, $Item['Caption'],
     451          $TypeItem['Ref'], $Id).'<br/>';
     452          }
     453          $I++;
     454        }
     455
     456    $Output .= $this->ShowTabs($Tabs, 'tab', $TabContent);
    417457    return($Output);
    418458  }
Note: See TracChangeset for help on using the changeset viewer.