Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
20de5bc8
Commit
20de5bc8
authored
Jun 12, 2019
by
Carsten Rose
Browse files
Merge branch 'B8460DropdownMenuMultipleS' into 'master'
htmlid fixed to not use space, unit tests adapted See merge request
!152
parents
bd578160
d96ee899
Pipeline
#1951
passed with stages
in 2 minutes and 36 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
20de5bc8
...
...
@@ -27,6 +27,7 @@ nbprojec
.support
.support_plantuml
.support_sonar
qfq.flowchart.dia.autosave
test.json
test.php
*.autosave
...
...
extension/Source/core/helper/Support.php
View file @
20de5bc8
...
...
@@ -1496,4 +1496,12 @@ class Support {
return
$output
;
}
/**
* @param string $prefix
* @return string
*/
public
static
function
uniqIdQfq
(
$prefix
)
{
return
$prefix
.
(
defined
(
'PHPUNIT_QFQ'
))
?
'badcaffee1234'
:
uniqid
();
}
}
\ No newline at end of file
extension/Source/core/report/Link.php
View file @
20de5bc8
...
...
@@ -392,7 +392,12 @@ class Link {
}
/**
* Renders a BS-dropdown menu.
*
* @param string $str
* 'z|t:menu|b|o:click me' - the menu button to click on. A text 'menu', a BS button, a tooltip 'click me'.
* '||p:detail&pId=1&s|t:Person 1' - Page id=detail with pId=1 will be opened in the browser.
* '||d:file.pdf|p:detail&pId=1&_sip=1||t:Person as PDF' - Page id=detail with pId=1 will downloaded as a PDF.
*
* @return string
* @throws CodeException
...
...
@@ -404,13 +409,8 @@ class Link {
$menuEntryStrArr
=
array
();
$menuEntryLinkArr
=
array
();
$tokenCollect
=
array
();
static
$count
=
0
;
$time
=
microtime
(
false
);
if
(
defined
(
'PHPUNIT_QFQ'
))
{
$time
=
'0.123 1234'
;
}
$htmlId
=
$time
.
' '
.
$count
++
;
$htmlId
=
Support
::
uniqIdQfq
(
'dd_'
);
$paramArr
=
KeyValueStringParser
::
explodeEscape
(
PARAM_DELIMITER
,
$str
);
...
...
@@ -457,6 +457,8 @@ class Link {
}
/**
* https://getbootstrap.com/docs/3.4/components/#dropdowns
*
* Start
* <span class="dropdown">
* <span class="glyphicon glyphicon-option-vertical dropdown-toggle" id="dropdownMenu11" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
...
...
@@ -1300,7 +1302,7 @@ class Link {
$arr
=
OnArray
::
explodeWithoutEscaped
(
':'
,
$vars
[
NAME_QUESTION
]);
$arr
=
array_merge
(
$arr
,
[
''
,
''
,
''
,
''
,
''
,
''
]);
$id
=
(
$this
->
phpUnit
===
true
)
?
'12345'
:
uniqid
(
'a_'
);
$id
=
Support
::
uniqIdQfq
(
'a_'
);
$content
=
Support
::
doAttribute
(
'id'
,
$id
);
$text
=
$arr
[
QUESTION_INDEX_TEXT
]
===
''
?
DEFAULT_QUESTION_TEXT
:
$arr
[
QUESTION_INDEX_TEXT
];
...
...
extension/Tests/unit/core/report/LinkTest.php
View file @
20de5bc8
...
...
@@ -1198,12 +1198,12 @@ class LinkTest extends TestCase {
$link
=
new
Link
(
$this
->
sip
,
DB_INDEX_DEFAULT
,
true
);
$js
=
<<<EOF
id="1234
5
" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm', type: 'info', modal: true, timeout: 0, buttons: [
id="
badcaffee
1234" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm', type: 'info', modal: true, timeout: 0, buttons: [
{ label: 'Ok', eventName: 'ok' }
, { label: 'Cancel',eventName: 'cancel'}
] } );
alert.on('alert.ok', function() {
window.location = $('#1234
5
').attr('href');
window.location = $('#
badcaffee
1234').attr('href');
});
alert.show();
...
...
@@ -1274,12 +1274,12 @@ EOF;
$link
=
new
Link
(
$this
->
sip
,
DB_INDEX_DEFAULT
,
true
);
$js
=
<<<EOF
id="1234
5
" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm', type: 'info', modal: true, timeout: 0, buttons: [
id="
badcaffee
1234" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm', type: 'info', modal: true, timeout: 0, buttons: [
{ label: 'Ok', eventName: 'ok' }
] } );
alert.on('alert.ok', function() {
window.location = $('#1234
5
').attr('href');
window.location = $('#
badcaffee
1234').attr('href');
});
alert.show();
...
...
@@ -1467,37 +1467,37 @@ EOF;
$link
=
new
Link
(
$this
->
sip
,
DB_INDEX_DEFAULT
,
true
);
// Empty definition
$expect
=
'<span class="dropdown"><span title="Details" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="
0.123
1234
0
" ><span class="glyphicon glyphicon-option-vertical" ></span></span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="
0.123
1234
0
"></ul></span>'
;
$expect
=
'<span class="dropdown"><span title="Details" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="
badcaffee
1234" ><span class="glyphicon glyphicon-option-vertical" ></span></span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="
badcaffee
1234"></ul></span>'
;
$result
=
$link
->
renderLink
(
'z'
);
$this
->
assertEquals
(
$expect
,
$result
);
// Empty definition.
$expect
=
'<span class="dropdown"><span title="Details" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="
0.123
1234
1
" ><span class="glyphicon glyphicon-option-vertical" ></span></span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="
0.123
1234
1
"></ul></span>'
;
$expect
=
'<span class="dropdown"><span title="Details" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="
badcaffee
1234" ><span class="glyphicon glyphicon-option-vertical" ></span></span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="
badcaffee
1234"></ul></span>'
;
$result
=
$link
->
renderLink
(
'z:'
);
$this
->
assertEquals
(
$expect
,
$result
);
// Dropdown menu with text, custom Glyph and a tooltip.
$expect
=
'<span class="dropdown"><span title="Open menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="
0.123
1234
2
" ><span class="glyphicon glyph-icon-left" ></span> Menu</span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="
0.123
1234
2
"></ul></span>'
;
$expect
=
'<span class="dropdown"><span title="Open menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="
badcaffee
1234" ><span class="glyphicon glyph-icon-left" ></span> Menu</span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="
badcaffee
1234"></ul></span>'
;
$result
=
$link
->
renderLink
(
'z|t:Menu|G:glyph-icon-left|o:Open menu'
);
$this
->
assertEquals
(
$expect
,
$result
);
// Dropdown menu with menu entry.
$expect
=
'<span class="dropdown"><span title="Open menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="
0.123
1234
3
" ><span class="glyphicon glyph-icon-left" ></span> Menu</span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="
0.123
1234
3
"><li><a href="?id=home" >Home</a></li></ul></span>'
;
$expect
=
'<span class="dropdown"><span title="Open menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="
badcaffee
1234" ><span class="glyphicon glyph-icon-left" ></span> Menu</span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="
badcaffee
1234"><li><a href="?id=home" >Home</a></li></ul></span>'
;
$result
=
$link
->
renderLink
(
'z|t:Menu|G:glyph-icon-left|o:Open menu||p:home|t:Home'
);
$this
->
assertEquals
(
$expect
,
$result
);
// Dropdown menu disabled.
$expect
=
'<span class="dropdown"><span title="Open menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle disabled" id="
0.123 1234
4" ><span class="glyphicon glyph-icon-left text-muted" ></span> <span class="text-muted">Menu</span></span></span>'
;
$expect
=
'<span class="dropdown"><span title="Open menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle disabled" id="
badcaffee123
4" ><span class="glyphicon glyph-icon-left text-muted" ></span> <span class="text-muted">Menu</span></span></span>'
;
$result
=
$link
->
renderLink
(
'z|t:Menu|G:glyph-icon-left|o:Open menu|r:3||p:home|t:Home'
);
$this
->
assertEquals
(
$expect
,
$result
);
// Dropdown menu with two entries, one is SIP encoded.
$expect
=
'<span class="dropdown"><span title="Open menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="
0.123
1234
5
" ><span class="glyphicon glyph-icon-left" ></span> Menu</span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="
0.123
1234
5
"><li><a href="index.php?id=home&s=badcaffee1234" >Home</a></li><li><a href="?id=back" title="Navigate back" >Back</a></li></ul></span>'
;
$expect
=
'<span class="dropdown"><span title="Open menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="
badcaffee
1234" ><span class="glyphicon glyph-icon-left" ></span> Menu</span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="
badcaffee
1234"><li><a href="index.php?id=home&s=badcaffee1234" >Home</a></li><li><a href="?id=back" title="Navigate back" >Back</a></li></ul></span>'
;
$result
=
$link
->
renderLink
(
'z|t:Menu|G:glyph-icon-left|o:Open menu||p:home|t:Home|s||p:back|t:Back|o:Navigate back'
);
$this
->
assertEquals
(
$expect
,
$result
);
// Dropdown menu header, separator and disabled entry.
$expect
=
'<span class="dropdown"><span title="Open menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="
0.123
1234
6
" ><span class="glyphicon glyph-icon-left" ></span> Menu</span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="
0.123
1234
6
"><li><a href="index.php?id=home&s=badcaffee1234" >Home</a></li><li><a href="?id=back" title="Navigate back" >Back</a></li><li role="separator" class="divider"></li><li class="dropdown-header">Header</li><li class="disabled"><a href="#">Disabled entry</a></li></ul></span>'
;
$expect
=
'<span class="dropdown"><span title="Open menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="
badcaffee
1234" ><span class="glyphicon glyph-icon-left" ></span> Menu</span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="
badcaffee
1234"><li><a href="index.php?id=home&s=badcaffee1234" >Home</a></li><li><a href="?id=back" title="Navigate back" >Back</a></li><li role="separator" class="divider"></li><li class="dropdown-header">Header</li><li class="disabled"><a href="#">Disabled entry</a></li></ul></span>'
;
$result
=
$link
->
renderLink
(
'z|t:Menu|G:glyph-icon-left|o:Open menu||p:home|t:Home|s||p:back|t:Back|o:Navigate back||r:1|t:---||t:===Header|r:1||r:1|t:---Disabled entry'
);
$this
->
assertEquals
(
$expect
,
$result
);
}
...
...
extension/Tests/unit/core/report/ReportTest.php
View file @
20de5bc8
...
...
@@ -526,12 +526,12 @@ class ReportTest extends AbstractDatabaseTest {
*/
public
function
testReportPageTokenQuestion
()
{
$js
=
<<<EOF
id="1234
5
" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm', type: 'info', modal: true, timeout: 0, buttons: [
id="
badcaffee
1234" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm', type: 'info', modal: true, timeout: 0, buttons: [
{ label: 'Ok', eventName: 'ok' }
, { label: 'Cancel',eventName: 'cancel'}
] } );
alert.on('alert.ok', function() {
window.location = $('#1234
5
').attr('href');
window.location = $('#
badcaffee
1234').attr('href');
});
alert.show();
...
...
@@ -604,12 +604,12 @@ EOF;
public
function
testReportPageFix
()
{
$js
=
<<<EOF
id="1234
5
" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm', type: 'info', modal: true, timeout: 0, buttons: [
id="
badcaffee
1234" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm', type: 'info', modal: true, timeout: 0, buttons: [
{ label: 'Ok', eventName: 'ok' }
, { label: 'Cancel',eventName: 'cancel'}
] } );
alert.on('alert.ok', function() {
window.location = $('#1234
5
').attr('href');
window.location = $('#
badcaffee
1234').attr('href');
});
alert.show();
...
...
@@ -699,12 +699,12 @@ EOF;
public
function
testReportPageC
()
{
$js
=
<<<EOF
id="1234
5
" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm!', type: 'info', modal: true, timeout: 0, buttons: [
id="
badcaffee
1234" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm!', type: 'info', modal: true, timeout: 0, buttons: [
{ label: 'Ok', eventName: 'ok' }
, { label: 'Cancel',eventName: 'cancel'}
] } );
alert.on('alert.ok', function() {
window.location = $('#1234
5
').attr('href');
window.location = $('#
badcaffee
1234').attr('href');
});
alert.show();
...
...
@@ -744,12 +744,12 @@ EOF;
public
function
testReportPageFixC
()
{
$js
=
<<<EOF
id="1234
5
" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm!', type: 'info', modal: true, timeout: 0, buttons: [
id="
badcaffee
1234" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm!', type: 'info', modal: true, timeout: 0, buttons: [
{ label: 'Ok', eventName: 'ok' }
, { label: 'Cancel',eventName: 'cancel'}
] } );
alert.on('alert.ok', function() {
window.location = $('#1234
5
').attr('href');
window.location = $('#
badcaffee
1234').attr('href');
});
alert.show();
...
...
@@ -789,12 +789,12 @@ EOF;
public
function
testReportPageD
()
{
$js
=
<<<EOF
id="1234
5
" onClick="var alert = new QfqNS.Alert({ message: 'Do you really want to delete the record?', type: 'warning', modal: true, timeout: 0, buttons: [
id="
badcaffee
1234" onClick="var alert = new QfqNS.Alert({ message: 'Do you really want to delete the record?', type: 'warning', modal: true, timeout: 0, buttons: [
{ label: 'Ok', eventName: 'ok' }
, { label: 'Cancel',eventName: 'cancel'}
] } );
alert.on('alert.ok', function() {
window.location = $('#1234
5
').attr('href');
window.location = $('#
badcaffee
1234').attr('href');
});
alert.show();
...
...
@@ -842,12 +842,12 @@ EOF;
public
function
testReportPageFixD
()
{
$js
=
<<<EOF
id="1234
5
" onClick="var alert = new QfqNS.Alert({ message: 'Do you really want to delete the record?', type: 'warning', modal: true, timeout: 0, buttons: [
id="
badcaffee
1234" onClick="var alert = new QfqNS.Alert({ message: 'Do you really want to delete the record?', type: 'warning', modal: true, timeout: 0, buttons: [
{ label: 'Ok', eventName: 'ok' }
, { label: 'Cancel',eventName: 'cancel'}
] } );
alert.on('alert.ok', function() {
window.location = $('#1234
5
').attr('href');
window.location = $('#
badcaffee
1234').attr('href');
});
alert.show();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment