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
5717cd1d
Commit
5717cd1d
authored
Jul 24, 2013
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated to latest JIO, fixed AMD check in complex_queries.js so does not break with require
parent
7a6598b6
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
724 additions
and
533 deletions
+724
-533
js/libs/jio/complex_queries.js
js/libs/jio/complex_queries.js
+680
-495
js/libs/jio/indexstorage.js
js/libs/jio/indexstorage.js
+3
-3
js/libs/jio/jio.js
js/libs/jio/jio.js
+2
-2
js/libs/jio/localstorage.js
js/libs/jio/localstorage.js
+39
-33
No files found.
js/libs/jio/complex_queries.js
View file @
5717cd1d
This diff is collapsed.
Click to expand it.
js/libs/jio/indexstorage.js
View file @
5717cd1d
...
...
@@ -401,7 +401,7 @@
*/
function
indexStorage
(
spec
,
my
)
{
var
that
,
priv
=
{};
that
=
my
.
basicStorage
(
spec
,
my
);
priv
.
indices
=
spec
.
indices
;
...
...
@@ -744,7 +744,7 @@
if
(
just_check
)
{
priv
.
getIndexDatabase
(
option
,
index
,
function
(
current_db
)
{
if
(
db
.
equals
(
current_db
))
{
return
that
.
success
({
"
ok
"
:
true
,
"
_
id
"
:
command
.
getDocId
()});
return
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()});
}
return
that
.
error
(
generateErrorObject
(
"
Different Index
"
,
...
...
@@ -754,7 +754,7 @@
});
}
else
{
priv
.
storeIndexDatabaseList
(
db_list
,
{},
function
()
{
that
.
success
({
"
ok
"
:
true
,
"
_
id
"
:
command
.
getDocId
()});
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()});
});
}
},
...
...
js/libs/jio/jio.js
View file @
5717cd1d
...
...
@@ -531,13 +531,13 @@ var command = function (spec, my) {
* @param {object} storage The storage.
*/
that
.
validate
=
function
(
storage
)
{
if
(
typeof
priv
.
doc
.
_id
===
"
string
"
&&
priv
.
doc
.
_id
.
match
(
"
"
)
)
{
if
(
typeof
priv
.
doc
.
_id
===
"
string
"
&&
priv
.
doc
.
_id
===
""
)
{
that
.
error
({
"
status
"
:
21
,
"
statusText
"
:
"
Invalid Document Id
"
,
"
error
"
:
"
invalid_document_id
"
,
"
message
"
:
"
The document id is invalid
"
,
"
reason
"
:
"
The document id contains spaces
"
"
reason
"
:
"
empty
"
});
return
false
;
}
...
...
js/libs/jio/localstorage.js
View file @
5717cd1d
...
...
@@ -11,6 +11,37 @@
/**
* JIO Local Storage. Type = 'local'.
* Local browser "database" storage.
*
* Storage Description:
*
* {
* "type": "local",
* "username": <non empty string>, // to define user space
* "application_name": <string> // default 'untitled'
* }
*
* Document are stored in path
* 'jio/localstorage/username/application_name/document_id' like this:
*
* {
* "_id": "document_id",
* "_attachments": {
* "attachment_name": {
* "length": data_length,
* "digest": "md5-XXX",
* "content_type": "mime/type"
* },
* "attachment_name2": {..}, ...
* },
* "metadata_name": "metadata_value"
* "metadata_name2": ...
* ...
* }
*
* Only "_id" and "_attachments" are specific metadata keys, other one can be
* added without loss.
*
* @class LocalStorage
*/
jIO
.
addStorageType
(
'
local
'
,
function
(
spec
,
my
)
{
...
...
@@ -64,34 +95,6 @@ jIO.addStorageType('local', function (spec, my) {
S4
()
+
S4
();
};
/**
* Update [doc] the document object and remove [doc] keys
* which are not in [new_doc]. It only changes [doc] keys not starting
* with an underscore.
* ex: doc: {key:value1,_key:value2} with
* new_doc: {key:value3,_key:value4} updates
* doc: {key:value3,_key:value2}.
* @param {object} doc The original document object.
* @param {object} new_doc The new document object
*/
priv
.
documentObjectUpdate
=
function
(
doc
,
new_doc
)
{
var
k
;
for
(
k
in
doc
)
{
if
(
doc
.
hasOwnProperty
(
k
))
{
if
(
k
[
0
]
!==
'
_
'
)
{
delete
doc
[
k
];
}
}
}
for
(
k
in
new_doc
)
{
if
(
new_doc
.
hasOwnProperty
(
k
))
{
if
(
k
[
0
]
!==
'
_
'
)
{
doc
[
k
]
=
new_doc
[
k
];
}
}
}
};
/**
* Checks if an object has no enumerable keys
* @method objectIsEmpty
...
...
@@ -137,11 +140,11 @@ jIO.addStorageType('local', function (spec, my) {
}
doc
=
localstorage
.
getItem
(
priv
.
localpath
+
"
/
"
+
doc_id
);
if
(
doc
===
null
)
{
// the document does not exist
doc
=
command
.
cloneDoc
();
doc
.
_id
=
doc_id
;
// the document does not exist
localstorage
.
setItem
(
priv
.
localpath
+
"
/
"
+
doc_id
,
doc
);
delete
doc
.
_attachments
;
localstorage
.
setItem
(
priv
.
localpath
+
"
/
"
+
doc_id
,
doc
);
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
doc_id
...
...
@@ -166,14 +169,17 @@ jIO.addStorageType('local', function (spec, my) {
*/
that
.
put
=
function
(
command
)
{
setTimeout
(
function
()
{
var
doc
;
var
doc
,
tmp
;
doc
=
localstorage
.
getItem
(
priv
.
localpath
+
"
/
"
+
command
.
getDocId
());
if
(
doc
===
null
)
{
// the document does not exist
doc
=
command
.
cloneDoc
();
delete
doc
.
_attachments
;
}
else
{
// the document already exists
priv
.
documentObjectUpdate
(
doc
,
command
.
cloneDoc
());
tmp
=
command
.
cloneDoc
();
tmp
.
_attachments
=
doc
.
_attachments
;
doc
=
tmp
;
}
// write
localstorage
.
setItem
(
priv
.
localpath
+
"
/
"
+
command
.
getDocId
(),
doc
);
...
...
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