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