Commit eed166fb authored by Romain Courteaud's avatar Romain Courteaud

[erp5_xhtml_style/web_renderjs_ui] Update RSVP

parent c219c40a
......@@ -379,10 +379,10 @@ define("rsvp/events",
__exports__.EventTarget = EventTarget;
});
define("rsvp/hash",
["rsvp/defer","exports"],
["rsvp/promise","exports"],
function(__dependency1__, __exports__) {
"use strict";
var defer = __dependency1__.defer;
var Promise = __dependency1__.Promise;
function size(object) {
var s = 0;
......@@ -395,38 +395,61 @@ define("rsvp/hash",
}
function hash(promises) {
var results = {}, deferred = defer(), remaining = size(promises);
function canceller() {
var promise,
key;
for (key in promises) {
if (promises.hasOwnProperty(key)) {
promise = promises[key];
if (promise && typeof promise.then === 'function' &&
typeof promise.cancel === 'function') {
promise.cancel();
}
}
}
}
return new Promise(function(resolve, reject) {
var results = {}, remaining = size(promises),
promise;
if (remaining === 0) {
deferred.resolve({});
resolve(results);
}
var resolver = function(prop) {
function resolver(key) {
return function(value) {
resolveAll(prop, value);
};
resolveAll(key, value);
};
}
var resolveAll = function(prop, value) {
results[prop] = value;
function resolveAll(key, value) {
results[key] = value;
if (--remaining === 0) {
deferred.resolve(results);
resolve(results);
}
}
};
var rejectAll = function(error) {
deferred.reject(error);
};
function cancelAll(rejectionValue) {
reject(rejectionValue);
canceller();
}
for (var prop in promises) {
if (promises[prop] && typeof promises[prop].then === 'function') {
promises[prop].then(resolver(prop), rejectAll);
promise = promises[prop];
if (promise && typeof promise.then === 'function') {
promise.then(resolver(prop), cancelAll);
} else {
resolveAll(prop, promises[prop]);
resolveAll(prop, promise);
}
}
return deferred.promise;
}, canceller
);
}
......
......@@ -148,11 +148,13 @@
</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/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -196,16 +198,20 @@
</item>
</dictionary>
</list>
</tuple>
</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/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -228,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>967.36619.48069.16759</string> </value>
<value> <string>977.38881.34981.23125</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1526454424.27</float>
<float>1576579789.68</float>
<string>UTC</string>
</tuple>
</state>
......@@ -255,16 +261,20 @@
</item>
</dictionary>
</list>
</tuple>
</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/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -312,7 +322,9 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -379,10 +379,10 @@ define("rsvp/events",
__exports__.EventTarget = EventTarget;
});
define("rsvp/hash",
["rsvp/defer","exports"],
["rsvp/promise","exports"],
function(__dependency1__, __exports__) {
"use strict";
var defer = __dependency1__.defer;
var Promise = __dependency1__.Promise;
function size(object) {
var s = 0;
......@@ -395,38 +395,61 @@ define("rsvp/hash",
}
function hash(promises) {
var results = {}, deferred = defer(), remaining = size(promises);
function canceller() {
var promise,
key;
for (key in promises) {
if (promises.hasOwnProperty(key)) {
promise = promises[key];
if (promise && typeof promise.then === 'function' &&
typeof promise.cancel === 'function') {
promise.cancel();
}
}
}
}
return new Promise(function(resolve, reject) {
var results = {}, remaining = size(promises),
promise;
if (remaining === 0) {
deferred.resolve({});
resolve(results);
}
var resolver = function(prop) {
function resolver(key) {
return function(value) {
resolveAll(prop, value);
};
resolveAll(key, value);
};
}
var resolveAll = function(prop, value) {
results[prop] = value;
function resolveAll(key, value) {
results[key] = value;
if (--remaining === 0) {
deferred.resolve(results);
resolve(results);
}
}
};
var rejectAll = function(error) {
deferred.reject(error);
};
function cancelAll(rejectionValue) {
reject(rejectionValue);
canceller();
}
for (var prop in promises) {
if (promises[prop] && typeof promises[prop].then === 'function') {
promises[prop].then(resolver(prop), rejectAll);
promise = promises[prop];
if (promise && typeof promise.then === 'function') {
promise.then(resolver(prop), cancelAll);
} else {
resolveAll(prop, promises[prop]);
resolveAll(prop, promise);
}
}
return deferred.promise;
}, canceller
);
}
......
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