Commit 749c2261 authored by Roque's avatar Roque

erp5_officejs: get rid of post view in discussion tool

parent e36ea1cf
/*global document, window, rJS */
/*global document, window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (document, window, rJS) {
(function (document, window, rJS, RSVP) {
"use strict";
rJS(window)
......@@ -10,10 +10,10 @@
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("submitContent", "submitContent")
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
/////////////////////////////////////////////////////////////////
// declared methods
......@@ -67,61 +67,55 @@
"_links": {}
},
form_definition: form_definition
};
for (var i = 0; i < form_definition.group_list.length; i++) {
var fields = form_definition.group_list[i][1];
for (var j = 0; j < fields.length; j++) {
var my_element = fields[j][0], element_id;
}, i, j, fields, field_info, my_element, element_id;
for (i = 0; i < form_definition.group_list.length; i += 1) {
fields = form_definition.group_list[i][1];
for (j = 0; j < fields.length; j += 1) {
my_element = fields[j][0];
if (my_element.startsWith("my_")) {
element_id = my_element.replace("my_", "");
}
var field_info = form_definition.field_info_dict[my_element];
field_info = form_definition.field_info_dict[my_element];
if (document && document.hasOwnProperty(element_id)) {
field_info["default"] = document[element_id];
}
form_json.erp5_document._embedded._view[my_element] = field_info;
}
}
//form_json.erp5_document._embedded._view._actions = form_definition._actions;
form_json.erp5_document._embedded._view._actions = form_definition._actions;
form_json.erp5_document._links = form_definition._links;
return this.getUrlFor({command: "change", options: {"page": "ojs_add_post"}})
.push(function (url) {
form_json.erp5_document._embedded._view._actions = { "put": { "href": url } };
return form_json;
});
return form_json;
})
/*.allowPublicAcquisition('submitContent', function (options) {
console.log("CONTROLLER ADQUISITION OF submitContent. options");
console.log(options);
//return this.submitContent(options);
return this.getUrlFor({command: "change", options: {"page": "ojs_add_post"}})
.push(function (url) {
console.log("url");
console.log(url);
.allowPublicAcquisition('submitContent', function (options) {
var gadget = this,
jio_key = options[0],
//target_url = options[1],
content_dict = options[2];
return gadget.notifySubmitting()
.push(function () {
// this should be jio_getattachment (using target_url)
return gadget.jio_get(jio_key)
.push(function (document) {
var property;
for (property in content_dict) {
if (content_dict.hasOwnProperty(property)) {
document[property] = content_dict[property];
}
}
return gadget.jio_put(jio_key, document);
});
})
.push(function () {
return gadget.notifySubmitted({message: 'Data Updated', status: 'success'});
});
})*/
})
.allowPublicAcquisition('notifySubmit', function () {
return this.triggerSubmit();
})
.allowPublicAcquisition('updateDocument', function (param_list) {
var gadget = this, content = param_list[0];
return gadget.jio_get(gadget.state.jio_key)
.push(function (doc) {
var property;
for (property in content) {
if (content.hasOwnProperty(property)) {
doc[property] = content[property];
}
}
return gadget.jio_put(gadget.state.jio_key, doc);
});
})
.declareMethod('triggerSubmit', function () {
return this.getDeclaredGadget('fg')
.push(function (g) {
return g.triggerSubmit();
.push(function (gadget) {
return gadget.triggerSubmit();
});
})
......@@ -135,39 +129,35 @@
view: gadget.state.view,
form_json: form_json
})
.push(function () {
return RSVP.all([
gadget.getUrlFor({command: 'history_previous'}),
gadget.getUrlFor({command: 'selection_previous'}),
gadget.getUrlFor({command: 'selection_next'})
]);
})
.push(function (url_list) {
return subgadget.updateHeader({
page_title: gadget.state.doc.title,
save_action: true,
selection_url: url_list[0],
previous_url: url_list[1],
next_url: url_list[2]
.push(function () {
return RSVP.all([
gadget.getUrlFor({command: 'history_previous'}),
gadget.getUrlFor({command: 'selection_previous'}),
gadget.getUrlFor({command: 'selection_next'})
]);
})
.push(function (url_list) {
return subgadget.updateHeader({
page_title: gadget.state.doc.title,
save_action: true,
selection_url: url_list[0],
previous_url: url_list[1],
next_url: url_list[2]
});
});
});
})
.declareMethod("render", function (options) {
console.log("CONTROLLER. render method -options-");
console.log(options);
var gadget = this,
child_gadget_url;
return gadget.jio_get(options.jio_key)
.push(function (result) {
if (result.portal_type !== undefined) {
child_gadget_url = 'gadget_officejs_jio_' +
/*child_gadget_url = 'gadget_officejs_jio_' +
result.portal_type.replace(/ /g, '_').toLowerCase() +
'_view.html';
'_view.html';*/
// [HARDCODED] force to use form view editable
//child_gadget_url = 'gadget_erp5_pt_form_view_editable.html'
child_gadget_url = 'gadget_erp5_pt_form_view_editable.html';
} else {
throw new Error('Can not display document: ' + options.jio_key);
}
......@@ -185,27 +175,8 @@
});
});
})
.onEvent('submit', function () {
console.log("CONTROLLER submit method");
var gadget = this;
return gadget.notifySubmitting()
.push(function () {
return gadget.getDeclaredGadget('form_view');
})
.push(function (form_gadget) {
return form_gadget.getContent();
})
.push(function (content) {
return gadget.updateDocument(content);
})
.push(function () {
return gadget.notifySubmitted({message: 'Data Updated', status: 'success'});
});
})
.onStateChange(function (modification_dict) {
console.log("CONTROLLER. onStateChange method");
var fragment = document.createElement('div'),
gadget = this;
return gadget.generateJsonRenderForm(gadget.state.form_definition, gadget.state.doc)
......@@ -228,4 +199,4 @@
});
});
}(document, window, rJS));
\ No newline at end of file
}(document, window, rJS, RSVP));
\ No newline at end of file
......@@ -227,7 +227,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>973.32497.3392.28501</string> </value>
<value> <string>973.33799.59117.25480</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -245,7 +245,7 @@
</tuple>
<state>
<tuple>
<float>1549487174.88</float>
<float>1549565293.34</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -150,13 +150,6 @@ gadget_erp5_header.html\n
gadget_erp5_header.js\n
gadget_ojs_jio.html\n
gadget_ojs_jio.js\n
gadget_erp5_page_ojs_controller.html\n
gadget_erp5_page_ojs_controller.js\n
\n
#gadget_erp5_page_ojs_add_document.html\n
#gadget_erp5_page_ojs_add_document.js\n
gadget_erp5_page_ojs_add_post.html\n
gadget_erp5_page_ojs_add_post.js\n
\n
gadget_erp5_page_ojs_configurator.html\n
gadget_erp5_page_ojs_configurator.js\n
......@@ -169,11 +162,6 @@ gadget_erp5_page_ojs_dropbox_configurator.js\n
gadget_erp5_page_ojs_sync.html\n
gadget_erp5_page_ojs_sync.js\n
\n
#gadget_erp5_page_ojs_document_list.html\n
#gadget_erp5_page_ojs_document_list.js\n
gadget_erp5_page_ojs_post_list.html\n
gadget_erp5_page_ojs_post_list.js\n
\n
gadget_ojs_configurator_access.html\n
gadget_ojs_configurator_access.js\n
gadget_html5_input.html\n
......@@ -188,7 +176,6 @@ gadget_erp5_form.html\n
gadget_erp5_form.js\n
gadget_erp5_label_field.html\n
gadget_erp5_label_field.js\n
gadget_erp5_field_listbox.html\n
gadget_erp5_field_listbox.js\n
gadget_erp5_field_datetime.html\n
gadget_erp5_field_datetime.js\n
......@@ -232,9 +219,20 @@ gadget_officejs_text_editor_install.json\n
officejs_logo_text_editor.png\n
\n
#discussion tool\n
gadget_erp5_pt_form_view_editable.html\n
gadget_erp5_pt_form_view_editable.js\n
gadget_officejs_discussion_tool_router.html\n
gadget_officejs_jio_html_post_view.html\n
gadget_officejs_jio_html_post_view.js\n
gadget_erp5_page_ojs_controller.html\n
gadget_erp5_page_ojs_controller.js\n
gadget_erp5_page_ojs_post_list.html\n
gadget_erp5_page_ojs_post_list.js\n
#gadget_officejs_jio_html_post_view.html\n
#gadget_officejs_jio_html_post_view.js\n
gadget_erp5_page_ojs_add_post.html\n
gadget_erp5_page_ojs_add_post.js\n
\n
gadget_erp5_field_listbox.html\n
gadget_erp5_field_listbox.js\n
\n
#Ckeditor\n
ckeditor.gadget.html\n
......@@ -716,7 +714,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>973.14544.10075.4932</string> </value>
<value> <string>973.33828.18786.32665</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -734,7 +732,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1548410072.15</float>
<float>1549567442.36</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -224,7 +224,7 @@
</tuple>
<state>
<tuple>
<float>1548320452.29</float>
<float>1549566213.89</float>
<string>UTC</string>
</tuple>
</state>
......@@ -269,7 +269,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>973.25023.19197.63385</string> </value>
<value> <string>973.33806.29832.64307</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>1549038779.7</float>
<float>1549565698.61</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>1549286006.65</float>
<float>1549461300.51</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -10,11 +10,8 @@
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
......@@ -52,11 +49,8 @@
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
......@@ -165,7 +159,7 @@
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
<value> <string>hide</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
......@@ -191,7 +185,7 @@
</tuple>
<state>
<tuple>
<float>1548258468.7</float>
<float>1549565688.07</float>
<string>UTC</string>
</tuple>
</state>
......@@ -200,7 +194,7 @@
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
<value> <string>hidden</string> </value>
</item>
</dictionary>
</list>
......@@ -236,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>973.30699.43343.35106</string> </value>
<value> <string>973.33807.14910.57139</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1549379311.18</float>
<float>1549565721.29</float>
<string>UTC</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