Skip to content

Commit

Permalink
Split display tables
Browse files Browse the repository at this point in the history
* The Errors Table should only supply the delete row method.
  • Loading branch information
Jack-Dane committed Nov 12, 2023
1 parent dc4098a commit 92decb0
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 22 deletions.
25 changes: 17 additions & 8 deletions admin/pageHelpers/table_display.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ function odoo_conn_page_scripts_callback()
}


class OdooConnCustomTableDisplay extends WP_List_Table
{
class OdooConnCustomTableDeletableDisplay extends WP_List_Table {

protected $get_backend;
protected $delete_backend;
Expand All @@ -41,16 +40,10 @@ public function __construct($get_backend, $delete_backend, $args = array())
protected function row_action_buttons($item)
{
return array(
"edit" => "<a href='?page=${_REQUEST["page"]}&id=${item["id"]}&page_action=edit'>Edit</a>",
"delete" => "<a href='?page=${_REQUEST["page"]}&id=${item["id"]}&page_action=delete'>Delete</a>"
);
}

public function column_name($item)
{
return $item["name"] . " " . $this->row_actions($this->row_action_buttons($item));
}

public function get_bulk_actions()
{
return array(
Expand Down Expand Up @@ -124,4 +117,20 @@ public function column_cb($item)
}


class OdooConnCustomTableEditableDisplay extends OdooConnCustomTableDeletableDisplay
{

protected function row_action_buttons($item)
{
return array_merge(
parent::row_action_buttons($item),
array(
"edit" => "<a href='?page=${_REQUEST["page"]}&id=${item["id"]}&page_action=edit'>Edit</a>"
)
);
}

}


?>
11 changes: 8 additions & 3 deletions admin/pages/connections/odoo_connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@
use odoo_conn\encryption\OdooConnEncryptionHandler;


class OdooConnOdooConnectionListTable extends OdooConnCustomTableDisplay
class OdooConnOdooConnectionListTableEditable extends OdooConnCustomTableEditableDisplay
{

function get_columns()
public function column_name($item)
{
return $item["name"] . " " . $this->row_actions($this->row_action_buttons($item));
}

public function get_columns()
{
return array(
"cb" => '<input type="checkbox" />',
Expand Down Expand Up @@ -57,7 +62,7 @@ protected function create_new_record()

protected function create_table_display()
{
return new OdooConnOdooConnectionListTable(
return new OdooConnOdooConnectionListTableEditable(
$this->get_backend, $this->delete_backend
);
}
Expand Down
23 changes: 17 additions & 6 deletions admin/pages/errors/odoo_errors.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
use odoo_conn\admin\api\endpoints\OdooConnDeleteOdooErrors;


class OdooConnOdooErrorsListTable extends OdooConnCustomTableDisplay
class OdooConnOdooErrorsListTableEditable extends OdooConnCustomTableDeletableDisplay
{

function get_columns()
public function column_contact_7_title($item)
{
return $item["contact_7_title"] . " " . $this->row_actions($this->row_action_buttons($item));
}

public function get_columns()
{
return array(
"cb" => "<input type='checkbox' />",
Expand All @@ -24,16 +29,22 @@ function get_columns()

class OdooConnOdooErrorRouter extends OdooConnPageRouter {

public function __construct()
{
$this->get_backend = new OdooConnGetOdooErrors(ARRAY_A);
$this->delete_backend = new OdooConnDeleteOdooErrors();
}

protected function create_table_display()
{
$odoo_errors_get_backend = new OdooConnGetOdooErrors(ARRAY_A);
$odoo_errors_delete_backend = new OdooConnDeleteOdooErrors();
return new OdooConnOdooErrorsListTable($odoo_errors_get_backend, $odoo_errors_delete_backend);
return new OdooConnOdooErrorsListTableEditable(
$this->get_backend, $this->delete_backend
);
}

protected function delete($id)
{
// TODO: Implement delete() method.
$this->delete_backend->request(["id" => $id]);
}
}

Expand Down
4 changes: 2 additions & 2 deletions admin/pages/form_mappings/odoo_form_mapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use odoo_conn\admin\api\endpoints\OdooConnPutOdooFormMappings;


class OdooConnOdooFormMappingListTable extends OdooConnCustomTableDisplay
class OdooConnOdooFormMappingListTableEditable extends OdooConnCustomTableEditableDisplay
{

public function column_odoo_form_name($item)
Expand Down Expand Up @@ -47,7 +47,7 @@ public function __construct($menu_slug)

protected function create_table_display()
{
return new OdooConnOdooFormMappingListTable(
return new OdooConnOdooFormMappingListTableEditable(
$this->get_backend, $this->delete_backend
);
}
Expand Down
11 changes: 8 additions & 3 deletions admin/pages/forms/odoo_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@
use odoo_conn\admin\api\endpoints\OdooConnPutOdooForm;


class OdooConnOdooFormListTable extends OdooConnCustomTableDisplay
class OdooConnOdooFormListTableEditable extends OdooConnCustomTableEditableDisplay
{

function get_columns()
public function column_name($item)
{
return $item["name"] . " " . $this->row_actions($this->row_action_buttons($item));
}

public function get_columns()
{
return array(
"cb" => "<input type='checkbox' />",
Expand Down Expand Up @@ -53,7 +58,7 @@ protected function create_new_record()

protected function create_table_display()
{
return new OdooConnOdooFormListTable(
return new OdooConnOdooFormListTableEditable(
$this->get_backend, $this->delete_backend
);
}
Expand Down

0 comments on commit 92decb0

Please sign in to comment.