Commit 840cf299 authored by Jérome Perrin's avatar Jérome Perrin

officejs_support_request_ui: comply with jslint and renderjs conventions

 * format code as jslint expects it
 * use RSVP.Queue instead of Promise
parent d05f146b
......@@ -72,19 +72,19 @@
// render the erp5 form
return this.getDeclaredGadget("erp5_form")
.push(function(erp5_form) {
.push(function (erp5_form) {
return gadget.getDeclaredGadget("editor")
.push(function(editor) {
.push(function (editor) {
return [editor, erp5_form];
})
});
})
.push(function (gadgets) {
var form_options = gadget.state.erp5_form,
rendered_form = gadget.state.erp5_document._embedded._view,
rendered_field,
key,
editor=gadgets[0],
erp5_form=gadgets[1];
editor = gadgets[0],
erp5_form = gadgets[1];
// Remove all empty fields, and mark all others as non editable
for (key in rendered_form) {
if (rendered_form.hasOwnProperty(key) && (key[0] !== "_")) {
......@@ -102,13 +102,15 @@
form_options.form_definition = gadget.state.form_definition;
form_options.view = gadget.state.view;
return gadget.jio_getAttachment(
'post_module',
gadget.hateoas_url + gadget.options.jio_key + "/Base_getEditorFieldPreferredTextEditor",
{format: "text"}
).push(function(preferred_editor) {
return Promise.all([
).push(function (preferred_editor) {
return new RSVP.Queue()
.push(
function () {
return RSVP.all([
erp5_form.render(form_options),
editor.render({
value: "",
......@@ -116,18 +118,20 @@
portal_type: "HTML Post",
editable: true,
editor: preferred_editor
})]).then(function (){
})]);
}
).push(function () {
// make our submit button editable
var element = /** @type {HTMLInputElement} */(gadget.element.querySelector('input[type="submit"]'));
var element = gadget.element.querySelector('input[type="submit"]');
element.removeAttribute('disabled');
element.classList.remove('ui-disabled');
});
})
});
})
// render the header
.push(function () {
return Promise.all([
return RSVP.all([
gadget.getUrlFor({command: 'change', options: {editable: true}}),
gadget.getUrlFor({command: 'change', options: {page: "action"}}),
gadget.getUrlFor({command: 'history_previous'}),
......@@ -157,10 +161,10 @@
return gadget.jio_getAttachment(
'post_module',
gadget.hateoas_url + "/Localizer/get_selected_language",
{format:'text'}
).push(function(lang){
{format: 'text'}
).push(function (lang) {
moment.locale(lang);
})
});
})
.push(function () {
return gadget.jio_getAttachment(
......@@ -169,9 +173,9 @@
);
})
.push(function (post_list) {
var queue_list = [];
var queue_list = [], i = 0;
if (post_list.length) {
for (var i = 0; i < post_list.length; i += 1) {
for (i = 0; i < post_list.length; i += 1) {
if (post_list[i].attachment_link !== null && post_list[i].attachment_link.indexOf("image_module") !== -1) {
queue_list.push(gadget.getImageUrl(post_list[i].attachment_link));
} else if (post_list[i].attachment_link !== null && post_list[i].attachment_link.indexOf("document_module") !== -1) {
......@@ -226,10 +230,11 @@
queue = null,
editor = null;
return gadget.getDeclaredGadget("editor")
.then(function(e) {
.push(function (e) {
editor = e;
return e.getContent(); })
.then(function (content) {
return e.getContent();
})
.push(function (content) {
if (content.comment === '') {
return gadget.notifySubmitted({message: "Post content can not be empty!"});
}
......@@ -267,15 +272,14 @@
})
.push(function () {
editor.changeState({value: ''})
.push(function (){
.push(function () {
return gadget.redirect({command: 'reload'});
})
});
queue.then(enableSubmitButton, enableSubmitButton);
});
queue.push(enableSubmitButton, enableSubmitButton);
return queue;
});
})
}
)
.onEvent('submit', function () {
this.submitPostComment();
});
......
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1539065902.53</float>
<float>1539132486.97</float>
<string>GMT+9</string>
</tuple>
</state>
......
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