Commit 7a0a695e authored by Romain Courteaud's avatar Romain Courteaud

erp5_web_renderjs_ui: fix cancellation handling

parent 24e948e9
......@@ -248,8 +248,7 @@
return RSVP.Queue()
.push(function () {
var plane = gadget.element.querySelector("a"),
ul = gadget.element.querySelector(".search_ul"),
translation_promise;
ul = gadget.element.querySelector(".search_ul");
plane.href = '';
// uid is known
......@@ -315,114 +314,112 @@
return RSVP.delay(200);
})
.push(function () {
translation_promise = gadget.getTranslationList([
'Create New',
'Explore the Search Result List'
]);
return gadget.jio_allDocs({
query: Query.objectToSearchText(new ComplexQuery({
operator: "AND",
query_list: [
QueryFactory.create(
new URI(gadget.state.query).query(true).query
),
new SimpleQuery({
key: gadget.state.catalog_index,
value: value_text
})
]
})),
limit: [0, 10],
select_list: [gadget.state.catalog_index, "uid"],
sort_on: JSON.parse(gadget.state.sort_list_json)
})
.push(function (result) {
return new RSVP.Queue()
.push(function () {
return RSVP.all([result, translation_promise]);
})
.push(function (result_list) {
var i,
row,
portal_type_list,
translated_portal_type_list,
fragment_element = document.createDocumentFragment(),
li_element;
plane.className = JUMP_UNKNOWN_CLASS_STR;
// Documents
return new RSVP.Queue(RSVP.all([
gadget.jio_allDocs({
query: Query.objectToSearchText(new ComplexQuery({
operator: "AND",
query_list: [
QueryFactory.create(
new URI(gadget.state.query).query(true).query
),
new SimpleQuery({
key: gadget.state.catalog_index,
value: value_text
})
]
})),
limit: [0, 10],
select_list: [gadget.state.catalog_index, "uid"],
sort_on: JSON.parse(gadget.state.sort_list_json)
}),
gadget.getTranslationList([
'Create New',
'Explore the Search Result List'
])
]))
.push(function (result_list) {
var i,
row,
portal_type_list,
translated_portal_type_list,
fragment_element = document.createDocumentFragment(),
li_element;
plane.className = JUMP_UNKNOWN_CLASS_STR;
// Documents
// <li class="ui-icon-sign-in ui-btn-icon-right" data-relative-url="{{id}}"
// data-uid="{{uid}}">{{value}}</li>
for (i = 0; i < result_list[0].data.rows.length; i += 1) {
row = result_list[0].data.rows[i];
li_element = document.createElement('li');
li_element.setAttribute('class',
'ui-icon-sign-in ui-btn-icon-right');
li_element.setAttribute('data-relative-url', row.id);
li_element.setAttribute('data-uid', row.value.uid);
li_element.textContent =
row.value[gadget.state.catalog_index];
fragment_element.appendChild(li_element);
}
// New documents
for (i = 0; i < result_list[0].data.rows.length; i += 1) {
row = result_list[0].data.rows[i];
li_element = document.createElement('li');
li_element.setAttribute('class',
'ui-icon-sign-in ui-btn-icon-right');
li_element.setAttribute('data-relative-url', row.id);
li_element.setAttribute('data-uid', row.value.uid);
li_element.textContent =
row.value[gadget.state.catalog_index];
fragment_element.appendChild(li_element);
}
// New documents
// <li class="ui-icon-plus ui-btn-icon-right" data-i18n="Create New"
// data-create-object="{{value}}" name="{{name}}">Create New
// <span> {{name}}: {{../value}}</span></li>
if (gadget.state.allow_creation) {
portal_type_list =
JSON.parse(gadget.state.portal_types);
translated_portal_type_list =
JSON.parse(gadget.state.translated_portal_types);
for (i = 0; i < portal_type_list.length; i += 1) {
li_element = document.createElement('li');
li_element.setAttribute('class',
'ui-icon-plus ui-btn-icon-right');
li_element.setAttribute('data-create-object',
portal_type_list[i]);
li_element.setAttribute('name',
translated_portal_type_list[i]);
li_element.textContent =
result_list[1][0] + ' ' +
translated_portal_type_list[i] +
': ' + value_text;
fragment_element.appendChild(li_element);
}
}
// Explore
// <li class="ui-icon-search ui-btn-icon-right" data-explore=true
// data-i18n="Explore the Search Result List" ></li>
if (gadget.state.allow_creation) {
portal_type_list =
JSON.parse(gadget.state.portal_types);
translated_portal_type_list =
JSON.parse(gadget.state.translated_portal_types);
for (i = 0; i < portal_type_list.length; i += 1) {
li_element = document.createElement('li');
li_element.setAttribute('class',
'ui-icon-search ui-btn-icon-right');
li_element.setAttribute('data-explore',
true);
li_element.textContent = result_list[1][1];
'ui-icon-plus ui-btn-icon-right');
li_element.setAttribute('data-create-object',
portal_type_list[i]);
li_element.setAttribute('name',
translated_portal_type_list[i]);
li_element.textContent =
result_list[1][0] + ' ' +
translated_portal_type_list[i] +
': ' + value_text;
fragment_element.appendChild(li_element);
}
}
while (ul.firstChild) {
ul.removeChild(ul.firstChild);
}
ul.appendChild(fragment_element);
});
}, function (error) {
if (error instanceof Error &&
error.hash &&
error.hash.expected &&
error.hash.expected.length === 1 &&
error.hash.expected[0] === "'QUOTE'") {
return gadget.getTranslationList([
"Invalid search criteria"
])
.push(function (translation_list) {
return gadget.notifyInvalid(translation_list[0]);
});
// Explore
// <li class="ui-icon-search ui-btn-icon-right" data-explore=true
// data-i18n="Explore the Search Result List" ></li>
li_element = document.createElement('li');
li_element.setAttribute('class',
'ui-icon-search ui-btn-icon-right');
li_element.setAttribute('data-explore',
true);
li_element.textContent = result_list[1][1];
fragment_element.appendChild(li_element);
while (ul.firstChild) {
ul.removeChild(ul.firstChild);
}
throw error;
ul.appendChild(fragment_element);
});
}, function (error) {
if (error instanceof Error &&
error.hash &&
error.hash.expected &&
error.hash.expected.length === 1 &&
error.hash.expected[0] === "'QUOTE'") {
return gadget.getTranslationList([
"Invalid search criteria"
])
.push(function (translation_list) {
return gadget.notifyInvalid(translation_list[0]);
});
}
throw error;
});
});
......
......@@ -154,173 +154,185 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1467996017.5</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</tuple>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1467996017.5</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>978.15497.3144.35652</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1567695948.47</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>978.15561.54943.25565</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1583400764.01</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_processing_state</string> </key>
<value> <string>empty</string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>0.0.0.0</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1541669313.0</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_processing_state</string> </key>
<value> <string>empty</string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>0.0.0.0</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1541669313.0</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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