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
e0036dff
Commit
e0036dff
authored
May 01, 2014
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
app: add spawn method to multiply records based on array in record
parent
c70ef8b4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
7 deletions
+43
-7
js/erp5_loader.js
js/erp5_loader.js
+43
-7
No files found.
js/erp5_loader.js
View file @
e0036dff
...
...
@@ -2882,7 +2882,7 @@
return
config
;
};
// TODO: remove, should be handled by content.set
// TODO: remove, should be handled by content.set
!!!
// TODO: why is this not done on click, when we can get the href > element
// from the link attribute?
/**
...
...
@@ -2928,6 +2928,7 @@
element
.
appendChild
(
content
);
})
.
then
(
function
()
{
// need this call otherwise loaded content is not enhanced
$el
=
$
(
element
).
enhanceWithin
();
// TODO: un-jQuery eventually...
...
...
@@ -6308,13 +6309,12 @@
};
// TODO: determine value to query based on URL (this stinks...)
if
(
lib
.
layout_level
>
0
)
{
// NOTE: picking value from URL if specified
if
(
lib
.
layout_level
>
0
&&
dict
.
property_dict
.
initial_query_url_identifier
)
{
last
=
lib
.
fragment_list
.
slice
(
-
1
)[
0
];
pass
.
data_dict
.
value
=
lib
.
fragment_list
[
lib
.
layout_level
];
if
(
!
lib
.
mode
||
last
!==
lib
.
mode
)
{
pass
.
data_dict
.
value
=
lib
.
fragment_list
[
lib
.
layout_level
];
}
}
// generate query object
...
...
@@ -6733,9 +6733,14 @@
if
(
is_parameter
)
{
kid
=
app
.
util
.
setParam
(
kid
,
wrapper
);
}
// ===================================================================
// spawn children based on trigger field (must be array)
if
(
kid
.
property_dict
&&
kid
.
property_dict
.
spawn_on
)
{
kid
.
children
=
app
.
util
.
spawn
(
kid
.
children
,
kid
.
property_dict
.
spawn_on
);
kid
.
property_dict
.
total_rows
=
kid
.
children
.
length
;
}
// ===================================================================
if
(
quirk_dict
.
update
!==
true
||
is_dynamic
||
quirk_dict
.
dynamic
)
{
// for content loaded via href, generate URL dict and undefine kid
...
...
@@ -6960,6 +6965,37 @@
/* ********************************************************************** */
app
.
util
=
{};
/** Spawn (multiply children based on an array (so far only used when
* an item returns an array of strings and we need items for every string
* (carousel)
* @method spawn
* @param {Array} kids Original array
* @param {String} trig Trigger field
* @returns {Array} new Array
*/
// TODO: really necessary like this...? Store data differently!
// Like store image urls and make a query on "items"
app
.
util
.
spawn
=
function
(
kids
,
trig
)
{
var
i
,
j
,
trig_len
,
len
,
kid
,
arr
,
clone
,
new_kids
,
new_kid
;
new_kids
=
[];
for
(
i
=
0
,
len
=
kids
.
length
;
i
<
len
;
i
+=
1
)
{
kid
=
kids
[
i
];
arr
=
kid
.
doc
[
trig
];
if
(
Array
.
isArray
(
arr
))
{
for
(
j
=
0
,
trig_len
=
arr
.
length
;
j
<
trig_len
;
j
+=
1
)
{
new_kid
=
util
.
cloneObject
(
kid
);
new_kid
.
doc
[
trig
]
=
arr
[
j
];
new_kids
.
push
(
new_kid
);
}
}
else
{
new_kids
.
push
(
kid
);
}
}
return
new_kids
;
};
/** Fetch a subordinate record to set values of an object
* @method setSubordinate
* @method setParam
...
...
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