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