Skip to content

Commit

Permalink
Include the create record button in the page's wrap div
Browse files Browse the repository at this point in the history
* It adds a margin to the top of the div, so it isn't touching the top menu bar.
* Use the apache WordPress image, just pull the latest image when it is out of date.
  • Loading branch information
Jack-Dane committed Jun 15, 2024
1 parent 2e6ede8 commit efd719f
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion admin/pages/connections/odoo_connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ protected function create_new_record()
$post_odoo_connection->request($_REQUEST);
}

protected function create_table_display()
protected function get_table_display()
{
return new OdooConnOdooConnectionListTableEditable(
$this->get_backend, $this->delete_backend
Expand Down
2 changes: 1 addition & 1 deletion admin/pages/errors/odoo_errors.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct()
parent::__construct();
}

protected function create_table_display()
protected function get_table_display()
{
return new OdooConnOdooErrorsListTableEditable(
$this->get_backend, $this->delete_backend
Expand Down
2 changes: 1 addition & 1 deletion admin/pages/form_mappings/odoo_form_mapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function __construct($menu_slug)
parent::__construct($menu_slug);
}

protected function create_table_display()
protected function get_table_display()
{
return new OdooConnOdooFormMappingListTableEditable(
$this->get_backend, $this->delete_backend
Expand Down
2 changes: 1 addition & 1 deletion admin/pages/forms/odoo_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected function create_new_record()
$post_odoo_connection->request($_REQUEST);
}

protected function create_table_display()
protected function get_table_display()
{
return new OdooConnOdooFormListTableEditable(
$this->get_backend, $this->delete_backend
Expand Down
30 changes: 22 additions & 8 deletions admin/pages/page_router.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ abstract class OdooConnPageRouter

public function __construct()
{
$this->table_display = $this->create_table_display();
$this->table_display = $this->get_table_display();
}

private function valid_capability() {
Expand Down Expand Up @@ -47,16 +47,26 @@ protected function handle_route($action)

protected function display_table()
{
echo "<div class='wrap'>";
$this->start_wrap();
$this->table_display->check_bulk_action();

echo "<form method='post'>";
$this->table_display->prepare_items();
$this->table_display->display();
echo "</form></div>";
echo "</form>";

$this->end_wrap();
}

protected abstract function create_table_display();
protected function start_wrap() {
echo "<div class='wrap'>";
}

protected function end_wrap() {
echo "</div>";
}

protected abstract function get_table_display();

protected abstract function delete($id);

Expand Down Expand Up @@ -113,7 +123,6 @@ private function verify_nonce() {
protected function display_table()
{
$request_method = $_SERVER["REQUEST_METHOD"];
$menu_page_slug = menu_page_url($this->menu_slug, false);

if ($request_method == "POST") {
$this->verify_nonce();
Expand All @@ -125,12 +134,17 @@ protected function display_table()
}
}

$connection_url = esc_url(add_query_arg("page_action", "new", $menu_page_slug));
echo "<a href='$connection_url' id='create-data' class='create-database-record button-primary'>Create a new record</a>";

parent::display_table();
}

protected function start_wrap() {
parent::start_wrap();

$menu_page_slug = menu_page_url($this->menu_slug, false);
$create_record_url = esc_url(add_query_arg("page_action", "new", $menu_page_slug));
echo "<a href='$create_record_url' id='create-data' class='create-database-record button-primary'>Create a new record</a>";
}

protected abstract function create_new_record();

protected abstract function update_record();
Expand Down
2 changes: 1 addition & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: '3.1'
services:

wordpress:
image: wordpress:beta-6.5-php8.3-apache
image: wordpress:apache
restart: always
ports:
- 8080:80
Expand Down

0 comments on commit efd719f

Please sign in to comment.