[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 07/10: Improve ManageTable : input can return
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 07/10: Improve ManageTable : input can return a value + cosmetic |
Date: |
Sun, 28 Mar 2021 09:22:05 -0400 (EDT) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit b607bb138ec2882517101c0f20bfab7714702970
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Thu Mar 25 17:44:30 2021 +0100
Improve ManageTable : input can return a value + cosmetic
---
html/js/managetable.js | 12 +++++++++++-
include/lib/manage_table_sql.class.php | 27 +++++++++++++++++++--------
2 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/html/js/managetable.js b/html/js/managetable.js
index ba54f18..5d8081b 100644
--- a/html/js/managetable.js
+++ b/html/js/managetable.js
@@ -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;
diff --git a/include/lib/manage_table_sql.class.php
b/include/lib/manage_table_sql.class.php
index fc14cb0..5b9ea64 100644
--- a/include/lib/manage_table_sql.class.php
+++ b/include/lib/manage_table_sql.class.php
@@ -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>';
- [Noalyss-commit] [noalyss] branch master updated (a02ebda -> b00558e), Dany De Bontridder, 2021/03/28
- [Noalyss-commit] [noalyss] 01/10: Manage_Table : add CSS Class, Dany De Bontridder, 2021/03/28
- [Noalyss-commit] [noalyss] 02/10: Merge branch 'master' of gitlab.noalyss.eu:noalyss/noalyss, Dany De Bontridder, 2021/03/28
- [Noalyss-commit] [noalyss] 03/10: Merge branch 'd8103', Dany De Bontridder, 2021/03/28
- [Noalyss-commit] [noalyss] 05/10: Task #0001878: quantité sur deux décimales, Dany De Bontridder, 2021/03/28
- [Noalyss-commit] [noalyss] 10/10: Task #0001904: Previsions et budgets Ajout montant initial and estimation cumulée pour avoir évolution passif/actif, Dany De Bontridder, 2021/03/28
- [Noalyss-commit] [noalyss] 08/10: Task #0001904: Previsions et budgets rewriting of forecast : missing SQL files, Dany De Bontridder, 2021/03/28
- [Noalyss-commit] [noalyss] 07/10: Improve ManageTable : input can return a value + cosmetic,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 06/10: Task #0001904: Previsions et budgets Réécriture prévision, Dany De Bontridder, 2021/03/28
- [Noalyss-commit] [noalyss] 09/10: Cosmetic, Dany De Bontridder, 2021/03/28
- [Noalyss-commit] [noalyss] 04/10: Task #1913 : cosmetic CSS, Dany De Bontridder, 2021/03/28