Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
ecommerce-ui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
ecommerce-ui
Commits
c9f69fe6
Commit
c9f69fe6
authored
Apr 11, 2014
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
app: update mapper for listitem and carousel to new format
parent
050b7fcc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
41 deletions
+34
-41
js/erp5_loader.js
js/erp5_loader.js
+34
-41
No files found.
js/erp5_loader.js
View file @
c9f69fe6
...
...
@@ -3595,7 +3595,7 @@
/* Mapper list item */
/* ********************************************************************** */
/**
* Map records to factory widget listview
* Map records to factory widget listview
and carousel
* @method listItem
* @param {object} item Item to be mapped
* @param {object} wrapper Configuration object containing parent info
...
...
@@ -3607,78 +3607,71 @@
// TODO: core?
map
.
listItem
=
function
(
item
,
wrapper
,
i
)
{
var
quirk_dict
,
level
,
core
,
new_item
,
section
,
pos
,
label
,
j
,
k
,
field
,
record
;
record
,
property
,
source
;
quirk_dict
=
wrapper
.
property_dict
;
record
=
item
.
doc
;
new_item
=
{
"
type
"
:
"
item
"
};
// link base
if
(
quirk_dict
.
link
&&
!
quirk_dict
.
link_source
)
{
level
=
quirk_dict
.
layout_level
||
0
;
core
=
quirk_dict
.
link_core
||
(
quirk_dict
.
fragment_list
?
if
(
quirk_dict
.
link
)
{
label
=
true
;
source
=
quirk_dict
.
link_source
;
if
(
source
)
{
new_item
.
href
=
source
;
}
else
{
level
=
quirk_dict
.
layout_level
||
0
;
core
=
quirk_dict
.
link_core
||
(
quirk_dict
.
fragment_list
?
quirk_dict
.
fragment_list
.
slice
(
0
,
level
+
1
).
join
(
"
/
"
)
:
""
);
}
// set
new_item
.
href
=
(
"
#
"
+
core
+
"
/
"
+
window
.
encodeURIComponent
(
record
[
quirk_dict
.
link_identifier
||
"
_id
"
])
);
}
new_item
=
{
"
type
"
:
"
item
"
,
"
center
"
:
{
"
text
"
:
[]
if
(
quirk_dict
.
link_external
)
{
new_item
.
external
=
true
;
}
}
;
}
// radio
if
(
quirk_dict
.
radio
)
{
label
=
true
;
new_item
.
right
=
{
"
radio
"
:
true
,
"
action
"
:
"
check
"
}
;
new_item
.
right
=
[{
"
type
"
:
"
radio
"
,
"
action
"
:
"
check
"
}]
;
}
// checkbox
if
(
quirk_dict
.
check
)
{
label
=
true
;
new_item
.
right
=
{
"
check
"
:
true
,
"
action
"
:
"
check
"
};
}
// link
if
(
quirk_dict
.
link
)
{
label
=
true
;
new_item
.
href
=
record
[
quirk_dict
.
link_source
]
||
(
"
#
"
+
core
+
"
/
"
+
window
.
encodeURIComponent
(
record
[
quirk_dict
.
link_identifier
||
"
id
"
]));
if
(
quirk_dict
.
link_external
)
{
new_item
.
external
=
true
;
}
new_item
.
right
=
[{
"
type
"
:
"
check
"
,
"
action
"
:
"
check
"
}];
}
// add record id for radio/check/linking
// TODO: develop a clean way to use _id and id. this is bad!
if
(
label
)
{
new_item
.
id
=
record
[
"
id
"
]
||
record
[
"
_id
"
]
||
items
[
i
][
"
id
"
]
||
null
;
new_item
.
id
=
record
[
"
id
"
]
||
record
[
"
_id
"
]
||
null
;
}
// loop scheme sections
for
(
j
=
0
;
j
<
item
.
scheme
.
length
;
j
+=
1
)
{
section
=
item
.
scheme
[
j
];
pos
=
section
.
position
;
new_item
[
pos
]
=
new_item
[
pos
]
||
{}
;
new_item
[
pos
]
=
new_item
[
pos
]
||
[]
;
// loop scheme fields
for
(
k
=
0
;
k
<
section
.
field_list
.
length
;
k
+=
1
)
{
field
=
section
.
field_list
[
k
];
// add object to text-array
if
(
new_item
[
pos
].
text
)
{
// TODO: so much nulllll, also how to convert to input field?
new_item
[
pos
].
text
.
push
({
"
type
"
:
field
.
type
||
"
span
"
,
"
text
"
:
util
.
generateText
(
record
[
field
.
field
],
field
,
record
),
"
aside
"
:
field
.
aside
||
null
,
"
count
"
:
field
.
count
||
null
,
"
text_i18n
"
:
record
.
text_i18n
||
null
,
"
class_list
"
:
field
.
class_list
||
""
});
}
else
{
// set type to record field or field value (custom fields!)
new_item
[
pos
][
field
.
type
]
=
record
[
field
.
field
||
field
.
value
];
}
new_item
[
pos
].
push
(
util
.
mergeObject
(
field
,
{
"
value
"
:
util
.
generateText
(
record
[
field
.
value
||
field
.
field
],
field
,
record
)
}
));
}
}
...
...
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