Commit 28891f0d authored by Carsten  Rose's avatar Carsten Rose
Browse files

Merge branch 'F6100UrlForwardAuto'

parents f0143573 b3bd1882
......@@ -224,18 +224,22 @@ The format of redirect information is outlined below
{
...
"redirect": "no" | "url" | "url-skip-history" | "client"
"redirect": "no" | "url" | "url-skip-history" | "auto" | "close"
"redirect-url": "<url>"
...
}
`"redirect"`
: type of redirection. `"no"` advises the Client to stay on the
Current Page. `"client"` advises the Client to decide where to
redirect to. `"url"` advices the Client to redirect to the URL
provided in `"redirect-url"`. `"url-skip-history"` behaves like
`"url"` but the current page will skip the browser history.
: type of redirection.
* `"no"` advises the Client to stay on the Current Page.
* `"close"` the client goes back one in history - if there is no history, stays on the same page.
* `"auto"` the Client decide where to redirect to.
* if the user clicks 'save', stay on the same page.
* if the user clicks 'close', go back one in history - if there is no history, stays on the same page.
* `"url"` advices the Client to redirect to the URL provided in `"redirect-url"`.
* `"url-skip-history"` behaves like `"url"` but the current page will skip the browser history.
`"redirect-url"`
: Used to provide an URL when `"redirect"` is set to `"url"`. It
......
......@@ -1888,7 +1888,7 @@ Definition
+-------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
|Show button | 'new, delete, close, save' (Default: 'new,delete,close,save'): Shown named buttons in the upper right corner of the form. See `form-showButton`_ |
+-------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
|Forward Mode | 'client | no | url | url-skip-history' (Default: client): See `form-forward`_. |
|Forward Mode | 'auto | close | no | url | url-skip-history' (Default: auto): See `form-forward`_. |
+-------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
|Forward (Mode) Page | a) URL / Typo3 page id/alias or b) Forward Mode (via '{{...}}') or combination of a) & b). See `form-forward`_. |
+-------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
......@@ -2003,14 +2003,15 @@ Forward (=forwardMode)
After the user presses *Save*, *Close*, *Delete* or *New*, different actions are possible where the browser redirects to.
* `client` (default) - the QFQ browser Javascript logic, decides to stay on the page or to force a redirection
to a previous page.
* `auto` (default) - the QFQ browser Javascript logic, decides to stay on the page or to force a redirection
to a previous page. The decision depends on:
* *Close* closes the current page and goes back to the previous page. Note: if a new tab is opened and the user presses
QFQ close (in any way) - in that new browser tab there is no previous page! QFQ won't close the tab, instead a message
is shown
* *Close* goes back (feels like close) to the previous page. Note: if there is no history, QFQ won't close the tab,
instead a message is shown.
* *Save* stays on the current page.
* `close` - goes back (feels like close) to the previous page. Note: if there is no history, QFQ won't close the tab,
instead a message is shown.
* `no` - no change, the browser remains on the current side. Close does not close the page. It just triggers a save if
there are modified data.
* `url` - the browser redirects to the URL or T3 page named in `Forward URL / Page`. Independent if the user presses `save` or `close`.
......@@ -2031,14 +2032,14 @@ Format: [<url>] or [<mode>|<url>]
* `{{SELECT ...}}`
* `<mode>|<url>`
* `<mode>` - Valid keywords are as above: `no|client|url|url-skip-history`
* `<mode>` - Valid keywords are as above: `auto|close|no|url|url-skip-history`
Specifying the mode in `forwardPage` overwrites `formMode` (but only if `formMode` is `url...`).
Also regular QFQ statements like {{var}} or {{SELECT ...}} are possible in `forwardPage`. This is useful to dynamically
redirect to different targets, depending on user input or any other dependencies.
If a forwardMode 'url...' is specified and there is no `forwardPage`, QFQ falls down to `client` mode.
If a forwardMode 'url...' is specified and there is no `forwardPage`, QFQ falls down to `auto` mode.
On a form, the user might click 'save' or 'save,close' or 'close' (with modified data this leads to 'save,close').
The CLIENT `submit_reason` shows the user action:
......@@ -2048,7 +2049,7 @@ The CLIENT `submit_reason` shows the user action:
Example forwardPage
^^^^^^^^^^^^^^^^^^^
* `{{SELECT IF('{{formModeGlobal:S:alnumx}}'='requiredOff', 'no', 'client') }}`
* `{{SELECT IF('{{formModeGlobal:S:alnumx}}'='requiredOff', 'no', 'auto') }}`
* `{{SELECT IF('{{submit_reason:CE:alnumx}}'='save', 'no', 'url'), '|http://example.com' }}`
Type: combined dynamic mode & URL/page
......
......@@ -89,7 +89,7 @@ try {
$answer = array();
if ($flagSuccess) {
$answer[API_MESSAGE] = 'Deleted';
$answer[API_REDIRECT] = API_ANSWER_REDIRECT_CLIENT;
$answer[API_REDIRECT] = API_ANSWER_REDIRECT_AUTO;
$answer[API_STATUS] = API_ANSWER_STATUS_SUCCESS;
} else {
$answer[API_STATUS] = API_ANSWER_STATUS_ERROR;
......
......@@ -49,12 +49,12 @@ require_once(__DIR__ . '/../qfq/exceptions/DbException.php');
$answer = array();
$answer[API_REDIRECT] = API_ANSWER_REDIRECT_CLIENT;
$answer[API_REDIRECT] = API_ANSWER_REDIRECT_AUTO;
$answer[API_STATUS] = API_ANSWER_STATUS_ERROR;
$answer[API_MESSAGE] = '';
try {
$qfq = new \qfq\QuickFormQuery(['bodytext' => ""]);
$qfq = new QuickFormQuery(['bodytext' => ""]);
$data = $qfq->saveForm();
......
......@@ -684,7 +684,8 @@ const API_ANSWER_STATUS_SUCCESS = 'success';
const API_ANSWER_STATUS_CONFLICT = 'conflict';
const API_ANSWER_STATUS_CONFLICT_ALLOW_FORCE = 'conflict_allow_force';
const API_ANSWER_STATUS_ERROR = 'error';
const API_ANSWER_REDIRECT_CLIENT = 'client';
const API_ANSWER_REDIRECT_AUTO = 'auto';
const API_ANSWER_REDIRECT_CLOSE = 'close';
const API_ANSWER_REDIRECT_NO = 'no';
const API_ANSWER_REDIRECT_URL = 'url';
const API_ANSWER_REDIRECT_URL_SKIP_HISTORY = 'url-skip-history';
......@@ -791,7 +792,8 @@ const F_SHOW_BUTTON = 'showButton';
const F_FORWARD_MODE = 'forwardMode';
const F_FORWARD_PAGE = 'forwardPage';
const F_FORWARD_MODE_CLIENT = API_ANSWER_REDIRECT_CLIENT;
const F_FORWARD_MODE_AUTO = API_ANSWER_REDIRECT_AUTO;
const F_FORWARD_MODE_CLOSE = API_ANSWER_REDIRECT_CLOSE;
const F_FORWARD_MODE_NO = API_ANSWER_REDIRECT_NO;
const F_FORWARD_MODE_URL = API_ANSWER_REDIRECT_URL;
const F_FORWARD_MODE_URL_SKIP_HISTORY = API_ANSWER_REDIRECT_URL_SKIP_HISTORY;
......
......@@ -548,7 +548,8 @@ class QuickFormQuery {
$forward = trim($forwardArray[0]);
switch ($forward) {
case F_FORWARD_MODE_CLIENT:
case F_FORWARD_MODE_AUTO:
case F_FORWARD_MODE_CLOSE:
case F_FORWARD_MODE_NO:
case F_FORWARD_MODE_URL:
case F_FORWARD_MODE_URL_SKIP_HISTORY:
......@@ -568,7 +569,7 @@ class QuickFormQuery {
if ('url' == substr($this->formSpec[F_FORWARD_MODE], 0, 3)) {
if ($this->formSpec[F_FORWARD_PAGE] == '') {
$this->formSpec[F_FORWARD_MODE] = F_FORWARD_MODE_CLIENT;
$this->formSpec[F_FORWARD_MODE] = F_FORWARD_MODE_AUTO;
$customForward = false;
} else {
$customForward = true;
......
......@@ -114,6 +114,12 @@ $UPDATE_ARRAY = array(
"ALTER TABLE `Cron` ADD `outputPattern` VARCHAR(255) NOT NULL AFTER `outputMode`",
],
'18.04.5' => [
"ALTER TABLE `Form` CHANGE `forwardMode` `forwardMode` ENUM('auto', 'client','no','url','url-skip-history','url-sip') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'client'",
"UPDATE `Form` SET forwardMode='auto' WHERE forwardMode='client'",
"ALTER TABLE `Form` CHANGE `forwardMode` `forwardMode` ENUM('auto', 'close', 'no','url','url-skip-history','url-sip') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'auto';",
],
);
......
......@@ -727,7 +727,7 @@ var QfqNS = QfqNS || {};
this.setButtonEnabled(this.getNewButton(), false);
this.destroyFormAndSetText("Record has been deleted!");
if (!data.redirect || data.redirect === "client") {
if (!data.redirect || data.redirect === "auto") {
this.goBack();
return;
}
......@@ -988,13 +988,18 @@ var QfqNS = QfqNS || {};
return;
}
if (data.redirect === "close") {
this.goBack();
return;
}
break;
case 'close':
if (!data.redirect || data.redirect === "no") {
return;
}
if (data.redirect === "client") {
if (data.redirect === "auto" || data.redirect === "close") {
this.goBack();
return;
}
......@@ -1017,7 +1022,7 @@ var QfqNS = QfqNS || {};
return;
default:
if (data.redirect === "client") {
if (data.redirect === "auto") {
this.goBack();
return;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment