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
18831a65
Commit
18831a65
authored
Jan 03, 2014
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added option force_field_definition on storage, use select_list vs include_docs if set
parent
4b57ee55
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
97 additions
and
48 deletions
+97
-48
data/storages.json
data/storages.json
+1
-0
js/erp5_loader.js
js/erp5_loader.js
+96
-48
No files found.
data/storages.json
View file @
18831a65
...
...
@@ -2,6 +2,7 @@
"generate"
:
"gadget"
,
"type"
:
"setStorage"
,
"property_dict"
:
{
"force_field_definitions"
:
true
,
"no_content"
:
true
,
"storage_type"
:
"JIO"
,
"modernizr"
:
[
"blobconstructor"
,
"filereader"
]
...
...
js/erp5_loader.js
View file @
18831a65
...
...
@@ -1182,7 +1182,13 @@
content_dict
.
property_dict
.
modernizr
);
}
if
(
supported
)
{
// set force_field_definitions over include_docs
if
(
content_dict
.
property_dict
.
force_field_definitions
)
{
storage
.
force_fields
=
true
;
}
if
(
supported
||
content_dict
.
property_dict
.
modernizr
===
undefined
)
{
// loop children = storages
for
(
i
=
0
;
i
<
content_dict
.
children
.
length
;
i
+=
1
)
{
promises
[
i
]
=
app
.
setContent
(
content_dict
.
children
[
i
]);
...
...
@@ -3949,6 +3955,23 @@
// generate storage object
storage
=
{};
/**
* Generate an array of fields from a dict
* @method makeSelectList
* @param {object} field_dict Dictionary of fields
* @return {array} select_list
**/
storage
.
makeSelectList
=
function
(
field_dict
)
{
var
field
,
select_list
=
[];
for
(
field
in
field_dict
)
{
if
(
field_dict
.
hasOwnProperty
(
field
))
{
select_list
.
push
(
field
);
}
}
return
select_list
;
};
/**
* Convert storage responses into allDocs response format which
* is used in subsequent methods
...
...
@@ -3958,29 +3981,32 @@
* @return {object} "allDocs" response object
**/
storage
.
mapResponse
=
function
(
response
,
convert
)
{
var
answer
,
i
,
record
,
key
,
data
;
var
answer
,
i
,
record
,
key
,
data
,
pushit
;
answer
=
{
"
data
"
:
{
"
total_rows
"
:
null
,
"
rows
"
:
[]}};
pushit
=
function
(
obj
,
record_id
)
{
return
{
"
id
"
:
record_id
,
"
key
"
:
record_id
,
"
value
"
:
{},
"
doc
"
:
obj
}
};
if
(
convert
===
"
single_item
"
)
{
answer
.
data
.
total_rows
=
1
;
answer
.
data
.
rows
.
push
({
"
id
"
:
response
.
id
,
"
key
"
:
response
.
id
,
"
values
"
:
{},
"
doc
"
:
response
.
data
});
answer
.
data
.
rows
.
push
(
pushit
(
response
.
data
,
response
.
id
));
}
else
{
data
=
{};
answer
.
data
.
total_rows
=
response
.
data
.
total_rows
;
for
(
i
=
0
;
i
<
response
.
data
.
total_rows
;
i
+=
1
)
{
record
=
response
.
data
.
rows
[
i
].
values
;
data
=
{};
record
=
response
.
data
.
rows
[
i
].
value
;
for
(
key
in
record
)
{
if
(
record
.
hasOwnProperty
(
key
))
{
data
[
key
]
=
record
[
key
];
}
}
answer
.
data
.
rows
.
push
(
data
);
answer
.
data
.
rows
.
push
(
pushit
(
data
)
);
}
}
return
answer
;
...
...
@@ -4208,7 +4234,6 @@
/**
* @object {object} Object containing default names, which can be overridden
**/
// TODO: remove!?
app
.
default_dict
=
{
"
storage_dict
"
:
{
"
settings
"
:
"
settings
"
,
...
...
@@ -4285,7 +4310,7 @@
* @param {string} provider Provider through which register should run
**/
app
.
register
=
function
(
provider
)
{
var
token
,
query
,
user
;
var
token
,
query
,
user
,
field_dict
,
field
;
// fetch profile
return
hello
(
provider
).
api
(
"
/me
"
)
...
...
@@ -4299,13 +4324,27 @@
token
,
profile
.
id
);
// check to find in storage
// need field values for allDocs select_list...
return
app
.
fetchConfiguration
({
"
storage
"
:
app
.
default_dict
.
storage_dict
.
settings
,
"
file
"
:
app
.
default_dict
.
storage_dict
.
data_type
,
"
attachment
"
:
"
person_fieldlist
"
,
"
pass
"
:
{
"
query
"
:
query
,
"
profile
"
:
profile
}
})
.
then
(
function
(
answer
)
{
if
(
answer
.
response
)
{
answer
.
query
.
select_list
=
storage
.
makeSelectList
(
util
.
parse
(
answer
.
response
)
);
}
return
app
.
fetchData
({
"
storage
"
:
"
items
"
,
"
query
"
:
query
,
"
pass
"
:
{
"
profile
"
:
profile
}
"
query
"
:
answer
.
query
,
"
pass
"
:
{
"
profile
"
:
answer
.
profile
}
})
// returns pass and user?
.
then
(
function
(
reply
)
{
if
(
reply
.
response
)
{
if
(
reply
.
response
.
result
===
"
success
"
&&
...
...
@@ -4330,6 +4369,8 @@
.
fail
(
util
.
error
);
})
.
fail
(
util
.
error
);
})
.
fail
(
util
.
error
);
};
/**
...
...
@@ -4952,7 +4993,7 @@
is_value
=
value
&&
value
!==
""
;
// "id" = "bar" => THIS SHOULD BE
A
GET!
// "id" = "bar" => THIS SHOULD BE GET!
if
(
is_value
&&
key
&&
key
===
"
_id
"
)
{
obj
=
{
"
_id
"
:
value
};
...
...
@@ -4993,7 +5034,7 @@
}
else
if
(
is_value
)
{
// we need to check an existing query for the fields we are already
// searching. These fields should not be set in the search
if
(
query
&&
field_list
)
{
if
(
field_dict
&&
query
)
{
wrap
=
""
;
for
(
property
in
field_list
)
{
if
(
field_list
.
hasOwnProperty
(
property
))
{
...
...
@@ -5022,6 +5063,12 @@
if
(
default_query
.
include_docs
||
value
!==
undefined
)
{
obj
.
include_docs
=
true
;
}
if
(
field_list
&&
storage
.
force_fields
)
{
delete
obj
.
include_docs
;
obj
.
select_list
=
storage
.
makeSelectList
(
field_list
);
}
if
(
default_query
.
select_list
&&
default_query
.
select_list
.
length
>
0
)
{
obj
.
select_list
=
default_query
.
select_list
;
}
...
...
@@ -5041,7 +5088,6 @@
obj
.
wildcard_character
=
"
%
"
;
}
}
return
obj
;
};
...
...
@@ -5389,7 +5435,8 @@
pass
.
config
.
initial_query
,
pass
.
type
,
pass
.
config
.
property_dict
.
initial_query_url_identifier
||
'
_id
'
,
pass
.
value
pass
.
value
,
pass
.
fields
);
}
...
...
@@ -5453,6 +5500,7 @@
}
// generate new query object
// TODO: we don't pass fields here!
if
(
pass
.
config
.
initial_query
)
{
pass
.
state
.
query
=
app
.
generateQueryObject
(
{
"
query
"
:
pass
.
config
.
initial_query
.
query
},
...
...
@@ -5900,9 +5948,8 @@
* @param {object} parcel Storage, query options and pass to return
* @return {object} promise object/pass
*/
// NOTE: until we have real data we load fake data on application init!
app
.
fetchData
=
function
(
parcel
)
{
var
method
,
convert
,
answer
,
select_list
;
var
method
,
convert
,
select_list
;
select_list
=
parcel
.
query
&&
parcel
.
query
.
select_list
&&
parcel
.
query
.
select_list
.
length
;
...
...
@@ -5922,12 +5969,13 @@
// TODO: best way?
if
(
convert
!==
undefined
&&
response
.
status
===
200
)
{
answer
=
storage
.
mapResponse
(
response
,
convert
);
}
else
{
answer
=
response
;
return
{
"
response
"
:
storage
.
mapResponse
(
response
,
convert
),
"
pass
"
:
parcel
.
pass
};
}
return
{
"
response
"
:
answer
,
"
response
"
:
response
,
"
pass
"
:
parcel
.
pass
};
});
...
...
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