Commit ceb47fef authored by Roque's avatar Roque

erp5_officejs: form view generic without only office

parent d5cc854b
......@@ -85,59 +85,6 @@
return form_json;
}
//TODO this should be in a custom view
//use: portal_type_dict.custom_view_gadget (handled by controller gadget)
function renderOnlyOffice(gadget, options, portal_type_dict, state_dict) {
//TODO doc should come with filename. for now hardcoded if undefined
//get format extension from portal_type_dict
if (!options.doc.filename) {
options.doc.filename = "default.docx";
}
state_dict.mime_type = portal_type_dict.file_extension;
state_dict.only_office = true;
if (options.doc.action) {
return gadget.changeState(state_dict);
}
state_dict.content_editable = options.doc.content_type === undefined ||
options.doc.content_type.indexOf("application/x-asc") === 0;
return new RSVP.Queue()
.push(function () {
if (!state_dict.content_editable) {
return gadget.jio_getAttachment(options.jio_key, "data");
}
return gadget.declareGadget("gadget_ojs_cloudooo.html")
.push(function (ojs_cloudooo) {
return ojs_cloudooo.getConvertedBlob({
jio_key: options.jio_key,
format: state_dict.mime_type,
filename: options.doc.filename
});
});
})
.push(undefined, function (error) {
if (error instanceof jIO.util.jIOError &&
error.status_code === 404) {
return new Blob();
}
throw error;
})
.push(function (blob) {
if (state_dict.content_editable) {
return jIO.util.readBlobAsDataURL(blob);
}
return jIO.util.readBlobAsText(blob);
})
.push(function (result) {
state_dict.data = result.target.result;
if (portal_type_dict.blob_type) {
state_dict.blob_type = portal_type_dict.blob_type;
} else {
state_dict.blob_type = "ooffice";
}
return gadget.changeState(state_dict);
});
}
function handleSubmit(gadget, child_gadget, content_dict) {
var data, name_list;
return gadget.notifySubmitting()
......@@ -146,19 +93,6 @@
//submit doc metadata
data = content_dict.text_content;
delete content_dict.text_content;
//TODO this should be in a custom view
//use: portal_type_dict.custom_view_gadget
//ONLY OFFICE
if (gadget.state.only_office) {
name_list = gadget.state.doc.filename.split('.');
if (name_list.pop() !== gadget.state.mime_type) {
name_list.push(gadget.state.mime_type);
content_dict.filename = name_list.join('.');
}
content_dict.content_type = gadget.state.blob_type;
}//
}
return child_gadget.submitContent(
child_gadget.state.jio_key, undefined, content_dict
......@@ -169,26 +103,7 @@
//submit doc blob data
return gadget
.jio_putAttachment(child_gadget.state.jio_key, 'data',
jIO.util.dataURItoBlob(data))
//TODO this should be in a custom view
//use: portal_type_dict.custom_view_gadget
//ONLY OFFICE
.push(function () {
if (gadget.state.only_office) {
return gadget.declareGadget("gadget_ojs_cloudooo.html");
}
})
.push(function (cloudooo) {
if (gadget.state.only_office) {
return cloudooo
.putAllCloudoooConvertionOperation({
format: gadget.state.mime_type,
jio_key: child_gadget.state.jio_key
});
}
});//
jIO.util.dataURItoBlob(data));
}
}, function (error) {
console.log(error);
......@@ -280,10 +195,6 @@
portal_type_dict = options.form_definition.portal_type_dict,
blob;
if (portal_type_dict.only_office && options.doc) {
return renderOnlyOffice(gadget, options, portal_type_dict, state_dict);
}
if (portal_type_dict.blob_type) {
if (options.jio_key) {
return gadget.jio_getAttachment(options.jio_key, "data")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment