From 6e8a0f79f5ad7182a0bc35308ae06c63222667ed Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sat, 23 Mar 2013 21:56:42 +0100 Subject: implemented interactions for multi user, show waiting queries on webui --- .../web/static/js/collections/InteractionList.js | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 module/web/static/js/collections/InteractionList.js (limited to 'module/web/static/js/collections') diff --git a/module/web/static/js/collections/InteractionList.js b/module/web/static/js/collections/InteractionList.js new file mode 100644 index 000000000..88651970e --- /dev/null +++ b/module/web/static/js/collections/InteractionList.js @@ -0,0 +1,47 @@ +define(['jquery', 'backbone', 'underscore', 'app', 'models/InteractionTask'], + function($, Backbone, _, App, InteractionTask) { + + return Backbone.Collection.extend({ + + model: InteractionTask, + + comparator: function(task) { + return task.get('iid'); + }, + + fetch: function(options) { + options = App.apiRequest('getInteractionTasks/0'); + + return Backbone.Collection.prototype.fetch.apply(this, options); + }, + + toJSON: function() { + var data = {queries: 0, notifications: 0, empty: false}; + + this.map(function(task) { + if (task.isNotification()) + data.notifications++; + else + data.queries++; + }); + + if (!data.queries && !data.notifications) + data.empty = true; + + return data; + }, + + // a task is waiting for attention (no notification) + hasTaskWaiting: function() { + var tasks = 0; + this.map(function(task) { + if (!task.isNotification()) + tasks++; + }); + + return tasks > 0; + } + + }); + + }); \ No newline at end of file -- cgit v1.2.3