Add support for supannMailPrive, supannAdressePostalePrivee and supannTelephonePrive attributes

This commit is contained in:
Benjamin Renard 2021-06-09 15:48:46 +02:00
parent 077a44fdf9
commit 0ac0a7e068
13 changed files with 637 additions and 209 deletions

View file

@ -92,22 +92,46 @@ $GLOBALS['LS_SUPANN_CIVILITES'] = array (
* ), * ),
* ); * );
* *
* [ETIQUETTE] : l'étiquette de la valeur * [ETIQUETTE] : l'étiquette de la valeur (correspondant le plus souvent ou mainteneur de la nomenclature)
* [table] : le nom de la table : * [table] : le nom de la table :
* - roleGenerique : les rôles génériques * - mailPriveLabel: le label des mails privés des personnes (supannMailPrive)
* - typeEntite : les types d'entités * - adressePostalePriveeLabel: le label des adresses privées des personnes (supannAdressePostalePrivee)
* - empCorps : les corps d'appartenances des personnels * - telephonePriveLabel: le label des télépgones privés des personnes (supannTelephonePrive)
* - codeEtablissement : les codes d'établissement * - roleGenerique : les rôles génériques (supannRoleGenerique)
* - etuRegimeInscription : les régimes d'inscription étudiant * - typeEntite : les types d'entités (supannTypeEntite)
* - etuSecteurDisciplinaire : les secteurs disciplinaires de dîplomes ou d'enseignements * - empCorps : les corps d'appartenances des personnels (supannEmpCorps)
* - etuTypeDiplome : les types de diplôme * - codeEtablissement : les codes d'établissement (supannEtablissement)
* - etuDiplome : les diplômes * - etuRegimeInscription : les régimes d'inscription étudiant (supannEtuRegimeInscription)
* - etuEtape : les étapes des enseignements * - etuSecteurDisciplinaire : les secteurs disciplinaires de dîplomes ou d'enseignements (supannEtuSecteurDisciplinaire)
* - etuElementPedagogique : les éléments pédagogiques * - etuTypeDiplome : les types de diplôme (supannEtuTypeDiplome)
* - etuDiplome : les diplômes (supannEtuDiplome)
* - etuEtape : les étapes des enseignements (supannEtuEtape)
* - etuElementPedagogique : les éléments pédagogiques (supannEtuElementPedagogique)
* *
*/ */
$GLOBALS['supannNomenclatures'] = array ( $GLOBALS['supannNomenclatures'] = array (
'SUPANN' => array ( 'SUPANN' => array (
'mailPriveLabel' => array (
'SECOURS' => ___('Backup'),
'PERSO' => ___('Personal'),
'PARENTS' => ___('Parents'),
'PRO' => ___('Professional'),
),
'adressePostalePriveeLabel' => array (
'TEMP' => ___('Temporary'),
'PERSO' => ___('Personal'),
'PARENTS' => ___('Parents'),
'PRO' => ___('Professional'),
),
'telephonePriveLabel' => array (
'MOBPERSO' => ___('Personal mobile'),
'FIXEPERSO' => ___('Personal landline'),
'FIXEPARENTS' => ___('Parents landline'),
'MOBPARENTS' => ___('Parents mobile'),
'MOBPRO' => ___('Professional mobile'),
'FIXEPRO' => ___('Professional landline'),
'SECOURS' => ___('Backup'),
),
'roleGenerique' => array ( 'roleGenerique' => array (
"D00" => "MINISTRE", "D00" => "MINISTRE",
"D01" => "DIRECTEUR DU CABINET", "D01" => "DIRECTEUR DU CABINET",

View file

@ -22,3 +22,25 @@ div.supannLabeledValue_possibleValues li:hover {
background-color: #CCC; background-color: #CCC;
cursor: pointer; cursor: pointer;
} }
pre.LSformElement_supannLabeledValue_value {
display: inline-block;
font-family: 'Lucida Grande', Verdana, Arial, Sans-Serif;
margin: 0;
}
@media (min-width: 401px) {
select.LSformElement_supannLabeledValue_label, input.LSformElement_supannLabeledValue_label, span.LSformElement_supannLabeledValue_label {
width: 50px;
vertical-align: top;
}
input.LSformElement_supannLabeledValue_value, textarea.LSformElement_supannLabeledValue_value {
scrollbar-width: thin;
width: calc(150px - 1em);
}
textarea.LSformElement_supannLabeledValue_value {
height: 5em;
}
}

View file

@ -198,7 +198,7 @@ td.LSobject-list, tr.LSobject-list, table.LStable tbody td, table.LStable th {
padding: 2px; padding: 2px;
} }
.LSform input[type=text], .LSform input[type=password], .LSform select, .LSform textarea, ul.LSformElement_text_autocomplete, ul.LSformElement_select_object_edit, div.LSformElement_wysiwyg_container, ul.LSformElement_jsonCompositeAttribute:not(.LSformElement_jsonCompositeAttribute_fullWidth), dd.LSform-errors { .LSform input[type=text], .LSform input[type=password], .LSform select, .LSform textarea, ul.LSformElement_text_autocomplete, ul.LSformElement_select_object_edit, div.LSformElement_wysiwyg_container, ul.LSformElement_jsonCompositeAttribute:not(.LSformElement_jsonCompositeAttribute_fullWidth), dd.LSform-errors, input.LSformElement_supannLabeledValue_search {
width: 32vw; width: 32vw;
} }
@ -234,6 +234,14 @@ td.LSobject-list, tr.LSobject-list, table.LStable tbody td, table.LStable th {
width: calc(32vw - 8em); width: calc(32vw - 8em);
} }
.LSform select.LSformElement_supannLabeledValue_label, .LSform input.LSformElement_supannLabeledValue_label {
width: 6em;
}
.LSform input.LSformElement_supannLabeledValue_value, textarea.LSformElement_supannLabeledValue_value {
width: calc(32vw - 14rem);
}
input.LSformElement_select_object_searchAdd, ul.LSformElement_select_object_searchAdd { input.LSformElement_select_object_searchAdd, ul.LSformElement_select_object_searchAdd {
width: 17vw!important; width: 17vw!important;
box-sizing: border-box; box-sizing: border-box;

View file

@ -381,17 +381,38 @@ LSerror :: defineError('SUPANN_03',
* Vérifie si une valeur et son étiquette sont valide pour une table donnée * Vérifie si une valeur et son étiquette sont valide pour une table donnée
* *
* @param[in] $table La table de nomenclature * @param[in] $table La table de nomenclature
* @param[in] $label L'étiquette de la valeur * @param[in] $label L'étiquette de la valeur (optionnel)
* @param[in] $value La valeur * @param[in] $value La valeur
* *
* @retval booleab True si valide, False sinon * @retval booleab True si valide, False sinon
**/ **/
function supannValidateNomenclatureValue($table, $label, $value) { function supannValidateNomenclatureValue($table, $label, $value) {
if ($label) {
$label = strtoupper($label); $label = strtoupper($label);
if (isset($GLOBALS['supannNomenclatures'][$label]) && if (
isset($GLOBALS['supannNomenclatures'][$label]) &&
isset($GLOBALS['supannNomenclatures'][$label][$table]) && isset($GLOBALS['supannNomenclatures'][$label][$table]) &&
isset($GLOBALS['supannNomenclatures'][$label][$table][$value])) { isset($GLOBALS['supannNomenclatures'][$label][$table][$value])
return true; ) {
return array(
'table' => $table,
'label' => $label,
'value' => $value,
'translated' => $GLOBALS['supannNomenclatures'][$label][$table][$value],
);
}
}
else {
foreach($GLOBALS['supannNomenclatures'] as $label => $tables) {
if (!array_key_exists($table, $tables) || !array_key_exists($value, $tables[$table]))
continue;
return array(
'table' => $table,
'label' => $label,
'value' => $value,
'translated' => $tables[$table][$value],
);
}
} }
return false; return false;
} }
@ -401,33 +422,57 @@ LSerror :: defineError('SUPANN_03',
* et de l'étiquette de la valeur. * et de l'étiquette de la valeur.
* *
* @param[in] $table La table de nomenclature * @param[in] $table La table de nomenclature
* @param[in] $label L'étiquette de la valeur * @param[in] $label L'étiquette de la valeur (optionnel)
* @param[in] $value La valeur * @param[in] $value La valeur
* *
* @retval array Le label de la valeur. En cas de valeur nor-reconnue, retourne * @retval array Le label de la valeur. En cas de valeur nor-reconnue, retourne
* la valeur en spécifiant qu'elle n'est pas reconnue. * la valeur en spécifiant qu'elle n'est pas reconnue.
**/ **/
function supannGetNomenclatureLabel($table, $label, $value) { function supannGetNomenclatureLabel($table, $label, $value) {
if (supannValidateNomenclatureValue($table,$label,$value)) { $translated = supannValidateNomenclatureValue($table, $label, $value);
$label=strtoupper($label); if ($translated)
return $GLOBALS['supannNomenclatures'][$label][$table][$value]; return $translated['translated'];
}
return getFData(__("%{value} (unrecognized value)"), $value); return getFData(__("%{value} (unrecognized value)"), $value);
} }
/**
* Retourne les valeurs possibles d'une table de nomenclature pour chaque fournisseur
*
* @param[in] $table La table de nomenclature
*
* @retval array Tableau contenant pour chaque fournisseur, les valeurs possibles de
* la table de nomenclature
**/
function supannGetNomenclatureTable($table) {
$retval=array();
foreach(array_keys($GLOBALS['supannNomenclatures']) as $provider) {
if (isset($GLOBALS['supannNomenclatures'][$provider][$table])) {
$retval[$provider] = $GLOBALS['supannNomenclatures'][$provider][$table];
}
}
return $retval;
}
/** /**
* Retourne les valeurs possibles d'une table de nomenclature * Retourne les valeurs possibles d'une table de nomenclature
* *
* @param[in] $table La table de nomenclature * @param[in] $table La table de nomenclature
* @param[in] $add_provider_label Booléen définissant si le fournisseur de la valeur
* doit être ajouté en tant qu'étiquette de la valeur
* (optinel, par défaut: vrai)
* *
* @retval array Tableau contenant les valeurs possibles de la table * @retval array Tableau contenant les valeurs possibles de la table
* de nomenclature * de nomenclature
**/ **/
function supannGetNomenclatureTable($table) { function supannGetNomenclaturePossibleValues($table, $add_provider_label=True) {
$retval = array(); $retval = array();
foreach($GLOBALS['supannNomenclatures'] as $label => $tables) { foreach(array_keys($GLOBALS['supannNomenclatures']) as $provider) {
if (isset($GLOBALS['supannNomenclatures'][$label][$table])) { if (isset($GLOBALS['supannNomenclatures'][$provider][$table])) {
$retval[$label]=$GLOBALS['supannNomenclatures'][$label][$table]; foreach($GLOBALS['supannNomenclatures'][$provider][$table] as $value => $label) {
if ($add_provider_label)
$value = "{$provider}$value";
$retval[$value] = __($label);
}
} }
} }
return $retval; return $retval;

View file

@ -0,0 +1,32 @@
<?php
/*******************************************************************************
* Copyright (C) 2021 Easter-eggs
* https://ldapsaisie.org
*
* Author: See AUTHORS file in top-level directory.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/
/**
* Type d'attribut HTML supannAdressePostalePrivee
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*/
class LSattr_html_supannAdressePostalePrivee extends LSattr_html {
var $LSformElement_type = 'supannAdressePostalePrivee';
}

View file

@ -0,0 +1,32 @@
<?php
/*******************************************************************************
* Copyright (C) 2021 Easter-eggs
* https://ldapsaisie.org
*
* Author: See AUTHORS file in top-level directory.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/
/**
* Type d'attribut HTML supannMailPrive
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*/
class LSattr_html_supannMailPrive extends LSattr_html {
var $LSformElement_type = 'supannMailPrive';
}

View file

@ -0,0 +1,32 @@
<?php
/*******************************************************************************
* Copyright (C) 2021 Easter-eggs
* https://ldapsaisie.org
*
* Author: See AUTHORS file in top-level directory.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/
/**
* Type d'attribut HTML supannTelephonePrive
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*/
class LSattr_html_supannTelephonePrive extends LSattr_html {
var $LSformElement_type = 'supannTelephonePrive';
}

View file

@ -0,0 +1,76 @@
<?php
/*******************************************************************************
* Copyright (C) 2021 Easter-eggs
* https://ldapsaisie.org
*
* Author: See AUTHORS file in top-level directory.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/
LSsession :: loadLSclass('LSformElement_supannLabeledValue');
LSsession :: loadLSaddon('supann');
/**
* Element supannAdressePostalePrivee d'un formulaire pour LdapSaisie
*
* Cette classe définis les éléments supannAdressePostalePrivee des formulaires.
* Elle etant la classe basic LSformElement_supannLabeledValue.
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*/
class LSformElement_supannAdressePostalePrivee extends LSformElement_supannLabeledValue {
var $supannLabelNomenclatureTable = 'adressePostalePriveeLabel';
var $valueFieldType = 'textarea';
/**
* Parse une valeur
*
* @param[in] $value La valeur
*
* @retval array Un tableau cle->valeur contenant value, translated et label
**/
public function parseValue($value) {
$retval = parent :: parseValue($value);
$retval['value'] = str_replace('$', "\n", $retval['value']);
$retval['translated'] = str_replace('$', "\n", $retval['translated']);
return $retval;
}
/**
* Recupère la valeur de l'élement passée en POST
*
* Cette méthode s'occupe de remplacer les retour à la ligne dans les valeur de l'attribut
* pas des caractères '$'.
* @see LSformElement::getPostData()
* @retval boolean true si la valeur est présente en POST, false sinon
*/
public function getPostData(&$return, $onlyIfPresent=false) {
$retval = parent :: getPostData($return, $onlyIfPresent);
if (isset($return[$this -> name])) {
$fixed_values = array();
foreach($return[$this -> name] as $value)
$fixed_values[] = str_replace("\n", "$", $value);
$return[$this -> name] = $fixed_values;
}
return $retval;
}
}

View file

@ -38,6 +38,10 @@ class LSformElement_supannLabeledValue extends LSformElement {
var $fieldTemplate = 'LSformElement_supannLabeledValue_field.tpl'; var $fieldTemplate = 'LSformElement_supannLabeledValue_field.tpl';
var $supannNomenclatureTable = null; var $supannNomenclatureTable = null;
var $supannLabelNomenclatureTable = null;
// HTML field type: text or textarea (only for field without nomenclature table)
var $valueFieldType = 'text';
/** /**
* Retourne les infos d'affichage de l'élément * Retourne les infos d'affichage de l'élément
@ -53,12 +57,25 @@ class LSformElement_supannLabeledValue extends LSformElement {
foreach($this -> values as $val) { foreach($this -> values as $val) {
$parseValues[]=$this -> parseValue($val); $parseValues[]=$this -> parseValue($val);
} }
$return['html'] = $this -> fetchTemplate(NULL,array('parseValues' => $parseValues)); $possibleLabels = (
$this -> supannLabelNomenclatureTable?
supannGetNomenclaturePossibleValues($this -> supannLabelNomenclatureTable, false):
null
);
$return['html'] = $this -> fetchTemplate(
NULL, array(
'parseValues' => $parseValues,
'nomenclatureTable' => $this -> supannNomenclatureTable,
'possibleLabels' => $possibleLabels,
'valueFieldType' => $this -> valueFieldType,
)
);
LStemplate :: addCssFile('LSformElement_supannLabeledValue.css'); LStemplate :: addCssFile('LSformElement_supannLabeledValue.css');
if (!$this -> isFreeze()) { if (!$this -> isFreeze()) {
LStemplate :: addJSconfigParam( LStemplate :: addJSconfigParam(
$this -> name, $this -> name,
array( array(
'nomenclatureTable' => boolval($this -> supannNomenclatureTable),
'searchBtn' => _('Modify'), 'searchBtn' => _('Modify'),
'noValueLabel' => _('No set value'), 'noValueLabel' => _('No set value'),
'noResultLabel' => _('No result'), 'noResultLabel' => _('No result'),
@ -86,7 +103,12 @@ class LSformElement_supannLabeledValue extends LSformElement {
$pv = supannParseLabeledValue($value); $pv = supannParseLabeledValue($value);
if ($pv) { if ($pv) {
$retval['label'] = $pv['label']; $retval['label'] = $pv['label'];
if ($this -> supannLabelNomenclatureTable)
$retval['translated_label'] = supannGetNomenclatureLabel($this -> supannLabelNomenclatureTable, null, $pv['label']);
if ($this -> supannNomenclatureTable)
$retval['translated'] = supannGetNomenclatureLabel($this -> supannNomenclatureTable,$pv['label'],$pv['value']); $retval['translated'] = supannGetNomenclatureLabel($this -> supannNomenclatureTable,$pv['label'],$pv['value']);
else
$retval['translated'] = $pv['value'];
} }
else { else {
$retval['label'] = 'no'; $retval['label'] = 'no';
@ -101,26 +123,38 @@ class LSformElement_supannLabeledValue extends LSformElement {
* *
* @param[in] $data The address to the array of data witch will be return by the ajax request * @param[in] $data The address to the array of data witch will be return by the ajax request
* *
* @retval void * @retval boolean True on success, False otherwise
**/ **/
public static function ajax_searchPossibleValues(&$data) { public static function ajax_searchPossibleValues(&$data) {
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['pattern'])) && (isset($_REQUEST['idform'])) ) { // Check all parameters is provided
if (LSsession ::loadLSobject($_REQUEST['objecttype'])) { foreach(array('attribute', 'objecttype', 'pattern', 'idform') as $parameter)
if (!isset($_REQUEST[$parameter]))
return;
if (!LSsession ::loadLSobject($_REQUEST['objecttype']))
return;
$object = new $_REQUEST['objecttype'](); $object = new $_REQUEST['objecttype']();
$form = $object -> getForm($_REQUEST['idform']); $form = $object -> getForm($_REQUEST['idform']);
$field = $form -> getElement($_REQUEST['attribute']); $field = $form -> getElement($_REQUEST['attribute']);
$data['possibleValues'] = $field -> searchPossibleValues($_REQUEST['pattern']); $data['possibleValues'] = $field -> searchPossibleValues($_REQUEST['pattern']);
} return true;
}
} }
/**
* Real private method to search possible values from pattern.
*
* @param[in] $pattern The search pattern
*
* @retval boolean|array Array of possible values, or False is case of error
**/
private function searchPossibleValues($pattern) { private function searchPossibleValues($pattern) {
$pattern=strtolower($pattern); if (!$this -> supannNomenclatureTable)
return false;
$pattern=withoutAccents(strtolower($pattern));
$retval=array(); $retval=array();
$table=supannGetNomenclatureTable($this -> supannNomenclatureTable); $table=supannGetNomenclatureTable($this -> supannNomenclatureTable);
foreach($table as $label => $values) { foreach($table as $label => $values) {
foreach($values as $v => $txt) { foreach($values as $v => $txt) {
if (strpos(strtolower($txt),$pattern)!==false) { if (strpos(withoutAccents(strtolower($txt)),$pattern)!==false) {
$retval[]=array( $retval[]=array(
'label' => $label, 'label' => $label,
'value' => "{".$label."}".$v, 'value' => "{".$label."}".$v,

View file

@ -0,0 +1,39 @@
<?php
/*******************************************************************************
* Copyright (C) 2021 Easter-eggs
* https://ldapsaisie.org
*
* Author: See AUTHORS file in top-level directory.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/
LSsession :: loadLSclass('LSformElement_supannLabeledValue');
LSsession :: loadLSaddon('supann');
/**
* Element supannMailPrive d'un formulaire pour LdapSaisie
*
* Cette classe définis les éléments supannMailPrive des formulaires.
* Elle etant la classe basic LSformElement_supannLabeledValue.
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*/
class LSformElement_supannMailPrive extends LSformElement_supannLabeledValue {
var $supannLabelNomenclatureTable = 'mailPriveLabel';
}

View file

@ -0,0 +1,39 @@
<?php
/*******************************************************************************
* Copyright (C) 2021 Easter-eggs
* https://ldapsaisie.org
*
* Author: See AUTHORS file in top-level directory.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/
LSsession :: loadLSclass('LSformElement_supannLabeledValue');
LSsession :: loadLSaddon('supann');
/**
* Element supannTelephonePrive d'un formulaire pour LdapSaisie
*
* Cette classe définis les éléments supannTelephonePrive des formulaires.
* Elle etant la classe basic LSformElement_supannLabeledValue.
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*/
class LSformElement_supannTelephonePrive extends LSformElement_supannLabeledValue {
var $supannLabelNomenclatureTable = 'telephonePriveLabel';
}

View file

@ -5,7 +5,8 @@ var LSformElement_supannLabeledValue_field_value = new Class({
this.field_type = field_type; this.field_type = field_type;
this.params = varLSdefault.LSjsConfig[this.name]; this.params = varLSdefault.LSjsConfig[this.name];
this.input = this.li.getElement('input'); this.inputRawValue = this.li.getElement('input');
if (this.params.nomenclatureTable) {
this.img = this.li.getElement('img.LSformElement_supannLabeledValue_label'); this.img = this.li.getElement('img.LSformElement_supannLabeledValue_label');
this.span = this.li.getElement('span'); this.span = this.li.getElement('span');
@ -34,6 +35,21 @@ var LSformElement_supannLabeledValue_field_value = new Class({
this._lastSearch=null; this._lastSearch=null;
this._possibleValues=null; this._possibleValues=null;
}
else {
this.inputLabel = this.li.getElement('select.LSformElement_supannLabeledValue_label');
if (!this.inputLabel)
this.inputLabel = this.li.getElement('input.LSformElement_supannLabeledValue_label');
this.inputValue = this.li.getElement('input.LSformElement_supannLabeledValue_value');
if (!this.inputValue)
this.inputValue = this.li.getElement('textarea.LSformElement_supannLabeledValue_value');
if (!this.inputLabel || !this.inputValue) {
alert('toto');
return;
}
this.inputLabel.addEvent('change', this.updateRawValue.bind(this));
this.inputValue.addEvent('change', this.updateRawValue.bind(this));
}
}, },
toggleInputSearch: function() { toggleInputSearch: function() {
@ -144,7 +160,7 @@ var LSformElement_supannLabeledValue_field_value = new Class({
if (event.target.tagName=='IMG') { if (event.target.tagName=='IMG') {
li=li.getParent(); li=li.getParent();
} }
this.input.set('value',li.get('data-value')); this.inputRawValue.set('value',li.get('data-value'));
if (li.get('data-label')!='no') { if (li.get('data-label')!='no') {
if (this.img==null) { if (this.img==null) {
this.img=new Element('img',{'class': 'LSformElement_supannLabeledValue_label'}); this.img=new Element('img',{'class': 'LSformElement_supannLabeledValue_label'});
@ -157,12 +173,16 @@ var LSformElement_supannLabeledValue_field_value = new Class({
this.toggleInputSearch(); this.toggleInputSearch();
}, },
updateRawValue: function(event) {
this.inputRawValue.set('value', '{'+this.inputLabel.value+'}'+this.inputValue.value);
},
clear: function() { clear: function() {
if (this.img) { if (this.img) {
this.img.dispose(); this.img.dispose();
this.img=null; this.img=null;
} }
this.input.set('value',''); this.inputRawValue.set('value','');
if (this.span) { if (this.span) {
this.span.set('html',this.params.noValueLabel); this.span.set('html',this.params.noValueLabel);
} }

View file

@ -1,15 +1,22 @@
{if $freeze} {if $freeze}
{if isset($parseValue)} {if isset($parseValue)}
{if !empty($parseValue.label) and $parseValue.label!='no'} {if isset($parseValue.translated_label)}
<span class='LSformElement_supannLabeledValue_label'>{tr msg=$parseValue.translated_label}&nbsp;:</span>
{elseif !empty($parseValue.label) and $parseValue.label!='no'}
{assign var=clabel value=$parseValue.label} {assign var=clabel value=$parseValue.label}
<img src='{img name="supann_label_$clabel"}' alt='[{$clabel|escape:"htmlall"}]' title='{$clabel|escape:"htmlall"}'/> <img src='{img name="supann_label_$clabel"}' alt='[{$clabel|escape:"htmlall"}]' title='{$clabel|escape:"htmlall"}'/>
{/if} {/if}
<span title='{$parseValue.value|escape:"htmlall"}'>{$parseValue.translated|escape:"htmlall"}</span> {if $valueFieldType == 'textarea'}
<pre class='LSformElement_supannLabeledValue_value' {if $nomenclatureTable}title='{$parseValue.value|escape:"htmlall"}'{/if}>{$parseValue.translated|escape:"htmlall"}</pre>
{else}
<span {if $nomenclatureTable}title='{$parseValue.value|escape:"htmlall"}'{/if}>{$parseValue.translated|escape:"htmlall"}</span>
{/if}
{else} {else}
{$noValueTxt|escape:"htmlall"} {$noValueTxt|escape:"htmlall"}
{/if} {/if}
{else} {else}
<input type='hidden' name='{$attr_name|escape:"htmlall"}[]' value='{if $parseValue}{$parseValue.value|escape:"htmlall"}{/if}'/> <input type='hidden' name='{$attr_name|escape:"htmlall"}[]' value='{if $parseValue}{$parseValue.value|escape:"htmlall"}{/if}'/>
{if $nomenclatureTable}
{if $parseValue and !empty($parseValue.label) and $parseValue.label!='no'} {if $parseValue and !empty($parseValue.label) and $parseValue.label!='no'}
{assign var=clabel value=$parseValue.label} {assign var=clabel value=$parseValue.label}
<img class='LSformElement_supannLabeledValue_label' src='{img name="supann_label_$clabel"}' alt='[{$clabel|escape:"htmlall"}]' title='{$clabel|escape:"htmlall"}'/> <img class='LSformElement_supannLabeledValue_label' src='{img name="supann_label_$clabel"}' alt='[{$clabel|escape:"htmlall"}]' title='{$clabel|escape:"htmlall"}'/>
@ -19,4 +26,22 @@
{else} {else}
<span>{$noValueTxt|escape:"htmlall"}</span> <span>{$noValueTxt|escape:"htmlall"}</span>
{/if} {/if}
{else}
{if $possibleLabels}
<select class='LSformElement_supannLabeledValue_label'>
{if $parseValue}
{html_options options=$possibleLabels selected=$parseValue.label}
{else}
{html_options options=$possibleLabels}
{/if}
</select>
{else}
<input type='text' class='LSformElement_supannLabeledValue_label'{if $parseValue} value='{$parseValue.label|escape:"htmlall"}'{/if}/>
{/if}
{if $valueFieldType == 'textarea'}
<textarea class='LSformElement_supannLabeledValue_value'>{if $parseValue}{$parseValue.translated|escape:"htmlall"}{/if}</textarea>
{else}
<input type='text' class='LSformElement_supannLabeledValue_value'{if $parseValue} value='{$parseValue.translated|escape:"htmlall"}'{/if}/>
{/if}
{/if}
{/if} {/if}