Fix management of collapsing of extrafields separators.
This commit is contained in:
parent
bfe6f4a163
commit
d2d7fb4b04
@ -1628,7 +1628,7 @@ class ExtraFields
|
|||||||
if ($hidden) return ''; // This is a protection. If field is hidden, we should just not call this method.
|
if ($hidden) return ''; // This is a protection. If field is hidden, we should just not call this method.
|
||||||
|
|
||||||
//if ($computed) $value = // $value is already calculated into $value before calling this method
|
//if ($computed) $value = // $value is already calculated into $value before calling this method
|
||||||
|
|
||||||
$showsize=0;
|
$showsize=0;
|
||||||
if ($type == 'date')
|
if ($type == 'date')
|
||||||
{
|
{
|
||||||
@ -1972,24 +1972,29 @@ class ExtraFields
|
|||||||
if (count($extrafield_param_list) > 0) {
|
if (count($extrafield_param_list) > 0) {
|
||||||
$extrafield_collapse_display_value = intval($extrafield_param_list[0]);
|
$extrafield_collapse_display_value = intval($extrafield_param_list[0]);
|
||||||
if ($extrafield_collapse_display_value == 1 || $extrafield_collapse_display_value == 2) {
|
if ($extrafield_collapse_display_value == 1 || $extrafield_collapse_display_value == 2) {
|
||||||
$collapse_display = ($extrafield_collapse_display_value == 2 ? false : true);
|
// Set the collapse_display status to cookie in priority or if ignorecollapsesetup is 1, if cookie and ignorecollapsesetup not defined, use the setup.
|
||||||
|
$collapse_display = ((isset($_COOKIE['DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key]) || GETPOST('ignorecollapsesetup', 'int')) ? ($_COOKIE['DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key] ? true : false) : ($extrafield_collapse_display_value == 2 ? false : true));
|
||||||
$extrafields_collapse_num = $this->attributes[$object->table_element]['pos'][$key];
|
$extrafields_collapse_num = $this->attributes[$object->table_element]['pos'][$key];
|
||||||
|
|
||||||
|
$out .= '<!-- Add js script to manage the collpase/uncollapse of extrafields separators '.$key.' -->';
|
||||||
$out .= '<script type="text/javascript">';
|
$out .= '<script type="text/javascript">';
|
||||||
$out .= 'jQuery(document).ready(function(){';
|
$out .= 'jQuery(document).ready(function(){';
|
||||||
if ($collapse_display === false) {
|
if ($collapse_display === false) {
|
||||||
$out .= ' jQuery("#trextrafieldseparator' . $key . ' td").prepend("<span class=\"cursorpointer fa fa-plus-square\"></span> ");';
|
$out .= ' jQuery("#trextrafieldseparator' . $key . ' td").prepend("<span class=\"cursorpointer fa fa-plus-square\"></span> ");'."\n";
|
||||||
$out .= ' jQuery(".trextrafields_collapse' . $extrafields_collapse_num . '").hide();';
|
$out .= ' jQuery(".trextrafields_collapse' . $extrafields_collapse_num . '").hide();'."\n";
|
||||||
} else {
|
} else {
|
||||||
$out .= ' jQuery("#trextrafieldseparator' . $key . ' td").prepend("<span class=\"cursorpointer fa fa-minus-square\"></span> ");';
|
$out .= ' jQuery("#trextrafieldseparator' . $key . ' td").prepend("<span class=\"cursorpointer fa fa-minus-square\"></span> ");'."\n";
|
||||||
|
$out .= ' document.cookie = "DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key.'=1; path='.$_SERVER["PHP_SELF"].'"'."\n";
|
||||||
}
|
}
|
||||||
$out .= ' jQuery("#trextrafieldseparator' . $key . '").click(function(){';
|
$out .= ' jQuery("#trextrafieldseparator' . $key . '").click(function(){'."\n";
|
||||||
$out .= ' jQuery(".trextrafields_collapse' . $extrafields_collapse_num . '").toggle("slow", function(){';
|
$out .= ' jQuery(".trextrafields_collapse' . $extrafields_collapse_num . '").toggle(300, function(){'."\n";
|
||||||
$out .= ' if (jQuery(".trextrafields_collapse' . $extrafields_collapse_num . '").is(":hidden")) {';
|
$out .= ' if (jQuery(".trextrafields_collapse' . $extrafields_collapse_num . '").is(":hidden")) {'."\n";
|
||||||
$out .= ' jQuery("#trextrafieldseparator' . $key . ' td span").addClass("fa-plus-square").removeClass("fa-minus-square");';
|
$out .= ' jQuery("#trextrafieldseparator' . $key . ' td span").addClass("fa-plus-square").removeClass("fa-minus-square");'."\n";
|
||||||
$out .= ' } else {';
|
$out .= ' document.cookie = "DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key.'=0; path='.$_SERVER["PHP_SELF"].'"'."\n";
|
||||||
$out .= ' jQuery("#trextrafieldseparator' . $key . ' td span").addClass("fa-minus-square").removeClass("fa-plus-square");';
|
$out .= ' } else {'."\n";
|
||||||
$out .= ' }';
|
$out .= ' jQuery("#trextrafieldseparator' . $key . ' td span").addClass("fa-minus-square").removeClass("fa-plus-square");'."\n";
|
||||||
|
$out .= ' document.cookie = "DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key.'=1; path='.$_SERVER["PHP_SELF"].'"'."\n";
|
||||||
|
$out .= ' }'."\n";
|
||||||
$out .= ' });';
|
$out .= ' });';
|
||||||
$out .= ' });';
|
$out .= ' });';
|
||||||
$out .= '});';
|
$out .= '});';
|
||||||
|
|||||||
@ -49,6 +49,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
|
|||||||
//var_dump($extrafields->attributes[$object->table_element]);
|
//var_dump($extrafields->attributes[$object->table_element]);
|
||||||
if (empty($reshook) && is_array($extrafields->attributes[$object->table_element]['label']))
|
if (empty($reshook) && is_array($extrafields->attributes[$object->table_element]['label']))
|
||||||
{
|
{
|
||||||
|
$lastseparatorkeyfound = '';
|
||||||
$extrafields_collapse_num = '';
|
$extrafields_collapse_num = '';
|
||||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label)
|
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label)
|
||||||
{
|
{
|
||||||
@ -101,6 +102,8 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element]
|
|||||||
}
|
}
|
||||||
|
|
||||||
print $extrafields->showSeparator($key, $object);
|
print $extrafields->showSeparator($key, $object);
|
||||||
|
|
||||||
|
$lastseparatorkeyfound=$key;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -108,8 +111,7 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element]
|
|||||||
print '<td class="titlefield">';
|
print '<td class="titlefield">';
|
||||||
print '<table width="100%" class="nobordernopadding">';
|
print '<table width="100%" class="nobordernopadding">';
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td';
|
print '<td class="';
|
||||||
print ' class="';
|
|
||||||
//var_dump($action);exit;
|
//var_dump($action);exit;
|
||||||
|
|
||||||
if ((! empty($action) && ($action == 'create' || $action == 'edit')) && ! empty($extrafields->attributes[$object->table_element]['required'][$key])) print ' fieldrequired';
|
if ((! empty($action) && ($action == 'create' || $action == 'edit')) && ! empty($extrafields->attributes[$object->table_element]['required'][$key])) print ' fieldrequired';
|
||||||
@ -136,7 +138,7 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element]
|
|||||||
{
|
{
|
||||||
$fieldid='id';
|
$fieldid='id';
|
||||||
if ($object->table_element == 'societe') $fieldid='socid';
|
if ($object->table_element == 'societe') $fieldid='socid';
|
||||||
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?'.$fieldid.'=' . $object->id . '&action=edit_extras&attribute=' . $key . '">' . img_edit().'</a></td>';
|
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?'.$fieldid.'=' . $object->id . '&action=edit_extras&attribute=' . $key . '&ignorecollapsesetup=1">' . img_edit().'</a></td>';
|
||||||
}
|
}
|
||||||
print '</tr></table>';
|
print '</tr></table>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user