Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
144
Merge Requests
144
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
c4374508
Commit
c4374508
authored
Mar 14, 2019
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: erp5_officejs: replicate appcache content into local storage
parent
52afccee
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
62 deletions
+66
-62
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_controller_page_controller_js.js
...e_module/gadget_officejs_controller_page_controller_js.js
+15
-44
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_controller_page_controller_js.xml
..._module/gadget_officejs_controller_page_controller_js.xml
+2
-2
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_js.js
...athTemplateItem/web_page_module/gadget_officejs_jio_js.js
+47
-14
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_js.xml
...thTemplateItem/web_page_module/gadget_officejs_jio_js.xml
+2
-2
No files found.
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_controller_page_controller_js.js
View file @
c4374508
...
...
@@ -78,6 +78,7 @@
// Acquired methods
/////////////////////////////////////////////////////////////////
.
declareAcquiredMethod
(
"
jio_get
"
,
"
jio_get
"
)
.
declareAcquiredMethod
(
"
jio_getAttachment
"
,
"
jio_getAttachment
"
)
.
declareAcquiredMethod
(
"
jio_put
"
,
"
jio_put
"
)
.
declareAcquiredMethod
(
"
getUrlFor
"
,
"
getUrlFor
"
)
.
declareAcquiredMethod
(
"
getSetting
"
,
"
getSetting
"
)
...
...
@@ -90,47 +91,16 @@
/////////////////////////////////////////////////////////////////
.
declareMethod
(
"
getFormDefinition
"
,
function
(
jio_key
)
{
var
gadget
=
this
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
all
([
gadget
.
getSetting
(
'
hateoas_url
'
),
gadget
.
getSetting
(
'
default_view_reference
'
),
gadget
.
jio_get
(
jio_key
)
]);
})
.
push
(
function
(
setting_list
)
{
var
jio_options_remote
=
{
type
:
"
erp5
"
,
url
:
setting_list
[
0
],
default_view_reference
:
setting_list
[
1
]
},
jio_options_localIndexdb
=
{
type
:
"
query
"
,
sub_storage
:
{
type
:
"
indexeddb
"
,
database
:
"
officejs-forms
"
}
},
jio_storage_remote
,
jio_indexdb_local
=
jIO
.
createJIO
(
jio_options_localIndexdb
),
form_path
=
'
portal_skins/erp5_officejs_jio_connector/
'
+
setting_list
[
2
].
portal_type
.
replace
(
/ /g
,
''
)
+
'
_viewAsJio
'
;
return
jio_indexdb_local
.
get
(
form_path
)
.
push
(
function
(
result
)
{
return
result
.
form_definition
;
},
function
(
error
)
{
if
((
error
.
constructor
.
name
===
'
jIOError
'
&&
error
.
status_code
===
404
))
{
jio_storage_remote
=
jIO
.
createJIO
(
jio_options_remote
);
return
jio_storage_remote
.
get
(
form_path
)
.
push
(
function
(
result
)
{
jio_indexdb_local
.
put
(
form_path
,
result
);
return
result
.
form_definition
;
});
}
throw
error
;
});
//TODO parameter will be a portal_type
var
gadget
=
this
,
// this urls will change to a more appropiate id like "portal_skins/couscous/MyPortalType_viewAsJio"
// and probably for a jio.get instead of getAttachment
// now it is like this due to the appcachestorage
url
=
"
./app/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_skins%2Ferp5_officejs_jio_connector%2FHTMLPost_viewAsJio&view=jio_view
"
,
origin_url
=
"
https://softinst112382.host.vifib.net/erp5/web_site_module/officejs_discussion_tool/app/#/?page=ojs_sync&auto_repair=true
"
;
return
gadget
.
jio_getAttachment
(
origin_url
,
url
,
{
"
format
"
:
"
json
"
})
.
push
(
function
(
result
)
{
return
result
.
_embedded
.
_view
.
my_form_definition
[
"
default
"
];
});
})
...
...
@@ -203,8 +173,8 @@
var
gadget
=
this
,
child_gadget_url
;
return
gadget
.
jio_get
(
options
.
jio_key
)
.
push
(
function
(
resul
t
)
{
if
(
resul
t
.
portal_type
!==
undefined
)
{
.
push
(
function
(
documen
t
)
{
if
(
documen
t
.
portal_type
!==
undefined
)
{
/*child_gadget_url = 'gadget_officejs_jio_' +
result.portal_type.replace(/ /g, '_').toLowerCase() +
'_view.html';*/
...
...
@@ -213,11 +183,12 @@
}
else
{
throw
new
Error
(
'
Can not display document:
'
+
options
.
jio_key
);
}
//TODO pass document.portal_type as parameter
return
gadget
.
getFormDefinition
(
options
.
jio_key
)
.
push
(
function
(
form_definition
)
{
return
gadget
.
changeState
({
jio_key
:
options
.
jio_key
,
doc
:
resul
t
,
doc
:
documen
t
,
child_gadget_url
:
child_gadget_url
,
form_definition
:
form_definition
,
editable
:
options
.
editable
,
...
...
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_controller_page_controller_js.xml
View file @
c4374508
...
...
@@ -225,7 +225,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
974.
18933.22256.43059
</string>
</value>
<value>
<string>
974.
22676.24081.12953
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -243,7 +243,7 @@
</tuple>
<state>
<tuple>
<float>
1552
346315.67
</float>
<float>
1552
570936.02
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_js.js
View file @
c4374508
...
...
@@ -74,21 +74,41 @@
.
declareAcquiredMethod
(
'
getUrlFor
'
,
'
getUrlFor
'
)
.
declareMethod
(
'
createJio
'
,
function
(
jio_options
)
{
var
gadget
=
this
;
var
gadget
=
this
,
// for now using appcachestorage to copy form json from appcache to local
// maybe it will be better to have a new storage
jio_appchache_options
=
{
type
:
"
replicate
"
,
parallel_operation_attachment_amount
:
10
,
parallel_operation_amount
:
1
,
conflict_handling
:
2
,
signature_hash_key
:
'
hash
'
,
check_remote_attachment_modification
:
true
,
check_remote_attachment_creation
:
true
,
check_remote_attachment_deletion
:
true
,
check_remote_deletion
:
true
,
check_local_creation
:
false
,
check_local_deletion
:
false
,
check_local_modification
:
false
,
signature_sub_storage
:
{
type
:
"
query
"
,
sub_storage
:
{
type
:
"
indexeddb
"
,
database
:
"
officejs-hash
"
}
},
local_sub_storage
:
{},
remote_sub_storage
:
{
type
:
"
appcache
"
,
manifest
:
"
gadget_officejs_discussion_tool.appcache
"
,
version
:
"
app/
"
,
take_installer
:
false
}
},
appcache_storage
;
if
(
jio_options
===
undefined
)
{
return
;
}
// adding a layer to replicate appcache content into jio data storage
jio_options
=
{
type
:
"
replicate
"
,
local_sub_storage
:
jio_options
,
remote_sub_storage
:
{
type
:
"
appcache
"
,
manifest
:
"
gadget_officejs_discussion_tool.appcache
"
,
version
:
"
app/
"
,
take_installer
:
true
}
};
jio_appchache_options
.
local_sub_storage
=
JSON
.
parse
(
JSON
.
stringify
(
jio_options
));
jio_options
=
{
type
:
'
dateupdater
'
,
sub_storage
:
jio_options
,
...
...
@@ -96,13 +116,26 @@
};
try
{
this
.
state_parameter_dict
.
jio_storage
=
jIO
.
createJIO
(
jio_options
);
appcache_storage
=
jIO
.
createJIO
(
jio_appchache_options
);
}
catch
(
error
)
{
this
.
state_parameter_dict
.
jio_storage
=
undefined
;
appcache_storage
=
undefined
;
}
return
this
.
getSetting
(
"
jio_storage_name
"
)
.
push
(
function
(
jio_storage_name
)
{
gadget
.
state_parameter_dict
.
jio_storage
.
repair
();
gadget
.
state_parameter_dict
.
jio_storage_name
=
jio_storage_name
;
// check if appcache-local sync needs to be done
// TODO: find a better flag for this
return
appcache_storage
.
get
(
"
appcache-stored
"
)
.
push
(
undefined
,
function
(
error
)
{
return
appcache_storage
.
repair
()
.
push
(
function
()
{
return
appcache_storage
.
put
(
"
appcache-stored
"
,
{})
.
push
(
undefined
);
},
function
(
error
)
{
console
.
log
(
"
Error while appcache-local storage synchronization
"
);
console
.
log
(
error
);
});
});
});
})
.
declareMethod
(
'
allDocs
'
,
function
()
{
...
...
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_js.xml
View file @
c4374508
...
...
@@ -234,7 +234,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
974.2
0177.56471.24439
</string>
</value>
<value>
<string>
974.2
2673.21626.15445
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>
1552
422100.12
</float>
<float>
1552
571020.07
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
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