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
1d52853b
Commit
1d52853b
authored
Jan 15, 2014
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added custom handler for portal_type person
parent
026d9e34
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
99 additions
and
6 deletions
+99
-6
js/erp5_loader.js
js/erp5_loader.js
+99
-6
No files found.
js/erp5_loader.js
View file @
1d52853b
...
...
@@ -17,6 +17,65 @@
**/
map
=
{};
/**
* Custom handlers necessary to make calls to ERP5 storage. These should
* not be needed, but are currently necessary.
* @object map.handlers
**/
// TODO: remove!
map
.
handlers
=
{
/**
* @method person
* @param {object} reply Object received from previous chain element
* @param {object} response Object object passed on to next element
**/
"
person
"
:
function
(
reply
)
{
var
config
,
property
,
props
,
pass
=
reply
.
pass
;
if
(
storage
)
{
config
=
{
"
url
"
:
storage
.
items
.
dict
.
url
,
"
type
"
:
"
GET
"
,
"
data
"
:
JSON
.
stringify
({
"
_id
"
:
""
})
};
// access storage
return
jIO
.
util
.
ajax
(
config
)
.
then
(
function
(
response
)
{
return
jIO
.
util
.
ajax
({
"
url
"
:
util
.
parse
(
response
.
target
.
responseText
).
_links
.
me
.
href
})
.
then
(
function
(
answer
){
if
(
pass
.
config
.
initial_query
)
{
for
(
property
in
pass
.
config
.
initial_query
)
{
if
(
pass
.
config
.
initial_query
.
hasOwnProperty
(
property
))
{
delete
pass
.
config
.
initial_query
[
property
];
}
}
pass
.
config
.
initial_query
.
query
=
{
"
_id
"
:
util
.
parse
(
answer
.
target
.
responseText
).
_relative_url
};
// pass hacked query back into chain
if
(
reply
.
response
)
{
return
{
"
response
"
:
util
.
parse
(
reply
.
response
),
"
pass
"
:
pass
};
}
return
{
"
pass
"
:
pass
}
}
}).
fail
(
util
.
error
);
}).
fail
(
util
.
error
);
}
return
(
reply
);
}
};
/**
* Add connection to application standard actions or add own actions here
* @object map.actions
...
...
@@ -1208,6 +1267,8 @@
if
(
content_dict
.
property_dict
.
definition
)
{
storage
[
content_dict
.
property_dict
.
definition
.
application_name
]
=
jIO
.
createJIO
(
content_dict
.
property_dict
.
definition
);
storage
[
content_dict
.
property_dict
.
definition
.
application_name
].
dict
=
content_dict
.
property_dict
.
definition
;
}
else
{
util
.
error
(
"
makeStorage: Missing storage definition
"
);
}
...
...
@@ -5270,13 +5331,14 @@
// WARNING: complex_queries dependency!
app
.
generateQueryObject
=
function
(
query
,
type
,
key
,
value
,
field_list
,
restore
)
{
var
property
,
wrap
,
query_object
,
query_clean
,
default_query
,
obj
,
is_value
,
i
;
is_value
,
i
,
is_id
;
is_value
=
value
&&
value
!==
""
;
is_id
=
query
&&
query
.
query
&&
query
.
query
.
_id
;
// "id" = "bar" => THIS SHOULD BE GET!
if
(
is_value
&&
key
&&
key
===
"
_id
"
)
{
obj
=
{
"
_id
"
:
value
};
if
(
is_value
&&
key
&&
key
===
"
_id
"
||
is_id
)
{
obj
=
{
"
_id
"
:
is_id
?
query
.
query
.
_id
:
value
};
// ALLDOCS
}
else
{
...
...
@@ -5724,7 +5786,6 @@
pass
.
field_list
=
storage
.
makeSelectList
(
pass
.
config
.
scheme
);
}
}
pass
.
state
.
query
=
app
.
generateQueryObject
(
pass
.
config
.
initial_query
,
pass
.
type
,
...
...
@@ -5736,6 +5797,7 @@
// get an item?
if
(
pass
.
mode
!==
"
new
"
||
pass
.
config
.
initial_query
!==
undefined
)
{
console
.
log
(
"
ALORE
"
)
return
app
.
fetchData
({
"
storage
"
:
"
items
"
,
"
query
"
:
pass
.
state
.
query
,
...
...
@@ -5748,6 +5810,36 @@
};
};
/**
* Run any mappings required for this datatype to correctly access data
* @method mapToStorage
**/
app
.
mapToStorage
=
function
(
reply
)
{
var
pass
=
reply
.
pass
,
answer
;
if
(
reply
.
response
)
{
// mapping required for this portal_type
if
(
pass
.
config
&&
pass
.
config
.
portal_type_mapper
)
{
return
map
.
handlers
[
pass
.
config
.
portal_type_mapper
](
reply
);
}
// standard procedure
answer
=
util
.
parse
(
answer
);
return
{
"
response
"
:
answer
,
"
pass
"
:
pass
};
}
// mapping
if
(
pass
.
config
&&
pass
.
config
.
portal_type_mapper
)
{
return
map
.
handlers
[
pass
.
config
.
portal_type_mapper
](
reply
);
}
// standard
return
{
"
pass
"
:
pass
};
};
/**
* Fetch total number of records
* @method fetchPortalTypeDataTotal
...
...
@@ -5915,7 +6007,7 @@
}
// add portal type
obj
.
portal_type
=
pass
.
type
;
//
obj.portal_type = pass.type;
// if an object identifier was set in the form, we PUT, else POST
if
(
obj
.
identifier
)
{
...
...
@@ -6166,6 +6258,7 @@
.
then
(
app
.
fetchFields
)
.
then
(
app
.
store
)
.
then
(
app
.
fetchDataTotal
)
.
then
(
app
.
mapToStorage
)
.
then
(
app
.
fetchDataQuery
)
.
then
(
app
.
makeContent
)
.
fail
(
util
.
error
);
...
...
@@ -6987,7 +7080,7 @@
/**
* parse to JSON if element is not in JSON
* @parse
IfNeeded
* @parse
* @param {object/string} data Data to parse
* @return {object} object Parsed object
*/
...
...
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