Changeset 843


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.
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Version.php

    r839 r843  
    11<?php
    22
    3 $Revision = 838; // Subversion revision
     3$Revision = 844; // Subversion revision
    44$DatabaseRevision = 838; // SQL structure revision
    5 $ReleaseTime = strtotime('2016-09-18');
     5$ReleaseTime = strtotime('2017-01-01');
  • 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  }
  • trunk/style/new/style.css

    r791 r843  
    468468  text-align: center;
    469469}
     470
     471.Tab
     472{
     473}
     474
     475.Tab ul
     476{
     477  list-style: none;
     478  padding: 0;
     479  margin: 0;
     480}
     481   
     482.Tab li
     483{
     484  float: left;
     485  border: 1px solid #bbb;
     486  border-bottom-width: 0;
     487  margin: 0;
     488}
     489   
     490.Tab a
     491{
     492  text-decoration: none;
     493  display: block;
     494  background: #eee;
     495  padding: 0.24em 1em;
     496  text-align: center;
     497}
     498 
     499.Tab a:hover
     500{
     501  background: #fdd;
     502}
     503 
     504.Tab #selected
     505{
     506  border-color: black;
     507}
     508 
     509.Tab #selected a
     510{
     511  position: relative;
     512  top: 1px;
     513  background: white;
     514  font-weight: bold;
     515}
     516
     517.TabContent
     518{
     519  border: 1px solid black;
     520  clear: both;
     521  padding: 5px;
     522}
Note: See TracChangeset for help on using the changeset viewer.