Commit b5c30097 authored by Elias Villiger's avatar Elias Villiger
Browse files

Merge branch 'master' into 3192-variables-in-form-title

parents cb967208 b3fe0ab8
......@@ -18,6 +18,7 @@ class QfqController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
public function showAction() {
$origErrorReporting = '';
$flagOk = false;
try {
$contentObject = $this->configurationManager->getContentObject();
......@@ -29,6 +30,7 @@ class QfqController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
$qfq = new \qfq\QuickFormQuery($contentObject->data);
$html = $qfq->process();
$flagOk = true;
} catch (qfq\UserFormException $e) {
$html = $e->formatMessage();
......@@ -52,6 +54,10 @@ class QfqController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
$html = "Generic Exception: " . $e->getMessage();
}
if (!$flagOk) {
$html = "<div class='alert alert-warning'>$html</div>";
}
// Restore has to be outside of try/catch - E_NOTICE needs to unset for further T3 handling after an QFQ Exception.
error_reporting($origErrorReporting);
......
......@@ -1321,7 +1321,7 @@ const EXCEPTION_REPORT_FULL_LEVEL = 'Report level key';
const EXCEPTION_SIP = 'current sip';
const EXCEPTION_PAGE_ID = 'Page Id';
const EXCEPTION_TT_CONTENT_UID = 'Content Id';
const EXCEPTION_EDIT_FORM = 'Edit form';
const EXCEPTION_EDIT_FORM = 'Edit';
const EXCEPTION_TIMESTAMP = 'Timestamp';
const EXCEPTION_CODE = 'Code';
......@@ -1330,3 +1330,5 @@ const EXCEPTION_MESSAGE = 'Message';
const EXCEPTION_FILE = 'File';
const EXCEPTION_LINE = 'Line';
const EXCEPTION_STACKTRACE = 'Stacktrace';
const EXCEPTION_TABLE_CLASS = 'table table-hover qfq-table-80';
\ No newline at end of file
......@@ -73,13 +73,6 @@ class AbstractException extends \Exception {
$arrDebugShow[EXCEPTION_PAGE_ID] = $t3Vars[TYPO3_PAGE_ID];
$arrDebugShow[EXCEPTION_TT_CONTENT_UID] = $t3Vars[TYPO3_TT_CONTENT_UID];
// In case there is a 'form' name given in SIP, we probably have a problem in a form and a direct link to
// edit the broken form will be helpful.
$storeSystem = $store->getStore(STORE_SYSTEM);
if (!empty($storeSystem[SYSTEM_FORM])) {
$arrDebugShow[EXCEPTION_EDIT_FORM] = $this->buildFormLink($storeSystem);
}
$arrDebugHidden = array();
$arrDebugHidden[EXCEPTION_FILE] = $this->getFile();
$arrDebugHidden[EXCEPTION_LINE] = $this->getLine();
......@@ -93,8 +86,15 @@ class AbstractException extends \Exception {
$arrDebugShow = OnArray::htmlentitiesOnArray($arrDebugShow);
$arrDebugHidden = OnArray::htmlentitiesOnArray($arrDebugHidden);
$htmlDebug = OnArray::arrayToHtmlTable($arrDebugShow, 'Debug', "table table-hover qfq-table-100");
$hidden = OnArray::arrayToHtmlTable($arrDebugHidden, 'Details', "table table-hover qfq-table-100");
// In case there is a 'form' name given in SIP, we probably have a problem in a form and a direct link to
// edit the broken form will be helpful.
$storeSystem = $store->getStore(STORE_SYSTEM);
if (!empty($storeSystem[SYSTEM_FORM])) {
$arrDebugShow[EXCEPTION_EDIT_FORM] = $this->buildFormLink($storeSystem);
}
$htmlDebug = OnArray::arrayToHtmlTable($arrDebugShow, 'Debug', EXCEPTION_TABLE_CLASS);
$hidden = OnArray::arrayToHtmlTable($arrDebugHidden, 'Details', EXCEPTION_TABLE_CLASS);
// $hidden = 'mein test<br>und mehr content';
// Show / hide with just CSS: http://jsfiddle.net/t5Nf8/1/
......@@ -104,11 +104,10 @@ class AbstractException extends \Exception {
// Sanitize any HTML content.
$arrShow = OnArray::htmlentitiesOnArray($arrShow);
$html = OnArray::arrayToHtmlTable($arrShow, 'Error', "table table-hover qfq-table-100");
$html = OnArray::arrayToHtmlTable($arrShow, 'Error', EXCEPTION_TABLE_CLASS);
// foreach ($show as $key => $value) {
// $html .= "$key: " . Support::wrapTag("<strong>", $value) . "<br>";
// }
$html = Support::wrapTag("<div class='warning'>", $html);
return $html . $htmlDebug;
}
......@@ -134,18 +133,21 @@ class AbstractException extends \Exception {
$link = new Link($sip);
// Link to 'Form'
$linkForm = $link->renderLink(TOKEN_SIP . '|' . TOKEN_PAGE . ':' . $storeSystem[SYSTEM_EDIT_FORM_PAGE] . '&' . CLIENT_FORM . '=' . FORM_NAME_FORM . '&' .
$linkForm = $link->renderLink(TOKEN_SIP . '|' . TOKEN_BOOTSTRAP_BUTTON . '|' . TOKEN_PAGE . ':' .
$storeSystem[SYSTEM_EDIT_FORM_PAGE] . '&' . CLIENT_FORM . '=' . FORM_NAME_FORM . '&' .
CLIENT_RECORD_ID . '=' . $r[F_ID] . '|' . TOKEN_TEXT . ':' . $storeSystem[SYSTEM_FORM]);
// Link to 'FormElement'
if (!empty($storeSystem[SYSTEM_FORM_ELEMENT_ID])) {
$linkFormElement = ' / ' . $link->renderLink(TOKEN_SIP . '|' . TOKEN_PAGE . ':' . $storeSystem[SYSTEM_EDIT_FORM_PAGE] . '&' . CLIENT_FORM . '=' . FORM_NAME_FORM_ELEMENT . '&' .
CLIENT_RECORD_ID . '=' . $storeSystem[SYSTEM_FORM_ELEMENT_ID] . '|' . TOKEN_TEXT . ':' . 'FormElement: ' . $storeSystem[SYSTEM_FORM_ELEMENT_ID]);
$linkFormElement = $link->renderLink(TOKEN_SIP . '|' . TOKEN_BOOTSTRAP_BUTTON . '|' . TOKEN_PAGE .
':' . $storeSystem[SYSTEM_EDIT_FORM_PAGE] . '&' . CLIENT_FORM . '=' . FORM_NAME_FORM_ELEMENT . '&' .
CLIENT_RECORD_ID . '=' . $storeSystem[SYSTEM_FORM_ELEMENT_ID] . '|' .
TOKEN_TEXT . ':' . $storeSystem[SYSTEM_FORM_ELEMENT_ID]);
}
} catch (\exception $e) {
}
return $linkForm . $linkFormElement;
return 'Form: ' . $linkForm . '&nbsp;&nbsp; FormElement: ' . $linkFormElement;
}
}
\ No newline at end of file
......@@ -129,7 +129,9 @@ class OnArray {
*/
public static function varExportArray(array $arr) {
foreach ($arr as $key => $value) {
$arr[$key] = var_export($value, true);
if (is_array($value)) {
$arr[$key] = var_export($value, true);
}
}
return $arr;
......
......@@ -315,7 +315,7 @@ var QfqNS = QfqNS || {};
return;
}
if (event.which === 13 && this.submitOnEnter()) {
if (this.form.formChanged) {
if (this.isFormChanged()) {
this.lastButtonPress = "save&close";
n.Log.debug("save&close click");
this.submit();
......@@ -531,8 +531,13 @@ var QfqNS = QfqNS || {};
n.QfqForm.prototype.callSave = function(uri) {
console.log("target: " + uri);
this.handleSaveClick();
this.goToAfterSave = uri;
if(this.isFormChanged()) {
this.handleSaveClick();
this.goToAfterSave = uri;
} else {
window.location = uri;
return;
}
};
/**
......
......@@ -351,4 +351,47 @@ i.@{spinner_class} {
// Buttons: text left aligned
.qfq-left {
text-align: left;
}
.alert-interactive {
position: absolute;
display: box;
left: 50%;
transform: translate(-50%,0);
top: 200px;
padding: 20px;
color: #d0d0d0;
width: 450px;
border-left: 5px solid;
background-color: #333;
}
.border-success {
border-color: #5cb85c;
}
.border-error {
border-color: #fb4f4f;
}
.border-warning {
border-color: #fbb64f;
}
.border-info {
border-color: #25adf1;
}
.alert-interactive p.title {
font-size: 1.5em;
margin-bottom: 0px;
}
.alert-interactive p.buttons {
margin-top: 20px;
text-align: center;
}
.alert-interactive p.buttons button {
margin-right: 4px;
}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="../css/bootstrap.min.css">
<link rel="stylesheet" href="../css/bootstrap-theme.min.css">
<link rel="stylesheet" href="../css/qfq-bs.css">
<title>Alert</title>
</head>
<body>
<button id="showalert1">Show Alert 1</button>
<button id="showalert2">Show Alert 2</button>
<button id="showalert3">Show Alert 3 primed</button>
<button id="showmanyalert1">Show Many Alert 1</button>
<button id="showmodalalert1">Show Modal Alert 1</button>
<a id="alertinlink" onclick="
var alert = new QfqNS.Alert('Text being displayed', 'info', [
{ label: 'OK', eventName: 'ok' },
{ label: 'Cancel', eventName: 'cancel'}
]);
alert.on('alert.ok', function() {
window.location = $('#alertinlink').attr('href');
});
alert.show();
return false;
" href="http://www.google.ch">Link alert</a>
<div style="margin-top: 20ex">
<button onclick="alert('Button clicked')">Modal test button</button>
</div>
<script src="../js/jquery.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/EventEmitter.min.js"></script>
<script src="../js/qfq.debug.js"></script>
<div class="alert-interactive border-success">
<p class="title">Success!</p>
<p class="body">Congratulations, your dataset has been saved successfully</p>
<p class="buttons">
<button type="button" class="btn btn-default">Ok</button>
<button type="button" class="btn btn-default">Cancel</button>
</p>
</div>
<div class="alert-interactive border-info" style="left: 54%; top: 225px;">
<p class="title">Information</p>
<p class="body">Congratulations, your dataset has been saved successfully</p>
<p class="buttons">
<button type="button" class="btn btn-default">Ok</button>
<button type="button" class="btn btn-default">Cancel</button>
</p>
</div>
<div class="alert-interactive border-warning" style="left: 58%; top: 250px;">
<p class="title">Warning</p>
<p class="body">Congratulations, your dataset has changed</p>
<p class="buttons">
<button type="button" class="btn btn-default">Ok</button>
<button type="button" class="btn btn-default">Cancel</button>
</p>
</div>
<div class="alert-interactive border-error" style="left: 62%; top: 275px;">
<p class="title">Error</p>
<p class="body">Congratulations, your dataset hasn't been saved!</p>
<p class="buttons">
<button type="button" class="btn btn-default">Try Again</button>
<button type="button" class="btn btn-default">Cancel</button>
</p>
</div>
</body>
</html>
\ No newline at end of file
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