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
3c2c8724
Commit
3c2c8724
authored
Jan 15, 2014
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup/method renaming
parent
616a1f27
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
60 deletions
+39
-60
js/erp5_loader.js
js/erp5_loader.js
+39
-60
No files found.
js/erp5_loader.js
View file @
3c2c8724
...
...
@@ -1921,7 +1921,7 @@
promises
=
[];
// fetch content
app
.
fetchConfig
uration
({
app
.
fetchConfig
({
"
storage
"
:
app
.
default_dict
.
storage_dict
.
settings
,
"
file
"
:
app
.
default_dict
.
storage_dict
.
gadgets
,
"
attachment
"
:
reference
,
...
...
@@ -4562,7 +4562,7 @@
);
// need field values for allDocs select_list...
return
app
.
fetchConfig
uration
({
return
app
.
fetchConfig
({
"
storage
"
:
app
.
default_dict
.
storage_dict
.
settings
,
"
file
"
:
app
.
default_dict
.
storage_dict
.
data_type
,
"
attachment
"
:
"
person_fieldlist
"
,
...
...
@@ -5601,17 +5601,17 @@
/**
* Generate gadget content based on query data and passed config
* @method
generateGadget
Content
* @method
make
Content
* @param {object} reply Response from previous promise and pass-params
* @return {object} response object/promise
*/
app
.
generateGadget
Content
=
function
(
reply
)
{
app
.
make
Content
=
function
(
reply
)
{
var
selector
,
element
,
pass
,
constructor
,
data
,
data_set
;
pass
=
reply
.
pass
;
constructor
=
map
.
gadgets
[
pass
.
constructor
];
if
(
constructor
===
undefined
)
{
return
util
.
error
(
"
generateGadget
Content: Missing constructor
"
);
return
util
.
error
(
"
make
Content: Missing constructor
"
);
}
// set data depending on auth
...
...
@@ -5870,7 +5870,7 @@
}
// TODO: bad way to set attachment value!!
return
app
.
fetchConfig
uration
({
return
app
.
fetchConfig
({
"
storage
"
:
app
.
default_dict
.
storage_dict
.
settings
,
"
file
"
:
app
.
default_dict
.
storage_dict
.
data_type
,
"
attachment
"
:
pass
.
type
.
toLowerCase
()
+
"
_fieldlist
"
,
...
...
@@ -5964,11 +5964,11 @@
/**
* If no data is found in JIO, we need to load fake data for now
* @method
retrieveSampleData
* @method
fetchDataSample
* @param {object} reply Response from previous promise and pass-params
* @return {object} response object/promise
*/
app
.
retrieveSampleData
=
function
(
reply
)
{
app
.
fetchDataSample
=
function
(
reply
)
{
var
pass
=
reply
.
pass
;
if
(
reply
.
response
)
{
...
...
@@ -5992,11 +5992,11 @@
/**
* Test if JIO has data of a certain portal_type
* @method test
StorageForData
* @method test
DataSample
* @param {object} reply Response from previous promise and pass-params
* @return {object} response object/promise
*/
app
.
test
StorageForData
=
function
(
reply
)
{
app
.
test
DataSample
=
function
(
reply
)
{
var
pass
=
reply
.
pass
;
if
(
pass
.
skip
===
undefined
)
{
...
...
@@ -6022,11 +6022,11 @@
// ======================== SAMPLE DATA ==================================
/**
* Load field definitions if necessary
* @method
loadFieldDefinition
* @method
fetchFields
* @param {object} pass through
* @return {object} field defintions and pass through
*/
app
.
loadFieldDefinition
=
function
(
reply
)
{
app
.
fetchFields
=
function
(
reply
)
{
var
pass
=
reply
.
pass
;
// active login?
...
...
@@ -6046,7 +6046,7 @@
// TODO: keep this until sample handling is removed
pass
.
needs_fields
=
true
;
return
app
.
fetchConfig
uration
({
return
app
.
fetchConfig
({
"
storage
"
:
app
.
default_dict
.
storage_dict
.
settings
,
"
file
"
:
app
.
default_dict
.
storage_dict
.
data_type
,
"
attachment
"
:
pass
.
config
.
portal_type_fields
,
...
...
@@ -6060,11 +6060,11 @@
/**
* parses a gadget configuration file
* @method
parseConfiguration
* @method
checkAuth
* @param {object} reply gadget configuration
* @return {object} response object/promise
*/
app
.
parseConfiguration
=
function
(
reply
)
{
app
.
checkAuth
=
function
(
reply
)
{
var
parsed
,
pass
=
reply
.
pass
;
if
(
pass
.
skip
===
undefined
)
{
...
...
@@ -6144,7 +6144,6 @@
"
create
"
:
create
,
"
layout_level
"
:
spec
.
layout_level
||
null
,
"
fragment_list
"
:
spec
.
fragment_list
,
// TODO: this should be a link!
"
href
"
:
content_dict
.
href
,
"
reference
"
:
content_dict
.
reference
||
null
};
...
...
@@ -6156,21 +6155,21 @@
}
// and go
return
app
.
fetchConfig
uration
({
return
app
.
fetchConfig
({
"
storage
"
:
app
.
default_dict
.
storage_dict
.
settings
,
"
file
"
:
pass
.
href
?
app
.
default_dict
.
storage_dict
.
gadgets
:
app
.
default_dict
.
storage_dict
.
settings
,
"
attachment
"
:
pass
.
href
||
app
.
default_dict
.
storage_dict
.
configuration
,
"
pass
"
:
pass
})
.
then
(
app
.
parseConfiguration
)
.
then
(
app
.
loadFieldDefinition
)
.
then
(
app
.
test
StorageForData
)
.
then
(
app
.
retrieveSampleData
)
.
then
(
app
.
checkAuth
)
.
then
(
app
.
fetchFields
)
.
then
(
app
.
test
DataSample
)
.
then
(
app
.
fetchDataSample
)
.
then
(
app
.
store
)
.
then
(
app
.
fetchDataTotal
)
.
then
(
app
.
fetchDataQuery
)
.
then
(
app
.
generateGadget
Content
)
.
then
(
app
.
make
Content
)
.
fail
(
util
.
error
);
default
:
...
...
@@ -6197,11 +6196,11 @@
/**
* Fetch a configuration file (attachment) from storage. Fallback to
* disk. Successfull fallback file fetches will be stored in JIO.
* @method fetchConfig
uration
* @method fetchConfig
* @param {object} parcel parameters & pass to pass to subsequent then()
* @return {object} object including pass and reply
*/
app
.
fetchConfig
uration
=
function
(
parcel
)
{
app
.
fetchConfig
=
function
(
parcel
)
{
var
reply
,
store
;
if
(
parcel
.
pass
&&
parcel
.
pass
.
skip
)
{
...
...
@@ -6232,7 +6231,7 @@
function
(
error
)
{
// if the file is not found in JIO, try to pull from disk
if
(
error
.
status
===
404
&&
error
.
id
===
parcel
.
file
)
{
return
app
.
getFromDisk
({
return
app
.
loadFile
({
"
store
"
:
store
,
"
file
"
:
parcel
.
file
,
"
attachment
"
:
parcel
.
attachment
,
...
...
@@ -6300,13 +6299,13 @@
/**
* Load files from disk
* @method
getFromDisk
* @method
loadFile
* @param {object} property_dict (including pass)
* @return {object} object
*/
// TODO: put/putAttachment should be set somewhere more general!
// TODO: refactor... such a mess
app
.
getFromDisk
=
function
(
property_dict
)
{
app
.
loadFile
=
function
(
property_dict
)
{
var
response
,
storage_location
,
url
,
hacked_view
;
url
=
property_dict
.
url
||
app
.
default_dict
.
path_dict
.
data
+
...
...
@@ -6317,7 +6316,7 @@
if
(
property_dict
.
optional
)
{
return
RSVP
.
all
([]);
}
util
.
error
(
"
getFromDisk
: URL undefined
"
);
util
.
error
(
"
loadFile
: URL undefined
"
);
}
// fetch file
...
...
@@ -6341,7 +6340,7 @@
}
if
(
storage_location
===
undefined
)
{
util
.
error
(
"
getFromDisk
: no storage defined
"
);
util
.
error
(
"
loadFile
: no storage defined
"
);
return
RSVP
.
all
([]);
}
...
...
@@ -6459,7 +6458,7 @@
destination
=
config
.
layout_identifier
;
}
return
app
.
fetchConfig
uration
({
return
app
.
fetchConfig
({
"
storage
"
:
app
.
default_dict
.
storage_dict
.
settings
,
"
file
"
:
"
pages
"
,
"
attachment
"
:
destination
,
...
...
@@ -6722,11 +6721,11 @@
/**
* Retrieve application configuration from path specified on the
* JavaScript file loaded (thx http://requirejs.org)
* @method
getPathFromScriptTag
* @method
fetchPath
* @param {string} attribute Attribute to find
* @return {string} path
*/
util
.
getPathFromScriptTag
=
function
(
attribute
)
{
util
.
fetchPath
=
function
(
attribute
)
{
var
i
,
path
,
script_list
=
document
.
getElementsByTagName
(
"
script
"
);
for
(
i
=
0
;
i
<
script_list
.
length
;
i
+=
1
)
{
...
...
@@ -6983,31 +6982,11 @@
* Return
* @method return
*/
// TODO: remove only used for JSLint
and
validval
// TODO: remove only used for JSLint
for
validval
util
.
return_out
=
function
()
{
return
;
};
/**
* escape a urlString
* @method encode
* @param {string} string String to escape
* @return {string} escaped string
**/
util
.
encode
=
function
(
string
)
{
return
encodeURIComponent
(
string
);
};
/**
* decode a urlString
* @method decode
* @param {string} string String to unescape
* @return {string} unescaped string
**/
util
.
decode
=
function
(
string
)
{
return
decodeURIComponent
(
string
);
};
/**
* parse to JSON if element is not in JSON
* @parseIfNeeded
...
...
@@ -7075,7 +7054,7 @@
* @method error
* @param {object} err Error object
*/
// TODO:
update global config so we know where to post a ticket to!
// TODO:
Post a ticket to ...
util
.
error
=
function
(
err
)
{
if
(
typeof
err
===
"
string
"
)
{
console
.
log
({
"
error
"
:
err
});
...
...
@@ -7089,21 +7068,21 @@
/* ====================================================================== */
app
.
contentLoaded
(
window
,
function
()
{
// TODO:
don't wipe. S
ync...!
//
Don't wipe if opened in a popup (like in oAuth redirect_uri
)
// TODO:
Don't wipe. Wait for s
ync...!
//
NOTE: Don't clear if page is opened in popup (like when using oauth
)
if
(
window
.
opener
===
null
)
{
window
.
localStorage
.
clear
();
}
app
.
getFromDisk
({
"
url
"
:
util
.
getPathFromScriptTag
(
"
data-storage
"
),
app
.
loadFile
({
"
url
"
:
util
.
fetchPath
(
"
data-storage
"
),
"
optional
"
:
true
,
"
skip
"
:
true
})
.
then
(
app
.
setContent
)
.
then
(
function
()
{
return
app
.
getFromDisk
({
"
url
"
:
util
.
getPathFromScriptTag
(
"
data-config
"
)
return
app
.
loadFile
({
"
url
"
:
util
.
fetchPath
(
"
data-config
"
)
});
})
.
then
(
app
.
setContent
)
...
...
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