diff --git a/extension/Classes/Controller/QfqController.php b/extension/Classes/Controller/QfqController.php index 52f447e72f9833d23976687051f000a62baadda0..b62115c9ab10b59aab82fc6a6abe264555af7e17 100644 --- a/extension/Classes/Controller/QfqController.php +++ b/extension/Classes/Controller/QfqController.php @@ -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); diff --git a/extension/qfq/qfq/Constants.php b/extension/qfq/qfq/Constants.php index e5db176db2720783c5d02241e5841f4941ab53ef..5c1af91717efff0cdc5d585e0ecd1c8a8ec3970c 100644 --- a/extension/qfq/qfq/Constants.php +++ b/extension/qfq/qfq/Constants.php @@ -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 diff --git a/extension/qfq/qfq/exceptions/AbstractException.php b/extension/qfq/qfq/exceptions/AbstractException.php index de028a3710cce1d3ac4f982d3bd2fc71a13a4977..d58f7876004899d1e892af47471b6ab39829aa04 100644 --- a/extension/qfq/qfq/exceptions/AbstractException.php +++ b/extension/qfq/qfq/exceptions/AbstractException.php @@ -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 . ' FormElement: ' . $linkFormElement; } } \ No newline at end of file diff --git a/extension/qfq/qfq/helper/OnArray.php b/extension/qfq/qfq/helper/OnArray.php index 9dc72e5c5b36872772887ae9dc14f33c9eaa262c..f7792bf1f95988389b713785f2d724c8ac7170c2 100644 --- a/extension/qfq/qfq/helper/OnArray.php +++ b/extension/qfq/qfq/helper/OnArray.php @@ -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; diff --git a/javascript/src/QfqForm.js b/javascript/src/QfqForm.js index d6a35d51186e90a20411aab52479dbbdeb8065fd..7f2cb3093b7f701ce9f7cd06f5c4be6709cd8c14 100644 --- a/javascript/src/QfqForm.js +++ b/javascript/src/QfqForm.js @@ -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; + } }; /** diff --git a/less/qfq-bs.css.less b/less/qfq-bs.css.less index 317d49c0c470968798c054d30a2eacab3e3d6ac5..ff144f0b760aaf965acfbbfaa71ef23f9eba1219 100644 --- a/less/qfq-bs.css.less +++ b/less/qfq-bs.css.less @@ -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 diff --git a/mockup/alert2.html b/mockup/alert2.html new file mode 100644 index 0000000000000000000000000000000000000000..9012c75ff60ecee11df046580e8cddee14de6a79 --- /dev/null +++ b/mockup/alert2.html @@ -0,0 +1,74 @@ +<!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