[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 37/119: javascript: remove hardcoding of dial
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 37/119: javascript: remove hardcoding of dialog box for manage_table |
Date: |
Mon, 26 Oct 2020 18:27:12 -0400 (EDT) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 232fd902fe9edfc4d608422b70166dffc6a8f188
Author: Dany De Bontridder <dany@alchimerys.be>
AuthorDate: Sun Sep 27 11:08:33 2020 +0200
javascript: remove hardcoding of dialog box for
manage_table
---
html/js/managetable.js | 8 ++++++--
html/js/scripts.js | 2 +-
include/ajax/ajax_save_predf_op.php | 10 ++++++++--
include/lib/manage_table_sql.class.php | 31 +++++++++++++++++++++++++++----
4 files changed, 42 insertions(+), 9 deletions(-)
diff --git a/html/js/managetable.js b/html/js/managetable.js
index 3d5d15f..916ba0e 100644
--- a/html/js/managetable.js
+++ b/html/js/managetable.js
@@ -87,6 +87,10 @@ var ManageTable = function (p_table_name)
this.sort_column=p_column;
};
+
+ this.set_dialog_box=function (p_dialog_box){
+ this.control=p_dialog_box;
+ }
/**
* Insert the row a the right location
* @param {type} p_element_row DOMElement TR
@@ -225,12 +229,12 @@ var ManageTable = function (p_table_name)
new Effect.Highlight(answer['ctl_row'] ,{startcolor:
'#FAD4D4',endcolor: '#F78082' });
alternate_row_color("tb"+answer['ctl']);
remove_waiting_box();
- $("dtr").hide();
+ $(here.control).hide();
} else {
remove_waiting_box();
smoke.alert(content[48]);
- $("dtr").update(answer['html']);
+ $(here.control).update(answer['html']);
}
}
diff --git a/html/js/scripts.js b/html/js/scripts.js
index 4451f83..3bd5e75 100644
--- a/html/js/scripts.js
+++ b/html/js/scripts.js
@@ -3676,7 +3676,7 @@ function toggle_row_warning_enable(p_enable, p_row)
/**
* return a json object which is the merge of the 2 json objects
- *
+ * from 2015 : Object.assign(obj1, obj2);
* @param p_json1 object 1 to merge
* @param p_json2 object 2 to merge
* @returns new json object
diff --git a/include/ajax/ajax_save_predf_op.php
b/include/ajax/ajax_save_predf_op.php
index c84830f..4286d1d 100644
--- a/include/ajax/ajax_save_predf_op.php
+++ b/include/ajax/ajax_save_predf_op.php
@@ -56,8 +56,14 @@ $operation_predef_mtable->set_callback("ajax_misc.php");
if ($action=="input")
{
- header('Content-type: text/xml; charset=UTF-8');
- echo $operation_predef_mtable->ajax_input()->saveXML();
+ if ($p_id == -1 ) {
+ // new operation to insert
+
+ } else {
+ // display existing operation for updating
+ header('Content-type: text/xml; charset=UTF-8');
+ echo $operation_predef_mtable->ajax_input()->saveXML();
+ }
return;
}
elseif ($action == "save")
diff --git a/include/lib/manage_table_sql.class.php
b/include/lib/manage_table_sql.class.php
index cd36468..2047942 100644
--- a/include/lib/manage_table_sql.class.php
+++ b/include/lib/manage_table_sql.class.php
@@ -71,15 +71,16 @@ class Manage_Table_SQL
protected $a_prop; //!< property for each col.
protected $a_type; //!< Type of the column : date , select ... Only in
input
protected $a_select; //!< Possible value if a_type is a SELECT
- protected $object_name; //!< Object_name is used for the javascript
+ protected $object_name; //!< Object_name is used for the javascript , it
is the row id to update or delete
protected $row_delete; //!< Flag to indicate if rows can be deleted
protected $row_update; //!< Flag to indicate if rows can be updated
protected $row_append; //!< Flag to indicate if rows can be added
- protected $json_parameter; //!< Default parameter to add (gDossier...)
+ protected $json_parameter; //!< Default parameter to add (gDossier...),
sent to the ajax callback
protected $aerror; //!< Array containing the error of the input data
protected $col_sort; //!< when inserting, it is the column to sort,-1 to
disable it and append only
protected $a_info; //!< Array with the infotip
protected $sort_column; //!< javascript sort , if empty there is no js sort
+ protected $dialog_box; //!< ID of the dialog box which display the result
of the ajax calls
const UPDATABLE=1;
const VISIBLE=2;
@@ -121,6 +122,7 @@ class Manage_Table_SQL
$this->col_sort=0;
// By default no js sort
$this->sort_column="";
+ $this->dialog_box="dtr";
}
/**
* send the XML headers for the ajax call
@@ -129,6 +131,25 @@ class Manage_Table_SQL
{
header('Content-type:text/xml;charset="UTF-8"');
}
+
+ /**
+ * @return mixed
+ */
+ public function get_dialog_box()
+ {
+ return $this->dialog_box;
+ return $this;
+ }
+
+ /**
+ * @param mixed $dialog_box
+ */
+ public function set_dialog_box($dialog_box)
+ {
+ $this->dialog_box = $dialog_box;
+ return $this;
+ }
+
/**
* When adding an element , it is column we checked to insert before,
* @return none
@@ -363,6 +384,7 @@ function check()
{$this->object_name}.set_callback(\"{$this->callback}\");
{$this->object_name}.param_add({$this->json_parameter});
{$this->object_name}.set_sort({$this->get_col_sort()});
+ {$this->object_name}.set_control(\"{$this->get_dialog_box()}\");
</script>
";
@@ -1046,9 +1068,10 @@ function check()
try
{
$status=$p_status;
+
ob_start();
- echo HtmlInput::title_box("Donnée", "dtr","close","","y");
+ echo HtmlInput::title_box("Donnée",
$this->dialog_box,"close","","y");
printf('<form id="frm%s_%s" method="POST"
onsubmit="%s.save(\'frm%s_%s\');return false;">',
$this->object_name, $this->table->get_pk_value(),
$this->object_name, $this->object_name,
@@ -1058,7 +1081,7 @@ function check()
echo HtmlInput::json_to_hidden($this->json_parameter);
echo HtmlInput::hidden("p_id", $this->table->get_pk_value());
// button Submit and cancel
- $close=sprintf("\$('%s').remove()", "dtr");
+ $close=sprintf("\$('%s').remove()", $this->dialog_box);
// display error if any
$this->display_error();
echo '<ul class="aligned-block">',
- [Noalyss-commit] [noalyss] 08/119: remove extract, (continued)
- [Noalyss-commit] [noalyss] 08/119: remove extract, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 03/119: Merge branch 'master' of gitlab.noalyss.eu:noalyss/noalyss, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 01/119: Fix warning with empty array, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 10/119: Fix bug : cannot use % when searching NEW : space can be used now, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 14/119: doc, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 11/119: Improve use of the security, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 17/119: javascript : add function to concat 2 json objects, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 18/119: javascript: remove hardcoding of dialog box for manage_table, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 30/119: Bug 1834 : duplicate , cannot confirm an duplicated operation because the $_GET is taken in priority, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 29/119: Remove debug info, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 37/119: javascript: remove hardcoding of dialog box for manage_table,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 52/119: NEW Security : add tag, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 22/119: ManageTable : you can set the style of the dialog box, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 23/119: Rewriting of Predefined Operation. You can add new Predefined Operation, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 43/119: Documentation, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 50/119: Follow-up search : show the closing status, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 60/119: FollowUp Deatil : add the amount + tva from card, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 74/119: Search concerned card with company , name , ... and export contact option to CSV, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 80/119: Follow Up : multiple card , search by category of card, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 15/119: doc, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 19/119: fix type, Dany De Bontridder, 2020/10/26