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
c8c2474f
Commit
c8c2474f
authored
Feb 28, 2014
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
offline work-in-progress commit
parent
2a7c34a3
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
323 additions
and
227 deletions
+323
-227
data/invoice_overview.json
data/invoice_overview.json
+1
-1
js/erp5_loader.js
js/erp5_loader.js
+246
-154
js/libs/jio/erp5storage.js
js/libs/jio/erp5storage.js
+36
-32
js/libs/jio/replicatestorage.js
js/libs/jio/replicatestorage.js
+40
-40
No files found.
data/invoice_overview.json
View file @
c8c2474f
...
@@ -52,7 +52,7 @@
...
@@ -52,7 +52,7 @@
{
"field"
:
"total_price"
,
"show"
:
true
,
"persist"
:
true
,
"sort"
:
false
},
{
"field"
:
"total_price"
,
"show"
:
true
,
"persist"
:
true
,
"sort"
:
false
},
{
"field"
:
"price_currency"
,
"show"
:
"true"
,
"priority"
:
4
,
"merge"
:
"total_price"
},
{
"field"
:
"price_currency"
,
"show"
:
"true"
,
"priority"
:
4
,
"merge"
:
"total_price"
},
{
"field"
:
"translated_simulation_state_title"
,
"show"
:
"true"
,
"priority"
:
5
},
{
"field"
:
"translated_simulation_state_title"
,
"show"
:
"true"
,
"priority"
:
5
},
{
"custom"
:
true
,
"show"
:
true
,
"persist"
:
true
,
"sort"
:
false
,
"action_list"
:
[{
"class_list"
:
"action translate"
,
"action"
:
"
download
"
,
"icon"
:
"file-alt"
,
"text"
:
"Download"
,
"text_i18n"
:
"portable_type_dict.invoice_dict.download"
}]}
{
"custom"
:
true
,
"show"
:
true
,
"persist"
:
true
,
"sort"
:
false
,
"action_list"
:
[{
"class_list"
:
"action translate"
,
"action"
:
"
get
"
,
"icon"
:
"file-alt"
,
"text"
:
"Download"
,
"text_i18n"
:
"portable_type_dict.invoice_dict.download"
}]}
]
]
}
}
],
],
...
...
js/erp5_loader.js
View file @
c8c2474f
This diff is collapsed.
Click to expand it.
js/libs/jio/erp5storage.js
View file @
c8c2474f
...
@@ -23,11 +23,10 @@
...
@@ -23,11 +23,10 @@
this
.
_url
=
spec
.
url
;
this
.
_url
=
spec
.
url
;
}
}
ERP5Storage
.
prototype
.
_get
Privates
=
function
(
site_hal
,
param
,
options
)
{
ERP5Storage
.
prototype
.
_get
File
=
function
(
command
,
site_hal
,
param
,
options
)
{
var
fetch
,
item
=
(
param
||
{}).
_id
||
(
site_hal
.
_links
.
me
||
{}).
href
;
var
fetch
,
item
=
(
param
||
{}).
_id
||
(
site_hal
.
_links
.
me
||
{}).
href
;
if
(
!
item
)
{
if
(
!
item
)
{
return
command
.
error
(
401
);
command
.
error
(
401
);
}
}
fetch
=
new
URI
(
item
);
fetch
=
new
URI
(
item
);
return
this
.
_getSiteDocument
(
return
this
.
_getSiteDocument
(
...
@@ -38,7 +37,6 @@
...
@@ -38,7 +37,6 @@
ERP5Storage
.
prototype
.
_getSiteDocument
=
function
(
traverse
,
expando
)
{
ERP5Storage
.
prototype
.
_getSiteDocument
=
function
(
traverse
,
expando
)
{
var
url
=
UriTemplate
.
parse
(
traverse
||
""
).
expand
(
expando
||
{});
var
url
=
UriTemplate
.
parse
(
traverse
||
""
).
expand
(
expando
||
{});
console
.
log
(
url
);
return
jIO
.
util
.
ajax
({
return
jIO
.
util
.
ajax
({
"
type
"
:
"
GET
"
,
"
type
"
:
"
GET
"
,
"
url
"
:
url
||
this
.
_url
,
"
url
"
:
url
||
this
.
_url
,
...
@@ -46,29 +44,24 @@
...
@@ -46,29 +44,24 @@
"
withCredentials
"
:
true
"
withCredentials
"
:
true
}
}
}).
then
(
function
(
response
)
{
}).
then
(
function
(
response
)
{
var
result
=
JSON
.
parse
(
response
.
target
.
responseText
);
return
JSON
.
parse
(
response
.
target
.
responseText
);
// result._id = param._id;
return
result
;
});
});
};
};
ERP5Storage
.
prototype
.
_get
=
function
(
param
,
options
)
{
ERP5Storage
.
prototype
.
_get
=
function
(
command
,
param
,
options
)
{
var
that
=
this
;
var
that
=
this
;
return
that
.
_getSiteDocument
()
return
that
.
_getSiteDocument
()
.
then
(
function
(
site_hal
)
{
.
then
(
function
(
site_hal
)
{
return
that
.
_get
Privates
(
site_hal
,
param
,
options
);
return
that
.
_get
File
(
command
,
site_hal
,
param
,
options
);
})
})
.
then
(
function
(
response
)
{
.
then
(
function
(
response
)
{
console
.
log
(
"
GET, response
"
)
response
.
_id
=
param
.
_id
;
console
.
log
(
response
)
return
response
;
var
result
=
JSON
.
parse
(
response
.
target
.
responseText
);
result
.
_id
=
param
.
_id
;
return
result
;
});
});
};
};
ERP5Storage
.
prototype
.
get
=
function
(
command
,
param
,
options
)
{
ERP5Storage
.
prototype
.
get
=
function
(
command
,
param
,
options
)
{
this
.
_get
(
param
,
options
)
this
.
_get
(
command
,
param
,
options
)
.
then
(
function
(
response
)
{
.
then
(
function
(
response
)
{
command
.
success
({
"
data
"
:
response
});
command
.
success
({
"
data
"
:
response
});
})
})
...
@@ -87,7 +80,7 @@
...
@@ -87,7 +80,7 @@
var
that
=
this
;
var
that
=
this
;
return
that
.
_getSiteDocument
()
return
that
.
_getSiteDocument
()
.
then
(
function
(
site_hal
)
{
.
then
(
function
(
site_hal
)
{
return
that
.
_get
Privates
(
site_hal
,
undefined
,
options
);
return
that
.
_get
File
(
command
,
site_hal
,
undefined
,
options
);
})
})
.
then
(
function
(
opts
)
{
.
then
(
function
(
opts
)
{
var
key
,
custom_action
=
opts
.
_actions
[
options
.
action
],
var
key
,
custom_action
=
opts
.
_actions
[
options
.
action
],
...
@@ -164,28 +157,39 @@
...
@@ -164,28 +157,39 @@
"
Unable to call put
"
"
Unable to call put
"
);
);
});
});
};
};
ERP5Storage
.
prototype
.
allDocs
=
function
(
command
,
param
,
options
)
{
ERP5Storage
.
prototype
.
allDocs
=
function
(
command
,
param
,
options
)
{
var
that
=
this
,
search_pointer
;
return
this
.
_getSiteDocument
()
return
this
.
_getSiteDocument
()
.
then
(
function
(
site_hal
)
{
.
then
(
function
(
site_hal
)
{
return
jIO
.
util
.
ajax
({
search_pointer
=
site_hal
.
_links
.
raw_search
.
href
;
"
type
"
:
"
GET
"
,
return
that
.
_getFile
(
command
,
site_hal
,
undefined
,
options
);
"
url
"
:
UriTemplate
.
parse
(
site_hal
.
_links
.
raw_search
.
href
)
.
expand
({
query
:
options
.
query
,
// XXX Force erp5 to return embedded document
select_list
:
options
.
select_list
||
[
"
title
"
,
"
reference
"
],
limit
:
options
.
limit
}),
"
xhrFields
"
:
{
withCredentials
:
true
}
});
})
})
.
then
(
function
(
response
)
{
.
then
(
function
(
opts
)
{
return
JSON
.
parse
(
response
.
target
.
responseText
);
var
i
,
len
,
jump_list
,
jump
;
// HACK: add ERP5 custom jump
if
(
param
.
_jump
&&
options
.
query
)
{
jump_list
=
opts
.
_links
[
"
slapos_jump
"
||
[]];
len
=
jump_list
.
length
;
for
(
i
=
0
;
i
<
len
;
i
+=
1
)
{
jump
=
jump_list
[
i
];
if
(
jump
.
name
===
param
.
_jump
)
{
options
.
query
=
jump
.
_query
;
}
}
}
return
that
.
_getSiteDocument
(
search_pointer
,
{
"
query
"
:
options
.
query
,
// XXX Force erp5 to return embedded document
"
select_list
"
:
options
.
select_list
||
[
"
title
"
,
"
reference
"
],
"
limit
"
:
options
.
limit
}
);
})
})
.
then
(
function
(
catalog_json
)
{
.
then
(
function
(
catalog_json
)
{
var
data
=
catalog_json
.
_embedded
.
contents
,
var
data
=
catalog_json
.
_embedded
.
contents
,
...
...
js/libs/jio/replicatestorage.js
View file @
c8c2474f
...
@@ -251,7 +251,6 @@
...
@@ -251,7 +251,6 @@
var
length
=
promise_list
.
length
;
var
length
=
promise_list
.
length
;
promise_list
=
promise_list
.
slice
();
promise_list
=
promise_list
.
slice
();
return
new
Promise
(
function
(
resolve
,
reject
,
notify
)
{
return
new
Promise
(
function
(
resolve
,
reject
,
notify
)
{
var
index
,
trace
,
conflict_list
,
count
,
error_count
,
tag
,
doc
;
var
index
,
trace
,
conflict_list
,
count
,
error_count
,
tag
,
doc
;
...
@@ -344,19 +343,20 @@
...
@@ -344,19 +343,20 @@
sequence
([
sequence
([
function
()
{
function
()
{
// master storage
if
(
master
!==
undefined
)
{
if
(
master
!==
undefined
)
{
return
last
(
priority_list
,
master
);
return
last
(
priority_list
,
master
);
}
}
return
{};
return
{};
},
},
function
(
response
)
{
function
(
response
)
{
// slave storages
var
method
,
subindex
=
0
;
var
method
,
subindex
=
0
;
// this is the id issued by the master storage
if
(
response
.
id
)
{
if
(
response
.
id
)
{
metadata
.
_id
=
response
.
id
;
metadata
.
_id
=
response
.
id
;
method
=
"
put
"
;
method
=
"
put
"
;
}
else
{
}
else
{
// TODO:
error
/offline handling
// TODO:
master 404
/offline handling
}
}
for
(
index
=
0
;
index
<
length
;
index
+=
1
)
{
for
(
index
=
0
;
index
<
length
;
index
+=
1
)
{
...
@@ -454,7 +454,7 @@
...
@@ -454,7 +454,7 @@
var
promise_list
=
[],
index
,
length
=
this
.
_storage_list
.
length
;
var
promise_list
=
[],
index
,
length
=
this
.
_storage_list
.
length
;
for
(
index
=
0
;
index
<
length
;
index
+=
1
)
{
for
(
index
=
0
;
index
<
length
;
index
+=
1
)
{
promise_list
[
index
]
=
promise_list
[
index
]
=
success
(
command
.
storage
(
this
.
_storage_list
[
index
]).
allDocs
(
option
));
success
(
command
.
storage
(
this
.
_storage_list
[
index
]).
allDocs
(
option
,
param
));
}
}
sequence
([
function
()
{
sequence
([
function
()
{
...
@@ -463,48 +463,49 @@
...
@@ -463,48 +463,49 @@
var
i
,
j
,
k
,
l
,
record
,
reply
,
rows
,
count
,
total
,
base
,
test
,
must_add
,
var
i
,
j
,
k
,
l
,
record
,
reply
,
rows
,
count
,
total
,
base
,
test
,
must_add
,
len
=
answers
.
length
;
len
=
answers
.
length
;
// loop storage response
// NOTE: every storage may return different records!
// NOTE: every storage may return different records!
for
(
i
=
0
;
i
<
len
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
len
;
i
+=
1
)
{
reply
=
answers
[
i
];
reply
=
answers
[
i
];
total
=
reply
.
data
.
total_rows
;
if
(
reply
.
result
===
"
success
"
)
{
total
=
reply
.
data
.
total_rows
;
// loop records returned in response
for
(
j
=
0
;
j
<
total
;
j
+=
1
)
{
// loop records returned in response
record
=
reply
.
data
.
rows
[
j
];
for
(
j
=
0
;
j
<
total
;
j
+=
1
)
{
must_add
=
undefined
;
record
=
reply
.
data
.
rows
[
j
];
must_add
=
undefined
;
if
(
rows
===
undefined
)
{
rows
=
[
record
];
if
(
rows
===
undefined
)
{
}
else
{
rows
=
[
record
];
count
=
rows
.
length
;
}
else
{
count
=
rows
.
length
;
// loop records already in rows object
for
(
k
=
0
;
k
<
count
;
k
+=
1
)
{
// loop records already in rows object
base
=
rows
[
k
];
for
(
k
=
0
;
k
<
count
;
k
+=
1
)
{
test
=
checksum
(
cleanClone
(
base
));
base
=
rows
[
k
];
test
=
checksum
(
cleanClone
(
base
));
// record exists, test for coherence
if
(
base
.
id
===
record
.
id
)
{
// record exists, test for coherence
must_add
=
undefined
;
if
(
base
.
id
===
record
.
id
)
{
if
(
test
!==
checksum
(
record
))
{
must_add
=
undefined
;
if
(
!
base
.
_conflict_list
)
{
if
(
test
!==
checksum
(
record
))
{
base
.
_conflict_list
=
[
base
];
if
(
!
base
.
_conflict_list
)
{
base
.
_conflict_list
=
[
base
];
}
base
.
_conflict_list
.
push
(
record
);
}
}
base
.
_conflict_list
.
push
(
record
);
// record does not exists, must add
}
else
{
must_add
=
true
;
}
}
// record does not exists, must add
}
else
{
must_add
=
true
;
}
}
}
// add missing records
// add missing records
if
(
must_add
)
{
if
(
must_add
)
{
// if on 2+ iteration, this means a 404 on previous storages
// if on 2+ iteration, this means a 404 on previous storages
if
(
i
>
0
)
{
if
(
i
>
0
)
{
record
.
_missing
=
true
;
record
.
_missing
=
true
;
}
rows
.
push
(
record
);
}
}
rows
.
push
(
record
);
}
}
}
}
}
}
...
@@ -517,7 +518,6 @@
...
@@ -517,7 +518,6 @@
rows
[
l
].
_missing
=
true
;
rows
[
l
].
_missing
=
true
;
}
}
}
}
return
{
"
data
"
:
{
"
total_rows
"
:
(
rows
||
[]).
length
,
"
rows
"
:
rows
||
[]}};
return
{
"
data
"
:
{
"
total_rows
"
:
(
rows
||
[]).
length
,
"
rows
"
:
rows
||
[]}};
},
[
command
.
success
,
command
.
error
]]);
},
[
command
.
success
,
command
.
error
]]);
};
};
...
...
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