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
8dfd95fb
Commit
8dfd95fb
authored
Dec 20, 2013
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix setContent-flow: test for purge when refreshing gadgets
parent
971e3536
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
120 additions
and
97 deletions
+120
-97
js/erp5_loader.js
js/erp5_loader.js
+120
-97
No files found.
js/erp5_loader.js
View file @
8dfd95fb
...
@@ -273,12 +273,17 @@
...
@@ -273,12 +273,17 @@
// update gadget
// update gadget
app
.
setContent
(
app
.
setContent
(
{
"
generate
"
:
"
gadget
"
,
"
id
"
:
id
,
"
href
"
:
id
},
{
"
generate
"
:
"
gadget
"
,
"
id
"
:
id
,
"
href
"
:
id
,
"
type
"
:
gadget
.
state
.
method
},
{
{
"
fragment_list
"
:
gadget
.
state
.
fragment_list
,
"
fragment_list
"
:
gadget
.
state
.
fragment_list
,
"
mode
"
:
gadget
.
state
.
view
"
mode
"
:
gadget
.
state
.
view
},
},
false
,
undefined
,
true
true
)
)
.
then
(
function
(
answer
){
.
then
(
function
(
answer
){
...
@@ -1185,7 +1190,7 @@
...
@@ -1185,7 +1190,7 @@
* @return {object} fragment
* @return {object} fragment
**/
**/
"
listgrid
"
:
function
(
spec
,
answer
,
field_dict
,
update
,
url_pointer
)
{
"
listgrid
"
:
function
(
spec
,
answer
,
field_dict
,
update
,
url_pointer
)
{
var
element
,
i
,
empty
,
target
;
var
element
,
i
,
empty
,
target
,
placeholder
;
// set update of gadget flag
// set update of gadget flag
if
(
spec
.
property_dict
.
depends_on
)
{
if
(
spec
.
property_dict
.
depends_on
)
{
...
@@ -1197,6 +1202,16 @@
...
@@ -1197,6 +1202,16 @@
spec
.
reset
=
spec
.
property_dict
.
resets
;
spec
.
reset
=
spec
.
property_dict
.
resets
;
}
}
// set placeholders
placeholder
=
spec
.
placeholder_dict
||
{};
// no auth
if
(
answer
===
null
)
{
target
=
factory
.
util
.
wrapInForm
(
spec
);
target
.
appendChild
(
app
.
noItemsFound
(
placeholder
.
no_auth
));
return
target
;
}
// when updating we only need a fragment container. Otherwise we
// when updating we only need a fragment container. Otherwise we
// generate the full gadget
// generate the full gadget
if
(
update
)
{
if
(
update
)
{
...
@@ -1395,7 +1410,6 @@
...
@@ -1395,7 +1410,6 @@
(
answer
.
data
===
undefined
&&
answer
.
request_new
===
undefined
))
{
(
answer
.
data
===
undefined
&&
answer
.
request_new
===
undefined
))
{
target
.
appendChild
(
app
.
noItemsFound
());
target
.
appendChild
(
app
.
noItemsFound
());
}
else
{
}
else
{
// set data
// set data
if
(
answer
&&
(
answer
.
data
||
answer
.
request_new
))
{
if
(
answer
&&
(
answer
.
data
||
answer
.
request_new
))
{
if
(
answer
.
request_new
||
answer
.
data
.
total_rows
===
0
)
{
if
(
answer
.
request_new
||
answer
.
data
.
total_rows
===
0
)
{
...
@@ -1407,6 +1421,9 @@
...
@@ -1407,6 +1421,9 @@
util
.
error
({
"
error
"
:
"
Fieldlist: More than 1 record
"
});
util
.
error
({
"
error
"
:
"
Fieldlist: More than 1 record
"
});
}
else
{
}
else
{
data
=
answer
.
data
.
rows
[
0
].
doc
;
data
=
answer
.
data
.
rows
[
0
].
doc
;
if
(
data
===
undefined
)
{
util
.
errorHandler
({
"
error
"
:
"
fieldlist: include_docs missing
"
});
}
}
}
}
}
...
@@ -2127,7 +2144,7 @@
...
@@ -2127,7 +2144,7 @@
fragment
=
factory
.
util
.
wrapInForm
(
spec
);
fragment
=
factory
.
util
.
wrapInForm
(
spec
);
secure
=
spec
.
property_dict
.
secure
;
secure
=
spec
.
property_dict
.
secure
;
item_id
=
spec
.
data
.
_id
||
undefined
;
item_id
=
spec
.
data
?
(
spec
.
data
.
_id
||
undefined
)
:
undefined
;
wrap
=
function
(
area
,
captcha
)
{
wrap
=
function
(
area
,
captcha
)
{
var
keys
=
{};
var
keys
=
{};
...
@@ -4799,6 +4816,9 @@
...
@@ -4799,6 +4816,9 @@
case
"
new
"
:
case
"
new
"
:
config
.
mode
=
"
new
"
;
config
.
mode
=
"
new
"
;
break
;
break
;
case
"
add
"
:
config
.
mode
=
"
add
"
;
break
;
};
};
}
}
...
@@ -4934,90 +4954,6 @@
...
@@ -4934,90 +4954,6 @@
document
.
title
=
value
;
document
.
title
=
value
;
};
};
/**
* Create/update elements
* @method setupPageElements
* @param {object} content_dict content to be generated
* @param {object} url_dict JSON pointers based on parsed link
* @param {boolean} create Create page/Generate content/Refresh content
* @param {boolean} purge Replace existing element/gadget
* @return {object} promise/HTML element
*/
// TODO: make this always return a promise. Requires to refactor listview!
// TODO: only pass around what we need. pass.CONFIG is too much!
app
.
setContent
=
function
(
content_dict
,
url_dict
,
create
,
purge
)
{
var
i
,
skip
,
container
,
target
,
pass
,
spec
,
dependency
;
spec
=
url_dict
||
{};
switch
(
content_dict
.
generate
)
{
case
"
widget
"
:
return
factory
[
content_dict
.
type
](
content_dict
,
spec
,
create
)
case
"
gadget
"
:
// no portal_type, no dynamic data
if
(
content_dict
.
portal_type_source
===
undefined
&&
content_dict
.
href
===
undefined
)
{
pass
=
{
"
skip
"
:
true
,
"
content_dict
"
:
content_dict
,
"
url_dict
"
:
spec
};
}
else
{
// this run needs query and dynamic data
pass
=
{
"
purge
"
:
purge
||
null
,
"
mode
"
:
spec
.
mode
||
null
,
"
create
"
:
create
,
"
layout_level
"
:
spec
.
layout_level
||
null
,
"
fragment_list
"
:
spec
.
fragment_list
,
"
layout
"
:
content_dict
,
"
id
"
:
content_dict
.
id
};
}
// set content constructor
if
(
create
!==
false
)
{
pass
.
constructor
=
content_dict
.
type
;
}
// and go
return
app
.
fetchConfiguration
({
"
storage
"
:
app
.
default_dict
.
storage_dict
.
settings
,
"
file
"
:
pass
.
id
?
app
.
default_dict
.
storage_dict
.
gadgets
:
app
.
default_dict
.
storage_dict
.
settings
,
"
attachment
"
:
pass
.
id
||
app
.
default_dict
.
storage_dict
.
configuration
,
"
pass
"
:
pass
})
.
then
(
app
.
parseConfiguration
)
.
then
(
app
.
loadFieldDefinition
)
// ===== SAMPLE DATA ========
.
then
(
app
.
testStorageForData
)
.
then
(
app
.
retrieveSampleData
)
// ===== SAMPLE DATA ========
.
then
(
app
.
store
)
.
then
(
app
.
fetchDataTotal
)
.
then
(
app
.
fetchDataQuery
)
.
then
(
app
.
generateGadgetContent
)
.
fail
(
util
.
error
);
default
:
switch
(
content_dict
.
type
)
{
case
"
input
"
:
case
"
select
"
:
return
factory
.
formElement
(
content_dict
,
false
)
default
:
return
factory
.
element
(
content_dict
.
type
,
content_dict
.
direct
,
content_dict
.
attributes
,
content_dict
.
logic
,
content_dict
.
children
);
}
}
};
/**
/**
* cross-browser wrapper for DOMContentLoaded
* cross-browser wrapper for DOMContentLoaded
...
@@ -5208,7 +5144,7 @@
...
@@ -5208,7 +5144,7 @@
* @return {object} response object/promise
* @return {object} response object/promise
*/
*/
app
.
fetchDataTotal
=
function
(
reply
)
{
app
.
fetchDataTotal
=
function
(
reply
)
{
var
pass
=
reply
.
pass
,
reference
;
var
pass
=
reply
.
pass
,
reference
,
identifier
,
search_string
;
if
(
pass
.
skip
===
undefined
)
{
if
(
pass
.
skip
===
undefined
)
{
// create or update state object
// create or update state object
...
@@ -5232,8 +5168,8 @@
...
@@ -5232,8 +5168,8 @@
};
};
// on deeplinks, we have additional query parameters,
// on deeplinks, we have additional query parameters,
//
pass them here
!
//
but we should not do if pass.mode is set
!
if
(
pass
.
layout_level
>
0
)
{
if
(
pass
.
layout_level
>
0
&&
pass
.
mode
===
undefined
)
{
pass
.
value
=
pass
.
fragment_list
[
pass
.
layout_level
];
pass
.
value
=
pass
.
fragment_list
[
pass
.
layout_level
];
}
}
...
@@ -5250,9 +5186,10 @@
...
@@ -5250,9 +5186,10 @@
}
}
}
}
}
}
if
(
pass
.
skip
===
undefined
&&
if
(
pass
.
skip
===
undefined
&&
(
pass
.
no_auth
||
(
pass
.
auth
&&
pass
.
active_login
||
(
pass
.
no_auth
||
(
pass
.
auth
&&
pass
.
active_login
||
pass
.
mode
===
"
new
"
)))
{
(
pass
.
mode
===
"
new
"
||
pass
.
purge
)
)))
{
// skip total for single item layouts!
// skip total for single item layouts!
if
(
pass
.
config
.
initial_query
)
{
if
(
pass
.
config
.
initial_query
)
{
...
@@ -5261,6 +5198,7 @@
...
@@ -5261,6 +5198,7 @@
// store the complete initial query, not only the "query"
// store the complete initial query, not only the "query"
pass
.
state
.
initial_query
=
pass
.
config
.
initial_query
;
pass
.
state
.
initial_query
=
pass
.
config
.
initial_query
;
return
app
.
fetchData
({
return
app
.
fetchData
({
"
pass
"
:
pass
,
"
pass
"
:
pass
,
"
storage
"
:
"
items
"
,
"
storage
"
:
"
items
"
,
...
@@ -5384,10 +5322,10 @@
...
@@ -5384,10 +5322,10 @@
if
(
reply
.
response
)
{
if
(
reply
.
response
)
{
pass
.
fields
=
util
.
parseIfNeeded
(
reply
.
response
);
pass
.
fields
=
util
.
parseIfNeeded
(
reply
.
response
);
}
}
// try to get 1 record
if
(
pass
.
create
!==
false
&&
pass
.
config
.
initial_query
&&
(
pass
.
no_auth
||
(
pass
.
auth
&&
pass
.
active_login
)))
{
// try to get 1 record
if
((
pass
.
create
!==
false
||
pass
.
purge
)
&&
pass
.
config
.
initial_query
&&
(
pass
.
no_auth
||
(
pass
.
auth
&&
pass
.
active_login
)))
{
return
app
.
fetchData
({
return
app
.
fetchData
({
"
storage
"
:
"
items
"
,
"
storage
"
:
"
items
"
,
"
query
"
:
app
.
generateQueryObject
({
"
limit
"
:
[
0
,
1
]},
pass
.
type
),
"
query
"
:
app
.
generateQueryObject
({
"
limit
"
:
[
0
,
1
]},
pass
.
type
),
...
@@ -5422,7 +5360,6 @@
...
@@ -5422,7 +5360,6 @@
if
(
pass
.
skip
===
undefined
&&
if
(
pass
.
skip
===
undefined
&&
(
pass
.
no_auth
||
(
pass
.
auth
&&
pass
.
active_login
||
(
pass
.
no_auth
||
(
pass
.
auth
&&
pass
.
active_login
||
pass
.
mode
===
"
new
"
))
&&
pass
.
mode
===
"
new
"
))
&&
//(pass.create !== false || pass.requires_fields) &&
pass
.
config
.
portal_type_fields
)
{
pass
.
config
.
portal_type_fields
)
{
return
app
.
fetchConfiguration
({
return
app
.
fetchConfiguration
({
...
@@ -5473,6 +5410,92 @@
...
@@ -5473,6 +5410,92 @@
}
}
};
};
/**
* Create/update elements
* @method setupPageElements
* @param {object} content_dict content to be generated
* @param {object} url_dict JSON pointers based on parsed link
* @param {boolean} create Create page/Generate content/Refresh content
* @param {boolean} purge Replace existing element/gadget
* @return {object} promise/HTML element
*/
// TODO: make this always return a promise. Requires to refactor listview!
// TODO: only pass around what we need. pass.CONFIG is too much!
app
.
setContent
=
function
(
content_dict
,
url_dict
,
create
,
purge
)
{
var
i
,
skip
,
container
,
target
,
pass
,
spec
,
dependency
;
spec
=
url_dict
||
{};
switch
(
content_dict
.
generate
)
{
case
"
widget
"
:
return
factory
[
content_dict
.
type
](
content_dict
,
spec
,
create
)
case
"
gadget
"
:
// no portal_type, no dynamic data
if
(
content_dict
.
portal_type_source
===
undefined
&&
content_dict
.
href
===
undefined
)
{
pass
=
{
"
skip
"
:
true
,
"
content_dict
"
:
content_dict
,
"
url_dict
"
:
spec
};
}
else
{
// this run needs query and dynamic data
pass
=
{
"
purge
"
:
purge
||
null
,
"
mode
"
:
spec
.
mode
||
null
,
"
create
"
:
create
,
"
layout_level
"
:
spec
.
layout_level
||
null
,
"
fragment_list
"
:
spec
.
fragment_list
,
"
layout
"
:
content_dict
,
"
id
"
:
content_dict
.
id
};
}
// set content constructor
if
(
create
!==
false
)
{
pass
.
constructor
=
content_dict
.
type
;
}
// and go
return
app
.
fetchConfiguration
({
"
storage
"
:
app
.
default_dict
.
storage_dict
.
settings
,
"
file
"
:
pass
.
id
?
app
.
default_dict
.
storage_dict
.
gadgets
:
app
.
default_dict
.
storage_dict
.
settings
,
"
attachment
"
:
pass
.
id
||
app
.
default_dict
.
storage_dict
.
configuration
,
"
pass
"
:
pass
})
.
then
(
app
.
parseConfiguration
)
.
then
(
app
.
loadFieldDefinition
)
// ===== SAMPLE DATA ========
.
then
(
app
.
testStorageForData
)
.
then
(
app
.
retrieveSampleData
)
// ===== SAMPLE DATA ========
.
then
(
app
.
store
)
.
then
(
app
.
fetchDataTotal
)
.
then
(
app
.
fetchDataQuery
)
.
then
(
app
.
generateGadgetContent
)
.
fail
(
util
.
error
);
default
:
switch
(
content_dict
.
type
)
{
case
"
input
"
:
case
"
select
"
:
return
factory
.
formElement
(
content_dict
,
false
)
default
:
return
factory
.
element
(
content_dict
.
type
,
content_dict
.
direct
,
content_dict
.
attributes
,
content_dict
.
logic
,
content_dict
.
children
);
}
}
};
/**
/**
* Fetch a configuration file (attachment) from storage. Fallback to
* Fetch a configuration file (attachment) from storage. Fallback to
* disk. Successfull fallback file fetches will be stored in JIO.
* disk. Successfull fallback file fetches will be stored in JIO.
...
...
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