commit 3eb44ec397d4f6a5a26f7d3d9d2fc3cd5e534d20
Author: Filip Jani <jsem@filek.cz>
Date:   Sat May 25 19:11:57 2019 +0200

    Re #7505 automatické otevření stromu pokud obsahuje hodnoty

diff --git a/app/AdminModule/component/Transliteration/TransliterationDataEditForm.latte b/app/AdminModule/component/Transliteration/TransliterationDataEditForm.latte
index ad52789..c78d1b5 100644
--- a/app/AdminModule/component/Transliteration/TransliterationDataEditForm.latte
+++ b/app/AdminModule/component/Transliteration/TransliterationDataEditForm.latte
@@ -2,11 +2,19 @@
     {form form class => 'form'}
         {foreach $containers as $containerName => $container}
 
+            {if isset($defaults[$containerName])}
+                {var show = ' show'}
+                {var expanded = 'true'}
+            {else}
+                {var show = ''}
+                {var expanded = 'false'}
+            {/if}
+
             <div class="card mb-1">
 
                 <h5 class="mb-0">
                     <a class="btn btn-link" data-toggle="collapse" data-target="#{$containerName}"
-                       aria-expanded="false">
+                       aria-expanded="{$expanded}">
                         <small>
                             <span class="fa fa-fw fa-plus"></span>
                             <span class="fa fa-fw fa-minus"></span>
@@ -14,7 +22,7 @@
                     </a>
                 </h5>
 
-                <div id="{$containerName}" class="collapse">
+                <div id="{$containerName}" class="collapse{$show}">
                     <div class="card-body">
 
                         {foreach $container as $multiplierName => $multiplier}
@@ -22,10 +30,18 @@
                             {if $multiplierName !== 'title'}
                                 {var name = $containerName . '-' . $multiplierName}
 
+                                {if isset($defaults[$containerName][$multiplierName])}
+                                    {var show = ' show'}
+                                    {var expanded = 'true'}
+                                {else}
+                                    {var show = ''}
+                                    {var expanded = 'false'}
+                                {/if}
+
                                 <div class="card mb-1">
                                     <h5 class="mb-0">
                                         <a class="btn btn-link" data-toggle="collapse" data-target="#{$name}"
-                                           aria-expanded="false" onclick="return false;">
+                                           aria-expanded="{$expanded}" onclick="return false;">
                                             <small>
                                                 <span class="fa fa-fw fa-plus"></span>
                                                 <span class="fa fa-fw fa-minus"></span>
@@ -33,7 +49,7 @@
                                         </a>
                                     </h5>
 
-                                    <div id="{$name}" class="collapse">
+                                    <div id="{$name}" class="collapse{$show}">
                                         <div class="card-body">
                                             <div n:multiplier="$name" n:class="row, mb-2">
                                                 <div class="col-5">
diff --git a/app/AdminModule/component/Transliteration/TransliterationDataEditForm.php b/app/AdminModule/component/Transliteration/TransliterationDataEditForm.php
index 2ba66f3..7cd6928 100644
--- a/app/AdminModule/component/Transliteration/TransliterationDataEditForm.php
+++ b/app/AdminModule/component/Transliteration/TransliterationDataEditForm.php
@@ -21,6 +21,8 @@ class TransliterationDataEditForm extends Control
     /** @var array Pole objektů a typu povrch pro strom dat transliterace */
     private $containers;
 
+    private $defaults;
+
     /**
      * @var ObjectTypeRepository
      */
@@ -56,7 +58,7 @@ class TransliterationDataEditForm extends Control
 
             foreach ($surfaceTypes as $surfaceType)
             {
-                $containers[$this->transliterationFacade->getInputName($objectType)][$this->transliterationFacade->getInputName($objectType, $surfaceType)] = $surfaceType;
+                $containers[$this->transliterationFacade->getInputName($objectType)][$this->transliterationFacade->getInputName($surfaceType)] = $surfaceType;
             }
         }
 
@@ -68,6 +70,7 @@ class TransliterationDataEditForm extends Control
         $this->template->setFile(__DIR__ . '/TransliterationDataEditForm.latte');
 
         $this->template->containers = $this->containers;
+        $this->template->defaults = $this->defaults = $this->getDefaults();
 
         $this->template->render();
     }
@@ -99,7 +102,7 @@ class TransliterationDataEditForm extends Control
             }
         }
 
-        $form->setDefaults($this->getDefaults());
+        $form->setDefaults($this->defaults);
 
         $form->onSuccess[] = [$this, 'formSuccess'];
         $form->addSubmit('submit', 'Save');
diff --git a/app/model/facade/TransliterationFacade.php b/app/model/facade/TransliterationFacade.php
index f29ade3..ebc6256 100644
--- a/app/model/facade/TransliterationFacade.php
+++ b/app/model/facade/TransliterationFacade.php
@@ -82,7 +82,7 @@ class TransliterationFacade
             $objectType = $objectTypes[$surface->{SurfaceRepository::COLUMN_OBJECT_TYPE_ID}];
 
             $objectName = $this->getInputName($objectType);
-            $surfaceName = $this->getInputName($objectType, $surfaceType);
+            $surfaceName = $this->getInputName($surfaceType);
 
             $defaults[$objectName][$surfaceName] = $lineRows;
         }
@@ -93,12 +93,11 @@ class TransliterationFacade
     /**
      * Vrací název inputu pro formulář
      *
-     * @param string $container
      * @param string|NULL $name
      * @return string
      */
-    public function getInputName(string $container, string $name = NULL)
+    public function getInputName(string $name)
     {
-        return str_replace(' ', '', $container) . str_replace(' ', '', $name);
+        return str_replace(' ', '', $name);
     }
 }
\ No newline at end of file
