Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
layout_paragraphs
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
layout_paragraphs
Commits
9fb45378
Commit
9fb45378
authored
11 months ago
by
Seth Hill
Committed by
Justin Toupin
11 months ago
Browse files
Options
Downloads
Patches
Plain Diff
#3397222
Make field multilingual and update builder.js for tests.
parent
7f9cb123
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!161
#3397222 Make field multilingual and update builder.js for tests.
Pipeline
#152781
passed with warnings
11 months ago
Stage: build
Stage: validate
Stage: test
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
js/builder.es6.js
+14
-11
14 additions, 11 deletions
js/builder.es6.js
js/builder.js
+11
-18
11 additions, 18 deletions
js/builder.js
src/Plugin/Field/FieldWidget/LayoutParagraphsWidget.php
+12
-0
12 additions, 0 deletions
src/Plugin/Field/FieldWidget/LayoutParagraphsWidget.php
with
37 additions
and
29 deletions
js/builder.es6.js
+
14
−
11
View file @
9fb45378
...
...
@@ -105,19 +105,22 @@
* @param {jQuery} $element The builder element.
*/
function
updateMoveButtons
(
$element
)
{
[...
$element
[
0
].
querySelectorAll
(
'
.lpb-up, .lpb-down
'
)].
forEach
((
el
)
=>
{
const
lpbBuilderElements
=
Array
.
from
(
$element
[
0
].
querySelectorAll
(
'
.js-lpb-component-list, .js-lpb-region
'
));
const
lpbBuilderComponent
=
lpbBuilderElements
.
filter
(
el
=>
el
.
querySelector
(
'
.js-lpb-component
'
));
$element
[
0
].
querySelectorAll
(
'
.lpb-up, .lpb-down
'
).
forEach
((
el
)
=>
{
// Set the tabindex of the up and down arrows to 0.
el
.
setAttribute
(
'
tabindex
'
,
'
0
'
);
});
[...
$element
[
0
].
querySelectorAll
(
'
.js-lpb-component-list:has(.js-lpb-component), .js-lpb-region:has(.js-lpb-component)
'
)].
forEach
((
el
)
=>
{
const
components
=
[...
el
.
childNodes
].
filter
(
n
=>
n
.
classList
&&
n
.
classList
.
contains
(
'
js-lpb-component
'
));
const
upBtn
=
components
[
0
].
querySelector
(
'
.lpb-up
'
);
if
(
upBtn
)
{
upBtn
.
setAttribute
(
'
tabindex
'
,
'
-1
'
);
}
const
downBtn
=
components
[
components
.
length
-
1
].
querySelector
(
'
.lpb-down
'
);
if
(
downBtn
)
{
downBtn
.
setAttribute
(
'
tabindex
'
,
'
-1
'
);
}
lpbBuilderComponent
.
forEach
((
el
)
=>
{
const
components
=
Array
.
from
(
el
.
children
).
filter
(
n
=>
n
.
classList
.
contains
(
'
js-lpb-component
'
));
// Set the tabindex of the first component's up arrow to -1.
components
[
0
].
querySelector
(
'
.lpb-up
'
)?.
setAttribute
(
'
tabindex
'
,
'
-1
'
);
// Set the tabindex of the last component's down arrow to -1.
components
[
components
.
length
-
1
].
querySelector
(
'
.lpb-down
'
)?.
setAttribute
(
'
tabindex
'
,
'
-1
'
);
});
}
...
...
This diff is collapsed.
Click to expand it.
js/builder.js
+
11
−
18
View file @
9fb45378
...
...
@@ -6,12 +6,6 @@
**/
"
use strict
"
;
function
_toConsumableArray
(
arr
)
{
return
_arrayWithoutHoles
(
arr
)
||
_iterableToArray
(
arr
)
||
_unsupportedIterableToArray
(
arr
)
||
_nonIterableSpread
();
}
function
_nonIterableSpread
()
{
throw
new
TypeError
(
"
Invalid attempt to spread non-iterable instance.
\n
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.
"
);
}
function
_unsupportedIterableToArray
(
o
,
minLen
)
{
if
(
!
o
)
return
;
if
(
typeof
o
===
"
string
"
)
return
_arrayLikeToArray
(
o
,
minLen
);
var
n
=
Object
.
prototype
.
toString
.
call
(
o
).
slice
(
8
,
-
1
);
if
(
n
===
"
Object
"
&&
o
.
constructor
)
n
=
o
.
constructor
.
name
;
if
(
n
===
"
Map
"
||
n
===
"
Set
"
)
return
Array
.
from
(
o
);
if
(
n
===
"
Arguments
"
||
/^
(?:
Ui|I
)
nt
(?:
8|16|32
)(?:
Clamped
)?
Array$/
.
test
(
n
))
return
_arrayLikeToArray
(
o
,
minLen
);
}
function
_iterableToArray
(
iter
)
{
if
(
typeof
Symbol
!==
"
undefined
"
&&
iter
[
Symbol
.
iterator
]
!=
null
||
iter
[
"
@@iterator
"
]
!=
null
)
return
Array
.
from
(
iter
);
}
function
_arrayWithoutHoles
(
arr
)
{
if
(
Array
.
isArray
(
arr
))
return
_arrayLikeToArray
(
arr
);
}
function
_arrayLikeToArray
(
arr
,
len
)
{
if
(
len
==
null
||
len
>
arr
.
length
)
len
=
arr
.
length
;
for
(
var
i
=
0
,
arr2
=
new
Array
(
len
);
i
<
len
;
i
++
)
arr2
[
i
]
=
arr
[
i
];
return
arr2
;
}
(
function
(
$
,
Drupal
,
debounce
,
dragula
,
once
)
{
var
idAttr
=
'
data-lpb-id
'
;
function
attachUiElements
(
$container
,
settings
)
{
...
...
@@ -68,21 +62,20 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
});
}
function
updateMoveButtons
(
$element
)
{
_toConsumableArray
(
$element
[
0
].
querySelectorAll
(
'
.lpb-up, .lpb-down
'
)).
forEach
(
function
(
el
)
{
var
lpbBuilderElements
=
Array
.
from
(
$element
[
0
].
querySelectorAll
(
'
.js-lpb-component-list, .js-lpb-region
'
));
var
lpbBuilderComponent
=
lpbBuilderElements
.
filter
(
function
(
el
)
{
return
el
.
querySelector
(
'
.js-lpb-component
'
);
});
$element
[
0
].
querySelectorAll
(
'
.lpb-up, .lpb-down
'
).
forEach
(
function
(
el
)
{
el
.
setAttribute
(
'
tabindex
'
,
'
0
'
);
});
_toConsumableArray
(
$element
[
0
].
querySelectorAll
(
'
.js-lpb-component-list:has(.js-lpb-component), .js-lpb-region:has(.js-lpb-component)
'
)).
forEach
(
function
(
el
)
{
var
components
=
_toConsumableArray
(
el
.
childNodes
).
filter
(
function
(
n
)
{
return
n
.
classList
&&
n
.
classList
.
contains
(
'
js-lpb-component
'
);
lpbBuilderComponent
.
forEach
(
function
(
el
)
{
var
_components$0$querySe
,
_components$querySele
;
var
components
=
Array
.
from
(
el
.
children
).
filter
(
function
(
n
)
{
return
n
.
classList
.
contains
(
'
js-lpb-component
'
);
});
var
upBtn
=
components
[
0
].
querySelector
(
'
.lpb-up
'
);
if
(
upBtn
)
{
upBtn
.
setAttribute
(
'
tabindex
'
,
'
-1
'
);
}
var
downBtn
=
components
[
components
.
length
-
1
].
querySelector
(
'
.lpb-down
'
);
if
(
downBtn
)
{
downBtn
.
setAttribute
(
'
tabindex
'
,
'
-1
'
);
}
(
_components$0$querySe
=
components
[
0
].
querySelector
(
'
.lpb-up
'
))
===
null
||
_components$0$querySe
===
void
0
||
_components$0$querySe
.
setAttribute
(
'
tabindex
'
,
'
-1
'
);
(
_components$querySele
=
components
[
components
.
length
-
1
].
querySelector
(
'
.lpb-down
'
))
===
null
||
_components$querySele
===
void
0
||
_components$querySele
.
setAttribute
(
'
tabindex
'
,
'
-1
'
);
});
}
function
hideEmptyRegionButtons
(
$element
)
{
...
...
This diff is collapsed.
Click to expand it.
src/Plugin/Field/FieldWidget/LayoutParagraphsWidget.php
+
12
−
0
View file @
9fb45378
...
...
@@ -425,4 +425,16 @@ class LayoutParagraphsWidget extends WidgetBase implements ContainerFactoryPlugi
return
$defaults
;
}
/**
* {@inheritdoc}
*/
public
function
form
(
FieldItemListInterface
$items
,
array
&
$form
,
FormStateInterface
$form_state
,
$get_delta
=
NULL
)
{
$elements
=
parent
::
form
(
$items
,
$form
,
$form_state
,
$get_delta
);
// Signal to content_translation that this field should be treated as
// multilingual and not be hidden, see
// \Drupal\content_translation\ContentTranslationHandler::entityFormSharedElements().
$elements
[
'#multilingual'
]
=
TRUE
;
return
$elements
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment