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
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
Gabriel Monnerat
erp5
Commits
27931f00
Commit
27931f00
authored
Feb 09, 2017
by
Vincent Bechu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_officejs: make attachment synchro erp5 work with bad hack
parent
7cb1e09e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
103 additions
and
27 deletions
+103
-27
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_jio_erp5_configurator_js.js
...e_module/gadget_officejs_page_jio_erp5_configurator_js.js
+39
-8
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_jio_erp5_configurator_js.xml
..._module/gadget_officejs_page_jio_erp5_configurator_js.xml
+2
-2
bt5/erp5_officejs/PathTemplateItem/web_page_module/jio_mappingstorage_js.js
...PathTemplateItem/web_page_module/jio_mappingstorage_js.js
+60
-15
bt5/erp5_officejs/PathTemplateItem/web_page_module/jio_mappingstorage_js.xml
...athTemplateItem/web_page_module/jio_mappingstorage_js.xml
+2
-2
No files found.
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_jio_erp5_configurator_js.js
View file @
27931f00
...
...
@@ -6,10 +6,19 @@
function
setjIOERP5Configuration
(
gadget
)
{
var
erp5_url
=
gadget
.
props
.
element
.
querySelector
(
"
input[name='erp5_url']
"
).
value
;
return
gadget
.
getSetting
(
"
portal_type
"
)
.
push
(
function
(
portal_type
)
{
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
all
([
gadget
.
getSetting
(
"
portal_type
"
),
gadget
.
getSetting
(
"
erp5_attachment_synchro
"
,
undefined
)
]);
})
.
push
(
function
(
result
)
{
var
old_date
=
new
Date
(),
configuration
=
{};
configuration
=
{},
portal_type
=
result
[
0
],
attachment_synchro
=
result
[
1
]
!==
undefined
,
extended_attachment_url
=
result
[
1
];
// We are looking for documents modified in the past 3 month
old_date
=
new
Date
(
old_date
.
getFullYear
(),
old_date
.
getMonth
(),
old_date
.
getDate
()
-
15
);
configuration
=
{
...
...
@@ -25,6 +34,11 @@
},
use_remote_post
:
true
,
conflict_handling
:
1
,
check_local_attachment_modification
:
attachment_synchro
,
check_local_attachment_creation
:
attachment_synchro
,
check_remote_attachment_modification
:
attachment_synchro
,
check_remote_attachment_creation
:
attachment_synchro
,
check_remote_attachment_deletion
:
attachment_synchro
,
check_local_modification
:
true
,
check_local_creation
:
true
,
check_local_deletion
:
false
,
...
...
@@ -42,12 +56,29 @@
}
},
remote_sub_storage
:
{
type
:
"
mapping
"
,
attachment_list
:
[
"
data
"
],
attachment
:
{
"
data
"
:
{
"
get
"
:
{
"
uri_template
"
:
(
new
URI
(
"
hateoas
"
))
.
absoluteTo
(
erp5_url
)
.
toString
()
+
extended_attachment_url
},
"
put
"
:
{
"
erp5_put_template
"
:
(
new
URI
(
"
hateoas
"
)).
absoluteTo
(
erp5_url
)
.
toString
()
+
"
/{+id}/Base_edit
"
}
}
},
sub_storage
:
{
type
:
"
erp5
"
,
url
:
(
new
URI
(
"
hateoas
"
))
.
absoluteTo
(
erp5_url
)
.
toString
(),
default_view_reference
:
"
jio_view
"
}
}
};
return
gadget
.
setSetting
(
'
jio_storage_description
'
,
configuration
);
})
...
...
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_jio_erp5_configurator_js.xml
View file @
27931f00
...
...
@@ -273,7 +273,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
95
6.4077.57694.3024
2
</string>
</value>
<value>
<string>
95
7.13706.29150.1517
2
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -291,7 +291,7 @@
</tuple>
<state>
<tuple>
<float>
148
2145123.94
</float>
<float>
148
6654781.05
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs/PathTemplateItem/web_page_module/jio_mappingstorage_js.js
View file @
27931f00
/*jslint indent:2, maxlen: 80, nomen: true */
/*global jIO, RSVP, UriTemplate, SimpleQuery, ComplexQuery, QueryFactory,
Query*/
Query
, FormData
*/
(
function
(
jIO
,
RSVP
,
UriTemplate
,
SimpleQuery
,
ComplexQuery
,
QueryFactory
,
Query
)
{
Query
,
FormData
)
{
"
use strict
"
;
function
getSubIdEqualSubProperty
(
storage
,
value
,
key
)
{
...
...
@@ -188,6 +188,7 @@
this
.
_query
=
spec
.
query
||
{};
this
.
_map_id
=
spec
.
id
||
[
"
equalSubId
"
];
this
.
_id_mapped
=
(
spec
.
id
!==
undefined
)
?
spec
.
id
[
1
]
:
false
;
this
.
_attachment_list
=
spec
.
attachment_list
||
[];
if
(
this
.
_query
.
query
!==
undefined
)
{
this
.
_query
.
query
=
QueryFactory
.
create
(
this
.
_query
.
query
);
...
...
@@ -201,12 +202,13 @@
var
mapping_dict
=
storage
.
_attachment_mapping_dict
;
if
(
mapping_dict
!==
undefined
&&
mapping_dict
[
attachment_id
]
!==
undefined
&&
mapping_dict
[
attachment_id
][
method
]
!==
undefined
&&
mapping_dict
[
attachment_id
][
method
].
uri_template
!==
undefined
)
{
&&
mapping_dict
[
attachment_id
][
method
]
!==
undefined
)
{
if
(
mapping_dict
[
attachment_id
][
method
].
uri_template
!==
undefined
)
{
return
UriTemplate
.
parse
(
mapping_dict
[
attachment_id
][
method
].
uri_template
).
expand
({
id
:
sub_id
});
}
}
return
attachment_id
;
}
...
...
@@ -302,12 +304,20 @@
return
getSubStorageId
(
storage
,
argument_list
[
0
])
.
push
(
function
(
sub_id
)
{
argument_list
[
0
]
=
sub_id
;
var
old_id
=
argument_list
[
1
];
argument_list
[
1
]
=
getAttachmentId
(
storage
,
sub_id
,
argument_list
[
0
]
,
argument_list
[
1
],
method
);
if
(
storage
.
_attachment_list
.
length
>
0
&&
storage
.
_attachment_list
.
indexOf
(
old_id
)
<
0
)
{
if
(
method
===
"
get
"
)
{
throw
new
jIO
.
util
.
jIOError
(
"
unhautorized attachment
"
,
404
);
}
return
;
}
return
storage
.
_sub_storage
[
method
+
"
Attachment
"
].
apply
(
storage
.
_sub_storage
,
argument_list
...
...
@@ -373,7 +383,32 @@
});
};
MappingStorage
.
prototype
.
putAttachment
=
function
(
id
,
attachment_id
)
{
MappingStorage
.
prototype
.
putAttachment
=
function
(
id
,
attachment_id
,
blob
)
{
var
storage
=
this
,
mapping_dict
=
storage
.
_attachment_mapping_dict
;
// THIS IS REALLY BAD, FIND AN OTHER WAY IN FUTURE
if
(
mapping_dict
!==
undefined
&&
mapping_dict
[
attachment_id
]
!==
undefined
&&
mapping_dict
[
attachment_id
].
put
!==
undefined
&&
mapping_dict
[
attachment_id
].
put
.
erp5_put_template
!==
undefined
)
{
return
getSubStorageId
(
storage
,
id
)
.
push
(
function
(
sub_id
)
{
var
url
=
UriTemplate
.
parse
(
mapping_dict
[
attachment_id
].
put
.
erp5_put_template
).
expand
({
id
:
sub_id
}),
data
=
new
FormData
();
data
.
append
(
"
field_my_file
"
,
blob
);
data
.
append
(
"
form_id
"
,
"
File_view
"
);
return
jIO
.
util
.
ajax
({
"
type
"
:
"
POST
"
,
"
url
"
:
url
,
"
data
"
:
data
,
"
xhrFields
"
:
{
withCredentials
:
true
}
});
});
}
return
handleAttachment
(
this
,
arguments
,
"
put
"
,
id
)
.
push
(
function
()
{
return
attachment_id
;
...
...
@@ -401,7 +436,8 @@
.
push
(
function
(
result
)
{
var
attachment_id
,
attachments
=
{},
mapping_dict
=
{};
mapping_dict
=
{},
i
;
for
(
attachment_id
in
storage
.
_attachment_mapping_dict
)
{
if
(
storage
.
_attachment_mapping_dict
.
hasOwnProperty
(
attachment_id
))
{
mapping_dict
[
getAttachmentId
(
storage
,
sub_id
,
attachment_id
,
"
get
"
)]
...
...
@@ -410,6 +446,8 @@
}
for
(
attachment_id
in
result
)
{
if
(
result
.
hasOwnProperty
(
attachment_id
))
{
if
(
!
(
storage
.
_attachment_list
.
length
>
0
&&
storage
.
_attachment_list
.
indexOf
(
attachment_id
)
<
0
))
{
if
(
mapping_dict
.
hasOwnProperty
(
attachment_id
))
{
attachments
[
mapping_dict
[
attachment_id
]]
=
{};
}
else
{
...
...
@@ -417,6 +455,12 @@
}
}
}
}
for
(
i
=
0
;
i
<
storage
.
_attachment_list
.
length
;
i
+=
1
)
{
if
(
!
attachments
.
hasOwnProperty
(
storage
.
_attachment_list
[
i
]))
{
attachments
[
storage
.
_attachment_list
[
i
]]
=
{};
}
}
return
attachments
;
});
};
...
...
@@ -571,4 +615,5 @@
};
jIO
.
addStorage
(
'
mapping
'
,
MappingStorage
);
}(
jIO
,
RSVP
,
UriTemplate
,
SimpleQuery
,
ComplexQuery
,
QueryFactory
,
Query
));
\ No newline at end of file
}(
jIO
,
RSVP
,
UriTemplate
,
SimpleQuery
,
ComplexQuery
,
QueryFactory
,
Query
,
FormData
));
\ No newline at end of file
bt5/erp5_officejs/PathTemplateItem/web_page_module/jio_mappingstorage_js.xml
View file @
27931f00
...
...
@@ -239,7 +239,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
957.1
1845.19520.59426
</string>
</value>
<value>
<string>
957.1
3731.19555.59477
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>
1486
546931.43
</float>
<float>
1486
656236.28
</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