Commit b34042dd authored by Romain Courteaud's avatar Romain Courteaud

WIP [erp5_web_jabber_client] Reuse ERP5JS gadgets

This is still a not working prototype.
Pasting multitext has not yet been reimplemented.
Way to slow to be usable.
parent 7f1415a0
......@@ -52,7 +52,7 @@
}
function disconnectOnbeforeunload(connection) {
return function (event) {
return function () {
/* XXX it can be interfere with changed warning
if (changed && $('button.save')) {
return unsaved_warn_message;
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>949.56116.24375.61559</string> </value>
<value> <string>963.11851.42215.35874</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1458087635.15</float>
<float>1509724529.27</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -12,11 +12,12 @@
<script src="jiodev.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_jabberclient_jio.js" type="text/javascript"></script>
</head>
<body>
<div class="ui-hidden-accessible connection-gadget-container"></div>
<div class="ui-screen-hidden connection-gadget-container"></div>
<div data-gadget-url='gadget_jio.html' data-gadget-scope='persistent_jio'></div>
</body>
......
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>949.35373.28357.37512</string> </value>
<value> <string>963.13564.52429.46011</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>1456843116.28</float>
<float>1509720807.28</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -140,7 +140,7 @@
function markOffline(key) {
return gadget.state_parameter_dict.volatile_jio.get(key)
.push(function (doc) {
doc.offline = true;
doc.connected = false;
return gadget.state_parameter_dict.volatile_jio.put(key, doc);
});
}
......@@ -178,8 +178,8 @@
(error.status_code === 404)) {
return {
jid: jid,
offline: true,
read: true
connected: false,
notification: false
};
}
throw error;
......@@ -252,9 +252,9 @@
.push(function (doc) {
if ((type === "unavailable") || (type === "unsubscribed")) {
// Bye dear contact
doc.offline = true;
doc.connected = false;
} else {
doc.offline = false;
doc.connected = true;
}
return gadget.state_parameter_dict.volatile_jio.put(from, doc);
})
......@@ -278,7 +278,7 @@
return initializeContact(gadget, argument_list[0]);
})
.push(function (doc) {
doc.read = false;
doc.notification = true;
return gadget.state_parameter_dict.volatile_jio.put(argument_list[0], doc);
})
.push(function () {
......@@ -423,7 +423,7 @@
.declareMethod('allDocs', function (options) {
if (!this.state_parameter_dict.connected) {
return this.redirect({command: 'display', options: {page: 'connect'}});
return this.redirect({command: 'display', options: {page: 'jabberclient_connect'}});
}
return this.state_parameter_dict.volatile_jio.allDocs(options);
})
......@@ -432,7 +432,7 @@
var gadget = this,
result;
if (!this.state_parameter_dict.connected) {
return this.redirect({command: 'display', options: {page: 'connect'}});
return this.redirect({command: 'display', options: {page: 'jabberclient_connect'}});
}
if (name === 'enclosure') {
return getLog(this, id, options)
......@@ -441,7 +441,7 @@
return initializeContact(gadget, id);
})
.push(function (doc) {
doc.read = true;
doc.notification = false;
return gadget.state_parameter_dict.volatile_jio.put(id, doc);
})
.push(function () {
......@@ -454,7 +454,7 @@
.declareMethod('putAttachment', function (id, name, blob) {
var gadget = this;
if (!this.state_parameter_dict.connected) {
return this.redirect({command: 'display', options: {page: 'connect'}});
return this.redirect({command: 'display', options: {page: 'jabberclient_connect'}});
}
if (name === 'MESSAGE') {
return this.getDeclaredGadget(CONNECTION_GADGET_SCOPE)
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>949.57481.62457.42496</string> </value>
<value> <string>963.13623.60350.63692</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1458172700.61</float>
<float>1509724327.32</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -10,11 +10,9 @@
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_jabberclient_page_connect.js" type="text/javascript"></script>
<script src="gadget_erp5_page_jabberclient_connect.js" type="text/javascript"></script>
</head>
<body>
<pre></pre>
<form class="dialog_form">
<button type="submit" data-i18n="Submit" class="ui-btn ui-btn-b ui-btn-inline
ui-icon-action ui-btn-icon-right ui-screen-hidden">Submit</button>
......
......@@ -75,7 +75,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_jabberclient_page_connect.html</string> </value>
<value> <string>gadget_erp5_page_jabberclient_connect.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>949.25270.37532.52872</string> </value>
<value> <string>963.11985.30461.59170</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1456843234.23</float>
<float>1509627042.14</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, RSVP, loopEventListener*/
/*global window, rJS, RSVP*/
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, loopEventListener) {
(function (window, rJS, RSVP) {
"use strict";
rJS(window)
/////////////////////////////////////////////////////////////////
// ready
/////////////////////////////////////////////////////////////////
// Init local properties
.ready(function (g) {
g.props = {};
})
// Assign the element to a variable
.ready(function (g) {
return g.getElement()
.push(function (element) {
g.props.element = element;
});
})
/////////////////////////////////////////////////////////////////
// Acquired methods
......@@ -26,6 +11,7 @@
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", "notifySubmitted")
.declareAcquiredMethod("notifyChange", "notifyChange")
.declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("redirect", "redirect")
......@@ -34,11 +20,11 @@
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod('triggerSubmit', function () {
this.props.element.querySelector('button').click();
this.element.querySelector('button').click();
})
.declareMethod("render", function () {
var page_gadget = this,
data;
var page_gadget = this;
return page_gadget.updateHeader({
page_title: 'Connect to a Jabber server',
submit_action: true
......@@ -46,17 +32,25 @@
.push(function () {
return page_gadget.jio_get("CONNECTION");
})
.push(function (result) {
data = result;
return page_gadget.getDeclaredGadget("erp5_form");
.push(function (data) {
return page_gadget.changeState({
server: data.server,
jid: data.jid,
passwd: data.passwd
});
});
})
.onStateChange(function () {
var page_gadget = this;
return page_gadget.getDeclaredGadget("erp5_form")
.push(function (form_gadget) {
return form_gadget.render({
erp5_document: {"_embedded": {"_view": {
"server": {
"description": "",
"title": "Server URL",
"default": data.server,
"default": page_gadget.state.server,
"css_class": "",
"required": 1,
"editable": 1,
......@@ -67,7 +61,7 @@
"jid": {
"description": "",
"title": "Jabber ID",
"default": data.jid,
"default": page_gadget.state.jid,
"css_class": "",
"required": 1,
"editable": 1,
......@@ -78,7 +72,7 @@
"passwd": {
"description": "",
"title": "Password",
"default": data.passwd,
"default": page_gadget.state.passwd,
"css_class": "",
"required": 1,
"editable": 1,
......@@ -97,44 +91,36 @@
});
})
.declareService(function () {
var form_gadget = this;
.onEvent('submit', function () {
var page_gadget = this;
function formSubmit() {
return form_gadget.notifySubmitting()
return page_gadget.notifySubmitting()
.push(function () {
return form_gadget.getDeclaredGadget("erp5_form");
return page_gadget.getDeclaredGadget("erp5_form");
})
.push(function (erp5_form) {
return erp5_form.getContent();
})
.push(function (content_dict) {
return form_gadget.jio_put(
return page_gadget.jio_put(
'CONNECTION',
content_dict
);
})
.push(function () {
return RSVP.all([
form_gadget.notifySubmitted(),
form_gadget.redirect({command: 'display', options: {page: 'contact'}})
page_gadget.notifySubmitted(),
page_gadget.redirect({command: 'display', options: {page: 'jabberclient_contact'}})
]);
}, function (error) {
return RSVP.all([
page_gadget.notifySubmitted(),
page_gadget.notifyChange({
'message': error,
'status': 'error'
})
.push(undefined, function (error) {
return form_gadget.notifySubmitted()
.push(function () {
form_gadget.props.element.querySelector('pre').textContent = error;
});
]);
});
}
// Listen to form submit
return loopEventListener(
form_gadget.props.element.querySelector('form'),
'submit',
false,
formSubmit
);
});
}(window, rJS, RSVP, loopEventListener));
\ No newline at end of file
}(window, rJS, RSVP));
\ No newline at end of file
......@@ -71,7 +71,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_jabberclient_page_connect.js</string> </value>
<value> <string>gadget_erp5_page_jabberclient_connect.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>949.35328.64444.1843</string> </value>
<value> <string>963.13625.4155.47957</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1456843227.61</float>
<float>1509724755.89</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -5,45 +5,17 @@
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>JabberClient Gadget Page Contact</title>
<script id="contact-list-template" type="text/x-handlebars-template">
<ul data-role="listview" data-inset="true">
{{#each contact}}
<li>
{{#if status}}
{{#if url}}
<a href="{{url}}" class="ui-btn ui-btn-icon-left ui-icon-check">
{{#if new_message}}
<span class="ui-li-count">!</span>
{{/if}}
{{jid}}</a>
{{else}}
{{jid}}
{{/if}}
{{else}}
{{#if url}}
<a href="{{url}}" class="ui-btn ui-btn-icon-left ui-icon-forbidden">
{{#if new_message}}
<span class="ui-li-count">!</span>
{{/if}}
{{jid}}</a>
{{else}}
{{jid}}
{{/if}}
{{/if}}
</li>
{{/each}}
</ul>
</script>
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_jabberclient_page_contact.js" type="text/javascript"></script>
<script src="gadget_erp5_page_jabberclient_contact.js" type="text/javascript"></script>
</head>
<body>
<div data-gadget-url="gadget_erp5_pt_form_list.html"
data-gadget-scope="form_list"
data-gadget-sandbox="public">
</div>
</body>
</html>
\ No newline at end of file
......@@ -75,7 +75,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_jabberclient_page_contact.html</string> </value>
<value> <string>gadget_erp5_page_jabberclient_contact.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>949.26690.60508.50432</string> </value>
<value> <string>963.12017.54400.15923</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1456843145.34</float>
<float>1509628438.87</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, RSVP, Handlebars*/
/*global window, rJS*/
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, Handlebars) {
(function (window, rJS) {
"use strict";
function compareContact(a, b) {
var result;
if (a.new_message && (!b.new_message)) {
result = -1;
} else if (b.new_message && (!a.new_message)) {
result = 1;
} else if (a.status && (!b.status)) {
result = -1;
} else if (b.status && (!a.status)) {
result = 1;
} else if (b.jid < a.jid) {
result = 1;
} else if (a.jid < b.jid) {
result = -1;
} else {
result = 0;
}
return result;
}
rJS(window)
/////////////////////////////////////////////////////////////////
// Handlebars
// Acquired methods
/////////////////////////////////////////////////////////////////
// Precompile the templates while loading the first gadget instance
var gadget_klass = rJS(window),
source = gadget_klass.__template_element
.getElementById("contact-list-template")
.innerHTML,
table_template = Handlebars.compile(source);
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
gadget_klass
/////////////////////////////////////////////////////////////////
// ready
// declared methods
/////////////////////////////////////////////////////////////////
// Init local properties
.ready(function (g) {
g.props = {};
.allowPublicAcquisition('updateHeader', function () {
return;
})
// Assign the element to a variable
.ready(function (g) {
return g.getElement()
.push(function (element) {
g.props.element = element;
.allowPublicAcquisition('getUrlFor', function (argument_list) {
if (argument_list[0].command === 'index') {
return this.getUrlFor({command: 'display', options: {jio_key: argument_list[0].options.jio_key,
page: 'jabberclient_dialog'}});
}
return this.getUrlFor.apply(this, argument_list);
})
.allowPublicAcquisition("jio_allDocs", function (param_list) {
var gadget = this;
return gadget.jio_allDocs(param_list[0])
.push(function (result) {
var i, len = result.data.total_rows;
for (i = 0; i < len; i += 1) {
if (result.data.rows[i].value.hasOwnProperty("connected")) {
result.data.rows[i].value.connected = {
editable: 0,
hidden: 0,
"default": result.data.rows[i].value.connected,
key: "field_connected",
required: 0,
type: "CheckBoxField"
};
result.data.rows[i].value["listbox_uid:list"] = {
key: "listbox_uid:list",
value: 2713
};
}
if (result.data.rows[i].value.hasOwnProperty("notification")) {
result.data.rows[i].value.notification = {
editable: 0,
hidden: 0,
"default": result.data.rows[i].value.notification,
key: "field_notification",
required: 0,
type: "CheckBoxField"
};
result.data.rows[i].value["listbox_uid:list"] = {
key: "listbox_uid:list",
value: 2713
};
}
}
return result;
});
})
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareMethod("triggerSubmit", function () {
var argument_list = arguments;
return this.getDeclaredGadget('form_list')
.push(function (gadget) {
return gadget.triggerSubmit.apply(gadget, argument_list);
});
})
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("render", function () {
var page_gadget = this,
contact_list = [],
gadget = this;
var gadget = this,
header_dict = {
page_title: 'Contacts',
page_icon: 'puzzle-piece',
filter_action: true
};
return page_gadget.updateHeader({
page_title: 'Contact'
})
return gadget.updateHeader(header_dict)
.push(function () {
return page_gadget.jio_allDocs({select_list: ['jid', 'read', 'offline']});
return gadget.getDeclaredGadget('form_list');
})
.push(function (result) {
var i,
contact,
promise_list = [];
for (i = 0; i < result.data.total_rows; i += 1) {
contact = result.data.rows[i].value;
contact_list.push({
jid: contact.jid,
new_message: !contact.read,
status: !contact.offline
});
promise_list.push(gadget.getUrlFor({command: 'display', options: {page: 'dialog', jid: contact.jid}}));
.push(function (form_gadget) {
var column_list = [
['jid', 'Name'],
['notification', 'Notification'],
['connected', 'Connected']
];
return form_gadget.render({
erp5_document: {"_embedded": {"_view": {
"listbox": {
"column_list": column_list,
"show_anchor": 0,
"default_params": {},
"editable": 1,
"editable_column_list": column_list,
"key": "field_listbox",
"lines": 1000,
"list_method": "portal_catalog",
"query": "urn:jio:allDocs",
"portal_type": [],
"search_column_list": column_list,
"sort_column_list": column_list,
"sort": [['notification', 'DESC'], ['connected', 'DESC'], ['jid', 'ASC']],
"title": "Contacts",
"type": "ListBox"
}
return RSVP.all(promise_list);
})
.push(function (url_list) {
var i;
for (i = 0; i < url_list.length; i += 1) {
contact_list[i].url = url_list[i];
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: {
group_list: [[
"bottom",
[["listbox"]]
]]
}
contact_list.sort(compareContact);
gadget.props.element.innerHTML =
table_template({
contact: contact_list
});
});
});
}(window, rJS, RSVP, Handlebars));
\ No newline at end of file
}(window, rJS));
\ No newline at end of file
......@@ -71,7 +71,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_jabberclient_page_contact.js</string> </value>
<value> <string>gadget_erp5_page_jabberclient_contact.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>949.36448.18833.13141</string> </value>
<value> <string>963.13593.12902.41028</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1456907564.65</float>
<float>1509722579.38</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -10,31 +10,20 @@
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_jabberclient_page_dialog.js" type="text/javascript"></script>
<script src="gadget_erp5_page_jabberclient_dialog.js" type="text/javascript"></script>
<script id="input-template" type="text/x-handlebars-template">
<input class="input-content" type="text" data-enhanced="true" name="content"
placeholder="Write something..." value="" required>
</script>
<script id="textarea-template" type="text/x-handlebars-template">
<textarea class="textarea-content" type="text" data-enhanced="true" name="content"
placeholder="Write a multi-line message..." value="" required></textarea>
</script>
</head>
<body>
<div class="discussion-content"></div>
<div data-role="footer" data-position="fixed" data-tap-toggle="false">
<form class="message-form">
<div class="ui-input-text ui-corner-all ui-body-inherit ui-shadow-inset ui-input-has-clear ui-input-has-multiline">
<div class="custom-mode-change ui-btn ui-btn-icon-notext ui-input-clear ui-input-btn ui-corner-all ui-icon-comment ui-btn-left">
<input data-enhanced="true" type="button" value="">
</div>
<div class="ui-btn ui-input-clear ui-input-btn ui-corner-all ui-icon-edit ui-btn-icon-notext">
<input data-enhanced="true" type="submit" value="Send">
<form class="dialog_form">
<div data-gadget-url="gadget_erp5_form.html"
data-gadget-scope="discussion_form"
data-gadget-sandbox="public">
</div>
<div data-gadget-url="gadget_erp5_form.html"
data-gadget-scope="input_form"
data-gadget-sandbox="public">
</div>
<input class="dialogconfirm" data-theme="b" data-inline="true" type="submit" data-i18n="[value]Send" value="Send" data-icon="check" />
</form>
</div>
</body>
</html>
\ No newline at end of file
......@@ -75,7 +75,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_jabberclient_page_dialog.html</string> </value>
<value> <string>gadget_erp5_page_jabberclient_dialog.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>950.63332.2255.41369</string> </value>
<value> <string>963.13312.9778.47496</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1462370312.21</float>
<float>1509718172.58</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -71,7 +71,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_jabberclient_page_dialog.js</string> </value>
<value> <string>gadget_erp5_page_jabberclient_dialog.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>951.19073.8210.16640</string> </value>
<value> <string>963.13465.59114.24746</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1463643257.07</float>
<float>1509719800.62</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -10,18 +10,16 @@
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_jabberclient_page_password.js" type="text/javascript"></script>
<script src="gadget_erp5_page_jabberclient_password.js" type="text/javascript"></script>
</head>
<body>
<pre></pre>
<form class="dialog_form">
<button type="submit" data-i18n="Submit" class="ui-btn ui-btn-b ui-btn-inline
ui-icon-action ui-btn-icon-right ui-screen-hidden">Submit</button>
<div data-gadget-url="gadget_erp5_form.html"
data-gadget-scope="erp5_form"
data-gadget-sandbox="public">
</div>
<input class="dialogconfirm" data-theme="b" data-inline="true" type="submit" data-i18n="[value]Change" value="Change" data-icon="check" />
</form>
</body>
</html>
\ No newline at end of file
......@@ -75,7 +75,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_jabberclient_page_password.html</string> </value>
<value> <string>gadget_erp5_page_jabberclient_password.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>949.26853.9657.64102</string> </value>
<value> <string>963.13535.17463.63488</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1456843254.57</float>
<float>1509719016.16</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, RSVP, loopEventListener*/
/*global window, rJS, RSVP*/
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, loopEventListener) {
(function (window, rJS, RSVP) {
"use strict";
function validatePassword(password1, password2) {
......@@ -8,21 +8,6 @@
}
rJS(window)
/////////////////////////////////////////////////////////////////
// ready
/////////////////////////////////////////////////////////////////
// Init local properties
.ready(function (g) {
g.props = {};
})
// Assign the element to a variable
.ready(function (g) {
return g.getElement()
.push(function (element) {
g.props.element = element;
});
})
/////////////////////////////////////////////////////////////////
// Acquired methods
......@@ -30,6 +15,7 @@
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", "notifySubmitted")
.declareAcquiredMethod("notifyChange", "notifyChange")
.declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("redirect", "redirect")
......@@ -44,7 +30,7 @@
var page_gadget = this;
return page_gadget.updateHeader({
page_title: 'Reset Password',
submit_action: true
page_icon: 'power-off'
})
.push(function () {
// Ensure user is connected...
......@@ -100,10 +86,9 @@
});
})
.declareService(function () {
.onEvent('submit', function () {
var form_gadget = this;
function formSubmit() {
return form_gadget.notifySubmitting()
.push(function () {
return form_gadget.getDeclaredGadget("erp5_form");
......@@ -116,32 +101,30 @@
return form_gadget.jio_put(
'PASSWORD',
content_dict
);
}
// XXX Uses field validation instead...
throw new Error('Password does not match.');
})
)
.push(function () {
return RSVP.all([
form_gadget.notifySubmitted(),
form_gadget.redirect({command: 'display', options: {page: 'contact'}})
form_gadget.notifyChange({
'message': "Password changed",
'status': 'success'
})
]);
})
.push(undefined, function (error) {
return form_gadget.notifySubmitted()
.push(function () {
throw error;
});
return form_gadget.redirect({command: 'display',
options: {page: 'jabberclient_contact'}});
});
}
// Listen to form submit
return loopEventListener(
form_gadget.props.element.querySelector('form'),
'submit',
false,
formSubmit
);
// XXX Uses field validation instead...
return RSVP.all([
form_gadget.notifySubmitted(),
form_gadget.notifyChange({
'message': "Password does not match.",
'status': 'error'
})
]);
});
});
}(window, rJS, RSVP, loopEventListener));
\ No newline at end of file
}(window, rJS, RSVP));
\ No newline at end of file
......@@ -71,7 +71,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_jabberclient_page_password.js</string> </value>
<value> <string>gadget_erp5_page_jabberclient_password.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>949.26900.6119.6246</string> </value>
<value> <string>963.13541.25372.11042</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1456843245.07</float>
<float>1509719421.2</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -10,18 +10,16 @@
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_jabberclient_page_subscribe.js" type="text/javascript"></script>
<script src="gadget_erp5_page_jabberclient_new_contact.js" type="text/javascript"></script>
</head>
<body>
<pre></pre>
<form class="dialog_form">
<button type="submit" data-i18n="Submit" class="ui-btn ui-btn-b ui-btn-inline
ui-icon-action ui-btn-icon-right ui-screen-hidden">Submit</button>
<div data-gadget-url="gadget_erp5_form.html"
data-gadget-scope="erp5_form"
data-gadget-sandbox="public">
</div>
<input class="dialogconfirm" data-theme="b" data-inline="true" type="submit" data-i18n="[value]Add" value="Add" data-icon="check" />
</form>
</body>
</html>
\ No newline at end of file
......@@ -75,7 +75,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_jabberclient_page_subscribe.html</string> </value>
<value> <string>gadget_erp5_page_jabberclient_new_contact.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>949.26823.54523.58094</string> </value>
<value> <string>963.13508.24026.19831</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1456843200.45</float>
<float>1509717763.65</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, RSVP, loopEventListener*/
/*global window, rJS, RSVP*/
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, loopEventListener) {
(function (window, rJS, RSVP) {
"use strict";
rJS(window)
/////////////////////////////////////////////////////////////////
// ready
/////////////////////////////////////////////////////////////////
// Init local properties
.ready(function (g) {
g.props = {};
})
// Assign the element to a variable
.ready(function (g) {
return g.getElement()
.push(function (element) {
g.props.element = element;
});
})
/////////////////////////////////////////////////////////////////
// Acquired methods
......@@ -26,6 +11,7 @@
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", "notifySubmitted")
.declareAcquiredMethod("notifyChange", "notifyChange")
.declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("redirect", "redirect")
......@@ -34,13 +20,13 @@
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod('triggerSubmit', function () {
this.props.element.querySelector('button').click();
this.element.querySelector('button').click();
})
.declareMethod("render", function () {
var page_gadget = this;
return page_gadget.updateHeader({
page_title: 'New Contact',
submit_action: true
page_icon: 'gear'
})
.push(function () {
// Ensure user is connected...
......@@ -74,10 +60,9 @@
});
})
.declareService(function () {
.onEvent('submit', function () {
var form_gadget = this;
function formSubmit() {
return form_gadget.notifySubmitting()
.push(function () {
return form_gadget.getDeclaredGadget("erp5_form");
......@@ -94,24 +79,16 @@
.push(function () {
return RSVP.all([
form_gadget.notifySubmitted(),
form_gadget.redirect({command: 'display', options: {page: 'contact'}})
form_gadget.notifyChange({
'message': "Contact added",
'status': 'success'
})
]);
})
.push(undefined, function (error) {
return form_gadget.notifySubmitted()
.push(function () {
throw error;
});
return form_gadget.redirect({command: 'display',
options: {page: 'jabberclient_contact'}});
});
}
// Listen to form submit
return loopEventListener(
form_gadget.props.element.querySelector('form'),
'submit',
false,
formSubmit
);
});
}(window, rJS, RSVP, loopEventListener));
\ No newline at end of file
}(window, rJS, RSVP));
\ No newline at end of file
......@@ -71,7 +71,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_jabberclient_page_subscribe.js</string> </value>
<value> <string>gadget_erp5_page_jabberclient_new_contact.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>949.26838.22974.62054</string> </value>
<value> <string>963.13526.23121.58146</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1456843207.84</float>
<float>1509718633.02</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -3,43 +3,70 @@
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>ERP5 Panel</title>
<title>Jabber Panel</title>
<!--
data-i18n=Editable
-->
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="handlebars.js" type="text/javascript"></script>
<script src="gadget_global.js" type="text/javascript"></script>
<script src="jquery.js" type="text/javascript"></script>
<script src="jquerymobile.js" type="text/javascript"></script>
<script id="panel-template-header" type="text/x-handlebars-template">
<div data-role="header" class="ui-bar-inherit">
<div class="ui-controlgroup ui-controlgroup-horizontal ui-btn-left">
<div class="ui-controlgroup-controls">
<form action="#" method="post">
<input type="submit" data-i18n="[value]Close" data-icon="delete" data-iconpos="notext" value="Close" />
</form>
</div>
</div>
<div class="ui-controlgroup ui-controlgroup-horizontal ui-btn-right">
<div class="ui-controlgroup-controls">
<a href="#" class="ui-btn ui-btn-icon-notext ui-icon-home" data-i18n="Home">Home</a>
<button data-i18n="Close" class="ui-btn ui-btn-icon-notext ui-icon-delete">Close</button>
</div>
</div>
<!--div class="panel_img">
<img class="ui-title" alt="ERP5" src="gadget_erp5_panel.png?format=png"/>
</div-->
</div>
</script>
<script id="panel-template-body" type="text/x-handlebars-template">
<div class="ui-content">
<ul data-role="listview" class="ui-listview" data-enhanced="true">
<li class="ui-first-child"><a href="{{contact_href}}" class="ui-btn ui-btn-icon-left ui-icon-puzzle-piece" data-i18n="Contacts">Contacts</a></li>
<li><a href="{{subscribe_href}}" class="ui-btn ui-btn-icon-left ui-icon-gear" data-i18n="New Contact">New Contact</a></li>
<li class="ui-last-child"><a href="{{password_href}}" class="ui-btn ui-btn-icon-left ui-icon-power-off" data-i18n="Password">Password</a></li>
</ul>
<!--form class="dialog_form">
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline
ui-icon-action ui-btn-icon-right ui-screen-hidden">Submit</button>
<div data-gadget-url="gadget_erp5_searchfield.html"
data-gadget-scope="erp5_searchfield"
data-gadget-sandbox="public"></div>
</form-->
<ul data-role="listview" class="ui-listview" data-enhanced="true"></ul>
<div data-gadget-url="gadget_erp5_field_checkbox.html"
data-gadget-scope="erp5_checkbox"
data-gadget-sandbox="public"></div>
<dl></dl>
</div>
</script>
<script id="panel-template-body-list" type="text/x-handlebars-template">
<li class="ui-first-child"><a href="{{contact_href}}" class="ui-btn ui-btn-icon-left ui-icon-puzzle-piece" data-i18n="Contacts">Contacts</a></li>
<li><a href="{{new_contact_href}}" class="ui-btn ui-btn-icon-left ui-icon-gear" data-i18n="New Contact" accesskey="m">New Contact</a></li>
<li><a href="{{password_href}}" class="ui-btn ui-btn-icon-left ui-icon-power-off" data-i18n="Password" accesskey="w">Password</a></li>
</script>
<!--script id="panel-template-body-desktop" type="text/x-handlebars-template">
<dt class="ui-content-title ui-body-c ui-btn ui-btn-icon-left ui-icon-eye" data-i18n="Views">Views</dt>
{{#each view_list}}
<dd data-role="listview" data-theme="c" data-inset="true" class="document-listview">
<a data-i18n="{{title}}" class="ui-body-inherit" href="{{href}}">{{title}}</a>
</dd>
{{/each}}
<dt class="ui-content-title ui-body-c ui-btn ui-btn-icon-left ui-icon-cogs" data-i18n="Decisions">Decisions</dt>
{{#each workflow_list}}
<dd data-role="listview" data-theme="c" data-inset="true" class="document-listview">
<a data-i18n="{{title}}" class="ui-body-inherit" href="{{href}}">{{title}}</a>
</dd>
{{/each}}
</script-->
<!-- custom script -->
<script src="gadget_jabberclient_panel.js" type="text/javascript"></script>
......@@ -47,6 +74,5 @@
<body>
<div class="jqm-navmenu-panel"></div>
</body>
</html>
\ No newline at end of file
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>949.35375.42111.29422</string> </value>
<value> <string>963.13496.32563.39014</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1456843184.4</float>
<float>1509724597.78</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>949.26657.64277.54118</string> </value>
<value> <string>963.13497.47750.35106</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1456843167.64</float>
<float>1509724562.9</float>
<string>UTC</string>
</tuple>
</state>
......
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>Router Gadget</title>
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="gadget_jabberclient_router.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>
......@@ -249,6 +249,16 @@
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_frontpage_gadget_url</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
......@@ -283,7 +293,7 @@
<value>
<tuple>
<string>caching_policy/must-revalidate</string>
<string>aggregate/web_page_module/rjs_gadget_erp5_html</string>
<string>aggregate/web_page_module/rjs_gadget_erp5_launcher_html</string>
</tuple>
</value>
</item>
......@@ -293,11 +303,17 @@
</item>
<item>
<key> <string>configuration_content_security_policy</string> </key>
<value> <string>default-src \'none\'; img-src \'self\' data:; media-src \'self\' blob:; connect-src \'self\' data:; script-src \'self\' \'unsafe-eval\'; font-src \'self\'; style-src \'self\' netdna.bootstrapcdn.com \'unsafe-inline\' data:; frame-src \'self\' data:</string> </value>
<value> <string>default-src \'none\'; img-src \'self\' data:; media-src \'self\' blob:; connect-src \'self\' data:; script-src \'self\' \'unsafe-eval\'; font-src \'self\'; style-src \'self\' \'unsafe-inline\' data:; frame-src \'self\' data:</string> </value>
</item>
<item>
<key> <string>configuration_frontpage_gadget_url</string> </key>
<value> <string>jabberclient_contact</string> </value>
</item>
<item>
<key> <string>configuration_header_gadget_url</string> </key>
<value> <string>gadget_officejs_header.html</string> </value>
<value>
<none/>
</value>
</item>
<item>
<key> <string>configuration_jio_gadget_url</string> </key>
......@@ -305,7 +321,9 @@
</item>
<item>
<key> <string>configuration_manifest_url</string> </key>
<value> <string>gadget_jabberclient.appcache</string> </value>
<value>
<none/>
</value>
</item>
<item>
<key> <string>configuration_panel_gadget_url</string> </key>
......@@ -313,7 +331,9 @@
</item>
<item>
<key> <string>configuration_router_gadget_url</string> </key>
<value> <string>gadget_jabberclient_router.html</string> </value>
<value>
<none/>
</value>
</item>
<item>
<key> <string>configuration_translation_gadget_url</string> </key>
......@@ -540,7 +560,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>vincent</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -554,7 +574,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.17525.46862.41420</string> </value>
<value> <string>963.11902.18137.7850</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -572,7 +592,7 @@
</tuple>
<state>
<tuple>
<float>1509358218.96</float>
<float>1509715169.81</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