NEW Enhance framework so we can use html/icons into SELECT options.
This commit is contained in:
parent
0a1b381bc5
commit
a1f862eba6
@ -269,7 +269,8 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty"
|
||||
$out.= img_picto($langs->trans("MoveBox",$this->box_id),'grip_title','class="boxhandle hideonsmartphone cursormove"');
|
||||
$out.= img_picto($langs->trans("CloseBox",$this->box_id),'close_title','class="boxclose cursorpointer" rel="x:y" id="imgclose'.$this->box_id.'"');
|
||||
$label=$head['text'];
|
||||
if (! empty($head['graph'])) $label.=' ('.$langs->trans("Graph").')';
|
||||
//if (! empty($head['graph'])) $label.=' ('.$langs->trans("Graph").')';
|
||||
if (! empty($head['graph'])) $label.=' <span class="fa fa-bar-chart"></span>';
|
||||
$out.= '<input type="hidden" id="boxlabelentry'.$this->box_id.'" value="'.dol_escape_htmltag($label).'">';
|
||||
$out.= '</td></tr></table>';
|
||||
}
|
||||
|
||||
@ -5370,7 +5370,9 @@ class Form
|
||||
}
|
||||
}
|
||||
|
||||
$out.='<select id="'.preg_replace('/^\./','',$htmlname).'" '.($disabled?'disabled ':'').'class="flat '.(preg_replace('/^\./','',$htmlname)).($morecss?' '.$morecss:'').'" name="'.preg_replace('/^\./','',$htmlname).'" '.($moreparam?$moreparam:'').'>';
|
||||
$out.='<select id="'.preg_replace('/^\./','',$htmlname).'" '.($disabled?'disabled ':'').'class="flat '.(preg_replace('/^\./','',$htmlname)).($morecss?' '.$morecss:'').'"';
|
||||
$out.=' name="'.preg_replace('/^\./','',$htmlname).'" '.($moreparam?$moreparam:'');
|
||||
$out.='>';
|
||||
|
||||
if ($show_empty)
|
||||
{
|
||||
@ -5407,10 +5409,6 @@ class Form
|
||||
$style=' class="warning"';
|
||||
}
|
||||
}
|
||||
$out.='<option value="'.$key.'"';
|
||||
$out.=$style.$disabled;
|
||||
if ($id != '' && $id == $key && ! $disabled) $out.=' selected'; // To preselect a value
|
||||
$out.='>';
|
||||
|
||||
if ($key_in_label)
|
||||
{
|
||||
@ -5423,6 +5421,12 @@ class Form
|
||||
else $selectOptionValue = $maxlen?dol_trunc($value,$maxlen):$value;
|
||||
if ($value == '' || $value == '-') $selectOptionValue=' ';
|
||||
}
|
||||
|
||||
$out.='<option value="'.$key.'"';
|
||||
$out.=$style.$disabled;
|
||||
if ($id != '' && $id == $key && ! $disabled) $out.=' selected'; // To preselect a value
|
||||
if ($nohtmlescape) $out.=' html="'.dol_escape_htmltag($selectOptionValue).'"';
|
||||
$out.='>';
|
||||
//var_dump($selectOptionValue);
|
||||
$out.=$selectOptionValue;
|
||||
$out.="</option>\n";
|
||||
|
||||
@ -1001,8 +1001,8 @@ class FormOther
|
||||
{
|
||||
if (! empty($boxidactivatedforuser[$box->id])) continue; // Already visible for user
|
||||
$label=$langs->transnoentitiesnoconv($box->boxlabel);
|
||||
if (preg_match('/graph/',$box->class)) $label.=' ('.$langs->trans("Graph").')';
|
||||
//$label = '<span class="fa fa-home fa-fw" aria-hidden="true"></span>'.$label; KO with select2. No html rendering.
|
||||
//if (preg_match('/graph/',$box->class)) $label.=' ('.$langs->trans("Graph").')';
|
||||
if (preg_match('/graph/',$box->class)) $label=$label.' <span class="fa fa-bar-chart"></span>';
|
||||
$arrayboxtoactivatelabel[$box->id]=$label; // We keep only boxes not shown for user, to show into combo list
|
||||
}
|
||||
foreach($boxidactivatedforuser as $boxid)
|
||||
@ -1014,6 +1014,7 @@ class FormOther
|
||||
//var_dump($boxidactivatedforuser);
|
||||
|
||||
// Class Form must have been already loaded
|
||||
$selectboxlist.='<!-- Form with select box list -->'."\n";
|
||||
$selectboxlist.='<form id="addbox" name="addbox" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
$selectboxlist.='<input type="hidden" name="addbox" value="addbox">';
|
||||
$selectboxlist.='<input type="hidden" name="userid" value="'.$user->id.'">';
|
||||
@ -1086,6 +1087,7 @@ class FormOther
|
||||
var self = this; // because JQuery can modify this
|
||||
var boxid=self.id.substring(8);
|
||||
var label=jQuery(\'#boxlabelentry\'+boxid).val();
|
||||
console.log("We close box "+boxid);
|
||||
jQuery(\'#boxto_\'+boxid).remove();
|
||||
if (boxid > 0) jQuery(\'#boxcombo\').append(new Option(label, boxid));
|
||||
updateBoxOrder(1); /* 1 to avoid message after a remove */
|
||||
|
||||
@ -427,6 +427,28 @@ function urlencode(s) {
|
||||
return news;
|
||||
}
|
||||
|
||||
/*
|
||||
* =================================================================
|
||||
* Purpose: Clean string to have it url encoded
|
||||
* Input: s
|
||||
* Author: Laurent Destailleur
|
||||
* Licence: GPL
|
||||
* ==================================================================
|
||||
*/
|
||||
function htmlEntityDecodeJs(inp){
|
||||
var replacements = {'<':'<','>':'>','/':'/','"':'"',''':'\'','&':'&',' ':' '};
|
||||
if (inp)
|
||||
{
|
||||
for(var r in replacements){
|
||||
inp = inp.replace(new RegExp(r,'g'),replacements[r]);
|
||||
}
|
||||
return inp.replace(/&#(\d+);/g, function(match, dec) {
|
||||
return String.fromCharCode(dec);
|
||||
});
|
||||
}
|
||||
else { return ''; }
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* =================================================================
|
||||
|
||||
@ -418,11 +418,16 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $
|
||||
$(container).addClass($(data.element).attr("class"));
|
||||
}
|
||||
|
||||
//console.log(data.html);
|
||||
if ($(data.element).attr("html") != undefined) return htmlEntityDecodeJs($(data.element).attr("html")); // If property html set, we decode html entities and use this
|
||||
return data.text;
|
||||
},
|
||||
templateSelection: function (selection) { /* Format visible output of selected value */
|
||||
return selection.text;
|
||||
},
|
||||
escapeMarkup: function(markup) {
|
||||
return markup;
|
||||
}
|
||||
})';
|
||||
if ($forcefocus) $msg.= '.select2(\'focus\')';
|
||||
$msg.= ';'."\n";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user