Commit b6cb6285 authored by Carsten  Rose's avatar Carsten Rose
Browse files

#3854 / Wrong final page: a) New > Save > Close, b) New > Save > Delete

QfqForm.js: Preparation for client, to handle window.location.replace() by new API status 'url-skip-history'. Also changed "(data.redirect === "url" || data['redirect-url'])" to "(data.redirect === "url" && data['redirect-url'])" - CR did not understand the former logic ('or' instead of 'and'). #OPEN#: window.location.replace = 'index.php....' throws an JS exception that it the attribute 'replace' is readonly. Instead "window.location.replace('index.php....')" works as expected.
PROTOCOL.md: add 'url-skip-history'.
save.php: recode to become more readable.
QuickFormQuery.php: getForwardMode() - temporarily fix to update status 'page' to 'url' (bug never caused a problem as long as '||' has been used on client side). Will change 'page' to 'url' asap.
parent ed4efb2a
......@@ -191,7 +191,7 @@ The format of redirect information is outlined below
{
...
"redirect": "no" | "url" | "client"
"redirect": "no" | "url" | "url-skip-history" | "client"
"redirect-url": "<url>"
...
}
......@@ -201,7 +201,8 @@ The format of redirect information is outlined below
: 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"`.
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
......
......@@ -63,7 +63,9 @@ try {
$data = $qfq->saveForm();
$answer[API_REDIRECT] = $qfq->getForwardMode($answer[API_REDIRECT_URL]);
$arr = $qfq->getForwardMode();
$answer[API_REDIRECT] = $arr[API_REDIRECT];
$answer[API_REDIRECT_URL] = $arr[API_REDIRECT_URL];
$answer[API_STATUS] = API_ANSWER_STATUS_SUCCESS;
$answer[API_MESSAGE] = 'save: success';
......
......@@ -538,6 +538,7 @@ const API_ANSWER_STATUS_ERROR = 'error';
const API_ANSWER_REDIRECT_CLIENT = 'client';
const API_ANSWER_REDIRECT_NO = 'no';
const API_ANSWER_REDIRECT_URL = 'url';
const API_ANSWER_REDIRECT_URL_SKIP_HISTORY = 'url-skip-history';
const API_TYPEAHEAD_KEY = 'key';
const API_TYPEAHEAD_VALUE = 'value';
......@@ -629,8 +630,8 @@ const F_SHOW_BUTTON = 'showButton';
const F_FORWARD_MODE = 'forwardMode';
const F_FORWARD_PAGE = 'forwardPage';
const F_FORWARD_MODE_CLIENT = 'client';
const F_FORWARD_MODE_NO = 'no';
const F_FORWARD_MODE_CLIENT = API_ANSWER_REDIRECT_CLIENT;
const F_FORWARD_MODE_NO = API_ANSWER_REDIRECT_NO;
const F_FORWARD_MODE_PAGE = 'page';
const F_FE_DATA_PATTERN_ERROR = 'data-pattern-error';
......
......@@ -159,14 +159,17 @@ class QuickFormQuery {
}
/**
* Returns the defined forwardMode and set $forwardPage (call by reference)
* Returns the defined forwardMode and set forwardPage
*
* @param $forwardPage
* @return mixed
* @return array
*/
public function getForwardMode(&$forwardPage) {
$forwardPage = $this->formSpec[F_FORWARD_PAGE];
return $this->formSpec[F_FORWARD_MODE];
public function getForwardMode() {
$mode = $this->formSpec[F_FORWARD_MODE];
if ($mode === F_FORWARD_MODE_PAGE) {
$mode = API_ANSWER_REDIRECT_URL;
}
return ([API_REDIRECT => $mode, API_REDIRECT_URL => $this->formSpec[F_FORWARD_PAGE]]);
}
/**
......@@ -374,7 +377,7 @@ class QuickFormQuery {
*/
private function buildNSetReloadUrl(array $formSpec, $recordId) {
$formSpec[F_FORWARD_MODE] = F_FORWARD_MODE_PAGE;
$formSpec[F_FORWARD_MODE] = API_ANSWER_REDIRECT_URL_SKIP_HISTORY;
// Rebuild original URL
$storeT3 = $this->store->getStore(STORE_TYPO3);
......
......@@ -503,9 +503,12 @@ var QfqNS = QfqNS || {};
return;
}
if (data.redirect === "url" || data['redirect-url']) {
if (data.redirect === "url" && data['redirect-url']) {
window.location = data['redirect-url'];
}
if (data.redirect === "url-skip-history" && data['redirect-url']) {
window.location.replace(data['redirect-url']);
}
};
......@@ -668,10 +671,16 @@ var QfqNS = QfqNS || {};
this.applyElementConfiguration(data['element-update']);
}
if (data.redirect === "url" || data['redirect-url']) {
if (data.redirect === "url" && data['redirect-url']) {
window.location = data['redirect-url'];
return;
}
if (data.redirect === "url-skip-history" && data['redirect-url']) {
window.location.replace(data['redirect-url']);
return;
}
break;
case 'close':
if (!data.redirect || data.redirect === "no") {
......@@ -683,10 +692,16 @@ var QfqNS = QfqNS || {};
return;
}
if (data.redirect === "url" || data['redirect-url']) {
if (data.redirect === "url" && data['redirect-url']) {
window.location = data['redirect-url'];
return;
}
if (data.redirect === "url-skip-history" && data['redirect-url']) {
window.location.replace(data['redirect-url']);
return;
}
break;
case 'new':
var target = this.getNewButtonTarget();
......@@ -699,11 +714,16 @@ var QfqNS = QfqNS || {};
return;
}
if (data.redirect === "url" || data['redirect-url']) {
if (data.redirect === "url" && data['redirect-url']) {
window.location = data['redirect-url'];
return;
}
if (data.redirect === "url-skip-history" && data['redirect-url']) {
window.location.replace(data['redirect-url']);
return;
}
break;
}
};
......
Markdown is supported
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