Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Admin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
osuny
Admin
Commits
8864e9fa
Commit
8864e9fa
authored
2 years ago
by
Arnaud Levy
Browse files
Options
Downloads
Patches
Plain Diff
not working, lacks a clear view
parent
9b84d466
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/models/communication/block/template/base.rb
+21
-5
21 additions, 5 deletions
app/models/communication/block/template/base.rb
app/models/communication/block/template/gallery/image.rb
+1
-1
1 addition, 1 deletion
app/models/communication/block/template/gallery/image.rb
with
22 additions
and
6 deletions
app/models/communication/block/template/base.rb
+
21
−
5
View file @
8864e9fa
...
...
@@ -55,11 +55,15 @@ class Communication::Block::Template::Base
CODE
end
def
initialize
(
block
)
# It can be initialized with no data, for a full block
# or with data provided, for nested elements
def
initialize
(
block
,
json
=
nil
)
@block
=
block
@data_loaded
=
false
@data
=
json
unless
json
.
nil?
end
# Transforms raw json into ruby objects, based on componenets
def
data
=
(
value
)
if
value
.
is_a?
String
json
=
JSON
.
parse
(
value
)
...
...
@@ -72,6 +76,9 @@ class Communication::Block::Template::Base
next
unless
json
.
has_key?
component
.
property
component
.
data
=
json
[
component
.
property
]
end
json
[
'elements'
].
each
do
|
json
|
default_element
json
end
if
has_elements?
end
def
data
...
...
@@ -79,6 +86,9 @@ class Communication::Block::Template::Base
components
.
each
do
|
component
|
hash
[
component
.
property
]
=
component
.
data
end
elements
.
each
do
|
element
|
hash
[
'elements'
]
<<
element
.
data
end
if
has_elements?
hash
end
...
...
@@ -95,13 +105,19 @@ class Communication::Block::Template::Base
[]
end
def
default_element
return
if
self
.
class
.
element_class
.
nil?
self
.
class
.
element_class
.
new
block
def
has_elements?
!
self
.
class
.
element_class
.
nil?
end
def
default_element
(
data
=
nil
)
return
unless
has_elements?
self
.
class
.
element_class
.
new
block
,
data
end
def
elements
data
[
'elements'
]
block
.
attributes
[
'data'
][
'elements'
].
map
do
|
json
|
default_element
json
end
if
has_elements?
end
def
default_layout
...
...
This diff is collapsed.
Click to expand it.
app/models/communication/block/template/gallery/image.rb
+
1
−
1
View file @
8864e9fa
...
...
@@ -8,7 +8,7 @@ class Communication::Block::Template::Gallery::Image < Communication::Block::Tem
{
'alt'
=>
''
,
'credit'
=>
''
,
'
fil
e'
=>
{}
'
imag
e'
=>
{}
}
end
end
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