Commit 436184d3 authored by Sven Franck's avatar Sven Franck

erp5_web_renderjs_ui: re-enable allow_jump in relationString

parent db3793ce
...@@ -213,6 +213,7 @@ promiseEventListener */\n ...@@ -213,6 +213,7 @@ promiseEventListener */\n
len = my_result_list.length,\n len = my_result_list.length,\n
prefix = "",\n prefix = "",\n
item,\n item,\n
value_dict,\n
result,\n result,\n
i;\n i;\n
\n \n
...@@ -227,7 +228,8 @@ promiseEventListener */\n ...@@ -227,7 +228,8 @@ promiseEventListener */\n
list.appendChild(head);\n list.appendChild(head);\n
\n \n
for (i = 0; i < len; i += 1) {\n for (i = 0; i < len; i += 1) {\n
result = my_result_list[i].value;\n result = my_result_list[i];\n
value_dict = result.value;\n
item = document.createElement("li");\n item = document.createElement("li");\n
item.className = str;\n item.className = str;\n
\n \n
...@@ -235,8 +237,9 @@ promiseEventListener */\n ...@@ -235,8 +237,9 @@ promiseEventListener */\n
// NOTE: if doing more complex UI, beware the textContent value won\'t\n // NOTE: if doing more complex UI, beware the textContent value won\'t\n
// work, because currently it\'s used to retrieve the link from\n // work, because currently it\'s used to retrieve the link from\n
// the last autocomplete query results!\n // the last autocomplete query results!\n
item.textContent = result[index];\n item.textContent = value_dict[index];\n
item.setAttribute("name", result.uid);\n item.setAttribute("data-relative-url", result.id);\n
item.setAttribute("name", value_dict.uid);\n
list.appendChild(item);\n list.appendChild(item);\n
}\n }\n
\n \n
...@@ -258,9 +261,33 @@ promiseEventListener */\n ...@@ -258,9 +261,33 @@ promiseEventListener */\n
my_gadget.notifyChange()\n my_gadget.notifyChange()\n
]);\n ]);\n
}\n }\n
\n
// set the link to jump to\n
function setRelationJump(my_gadget, my_initial_call, my_selected_value) {\n
var props = my_gadget.property_dict,\n
field_json = props.field_json,\n
target_url = my_selected_value || field_json.relation_item_relative_url,\n
is_init = my_initial_call === true;\n
\n
if (target_url && field_json.allow_jump) {\n
return new RSVP.Queue()\n
.push(function () {\n
return my_gadget.whoWantToDisplayThis(target_url);\n
})\n
.push(function (my_url) {\n
var plane = props.plane;\n
plane.href = my_url;\n
plane.className = "ui-btn ui-corner-all ui-btn-icon-notext " +\n
"ui-icon-plane ui-shadow-inset ui-btn-inline";\n
if (is_init === false) {\n
return notifyChange(my_gadget);\n
}\n
});\n
}\n
}\n
\n \n
// trigger autocomplete for field value, on render() with value only sets link\n // trigger autocomplete for field value, on render() with value only sets link\n
function triggerAutocomplete(my_gadget, my_value, my_initial_call) {\n function triggerAutocomplete(my_gadget, my_value) {\n
var props = my_gadget.property_dict,\n var props = my_gadget.property_dict,\n
field_json = props.field_json,\n field_json = props.field_json,\n
index = field_json.catalog_index,\n index = field_json.catalog_index,\n
...@@ -268,7 +295,8 @@ promiseEventListener */\n ...@@ -268,7 +295,8 @@ promiseEventListener */\n
lines = field_json.lines || 11,\n lines = field_json.lines || 11,\n
select_list = [index, "uid"],\n select_list = [index, "uid"],\n
query_string = " AND (" + index + \':"\' + my_value + \'")\',\n query_string = " AND (" + index + \':"\' + my_value + \'")\',\n
result_dict;\n result_dict,\n
no_results;\n
\n \n
delete props.selected_uid;\n delete props.selected_uid;\n
\n \n
...@@ -289,14 +317,10 @@ promiseEventListener */\n ...@@ -289,14 +317,10 @@ promiseEventListener */\n
}).push(function (my_result) {\n }).push(function (my_result) {\n
result_dict = my_result.data;\n result_dict = my_result.data;\n
props.spinner.className = "ui-hidden-accessible";\n props.spinner.className = "ui-hidden-accessible";\n
no_results = result_dict.total_rows === 0;\n
\n \n
// skip showing single result on render(), only set link\n // show "new" tag\n
// if (my_initial_call) {\n if (no_results && field_json.allow_creation) {\n
// return {"target": {"textContent": my_value}};\n
// }\n
\n
// show "new" tag if no results and creation allowed\n
if (result_dict.total_rows === 0 && field_json.allow_creation) {\n
return new RSVP.Queue()\n return new RSVP.Queue()\n
.push(function () {\n .push(function () {\n
props.wrapper.appendChild(createNewTag(my_gadget));\n props.wrapper.appendChild(createNewTag(my_gadget));\n
...@@ -313,23 +337,26 @@ promiseEventListener */\n ...@@ -313,23 +337,26 @@ promiseEventListener */\n
var original_value = field_json.value || field_json.default || "";\n var original_value = field_json.value || field_json.default || "";\n
clearResults(my_gadget);\n clearResults(my_gadget);\n
props.wrapper.querySelector("input").value = original_value;\n props.wrapper.querySelector("input").value = original_value;\n
return triggerAutocomplete(my_gadget, original_value, true);\n return triggerAutocomplete(my_gadget, original_value);\n
});\n });\n
}\n }\n
\n \n
// default autocomplete\n // default autocomplete\n
// XXX: on small displays JQM will toggle headers, find way to prevent!\n
return new RSVP.Queue()\n return new RSVP.Queue()\n
.push(function () {\n .push(function () {\n
var list;\n var list;\n
props.wrapper.appendChild(createResults(result_dict.rows, index));\n
list = props.wrapper.querySelector("ul");\n
\n \n
return RSVP.any([\n if (no_results === false) {\n
promiseEventListener(list, "click", true),\n props.wrapper.appendChild(createResults(result_dict.rows, index));\n
promiseEventListener(list, "touchend", true)\n list = props.wrapper.querySelector("ul");\n
]);\n \n
return RSVP.any([\n
promiseEventListener(list, "click", true),\n
promiseEventListener(list, "touchend", true)\n
]);\n
}\n
});\n });\n
\n
}).push(undefined, function (my_error) {\n }).push(undefined, function (my_error) {\n
if (my_error instanceof RSVP.CancellationError) {\n if (my_error instanceof RSVP.CancellationError) {\n
props.spinner.className = "ui-hidden-accessible";\n props.spinner.className = "ui-hidden-accessible";\n
...@@ -337,41 +364,20 @@ promiseEventListener */\n ...@@ -337,41 +364,20 @@ promiseEventListener */\n
}\n }\n
throw my_error;\n throw my_error;\n
}).push(function (my_selection_event) {\n }).push(function (my_selection_event) {\n
var selected_value,\n var element,\n
record,\n jump_url;\n
i,\n
prop;\n
\n \n
if (my_selection_event) {\n if (my_selection_event) {\n
\n \n
// take entered text, set to input and clear list options\n // take entered text, set to input and clear list options\n
selected_value = my_selection_event.target.textContent;\n element = my_selection_event.target;\n
props.selected_uid = my_selection_event.target.getAttribute("name");\n jump_url = element.getAttribute("data-relative-url");\n
props.selected_uid = element.getAttribute("name");\n
props.valid = true;\n props.valid = true;\n
props.wrapper.querySelector("input").value = selected_value;\n props.wrapper.querySelector("input").value = element.textContent;\n
clearResults(my_gadget, "skip");\n clearResults(my_gadget, "skip");\n
\n \n
// retrieve url if "allow_jump" is set\n return setRelationJump(my_gadget, undefined, jump_url);\n
if (props.field_json.allow_jump) {\n
for (i = 0; i < result_dict.total_rows; i += 1) {\n
record = result_dict.rows[i].value;\n
for (prop in record) {\n
if (record.hasOwnProperty(prop) &&\n
record[prop] === selected_value) {\n
return my_gadget.whoWantToDisplayThis(result_dict.rows[i].id);\n
}\n
}\n
}\n
}\n
}\n
}).push(function (my_url) {\n
if (my_url) {\n
props.plane.href = my_url;\n
props.plane.className = "ui-btn ui-corner-all ui-btn-icon-notext " +\n
"ui-icon-plane ui-shadow-inset ui-btn-inline";\n
if (my_initial_call === undefined) {\n
return notifyChange(my_gadget);\n
}\n
}\n }\n
});\n });\n
}\n }\n
...@@ -435,10 +441,9 @@ promiseEventListener */\n ...@@ -435,10 +441,9 @@ promiseEventListener */\n
// input.setAttribute(\'disabled\', \'disabled\');\n // input.setAttribute(\'disabled\', \'disabled\');\n
}\n }\n
\n \n
/* // set relation field links (without showing 1 autocomplete result)\n
if (value) {\n if (value) {\n
return triggerAutocomplete(field_gadget, value, true);\n return setRelationJump(field_gadget, true);\n
} */\n }\n
})\n })\n
\n \n
// get content (needs hidden fields, too, when creating new records)\n // get content (needs hidden fields, too, when creating new records)\n
...@@ -590,6 +595,8 @@ promiseEventListener */\n ...@@ -590,6 +595,8 @@ promiseEventListener */\n
- OK fix double list because not clearing what previous chain appended to DOM\n - OK fix double list because not clearing what previous chain appended to DOM\n
- OK cleanup\n - OK cleanup\n
- OK fix textinput css, not generic enough\n - OK fix textinput css, not generic enough\n
- OK reimplement setting link without calling allDocs\n
- on small displays JQM will toggle headers, find way to prevent!\n
- fix broken promise chain\n - fix broken promise chain\n
- test\n - test\n
- keyboard speed test\n - keyboard speed test\n
...@@ -597,6 +604,9 @@ promiseEventListener */\n ...@@ -597,6 +604,9 @@ promiseEventListener */\n
- do multiRelationfield\n - do multiRelationfield\n
- find way to digest response of erp5? submit should clean input\n - find way to digest response of erp5? submit should clean input\n
- add column_list parameter to pass more than title = "John Smith", render?\n - add column_list parameter to pass more than title = "John Smith", render?\n
\n
\n
\n
*/\n */\n
...@@ -735,7 +745,7 @@ promiseEventListener */\n ...@@ -735,7 +745,7 @@ promiseEventListener */\n
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>941.663.47886.51865</string> </value> <value> <string>941.954.47433.61593</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -753,7 +763,7 @@ promiseEventListener */\n ...@@ -753,7 +763,7 @@ promiseEventListener */\n
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1424080843.6</float> <float>1424099091.91</float>
<string>GMT</string> <string>GMT</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