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
485c0655
Commit
485c0655
authored
Apr 14, 2014
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
app: pagination works (again)
parent
ff92ee42
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
93 additions
and
61 deletions
+93
-61
js/erp5_loader.js
js/erp5_loader.js
+93
-61
No files found.
js/erp5_loader.js
View file @
485c0655
...
@@ -1941,6 +1941,8 @@
...
@@ -1941,6 +1941,8 @@
"
logic
"
:
{
"
logic
"
:
{
"
id
"
:
spec
.
id
||
null
,
"
id
"
:
spec
.
id
||
null
,
"
data-update
"
:
spec
.
dynamic
?
true
:
null
,
"
data-update
"
:
spec
.
dynamic
?
true
:
null
,
// NOTE: on updates, we need wrapper with generator...
"
data-widget
"
:
"
listview
"
,
"
data-reference
"
:
spec
.
reference
||
null
,
"
data-reference
"
:
spec
.
reference
||
null
,
"
data-filter
"
:
spec
.
filter
||
null
,
"
data-filter
"
:
spec
.
filter
||
null
,
"
data-input
"
:
spec
.
input
||
null
,
"
data-input
"
:
spec
.
input
||
null
,
...
@@ -2276,8 +2278,8 @@
...
@@ -2276,8 +2278,8 @@
});
});
// header
// header
for
(
i
=
0
;
i
<
spec
.
scheme
s
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
spec
.
scheme
.
length
;
i
+=
1
)
{
section
=
spec
.
scheme
s
[
i
];
section
=
spec
.
scheme
[
i
];
switch
(
section
.
position
)
{
switch
(
section
.
position
)
{
case
"
header
"
:
case
"
header
"
:
tag
=
factory
.
element
({
"
type
"
:
"
thead
"
});
tag
=
factory
.
element
({
"
type
"
:
"
thead
"
});
...
@@ -2292,7 +2294,10 @@
...
@@ -2292,7 +2294,10 @@
case
"
body
"
:
case
"
body
"
:
container
.
appendChild
(
factory
.
element
({
container
.
appendChild
(
factory
.
element
({
"
type
"
:
"
tbody
"
,
"
type
"
:
"
tbody
"
,
"
attributes
"
:
{
"
data-update
"
:
"
true
"
}
"
attributes
"
:
{
"
data-update
"
:
"
true
"
,
"
data-widget
"
:
"
table
"
}
}));
}));
break
;
break
;
}
}
...
@@ -3340,7 +3345,7 @@
...
@@ -3340,7 +3345,7 @@
new_item
.
external
=
quirk_dict
.
external
;
new_item
.
external
=
quirk_dict
.
external
;
}
}
// loop scheme
s
// loop scheme
for
(
j
=
0
;
j
<
item
.
scheme
.
length
;
j
+=
1
)
{
for
(
j
=
0
;
j
<
item
.
scheme
.
length
;
j
+=
1
)
{
segment
=
item
.
scheme
[
j
];
segment
=
item
.
scheme
[
j
];
row
=
[];
row
=
[];
...
@@ -3536,7 +3541,7 @@
...
@@ -3536,7 +3541,7 @@
section_list
=
[];
section_list
=
[];
// Need mapping, fill helper with sections filled with (mapped) fields
// Need mapping, fill helper with sections filled with (mapped) fields
// loop scheme
s
// loop scheme
for
(
j
=
0
;
j
<
item
.
scheme
.
length
;
j
+=
1
)
{
for
(
j
=
0
;
j
<
item
.
scheme
.
length
;
j
+=
1
)
{
segment
=
item
.
scheme
[
j
];
segment
=
item
.
scheme
[
j
];
field_list
=
[];
field_list
=
[];
...
@@ -4762,7 +4767,6 @@
...
@@ -4762,7 +4767,6 @@
}
}
if
((
start
>
total
&&
total
!==
undefined
)
||
start
<
0
)
{
if
((
start
>
total
&&
total
!==
undefined
)
||
start
<
0
)
{
console
.
log
(
"
DONE
"
)
return
;
return
;
}
}
...
@@ -4773,13 +4777,18 @@
...
@@ -4773,13 +4777,18 @@
if
(
config
.
state
.
selected
)
{
if
(
config
.
state
.
selected
)
{
config
.
state
.
selected
=
[];
config
.
state
.
selected
=
[];
}
}
console
.
log
(
"
fertig
"
)
console
.
log
(
"
let's set content
"
)
console
.
log
(
config
)
// update gadget
// update gadget
app
.
content
.
set
(
app
.
content
.
set
(
{
{
"
portal_type_source
"
:
config
.
state
.
type
"
portal_type_source
"
:
config
.
state
.
type
,
"
portal_type_title
"
:
config
.
state
.
title
,
"
property_dict
"
:
util
.
mergeObject
({
"
dynamic
"
:
true
,
"
map_children
"
:
"
listItem
"
},
config
.
state
.
dyno_dict
),
"
scheme
"
:
config
.
state
.
scheme
},
},
{
{
"
reference
"
:
config
.
id
,
"
reference
"
:
config
.
id
,
...
@@ -5007,6 +5016,7 @@
...
@@ -5007,6 +5016,7 @@
"
id
"
:
id
,
"
id
"
:
id
,
"
gadget
"
:
document
.
getElementById
(
id
)
"
gadget
"
:
document
.
getElementById
(
id
)
};
};
has_form
=
response
.
gadget
.
getElementsByTagName
(
"
form
"
);
has_form
=
response
.
gadget
.
getElementsByTagName
(
"
form
"
);
return
util
.
mergeObject
(
return
util
.
mergeObject
(
{
{
...
@@ -5301,6 +5311,25 @@
...
@@ -5301,6 +5311,25 @@
*/
*/
util
=
{};
util
=
{};
/**
* Inherit objects to an array of items
* @inherit
* @param {array} kids Array of elements to inherit objects
* @param {object} Objects to inherit
* @return {array} kids
**/
util
.
inherit
=
function
(
kids
,
property_dict
)
{
var
i
,
kids_len
,
obj
;
for
(
i
=
0
,
kids_len
=
kids
.
length
;
i
<
kids_len
;
i
+=
1
)
{
for
(
obj
in
property_dict
)
{
if
(
property_dict
.
hasOwnProperty
(
obj
))
{
kids
[
i
][
obj
]
=
property_dict
[
obj
];
}
}
}
return
kids
;
};
/**
/**
* Crop a string (data field)
* Crop a string (data field)
...
@@ -5853,8 +5882,8 @@
...
@@ -5853,8 +5882,8 @@
// TODO: no docById, get element from state itself!
// TODO: no docById, get element from state itself!
// TODO: find better way to determine "value"
// TODO: find better way to determine "value"
app
.
content
.
total
=
function
(
reply
)
{
app
.
content
.
total
=
function
(
reply
)
{
var
pass
=
reply
.
pass
,
last
;
var
dict
,
lib
,
pass
=
reply
.
pass
,
last
;
console
.
log
(
"
total=?
"
)
if
(
!
pass
.
skip
)
{
if
(
!
pass
.
skip
)
{
//pass.data_dict.field_dict = util.parse(reply.response);
//pass.data_dict.field_dict = util.parse(reply.response);
...
@@ -5866,34 +5895,39 @@
...
@@ -5866,34 +5895,39 @@
// create state object
// create state object
}
else
{
}
else
{
dict
=
pass
.
config_dict
;
lib
=
pass
.
url_dict
;
pass
.
state
=
{
pass
.
state
=
{
"
type
"
:
pass
.
config_dict
.
portal_type_source
,
"
dyno_dict
"
:
dict
.
property_dict
,
"
fragment_list
"
:
pass
.
url_dict
.
fragment_list
,
"
scheme
"
:
dict
.
scheme
,
"
layout_level
"
:
pass
.
url_dict
.
layout_level
,
"
type
"
:
dict
.
portal_type_source
,
"
href
"
:
pass
.
url_dict
.
href
,
"
title
"
:
dict
.
portal_type_title
,
"
mode
"
:
pass
.
url_dict
.
mode
,
"
fragment_list
"
:
lib
.
fragment_list
,
"
view
"
:
pass
.
config_dict
.
view
,
"
layout_level
"
:
lib
.
layout_level
,
"
href
"
:
lib
.
href
,
"
mode
"
:
lib
.
mode
,
"
view
"
:
dict
.
view
,
// HACK so it's available on storage ops
// HACK so it's available on storage ops
"
url_pointer
"
:
pass
.
config_
dict
.
property_dict
.
url_pointer
"
url_pointer
"
:
dict
.
property_dict
.
url_pointer
};
};
// TODO: determine value to query based on URL (this stinks...)
// TODO: determine value to query based on URL (this stinks...)
if
(
pass
.
url_dict
.
layout_level
>
0
)
{
if
(
lib
.
layout_level
>
0
)
{
last
=
pass
.
url_dict
.
fragment_list
.
slice
(
-
1
)[
0
];
last
=
lib
.
fragment_list
.
slice
(
-
1
)[
0
];
if
(
!
pass
.
url_dict
.
mode
||
last
!==
pass
.
url_dict
.
mode
)
{
if
(
!
lib
.
mode
||
last
!==
lib
.
mode
)
{
pass
.
data_dict
.
value
=
pass
.
data_dict
.
value
=
pass
.
url_dict
.
fragment_list
[
pass
.
url_dict
.
layout_level
];
lib
.
fragment_list
[
lib
.
layout_level
];
}
}
}
}
// generate query object
// generate query object
if
(
pass
.
config_
dict
.
initial_query
)
{
if
(
dict
.
initial_query
)
{
pass
.
state
.
initial_query
=
pass
.
config_
dict
.
initial_query
;
pass
.
state
.
initial_query
=
dict
.
initial_query
;
pass
.
state
.
query
=
storage
.
parseQuery
(
pass
.
state
.
query
=
storage
.
parseQuery
(
pass
.
config_
dict
.
initial_query
,
dict
.
initial_query
,
pass
.
config_
dict
.
portal_type_source
,
dict
.
portal_type_source
,
pass
.
config_
dict
.
property_dict
.
initial_query_url_identifier
,
dict
.
property_dict
.
initial_query_url_identifier
,
pass
.
data_dict
.
value
pass
.
data_dict
.
value
);
);
}
else
{
}
else
{
...
@@ -5931,8 +5965,7 @@
...
@@ -5931,8 +5965,7 @@
**/
**/
app
.
content
.
query
=
function
(
reply
)
{
app
.
content
.
query
=
function
(
reply
)
{
var
pass
=
reply
.
pass
;
var
pass
=
reply
.
pass
;
console
.
log
(
"
query?
"
)
console
.
log
(
pass
)
if
(
!
pass
.
skip
)
{
if
(
!
pass
.
skip
)
{
// set total rows
// set total rows
...
@@ -5996,11 +6029,9 @@
...
@@ -5996,11 +6029,9 @@
app
.
content
.
make
=
function
(
reply
)
{
app
.
content
.
make
=
function
(
reply
)
{
var
pass
,
method
,
type
,
kids
,
promise_list
,
route
,
var
pass
,
method
,
type
,
kids
,
promise_list
,
route
,
search
,
search_id
,
kid
,
is_html
,
is_dynamic
,
is_id
,
i
,
j
,
last
,
search
,
search_id
,
kid
,
is_html
,
is_dynamic
,
is_id
,
i
,
j
,
last
,
encoded
,
wrapper
,
active
,
selector
,
update_target
,
target
,
encoded
,
wrapper
,
active
,
selector
,
update_target
,
target
,
widget
,
grant_child
,
quirk_dict
,
generator
,
pointer_results
,
data_total_rows
;
grant_child
,
quirk_dict
,
generator
,
pointer_results
,
data_total_rows
;
console
.
log
(
"
REACHED MAKE
"
)
console
.
log
(
reply
.
pass
)
pass
=
reply
.
pass
;
pass
=
reply
.
pass
;
pass
.
config_dict
=
pass
.
config_dict
||
{};
pass
.
config_dict
=
pass
.
config_dict
||
{};
type
=
pass
.
content_dict
.
type
;
type
=
pass
.
content_dict
.
type
;
...
@@ -6034,7 +6065,7 @@
...
@@ -6034,7 +6065,7 @@
"
layout_level
"
:
pass
.
url_dict
.
layout_level
,
"
layout_level
"
:
pass
.
url_dict
.
layout_level
,
"
fragment_list
"
:
pass
.
url_dict
.
fragment_list
,
"
fragment_list
"
:
pass
.
url_dict
.
fragment_list
,
"
data_url
"
:
pass
.
url_dict
.
data_url
,
"
data_url
"
:
pass
.
url_dict
.
data_url
,
"
scheme
s
"
:
pass
.
config_dict
.
scheme
,
"
scheme
"
:
pass
.
config_dict
.
scheme
,
"
field_dict
"
:
(
pass
.
data_dict
||
{}).
field_dict
,
"
field_dict
"
:
(
pass
.
data_dict
||
{}).
field_dict
,
"
skip
"
:
pass
.
skip
,
"
skip
"
:
pass
.
skip
,
"
purge
"
:
pass
.
purge
"
purge
"
:
pass
.
purge
...
@@ -6092,7 +6123,7 @@
...
@@ -6092,7 +6123,7 @@
kids
.
push
(
factory
.
util
.
noItems
(
kids
.
push
(
factory
.
util
.
noItems
(
quirk_dict
.
no_show
,
quirk_dict
.
no_show
,
wrapper
.
base
,
wrapper
.
base
,
wrapper
.
count
?
wrapper
.
count
(
quirk_dict
.
scheme
s
[
0
])
:
null
wrapper
.
count
?
wrapper
.
count
(
quirk_dict
.
scheme
[
0
])
:
null
));
));
}
}
...
@@ -6131,9 +6162,7 @@
...
@@ -6131,9 +6162,7 @@
// add auto pagination bar
// add auto pagination bar
if
(
quirk_dict
.
pagination
)
{
if
(
quirk_dict
.
pagination
)
{
kids
.
push
(
kids
.
push
(
factory
.
util
.
paginationBar
(
quirk_dict
.
pagination
));
factory
.
util
.
paginationBar
(
quirk_dict
.
pagination
)
);
}
}
// add caption
// add caption
...
@@ -6171,11 +6200,21 @@
...
@@ -6171,11 +6200,21 @@
}
}
break
;
break
;
}
}
}
else
{
widget
=
pass
.
state
.
gadget
.
querySelector
(
"
[data-update]
"
)
.
getAttribute
(
"
data-widget
"
);
wrapper
=
util
.
mergeObject
(
factory
.
widget
[
widget
](
wrapper
.
property_dict
),
wrapper
);
// add scheme and field_dict to list
kids
=
util
.
inherit
(
pointer_results
.
data
.
rows
,
{
"
scheme
"
:
quirk_dict
.
scheme
,
"
field_dict
"
:
quirk_dict
.
field_dict
}
);
}
}
}
}
console
.
log
(
pointer_results
)
console
.
log
(
kids
)
// loop over children
// loop over children
if
(
kids
.
length
)
{
if
(
kids
.
length
)
{
...
@@ -6213,14 +6252,10 @@
...
@@ -6213,14 +6252,10 @@
// inherit properties of parent (> dynamic!) and add data to kid
// inherit properties of parent (> dynamic!) and add data to kid
kid
.
property_dict
=
util
.
mergeObject
(
kid
.
property_dict
,
quirk_dict
);
kid
.
property_dict
=
util
.
mergeObject
(
kid
.
property_dict
,
quirk_dict
);
kid
.
children
=
pointer_results
.
data
.
rows
.
concat
(
kid
.
children
||
[]);
kid
.
children
=
util
.
inherit
(
pointer_results
.
data
.
rows
.
concat
(
kid
.
children
||
[]),
// add scheme/fields/id to children of kid (eg listview > list items)
{
"
scheme
"
:
quirk_dict
.
scheme
,
"
field_dict
"
:
quirk_dict
.
field_dict
}
for
(
j
=
0
;
j
<
kid
.
children
.
length
;
j
+=
1
)
{
);
grant_child
=
kid
.
children
[
j
];
grant_child
.
scheme
=
quirk_dict
.
schemes
;
grant_child
.
field_dict
=
quirk_dict
.
field_dict
;
}
}
}
// HACK for setParam in login window
// HACK for setParam in login window
...
@@ -6251,9 +6286,8 @@
...
@@ -6251,9 +6286,8 @@
kid
=
undefined
;
kid
=
undefined
;
}
}
// reference
if
(
quirk_dict
.
reference
)
{
if
(
quirk_dict
.
reference
)
{
if
(
!!
kid
.
attribute
)
{
if
(
!!
kid
.
attribute
s
)
{
kid
.
attributes
[
"
data-reference
"
]
=
quirk_dict
.
reference
;
kid
.
attributes
[
"
data-reference
"
]
=
quirk_dict
.
reference
;
}
else
if
(
!!
kid
.
property_dict
)
{
}
else
if
(
!!
kid
.
property_dict
)
{
kid
.
property_dict
.
reference
=
quirk_dict
.
reference
;
kid
.
property_dict
.
reference
=
quirk_dict
.
reference
;
...
@@ -6285,9 +6319,8 @@
...
@@ -6285,9 +6319,8 @@
return
RSVP
.
all
(
promise_list
)
return
RSVP
.
all
(
promise_list
)
.
then
(
function
(
response_list
)
{
.
then
(
function
(
response_list
)
{
var
k
,
l
,
target
,
wrapper_selector
,
response
,
content
;
var
k
,
l
,
done_target
,
wrapper_selector
,
response
,
content
,
console
.
log
(
"
DONE
"
)
content_target
;
console
.
log
(
promise_list
)
for
(
k
=
0
,
l
=
response_list
.
length
;
k
<
l
;
k
+=
1
)
{
for
(
k
=
0
,
l
=
response_list
.
length
;
k
<
l
;
k
+=
1
)
{
response
=
response_list
[
k
];
response
=
response_list
[
k
];
...
@@ -6432,7 +6465,6 @@
...
@@ -6432,7 +6465,6 @@
.
fail
(
app
.
util
.
error
);
.
fail
(
app
.
util
.
error
);
};
};
/* ********************************************************************** */
/* ********************************************************************** */
/* APP UTIL */
/* APP UTIL */
/* ********************************************************************** */
/* ********************************************************************** */
...
...
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