Commit 96cb6422 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] RelationInput: always listen to the click event

This allow to separate management of click/blur events.
Blur is only used to remove the li elements.
Click check if user selected a li element.
parent 9db00ea6
/*jslint indent: 2, maxerr: 3, nomen: true, maxlen: 80 */ /*jslint indent: 2, maxerr: 3, nomen: true, maxlen: 80 */
/*global window, rJS, RSVP, URI, Handlebars, /*global window, rJS, RSVP, URI, Handlebars,
SimpleQuery, ComplexQuery, Query, QueryFactory, promiseEventListener*/ SimpleQuery, ComplexQuery, Query, QueryFactory*/
(function (window, rJS, RSVP, URI, promiseEventListener, (function (window, rJS, RSVP, URI,
SimpleQuery, ComplexQuery, Query, QueryFactory, Handlebars) { SimpleQuery, ComplexQuery, Query, QueryFactory, Handlebars) {
"use strict"; "use strict";
...@@ -286,40 +286,20 @@ ...@@ -286,40 +286,20 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared services // declared services
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.onEvent('blur', function () { .onEvent('click', function (evt) {
var gadget = this, var gadget = this,
ul, li,
new_state = { data_relative_url,
has_focus: false data_uid,
}; data_portal_type,
data_explore,
if (!gadget.state.editable) { new_state = {};
return;
} if (evt.target.tagName.toLowerCase() === 'li') {
li = evt.target;
ul = gadget.element.querySelector(".search_ul"); data_relative_url = li.getAttribute("data-relative-url");
return new RSVP.Queue() data_uid = li.getAttribute("data-uid");
.push(function () { data_portal_type = li.getAttribute("data-create-object");
return RSVP.any([
new RSVP.Queue()
.push(function () {
return RSVP.delay(200);
})
.push(function () {
return gadget.changeState(new_state);
}),
new RSVP.Queue()
.push(function () {
return promiseEventListener(ul, "click", true);
})
.push(function (event) {
// Check which 'li' element was clicked
var li = event.target,
data_relative_url = li.getAttribute("data-relative-url"),
data_uid = li.getAttribute("data-uid"),
data_portal_type = li.getAttribute("data-create-object"),
data_explore = li.getAttribute("data-explore"); data_explore = li.getAttribute("data-explore");
// User want to create a new document // User want to create a new document
...@@ -362,20 +342,17 @@ ...@@ -362,20 +342,17 @@
}); });
}); });
} }
}
}, false, false)
// No idea what has been clicked... .onEvent('blur', function (evt) {
return gadget.changeState({ if (evt.target === this.element.querySelector(".search_ul")) {
return this.changeState({
has_focus: false has_focus: false
}); });
}) }
.push(function () {
return gadget.notifyChange();
})
]);
});
}, true, false) }, true, false)
.declareMethod('checkValidity', function () { .declareMethod('checkValidity', function () {
return true; return true;
}) })
...@@ -412,5 +389,5 @@ ...@@ -412,5 +389,5 @@
}); });
}, true, false); }, true, false);
}(window, rJS, RSVP, URI, promiseEventListener, }(window, rJS, RSVP, URI,
SimpleQuery, ComplexQuery, Query, QueryFactory, Handlebars)); SimpleQuery, ComplexQuery, Query, QueryFactory, Handlebars));
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>955.20665.33421.35549</string> </value> <value> <string>955.62393.33328.52019</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -254,7 +254,7 @@ ...@@ -254,7 +254,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1479294380.88</float> <float>1481711639.59</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