Tache 0001743 : couleur sont dans un menu séparé,
amélioration de l'ergonomie + test phpunit
This commit is contained in:
parent
4276b63fdb
commit
9fc6cb1454
8 changed files with 212 additions and 34 deletions
BIN
html/image/default-screen.png
Normal file
BIN
html/image/default-screen.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 163 KiB |
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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">
|
||||
|
|
|
|||
72
include/noalyss-color.inc.php
Normal file
72
include/noalyss-color.inc.php
Normal file
|
|
@ -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>
|
||||
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
67
unit-test/include/class/noalyssAppearanceTest.php
Normal file
67
unit-test/include/class/noalyssAppearanceTest.php
Normal file
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
0
unit-test/include/class/upgrade176.sql
Normal file
0
unit-test/include/class/upgrade176.sql
Normal file
Loading…
Add table
Add a link
Reference in a new issue