noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 06/14: Tache 0001743 : couleur sont dans un m


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 06/14: Tache 0001743 : couleur sont dans un menu séparé, amélioration de l'ergonomie + test phpunit
Date: Mon, 22 Aug 2022 12:21:53 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 9fc6cb14541a867b3850cc7539c1de9368bea2a2
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Sat Aug 20 18:18:30 2022 +0200

    Tache 0001743 : couleur sont dans un menu séparé,
    amélioration de l'ergonomie + test phpunit
---
 html/image/default-screen.png                     | Bin 0 -> 166837 bytes
 include/class/noalyss_appearance.class.php        |  87 +++++++++++++++++-----
 include/company.inc.php                           |  15 ----
 include/noalyss-color.inc.php                     |  72 ++++++++++++++++++
 include/sql/patch/upgrade174.sql                  |   2 +-
 include/sql/patch/upgrade175.sql                  |   3 +
 unit-test/include/class/noalyssAppearanceTest.php |  67 +++++++++++++++++
 unit-test/include/class/upgrade176.sql            |   0
 8 files changed, 212 insertions(+), 34 deletions(-)

diff --git a/html/image/default-screen.png b/html/image/default-screen.png
new file mode 100644
index 000000000..fe28232af
Binary files /dev/null and b/html/image/default-screen.png differ
diff --git a/include/class/noalyss_appearance.class.php 
b/include/class/noalyss_appearance.class.php
index 98470f551..bc2193326 100644
--- a/include/class/noalyss_appearance.class.php
+++ b/include/class/noalyss_appearance.class.php
@@ -35,7 +35,7 @@ class Noalyss_Appearance
         'MENU1' => '#000074',
         'BODY' => '#ffffff',
         'MENU2' => '#3d3d87',
-        'MENU1-SELECTED' => '#3d3d87',
+        'MENU1-SELECTED' => '#506cb8',
         'TR-ODD'=>'#DCE7F5',
         'TR-EVEN'=>'#ffffff',
         'INNER-BOX'=>'#DCE1EF',
@@ -90,6 +90,16 @@ class Noalyss_Appearance
         }
     }
 
+    /**
+     * @param string[] $aColor
+     */
+    public function get_color($p_code)
+    {
+        if (isset($this->aColor[$p_code])) {
+            return $this->aColor[$p_code];
+        }
+        throw new Exception('NAP100: INVALID CODE');
+    }
     function set_color($p_code, $p_value)
     {
         $aKey = array_keys($this->aColor);
@@ -189,30 +199,71 @@ EOF;
         return $r;
 
     }
-    function input_form()
+
+    /**
+     * Build a html string for each color
+     * @param $p_key string key of $this->aCSSColor
+     * @return string
+     */
+    private function build_input_row(string $p_key):string
     {
-        $str = "";
-        $str = '<h3 style="text-align: center;border:1px solid 
black;">'._("Couleur de fond").'</h3>';
-        $f=0;
-        foreach (self::$aCSSColorName as $key => $value) {
-            $value = $this->aColor[$key];
-            $icolor = new IColor($key, $value);
-            $str_icolor = $icolor->input();
-            $label = self::$aCSSColorName[$key];
-            $part=mb_strcut($key,0,4);
-            if (  strcmp($part , "FONT")==0 && $f==0 ){
-                $str .=  '<h3 style="text-align: center;border:1px solid 
black;">'._("Couleur police").'</h3>';
-                $f=1;
-            }
-            $str .= <<<EOF
+        $value = $this->aColor[$p_key];
+        $icolor = new IColor($p_key, $value);
+        $label = self::$aCSSColorName[$p_key];
+        $str_icolor = $icolor->input();
+        $str="";
+        $str .= <<<EOF
 <div class="form-group">
-    <label for="{$key}">
+    <label for="{$p_key}">
     {$label}
 </label>
     {$str_icolor}
 </div>
 EOF;
-        }
+        return $str;
+    }
+    private function title($p_string)
+    {
+        return '<h3 class="">'.h($p_string).'</h3>';
+    }
+    /**
+     * Build the HTML string for inputing the color
+     * @return string
+     */
+    function input_form()
+    {
+        $str = "";
+        $str.=$this->title(_("(1) Général"));
+        $str .= $this->build_input_row('BODY');
+        $str .= $this->build_input_row('FONT-DEFAULT');
+
+        $str.=$this->title(_("(2) En-tête dossier"));
+        $str .= $this->build_input_row('FOLDER');
+        $str .= $this->build_input_row('FONT-FOLDER');
+
+        $str.=$this->title('(3)'._("Titre"));
+        $str .= $this->build_input_row('H2');
+
+        $str.=$this->title('(4)'._("Menu principal"));
+        $str .= $this->build_input_row('MENU1');
+        $str .= $this->build_input_row('FONT-MENU1');
+        $str .= $this->build_input_row('MENU1-SELECTED');
+
+        $str.=$this->title('(5)'._("Sous-Menu"));
+        $str .= $this->build_input_row('MENU2');
+        $str .= $this->build_input_row('FONT-MENU2');
+
+        $str.=$this->title('(6)'._("Tableau"));
+        $str .= $this->build_input_row('FONT-TABLE');
+        $str .= $this->build_input_row('TR-ODD');
+        $str .= $this->build_input_row('TR-EVEN');
+        $str .= $this->build_input_row('FONT-TABLE-HEADER');
+
+
+        $str.=$this->title('(7)'._("Boîte de dialogue"));
+        $str .= $this->build_input_row('INNER-BOX');
+        $str .= $this->build_input_row('INNER-BOX-TITLE');
+
         $str.=$this->input_reset();
         return $str;
     }
diff --git a/include/company.inc.php b/include/company.inc.php
index e90879aee..596507d9c 100644
--- a/include/company.inc.php
+++ b/include/company.inc.php
@@ -201,22 +201,7 @@ $all->style=' class="input_text"';
                     ?>
                 </div>
             </div>
-            <div class="row">
-                <div class="col">
-                    <h2><?=_("Apparence")?></h2>
-                    <?php
-                    $noalyss_appearance=new Noalyss_Appearance();
-                    $noalyss_appearance->load();
-                    if ( $noalyss_appearance->from_post() ) {
-                        if (DEBUGNOALYSS > 1 ) { echo "save appearance";}
-                        $noalyss_appearance->save();
-                    }
-                    echo $noalyss_appearance->input_form();
-                    ?>
 
-
-                </div>
-            </div>
             <div class="row">
                 <div class="col-4"></div>
                 <div class="col-4">
diff --git a/include/noalyss-color.inc.php b/include/noalyss-color.inc.php
new file mode 100644
index 000000000..f5c08cf47
--- /dev/null
+++ b/include/noalyss-color.inc.php
@@ -0,0 +1,72 @@
+<?php
+/*
+ *   This file is part of NOALYSS.
+ *    NOALYSS is free software; you can redistribute it and/or modify
+ *    it under the terms of the GNU General Public License as published by
+ *    the Free Software Foundation; either version 2 of the License, or
+ *    (at your option) any later version.
+ *
+ *    NOALYSS is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *    GNU General Public License for more details.
+ *
+ *    You should have received a copy of the GNU General Public License
+ *    along with NOALYSS; if not, write to the Free Software
+ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *    Copyright Author Dany De Bontridder danydb@noalyss.eu
+ *
+ */
+
+
+/* !
+ * \file
+ * \brief Manage the colors and apparence of noalyss
+ */
+if (!defined('ALLOWED'))
+    die('Appel direct ne sont pas permis');
+global $g_user;
+$http = new HttpInput();
+
+?>
+<div class="content">
+
+    <form method="post">
+        <?= dossier::hidden(); ?>
+        <div class="row">
+            <div class="col">
+                <h2><?= _("Apparence") ?></h2>
+                <?php
+                $noalyss_appearance = new Noalyss_Appearance();
+                $noalyss_appearance->load();
+                if ($noalyss_appearance->from_post()) {
+                    if (DEBUGNOALYSS > 1) {
+                        echo "save appearance";
+                    }
+                    echo h2(_("Recharger la page pour voir la 
changements"),'class="notice"');
+                    $noalyss_appearance->save();
+                }
+                ?>
+               <?php
+               echo $noalyss_appearance->input_form();
+                ?>
+
+
+            </div>
+            <div class="col">
+                <h2><?= _("Ecran") ?></h2>
+                <img src="image/default-screen.png" width="100%">
+            </div>
+        </div>
+        <div class="row">
+            <div class="col">
+        <?php
+        echo HtmlInput::submit("record_company", _("Sauve"), "", "button");
+        ?>
+            </div>
+
+        </div>
+
+    </form>
+</div>
diff --git a/include/sql/patch/upgrade174.sql b/include/sql/patch/upgrade174.sql
index 953345a3f..35aab83fb 100644
--- a/include/sql/patch/upgrade174.sql
+++ b/include/sql/patch/upgrade174.sql
@@ -5,7 +5,7 @@ insert into parm_appearance values ('H2' , '#9fbcd6')
                                  ,('MENU1','#000074')
                                  ,('BODY','#ffffff')
                                  ,('MENU2','#3d3d87')
-                                 ,('MENU1-SELECTED','#3d3d87')
+                                 ,('MENU1-SELECTED','#506cb8')
                                  ,('FONT-MENU1','#ffffff')
                                  ,('FONT-MENU2','#ffffff')
                                  ,('FONT-TABLE','#222bd0')
diff --git a/include/sql/patch/upgrade175.sql b/include/sql/patch/upgrade175.sql
index df0fc20a6..742c26d3e 100644
--- a/include/sql/patch/upgrade175.sql
+++ b/include/sql/patch/upgrade175.sql
@@ -1,4 +1,7 @@
 begin;
 insert into parm_appearance values ('INNER-BOX-TITLE' , '#023575');
+insert into 
menu_ref(me_code,me_menu,me_file,me_description,me_type,me_description_etendue) 
values ('NCOL','Apparence','noalyss-color.inc.php','Couleur de 
NOALYSS','ME','Personnalisation des couleurs de NOYALYSS');
+INSERT INTO PROFILE_MENU(ME_CODE, ME_CODE_DEP, P_ID, P_ORDER, P_TYPE_DISPLAY, 
PM_DEFAULT, PM_ID_DEP) values ('NCOL','PARAM',1,5,'E',0,45);
+
 insert into version (val,v_description) values (176,'Folder Appearance : 
dialog box');
 commit;
diff --git a/unit-test/include/class/noalyssAppearanceTest.php 
b/unit-test/include/class/noalyssAppearanceTest.php
new file mode 100644
index 000000000..0f35f3e69
--- /dev/null
+++ b/unit-test/include/class/noalyssAppearanceTest.php
@@ -0,0 +1,67 @@
+<?php
+/*
+ *   This file is part of NOALYSS.
+ *    NOALYSS is free software; you can redistribute it and/or modify
+ *    it under the terms of the GNU General Public License as published by
+ *    the Free Software Foundation; either version 2 of the License, or
+ *    (at your option) any later version.
+ *
+ *    NOALYSS is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *    GNU General Public License for more details.
+ *
+ *    You should have received a copy of the GNU General Public License
+ *    along with NOALYSS; if not, write to the Free Software
+ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *    Copyright Author Dany De Bontridder danydb@noalyss.eu
+ *
+ */
+
+use PHPUnit\Framework\TestCase;
+
+class noalyssAppearanceTest extends TestCase
+{
+    protected $object;
+    protected function setUp(): void
+    {
+        include 'global.php';
+        $this->object=new Noalyss_Appearance();
+    }
+
+    public function testSetColor()
+    {
+        $this->object->set_color("FOLDER","#554433");
+        $this->assertEquals("#554433",$this->object->get_color("FOLDER"));
+
+    }
+
+    /**
+     * @covers Noalyss_Appearance::set_color Noalyss_Apperance::save  
Noalyss_Apperance::reset  Noalyss_Apperance::get_color
+     */
+    public function testReset()
+    {
+        $this->object->set_color("FOLDER","#554433");
+        $this->assertEquals("#554433",$this->object->get_color("FOLDER"));
+        $this->object->save();
+        $this->object->load();
+        $this->assertEquals("#554433",$this->object->get_color("FOLDER"));
+        $this->object->reset();
+        $this->assertEquals("#ffffff",$this->object->get_color("FOLDER"));
+    }
+
+    /**
+     * @return void
+     * @throws Exception
+     */
+    public function testValidateColor()
+    {
+
+        $this->object->set_color("FOLDER","#554411");
+        $this->expectException(Exception::class );
+        $this->object->set_color("FOLDER","#white");
+    }
+
+
+}
diff --git a/unit-test/include/class/upgrade176.sql 
b/unit-test/include/class/upgrade176.sql
new file mode 100644
index 000000000..e69de29bb



reply via email to

[Prev in Thread] Current Thread [Next in Thread]