Improve ManageTable : input can return a value + cosmetic

This commit is contained in:
sparkyx 2021-03-25 17:44:30 +01:00
parent d0274f5bed
commit b607bb138e
2 changed files with 30 additions and 9 deletions

View file

@ -128,7 +128,17 @@ var ManageTable = function (p_table_name)
// value if less than insert before
var i = 0;
for (i = 1;i<p_table.rows.length;i++) {
if (p_table.rows[i].cells[sort_column].getAttribute('sort_value') > p_element_row.cells[sort_column].getAttribute('sort_value')) {
var table_value=p_table.rows[i].cells[sort_column].getAttribute('sort_value') ;
var element_value=p_element_row.cells[sort_column].getAttribute('sort_value');
// if both are numeric so we force a numeric comparison
if ( ! isNaN(parseFloat(table_value)) && ! isNaN(parseFloat(element_value)) ) {
table_value=parseFloat(table_value);
element_value=parseFloat(element_value);
}
if (table_value > element_value) {
var row=p_table.insertRow(i);
row.innerHTML=p_element_row.innerHTML;
row.id=p_element_row.id;

View file

@ -997,7 +997,10 @@ function check()
* to be appended or modified. Can be override if you need
* a more complex form or add elements with "set_order" before
* calling this function.
* This function does not add the form , only the table,
* This function does not add the form , only the table.
*
* It returns true , if it is not readyonly and the form will have a "save" button, if it returns nothing or false
* then there is no save button, nor form, the content is then readonly
*
*/
function input()
@ -1089,6 +1092,7 @@ function check()
echo "</tr>";
}
echo "</table>";
return true;
}
/**
* @brief this function let you create your own input , for example for a ITEXT , a IRADIO , ...
@ -1179,7 +1183,10 @@ function check()
}
/**
* @brief send an xml with input of the object, create an xml answer.
* @brief send an xml with input of the object, create an xml answer. It will call Manage_Table_SQL.input to
* display the input , but if that function returns false, the "save" button will disappear but the form can be
* submitted with enter.
*
* XML Tag
* - status : OK , NOK
* - ctl : Dom id to update
@ -1201,7 +1208,8 @@ function check()
$this->object_name, $this->table->get_pk_value(),
$this->object_name, $this->object_name,
$this->table->get_pk_value());
$this->input();
$can_update=$this->input();
$can_update =( $can_update===false) ? false:true;
// JSON param to hidden
echo HtmlInput::json_to_hidden($this->json_parameter);
echo HtmlInput::hidden("p_id", $this->table->get_pk_value());
@ -1209,11 +1217,14 @@ function check()
$close=sprintf("\$('%s').remove()", $this->dialog_box);
// display error if any
$this->display_error();
echo '<ul class="aligned-block">',
'<li>',
HtmlInput::submit('update', _("Sauver")),
'</li>',
'<li>',
echo '<ul class="aligned-block">';
// form readonly
if ( $can_update ) {
echo '<li>',
HtmlInput::submit('update', _("Sauver")),
'</li>';
}
echo '<li>',
HtmlInput::button_action(_("Annuler"), $close, "", "smallbutton"),
'</li>',
'</ul>';