From 6fb2bfdaf4982f3517461c7953be260521f88fda Mon Sep 17 00:00:00 2001
From: "florian.azizian" <florian.azizian@maarch.org>
Date: Mon, 26 Feb 2018 11:51:59 +0100
Subject: [PATCH] FEAT #122 view administration doctype

---
 .../doctypes-administration.component.js      | 20 +++++++++----------
 .../doctypes-administration.component.ts      | 16 +++++++--------
 .../controllers/FirstLevelController.php      |  1 +
 3 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/apps/maarch_entreprise/js/angular/app/administration/doctypes-administration.component.js b/apps/maarch_entreprise/js/angular/app/administration/doctypes-administration.component.js
index afc189c54cc..e1bae8711f9 100644
--- a/apps/maarch_entreprise/js/angular/app/administration/doctypes-administration.component.js
+++ b/apps/maarch_entreprise/js/angular/app/administration/doctypes-administration.component.js
@@ -67,6 +67,16 @@ var DoctypesAdministrationComponent = /** @class */ (function () {
                     },
                     "plugins": ["search", "dnd", "contextmenu"],
                 });
+                var to = false;
+                $j('#jstree_search').keyup(function () {
+                    if (to) {
+                        clearTimeout(to);
+                    }
+                    to = setTimeout(function () {
+                        var v = $j('#jstree_search').val();
+                        $j('#jstree').jstree(true).search(v);
+                    }, 250);
+                });
                 $j('#jstree')
                     .on('select_node.jstree', function (e, data) {
                     _this.loadDoctype(data.node);
@@ -78,16 +88,6 @@ var DoctypesAdministrationComponent = /** @class */ (function () {
                     .jstree();
             }, 0);
             $j('#jstree').jstree('select_node', _this.doctypes[0]);
-            var to = false;
-            $j('#jstree_search').keyup(function () {
-                if (to) {
-                    clearTimeout(to);
-                }
-                to = setTimeout(function () {
-                    var v = $j('#jstree_search').val();
-                    $j('#jstree').jstree(true).search(v);
-                }, 250);
-            });
             _this.loading = false;
         }, function () {
             location.href = "index.php";
diff --git a/apps/maarch_entreprise/js/angular/app/administration/doctypes-administration.component.ts b/apps/maarch_entreprise/js/angular/app/administration/doctypes-administration.component.ts
index 4585390db94..c93be5b05bf 100644
--- a/apps/maarch_entreprise/js/angular/app/administration/doctypes-administration.component.ts
+++ b/apps/maarch_entreprise/js/angular/app/administration/doctypes-administration.component.ts
@@ -76,6 +76,14 @@ export class DoctypesAdministrationComponent implements OnInit {
                         },
                         "plugins": ["search", "dnd", "contextmenu"],
                     });
+                    var to: any = false;
+                    $j('#jstree_search').keyup(function () {
+                        if (to) { clearTimeout(to); }
+                        to = setTimeout(function () {
+                            var v = $j('#jstree_search').val();
+                            $j('#jstree').jstree(true).search(v);
+                        }, 250);
+                    });
                     $j('#jstree')
                         // listen for event
                         .on('select_node.jstree', (e: any, data: any) => {
@@ -90,14 +98,6 @@ export class DoctypesAdministrationComponent implements OnInit {
                         .jstree();
                 }, 0);
                 $j('#jstree').jstree('select_node', this.doctypes[0]);
-                var to: any = false;
-                $j('#jstree_search').keyup(function () {
-                    if (to) { clearTimeout(to); }
-                    to = setTimeout(function () {
-                        var v = $j('#jstree_search').val();
-                        $j('#jstree').jstree(true).search(v);
-                    }, 250);
-                });
                 this.loading = false;
             }, () => {
                 location.href = "index.php";
diff --git a/src/app/doctype/controllers/FirstLevelController.php b/src/app/doctype/controllers/FirstLevelController.php
index c0d7de75b9b..9bc7a638349 100644
--- a/src/app/doctype/controllers/FirstLevelController.php
+++ b/src/app/doctype/controllers/FirstLevelController.php
@@ -43,6 +43,7 @@ class FirstLevelController
             $firstLevelValue['id']     = 'firstlevel_'.$firstLevelValue['doctypes_first_level_id'];
             $firstLevelValue['text']   = $firstLevelValue['doctypes_first_level_label'];
             $firstLevelValue['parent'] = '#';
+            $firstLevelValue['state']['opened'] = true;
             array_push($structure, $firstLevelValue);
         }
         foreach ($secondLevels as $secondLevelValue) {
-- 
GitLab