Commit 48f7d3fb authored by Eugene Shen's avatar Eugene Shen

Fix enough miscellaneous bugs to pass all tests

Split local Text Post storage from the configurator Person storage,
completely rewrite URL matching regexp, handle Handlebars' =,
add field in MappingStorage to keep mapping in the main document,
always set that to true, wrap custom configs in MappingStorages,
use Rusha to generate SHA1 hashes of JSON messages for mapping,
set dav_url as the value of its input and not the placeholder,
rename connect-form to storage-form to avoid style conflicts,
wrap labels and inputs by <label>, prepend "chat-" to stuff,
remove all line breaks from all forms, make email readonly,
prepend https:// instead of http:// to protocol-less URLs,
update join_time on actual join instead of jIO discovery,
use has_joined instead of message_count > 0 for joining,
create all queries as modifications to a general_query,
stop repairing the non-replicate configurator storage,
shift the chat-hidden class instead of style.display,
and leave all the things with XXX to future commits!
parent 97465970
......@@ -10,7 +10,7 @@
<script src="handlebars.js"></script>
<script src="jio_mappingstorage.js"></script>
<script src="gadget_erp5_chat_room.js"></script>
<script class="connect-form-template" type="text/x-handlebars-template">
<script class="storage-form-template" type="text/x-handlebars-template">
<label>
<input type="radio" name="jio_type" value="erp5" required="required" {{#if jio_type_erp5}}checked="checked"{{/if}} />
ERP5,
......@@ -25,7 +25,7 @@
</label>
<label>
URL:
<input type="text" name="dav_url" placeholder="{{dav_url}}" />
<input type="text" name="dav_url" value="{{dav_url}}" />
</label>
<label>
WebDAV Username:
......@@ -43,30 +43,35 @@
jIO Configuration:
<input type="text" name="custom_configuration" value="{{jio_configuration}}" />
</label>
<br />
<input type="submit" value="Connect!" />
<input class="chat-submit" type="submit" value="Connect!" />
</script>
<script class="contact-form-template" type="text/x-handlebars-template">
<label>E-mail Address:</label>
<input type="text" name="default_email_coordinate_text"
value="{{default_email_coordinate_text}}" />
<label>Last Name:</label>
<input type="text" name="last_name" value="{{last_name}}" />
<label>First Name:</label>
<input type="text" name="first_name" value="{{first_name}}" />
<label>jIO Configuration:</label>
<input type="text" name="jio_configuration"
value="{{jio_configuration}}" />
<br />
<input type="submit" value="Update!" />
<label>
E-mail Address:
<input type="text" name="default_email_coordinate_text"
value="{{default_email_coordinate_text}}" readonly />
</label>
<label>
Last Name:
<input type="text" name="last_name" value="{{last_name}}" />
</label>
<label>
First Name:
<input type="text" name="first_name" value="{{first_name}}" />
</label>
<label>
jIO Configuration:
<input type="text" name="jio_configuration" value="{{jio_configuration}}" />
</label>
<input class="chat-submit" type="submit" value="Update!" />
</script>
</head>
<body>
<h1>Choose Shared Storage</h1>
<form class="connect-form">
<form class="chat-storage-form">
</form>
<h1>Edit Contact Details</h1>
<form class="contact-form">
<form class="chat-contact-form">
</form>
</body>
</html>
\ No newline at end of file
......@@ -241,7 +241,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>958.41620.48534.44868</string> </value>
<value> <string>958.51664.2960.4232</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -259,7 +259,7 @@
</tuple>
<state>
<tuple>
<float>1492008152.73</float>
<float>1492679668.09</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -16,7 +16,6 @@
.declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_repair", "jio_repair")
/* Render the gadget.
......@@ -33,15 +32,15 @@
var gadget = this;
return gadget.jio_get(gadget.state.jio_id)
.push(function (result) {
var connect_form_template = Handlebars.compile(
var storage_form_template = Handlebars.compile(
Object.getPrototypeOf(gadget).constructor.__template_element
.querySelector(".connect-form-template").innerHTML
.querySelector(".storage-form-template").innerHTML
),
contact_form_template = Handlebars.compile(
Object.getPrototypeOf(gadget).constructor.__template_element
.querySelector(".contact-form-template").innerHTML
),
connect_form_param_dict = {
storage_form_param_dict = {
erp5_url: gadget.state.default_erp5_url,
dav_url: gadget.state.default_dav_url,
jio_configuration: result.jio_configuration
......@@ -49,19 +48,19 @@
switch (gadget.state.default_jio_type) {
case "erp5":
connect_form_param_dict.jio_type_erp5 = true;
storage_form_param_dict.jio_type_erp5 = true;
break;
case "dav":
connect_form_param_dict.jio_type_dav = true;
storage_form_param_dict.jio_type_dav = true;
break;
case "custom":
connect_form_param_dict.jio_type_custom = true;
storage_form_param_dict.jio_type_custom = true;
break;
}
gadget.element.querySelector(".connect-form").innerHTML =
connect_form_template(connect_form_param_dict);
gadget.element.querySelector(".contact-form").innerHTML =
gadget.element.querySelector(".chat-storage-form").innerHTML =
storage_form_template(storage_form_param_dict);
gadget.element.querySelector(".chat-contact-form").innerHTML =
contact_form_template(result);
});
})
......@@ -82,11 +81,23 @@
remote_sub_storage,
fields = event.target.elements;
/* The goal of jIO MappingStorage is to ensure that all Text Posts
* have exactly the same IDs in all MappingStorage sub_storages,
* by storing a unique deterministic ID for each Text Post
* in its mapping property. This allows repair to correctly
* synchronize Text Posts across many storages simultaneously.
* If the implementation of MappingStorage changes in the future,
* please carefully consider other options to synchronize
* across many storages simultaneously, since that is the
* only reason MappingStorage is used, before taking action.
*/
switch (fields.jio_type.value) {
case "erp5":
remote_sub_storage = {
type: "mapping",
id: ["equalSubProperty", "mapping"],
keep_map_id_in_main_document: true,
query: gadget.state.mapping_query,
sub_storage: {
type: "erp5",
......@@ -110,7 +121,13 @@
};
break;
case "custom":
remote_sub_storage = JSON.parse(fields.custom_configuration.value);
remote_sub_storage = {
type: "mapping",
id: ["equalSubProperty", "mapping"],
keep_map_id_in_main_document: true,
query: gadget.state.mapping_query,
sub_storage: JSON.parse(fields.custom_configuration.value)
};
break;
}
......@@ -118,7 +135,7 @@
type: "replicate",
use_remote_post: true,
conflict_handling: 2,
query: gadget.state.query,
query: gadget.state.sorted_query,
local_sub_storage: gadget.state.local_sub_storage,
remote_sub_storage: remote_sub_storage
});
......@@ -147,10 +164,7 @@
jio_document[fields[i].name] = fields[i].value;
}
}
return gadget.jio_put(gadget.state.jio_id, jio_document)
.push(function () {
return gadget.jio_repair();
});
return gadget.jio_put(gadget.state.jio_id, jio_document);
})
......@@ -179,10 +193,10 @@
.onEvent("submit", function (event) {
var gadget = this;
if (event.target.className === "connect-form") {
if (event.target.className === "chat-storage-form") {
return gadget.createJioReplicate(event);
}
if (event.target.className === "contact-form") {
if (event.target.className === "chat-contact-form") {
return gadget.updateContact(event);
}
});
......
......@@ -237,7 +237,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>958.44541.58107.9130</string> </value>
<value> <string>958.54709.48866.24405</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -255,7 +255,7 @@
</tuple>
<state>
<tuple>
<float>1492188930.99</float>
<float>1492794053.33</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -7,6 +7,7 @@
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="handlebars.js"></script>
<script src="rusha.js"></script>
<script src="gadget_global.js"></script>
<script src="gadget_erp5_page_chat_box.js"></script>
<script class="chat-list-template" type="text/x-handlebars-template">
......@@ -33,10 +34,10 @@
<div class="chat-form-panel">
<form class="join-form">
<input type="text" name="content" />
<input type="submit" value="Join room!" />
<input class="chat-submit" type="submit" value="Join room!" />
</form>
<form class="edit-form">
<input type="submit" value="Edit contact!" />
<input class="chat-submit" type="submit" value="Edit contact!" />
</form>
</div>
</div>
......@@ -48,7 +49,7 @@
</ul>
<form class="send-form">
<input type="text" name="content" />
<input type="submit" name="send" value="Send!" />
<input class="chat-submit" type="submit" name="send" value="Send!" />
</form>
</div>
</div>
......
......@@ -241,7 +241,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>958.41714.1894.49698</string> </value>
<value> <string>958.54482.29236.23739</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -259,7 +259,7 @@
</tuple>
<state>
<tuple>
<float>1492008152.15</float>
<float>1492783825.69</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -237,7 +237,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>958.44733.2615.38656</string> </value>
<value> <string>958.54814.24278.28364</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -255,7 +255,7 @@
</tuple>
<state>
<tuple>
<float>1492189329.87</float>
<float>1492794457.43</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -191,6 +191,7 @@
this._query = spec.query || {};
this._map_id = spec.id || ["equalSubId"];
this._id_mapped = (spec.id !== undefined) ? spec.id[1] : false;
this._keep_map_id_in_main_document = spec.keep_map_id_in_main_document;
if (this._query.query !== undefined) {
this._query.query = QueryFactory.create(this._query.query);
......@@ -255,7 +256,10 @@
function mapToMainDocument(storage, sub_doc, sub_id) {
var doc = {},
property,
property_list = [storage._id_mapped];
property_list = [];
if (!storage._keep_map_id_in_main_document) {
property_list.push(storage._id_mapped);
}
for (property in storage._mapping_dict) {
if (storage._mapping_dict.hasOwnProperty(property)) {
property_list.push(mapToMainProperty(
......
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1492185269.35</float>
<float>1492787013.94</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