javascript: remove hardcoding of dialog box for

manage_table
This commit is contained in:
Dany De Bontridder 2020-09-27 11:08:33 +02:00 committed by Dany De Bontridder
parent 0982ee1c4a
commit 232fd902fe
4 changed files with 42 additions and 9 deletions

View file

@ -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']);
}
}

View file

@ -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

View file

@ -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")

View file

@ -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">',