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
0247423b
Commit
0247423b
authored
Dec 18, 2013
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixing loading of pages with/without auth, new items loading
parent
2efdfaab
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
134 additions
and
130 deletions
+134
-130
js/erp5_loader.js
js/erp5_loader.js
+134
-130
No files found.
js/erp5_loader.js
View file @
0247423b
...
...
@@ -1211,82 +1211,93 @@
* @return {object} fragment
**/
"
listbox
"
:
function
(
spec
,
answer
,
field_dict
,
update
,
url_pointer
)
{
var
element
,
i
,
empty
,
target
,
container
,
pack
,
slot
,
pop
,
active
;
var
element
,
i
,
empty
,
target
,
container
,
pack
,
slot
,
pop
,
active
,
placeholder
;
// determine target element, that will be returned
if
(
update
)
{
target
=
document
.
createDocumentFragment
();
// 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
;
}
else
{
slot
=
spec
.
property_dict
.
wrap_gadget
;
pop
=
spec
.
property_dict
.
need_popup
;
if
(
slot
)
{
container
=
factory
.
element
(
"
div
"
,
{
"
className
"
:
"
span_
"
+
slot
});
pack
=
true
;
// determine target element, that will be returned
if
(
update
)
{
target
=
document
.
createDocumentFragment
();
}
else
{
slot
=
spec
.
property_dict
.
wrap_gadget
;
pop
=
spec
.
property_dict
.
need_popup
;
if
(
slot
)
{
container
=
factory
.
element
(
"
div
"
,
{
"
className
"
:
"
span_
"
+
slot
});
pack
=
true
;
}
target
=
factory
.
util
.
wrapInForm
(
spec
);
}
target
=
factory
.
util
.
wrapInForm
(
spec
);
}
// add popups if needed
// TODO: will this find a popup if the page is being generated?
if
(
pop
)
{
if
(
pop
===
"
local
"
)
{
active
=
util
.
getActivePage
();
if
(
document
.
getElementById
(
active
)
.
querySelectorAll
(
"
div.local_popup
"
)
===
null
)
{
target
.
appendChild
(
factory
.
popup
(
undefined
,
active_page
));
}
}
else
{
if
(
document
.
getElementById
(
"
global_popup
"
)
===
null
)
{
// NOTE: was passing undefined, undefined, this should work, too
document
.
documentElement
.
appendChild
(
factory
.
popup
());
// add popups if needed
// TODO: will this find a popup if the page is being generated?
if
(
pop
)
{
if
(
pop
===
"
local
"
)
{
active
=
util
.
getActivePage
();
if
(
document
.
getElementById
(
active
)
.
querySelectorAll
(
"
div.local_popup
"
)
===
null
)
{
target
.
appendChild
(
factory
.
popup
(
undefined
,
active_page
));
}
}
else
{
if
(
document
.
getElementById
(
"
global_popup
"
)
===
null
)
{
// NOTE: was passing undefined, undefined, this should work, too
document
.
documentElement
.
appendChild
(
factory
.
popup
());
}
}
}
}
// loop over dynamic data and generate table
if
(
answer
.
data
.
total_rows
>
0
)
{
for
(
i
=
0
;
i
<
spec
.
children
.
length
;
i
+=
1
)
{
element
=
spec
.
children
[
i
];
// loop over dynamic data and generate table
if
(
answer
.
data
.
total_rows
>
0
)
{
for
(
i
=
0
;
i
<
spec
.
children
.
length
;
i
+=
1
)
{
element
=
spec
.
children
[
i
];
// set flag for referencing gadget
element
.
reference
=
spec
.
id
;
// set flag for referencing gadget
element
.
reference
=
spec
.
id
;
// set flag to label elements that should contain dynamic data
if
(
spec
.
property_dict
.
dynamic_children
)
{
if
(
spec
.
property_dict
.
dynamic_children
.
indexOf
(
i
)
>
-
1
)
{
// pass relevant information to method generating the gadget
element
.
portal_type
=
spec
.
portal_type_title
;
element
.
feature_dict
=
spec
.
property_dict
.
feature_dict
;
element
.
dynamic
=
true
;
// set flag to label elements that should contain dynamic data
if
(
spec
.
property_dict
.
dynamic_children
)
{
if
(
spec
.
property_dict
.
dynamic_children
.
indexOf
(
i
)
>
-
1
)
{
// pass relevant information to method generating the gadget
element
.
portal_type
=
spec
.
portal_type_title
;
element
.
feature_dict
=
spec
.
property_dict
.
feature_dict
;
element
.
dynamic
=
true
;
}
}
}
// generate table rows with dynamic data
if
(
element
.
type
===
"
table
"
)
{
element
.
children
=
map
.
utils
.
mapTableRows
(
answer
.
data
.
rows
,
spec
,
field_dict
,
url_pointer
,
update
);
}
// generate table rows with dynamic data
if
(
element
.
type
===
"
table
"
)
{
element
.
children
=
map
.
utils
.
mapTableRows
(
answer
.
data
.
rows
,
spec
,
field_dict
,
url_pointer
,
update
);
}
// add elements when not updating, if updating only add dynamic
if
(
update
!==
true
||
element
.
dynamic
)
{
target
.
appendChild
(
app
.
setContent
(
element
,
{},
update
));
// add elements when not updating, if updating only add dynamic
if
(
update
!==
true
||
element
.
dynamic
)
{
target
.
appendChild
(
app
.
setContent
(
element
,
{},
update
));
}
}
}
else
{
target
.
appendChild
(
app
.
noItemsFound
(
placeholder
.
no_items
));
}
}
else
{
target
.
appendChild
(
app
.
noItemsFound
());
}
// assemble and/or return
if
(
pack
)
{
container
.
appendChild
(
target
);
return
container
;
// assemble and/or return
if
(
pack
)
{
container
.
appendChild
(
target
);
return
container
;
}
return
target
;
}
return
target
;
},
/**
...
...
@@ -1300,12 +1311,19 @@
* @return {object} fragment
**/
"
fieldlist
"
:
function
(
spec
,
answer
,
field_dict
,
update
,
url_pointer
)
{
var
i
,
element
,
target
;
var
i
,
element
,
target
,
placeholder
;
// set placeholders
placeholder
=
spec
.
placeholder_dict
||
{};
// no auth
console
.
log
(
"
so what is answer
"
)
console
.
log
(
answer
)
console
.
log
(
answer
===
null
)
if
(
answer
===
null
)
{
target
=
factory
.
util
.
wrapInForm
(
spec
);
target
.
appendChild
(
app
.
noItemsFound
(
"
auth
"
));
target
.
appendChild
(
app
.
noItemsFound
(
placeholder
.
no_auth
));
return
target
;
}
else
{
target
=
document
.
createDocumentFragment
();
...
...
@@ -2038,11 +2056,11 @@
position
,
doc
,
config
,
value
,
stamp
,
sauce
,
encode
,
secure
,
safety_box
,
noscript
,
fragment
,
wrap
;
fragment
=
factory
.
util
.
wrapInForm
(
spec
);
secure
=
spec
.
property_dict
.
secure
;
if
(
spec
.
property_dict
.
update
)
{
spec
.
update
=
spec
.
property_dict
.
update
;
}
fragment
=
factory
.
util
.
wrapInForm
(
spec
);
secure
=
spec
.
property_dict
.
secure
;
wrap
=
function
(
area
,
captcha
)
{
var
keys
=
{};
...
...
@@ -3750,8 +3768,14 @@
"
pass
"
:
{
"
type
"
:
config
.
gadget
.
state
.
type
,
"
reply
"
:
true
}
})
.
then
(
function
(
answer
)
{
console
.
log
(
"
soo....
"
)
console
.
log
(
answer
)
// TODO: This is not the correct place to run all status updates!
if
(
answer
.
response
.
result
===
"
success
"
)
{
console
.
log
(
"
swithing
"
)
console
.
log
(
config
)
console
.
log
(
config
.
gadget
)
console
.
log
(
"
mh
"
)
switch
(
config
.
gadget
.
getAttribute
(
"
data-set
"
))
{
case
"
login_state
"
:
app
.
setLoginStatus
(
answer
.
response
,
config
.
portal_type_source
);
...
...
@@ -4170,63 +4194,36 @@
/**
* return a placeholder with button in case no items were found
* @method noItemsFound
* @param {
string} type
Type of placeholder to create
* @param {
object} content_dict
Type of placeholder to create
* @return {object} HTML fragment
*/
// TODO: don't get global popup like this!!!!!!
// TODO: make this element fit to whoever calls (tr, li, div...)
app
.
noItemsFound
=
function
(
type
)
{
var
reply
,
content
,
message
,
message_i18n
;
// TODO: find less content-heavy way!
switch
(
type
)
{
case
"
auth
"
:
message
=
"
Requires authorization.
"
;
message_i18n
=
"
validation_dict.requires_auth
"
;
content
=
{
"
generate
"
:
"
widget
"
,
"
type
"
:
"
controlgroup
"
,
"
property_dict
"
:
{
"
direction
"
:
"
horizontal
"
},
"
children
"
:
[{
"
type
"
:
"
a
"
,
"
direct
"
:{
"
className
"
:
"
translate action
"
,
"
href
"
:
"
#global-popup
"
},
"
attributes
"
:{
"
data-i18n
"
:
"
global_dict.common_dict.login
"
,
"
data-action
"
:
"
login
"
,
"
data-icon
"
:
"
lock
"
,
"
data-rel
"
:
"
popup
"
},
"
logic
"
:
{
"
text
"
:
"
Login
"
}
},
{
"
type
"
:
"
a
"
,
"
direct
"
:
{
"
className
"
:
"
translate
"
,
"
href
"
:
"
#person::new
"
},
"
attributes
"
:
{
"
data-i18n
"
:
"
global_dict.common_dict.register
"
,
"
data-icon
"
:
"
edit
"
},
"
logic
"
:
{
"
text
"
:
"
Register
"
}
}
]
};
break
;
default
:
message
=
"
No items found.
"
;
message_i18n
=
"
validation_dict.no_items_found
"
;
content
=
{
"
type
"
:
"
a
"
,
"
direct
"
:
{
"
href
"
:
"
#
"
,
"
className
"
:
"
ui-corner-all ui-btn ui-shadow ui-btn-inline
"
+
"
ui-icon-chevron-sign-left ui-btn-icon-left translate
"
},
"
attributes
"
:
{
"
data-rel
"
:
"
back
"
,
"
data-i18n
"
:
"
global_dict.pagination_dict.back
"
},
"
logic
"
:
{
"
Text
"
:
"
Back
"
}
}
break
;
};
app
.
noItemsFound
=
function
(
content_dict
)
{
var
i
,
reply
,
content
,
message
,
message_i18n
;
// provided in gadget config
if
(
content_dict
)
{
message
=
content_dict
.
text
;
message_i18n
=
content_dict
.
text_i18n
;
content
=
content_dict
.
children
;
// fallback
}
else
{
message
=
"
No items found.
"
;
message_i18n
=
"
validation_dict.no_items_found
"
;
content
=
[{
"
type
"
:
"
a
"
,
"
direct
"
:
{
"
href
"
:
"
#
"
,
"
className
"
:
"
ui-corner-all ui-btn ui-shadow ui-btn-inline
"
+
"
ui-icon-chevron-sign-left ui-btn-icon-left translate
"
},
"
attributes
"
:
{
"
data-rel
"
:
"
back
"
,
"
data-i18n
"
:
"
global_dict.pagination_dict.back
"
},
"
logic
"
:
{
"
Text
"
:
"
Back
"
}
}]
}
// <p> is not flexible...
reply
=
factory
.
element
(
...
...
@@ -4240,8 +4237,10 @@
{
"
data-i18n
"
:
message_i18n
},
{
"
text
"
:
message
}
));
reply
.
appendChild
(
app
.
setContent
(
content
));
for
(
i
=
0
;
i
<
content
.
length
;
i
+=
1
)
{
reply
.
appendChild
(
app
.
setContent
(
content
[
i
]));
}
return
reply
;
};
...
...
@@ -4268,7 +4267,8 @@
"
issued
"
:
stamp
,
"
expires
"
:
auth
?
auth
.
expires_in
:
3600
}
console
.
log
(
"
so...
"
)
console
.
log
(
flux
)
// need to update the .... button
// TODO: make a login gadget, store dependend buttons in state
links
=
util
.
getHeader
().
getElementsByTagName
(
"
A
"
);
...
...
@@ -4672,11 +4672,9 @@
* @param {string} url Url to go to
* @return {object} pointer object
*/
// TODO: renderJS should parse a link
app
.
generateLinkObject
=
function
(
url
)
{
var
i
,
query
,
parameter
,
path
,
clean_hash
,
config
;
parameter
=
0
;
path
=
$
.
mobile
.
path
.
parseUrl
(
url
.
replace
(
$
.
mobile
.
dialogHashKey
,
""
)),
clean_hash
=
path
.
hash
.
replace
(
"
#
"
,
""
),
config
=
{
...
...
@@ -4695,20 +4693,19 @@
for
(
i
=
0
;
i
<
query
.
length
;
i
+=
1
)
{
switch
(
query
[
i
])
{
case
"
new
"
:
// person::new = create a new entry for person
// NOTE: this will allow loading of field definitions in auth!
config
.
mode
=
"
new
"
;
parameter
=
1
;
break
;
};
}
config
.
fragment_list
=
clean_hash
.
split
(
"
::
"
);
config
.
id
=
clean_hash
;
config
.
layout_level
=
config
.
fragment_list
.
length
-
1
-
parameter
;
config
.
layout_level
=
config
.
fragment_list
.
length
-
1
;
config
.
deeplink
=
true
;
config
.
layout_identifier
=
clean_hash
.
split
(
"
::
"
)[
0
];
}
console
.
log
(
"
parsed link
"
)
console
.
log
(
config
)
return
config
;
};
...
...
@@ -4976,8 +4973,14 @@
pass
=
reply
.
pass
;
constructor
=
map
.
gadgets
[
pass
.
constructor
];
// TODO: this always sets "new" urls to an empty result. Good?
request_new
=
pass
.
mode
===
"
new
"
?
{
"
request_new
"
:
true
}
:
null
;
// set answer depending on mode=new and auth
if
(
pass
.
mode
===
"
new
"
)
{
if
(
pass
.
auth
&&
pass
.
active_login
===
false
)
{
request_new
=
null
;
}
else
{
request_new
=
{
"
request_new
"
:
true
}
}
}
if
(
constructor
===
undefined
)
{
util
.
error
(
...
...
@@ -5571,7 +5574,8 @@
}
else
{
destination
=
config
.
layout_identifier
;
}
console
.
log
(
"
RUNNING WITH
"
)
console
.
log
(
destination
)
return
app
.
fetchConfiguration
({
"
storage
"
:
app
.
default_dict
.
storage_dict
.
settings
,
"
file
"
:
"
pages
"
,
...
...
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