Skip to content
Permalink
Browse files

Convert to dialog workflow

  • Loading branch information...
flack committed Oct 7, 2019
1 parent 0b47d33 commit aa71cdd2d7eec3f2e27c16e133978b9fec2a06e7
@@ -65,7 +65,7 @@ private function _process_order_form(Request $request)
if ($success) {
midcom::get()->uimessages->add($this->_l10n->get($this->_component), $this->_l10n_midcom->get('order saved'));
return new midcom_response_relocate('');
return $this->get_workflow('viewer')->js_response('refresh_opener();');
}
}
@@ -131,8 +131,8 @@ public function _handler_order(Request $request, array &$data)
// Set page title
$data['folder'] = $this->_topic;
$data['title'] = sprintf($this->_l10n->get('order navigation in folder %s'), $this->_topic->get_label());
midcom::get()->head->set_pagetitle($data['title']);
$title = sprintf($this->_l10n->get('order navigation in folder %s'), $this->_topic->get_label());
midcom::get()->head->set_pagetitle($title);
// Set the help object in the toolbar
$help_toolbar = midcom::get()->toolbars->get_help_toolbar();
@@ -147,6 +147,7 @@ public function _handler_order(Request $request, array &$data)
$this->add_stylesheet(MIDCOM_STATIC_URL . '/midcom.admin.folder/midcom-admin-order.css');
$this->add_stylesheet(MIDCOM_STATIC_URL . '/stock-icons/font-awesome-4.7.0/css/font-awesome.min.css');
}
return $this->get_workflow('viewer')->run($request);
}
/**
@@ -1,4 +1,3 @@
<h1><?php echo $data['title']; ?></h1>
<form method="post" action="<?php echo midcom_connection::get_url('uri'); ?>" id="midcom_admin_folder_order_form_sort_type" class="datamanager datamanager2 midcom_admin_folder sort_folder">
<div class="wrapper">
<label for="midcom_admin_folder_order_navorder">
@@ -82,12 +82,12 @@ private function add_commands()
if ( $this->topic->can_do('midgard:update')
&& $this->topic->can_do('midcom.admin.folder:topic_management')) {
$buttons[] = [
MIDCOM_TOOLBAR_URL => "__ais/folder/order/",
$viewer = new midcom\workflow\viewer;
$buttons[] = $viewer->get_button("__ais/folder/order/", [
MIDCOM_TOOLBAR_LABEL => midcom::get()->i18n->get_string('order navigation', 'midcom.admin.folder'),
MIDCOM_TOOLBAR_GLYPHICON => 'sort',
MIDCOM_TOOLBAR_ACCESSKEY => 'o',
];
]);
$buttons[] = [
MIDCOM_TOOLBAR_URL => midcom_connection::get_url('self') . "__mfa/asgard/object/open/{$this->topic->guid}/",
@@ -14,7 +14,6 @@
use midcom\datamanager\controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelEvents;
/**
* @package midcom.workflow
@@ -74,11 +73,7 @@ public function run(Request $request) : Response
if ($this->state == controller::SAVE) {
$script = $this->handle_save();
midcom::get()->head->add_jsfile(MIDCOM_STATIC_URL . '/midcom.workflow/dialog.js');
midcom::get()->head->add_jscript($script);
midcom::get()->dispatcher->addListener(KernelEvents::RESPONSE, [midcom::get()->head, 'inject_head_elements']);
$content = '<!DOCTYPE html><html><head>' . \midcom_helper_head::TOOLBAR_PLACEHOLDER . '</head><body></body></html>';
return new Response($content);
return $this->js_response($script);
}
$context = midcom_core_context::get();
$context->set_key(MIDCOM_CONTEXT_SHOWCALLBACK, [$this->controller, 'display_form']);
@@ -13,6 +13,7 @@
use midcom_response_styled;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelEvents;
/**
* Workflow base class
@@ -110,6 +111,15 @@ public function render_attributes() : string
return $output;
}
public function js_response(string $script) : Response
{
midcom::get()->head->add_jsfile(MIDCOM_STATIC_URL . '/midcom.workflow/dialog.js');
midcom::get()->head->add_jscript($script);
midcom::get()->dispatcher->addListener(KernelEvents::RESPONSE, [midcom::get()->head, 'inject_head_elements']);
$content = '<!DOCTYPE html><html><head>' . \midcom_helper_head::TOOLBAR_PLACEHOLDER . '</head><body></body></html>';
return new Response($content);
}
abstract public function get_button_config() : array;
abstract public function run(Request $request) : Response;

0 comments on commit aa71cdd

Please sign in to comment.
You can’t perform that action at this time.