Commit 83c2c7d9 authored by Carsten  Rose's avatar Carsten Rose

#10080 - WIP

parent f2f92926
Pipeline #3478 failed with stages
in 2 minutes and 10 seconds
......@@ -334,15 +334,22 @@ class BuildFormBootstrap extends AbstractBuildForm {
$toolTip .= PHP_EOL . "Table: " . $this->formSpec[F_TABLE_NAME];
}
$arrQuestion = $this->link->buildQuestion('q:Really?', 'save-button');
$buttonSave = $this->buildButtonCode('save-button', $this->formSpec[F_SAVE_BUTTON_TEXT], $toolTip,
$this->formSpec[F_SAVE_BUTTON_GLYPH_ICON], '', $this->formSpec[F_BUTTON_ON_CHANGE_CLASS], $this->formSpec[F_SAVE_BUTTON_CLASS]);
$this->formSpec[F_SAVE_BUTTON_GLYPH_ICON], '', $this->formSpec[F_BUTTON_ON_CHANGE_CLASS],
$this->formSpec[F_SAVE_BUTTON_CLASS], $arrQuestion);
}
// Button: Close
if (Support::findInSet(FORM_BUTTON_CLOSE, $this->formSpec[F_SHOW_BUTTON])) {
$arrQuestion = array();
# $arrQuestion = $this->link->buildQuestion('q:Really?','close-button');
$buttonClose = $this->buildButtonCode('close-button', $this->formSpec[F_CLOSE_BUTTON_TEXT],
$this->formSpec[F_CLOSE_BUTTON_TOOLTIP],
$this->formSpec[F_CLOSE_BUTTON_GLYPH_ICON], '', '', $this->formSpec[F_CLOSE_BUTTON_CLASS]);
$this->formSpec[F_CLOSE_BUTTON_GLYPH_ICON], '', '',
$this->formSpec[F_CLOSE_BUTTON_CLASS], $arrQuestion);
}
// Button: Delete
......@@ -420,13 +427,14 @@ class BuildFormBootstrap extends AbstractBuildForm {
* @param string $tooltip
* @param string $icon
* @param string $disabled
*
* @param string $buttonOnChangeClass
* @param string $class
* @param array $arrAttributes
* @return string
* @throws \CodeException
*/
private function buildButtonCode($buttonHtmlId, $text, $tooltip, $icon, $disabled = '', $buttonOnChangeClass = '', $class = '') {
private function buildButtonCode($buttonHtmlId, $text, $tooltip, $icon, $disabled = '', $buttonOnChangeClass = '',
$class = '', array $arrAttributes = []) {
if ($icon === '') {
$element = $text;
......@@ -438,7 +446,12 @@ class BuildFormBootstrap extends AbstractBuildForm {
$dataClassOnChange = Support::doAttribute('data-class-on-change', $buttonOnChangeClass);
$tooltip = Support::doAttribute('title', $tooltip);
return "<button id='$buttonHtmlId' type='button' $class $dataClassOnChange $tooltip $disabled>$element</button>";
$attributes = '';
foreach ($arrAttributes as $key => $value) {
$attributes .= Support::doAttribute($key, $value);
}
return "<button id='$buttonHtmlId' type='button' $attributes $class $dataClassOnChange $tooltip $disabled>$element</button>";
}
/**
......@@ -627,7 +640,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
// Button Save at bottom of form - only if there is a button text given.
if ($this->formSpec[F_SUBMIT_BUTTON_TEXT] !== '') {
// Default setzen:
// Set default:
$this->fillWrapLabelInputNote($this->formSpec[F_BS_LABEL_COLUMNS], $this->formSpec[F_BS_INPUT_COLUMNS], $this->formSpec[F_BS_NOTE_COLUMNS]);
$buttonText = $this->formSpec[F_SUBMIT_BUTTON_TEXT];
......
......@@ -26,9 +26,9 @@ namespace IMATHUZH\Qfq\Core\Report;
use IMATHUZH\Qfq\Core\Helper\KeyValueStringParser;
use IMATHUZH\Qfq\Core\Helper\OnArray;
use IMATHUZH\Qfq\Core\Helper\Sanitize;
use IMATHUZH\Qfq\Core\Helper\Support;
use IMATHUZH\Qfq\Core\Helper\Token;
use IMATHUZH\Qfq\Core\Helper\Sanitize;
use IMATHUZH\Qfq\Core\Store\Sip;
use IMATHUZH\Qfq\Core\Store\Store;
......@@ -1221,28 +1221,26 @@ class Link {
return Support::wrapTag($vars[NAME_EXTRA_CONTENT_WRAP], $contentPure);
}
/**
* Build 'alert' JS. $vars['question'] = '<text>:<color>:<button ok>:<button fail>'
* Return JS Code to place in '<a>' tag. Be carefull: function creates a uniqe 'id' tag.
* Return JS Code to place in '<a>' or ''<button>' tag. Be careful: function creates a uniq 'id' tag.
*
* @param array $vars
*
* @return string
* @param string $tokenStr "q[:<alert text>[:<level>[:<positive button text>[:<negative button text>[:<timeout>[:<flag modal>]]]]]]"
* @param string $htmlId reference to the given id
* @return array
* @throws \CodeException
* @throws \UserReportException
*/
private function doQuestion(array $vars) {
public function buildQuestion($tokenStr, $htmlId) {
if ($vars[NAME_QUESTION] === '') {
return '';
if ($tokenStr === '') {
return [];
}
$arr = OnArray::explodeWithoutEscaped(':', $vars[NAME_QUESTION]);
$arr = OnArray::explodeWithoutEscaped(':', $tokenStr);
$arr = array_merge($arr, ['', '', '', '', '', '']);
$id = Support::uniqIdQfq('a_');
$content = Support::doAttribute('id', $id);
$text = $arr[QUESTION_INDEX_TEXT] === '' ? DEFAULT_QUESTION_TEXT : $arr[QUESTION_INDEX_TEXT];
$level = ($arr[QUESTION_INDEX_LEVEL] === '') ? DEFAULT_QUESTION_LEVEL : $arr[QUESTION_INDEX_LEVEL];
$ok = ($arr[QUESTION_INDEX_BUTTON_OK] === '') ? 'Ok' : $arr[QUESTION_INDEX_BUTTON_OK];
......@@ -1259,15 +1257,36 @@ var alert = new QfqNS.Alert({ message: '$text', type: '$level', modal: $flagModa
$cancel
] } );
alert.on('alert.ok', function() {
window.location = $('#$id').attr('href');
window.location = $('#$htmlId').attr('href');
});
alert.show();
return false;
EOF;
$content .= Support::doAttribute('onClick', $js);
return ['onClick' => $js];
}
/**
* Build 'alert' JS. $vars['question'] = '<text>:<color>:<button ok>:<button fail>'
* Return JS Code to place in '<a>' or ''<button>' tag. Be careful: function creates a uniq 'id' tag.
*
* @param array $vars
* @param string $htmlId If empty, create uniq id and add 'id=...', else just reference to the given id
* @return string
* @throws \CodeException
* @throws \UserReportException
*/
private function doQuestion(array $vars) {
$htmlId = Support::uniqIdQfq('a_');
$content = Support::doAttribute('id', $htmlId);
$arr = $this->buildQuestion($vars[NAME_QUESTION], $htmlId);
foreach ($arr as $key => $value) {
$content .= Support::doAttribute($key, $value);
}
return $content;
}
......
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