From: Jason Skomorowski Date: Sat, 23 Aug 2014 00:36:05 +0000 (-0400) Subject: Details widget X-Git-Tag: 1.0.0~324^2~28 X-Git-Url: http://git.indexdata.com/?p=mkws-moved-to-github.git;a=commitdiff_plain;h=696d1d9e680bfb287e5347134768f5d0e8c10567 Details widget --- diff --git a/src/mkws-team.js b/src/mkws-team.js index 4dccde4..ead2f03 100644 --- a/src/mkws-team.js +++ b/src/mkws-team.js @@ -46,6 +46,7 @@ function team($, teamName) { that.currentRecordId = function() { return m_currentRecordId; }; that.currentRecordData = function() { return m_currentRecordData; }; that.filters = function() { return m_filterSet; }; + that.gotRecords = function() { return m_gotRecords; }; // Accessor methods for individual widgets: writers that.set_sortOrder = function(val) { m_sortOrder = val }; @@ -149,6 +150,7 @@ function team($, teamName) { log("record"); // FIXME: record is async!! clearTimeout(m_paz.recordTimer); + queue("record").publish(data); var detRecordDiv = findnode(recordDetailsId(data.recid[0])); if (detRecordDiv.length) { // in case on_show was faster to redraw element @@ -303,6 +305,12 @@ function team($, teamName) { m_paz.search(m_query, m_perpage, m_sortOrder, pp2filter, undefined, params); } + // fetch record details to be retrieved from the record queue + that.fetchDetails = function(recId) { + log("fetchDetails() requesting record '" + recId + "'"); + m_paz.record(recId); + }; + // switching view between targets and records function switchView(view) { diff --git a/src/mkws-widget-main.js b/src/mkws-widget-main.js index 1ea1835..fce4779 100644 --- a/src/mkws-widget-main.js +++ b/src/mkws-widget-main.js @@ -86,6 +86,25 @@ mkws.registerWidgetType('Pager', function() { }); }); +mkws.registerWidgetType('Details', function() { + var that = this; + var recid = that.node.attr("data-mkws-recid"); + if (this.team.gotRecords()) { + that.team.fetchDetails(recid); + } else { + this.team.queue("firstrecords").subscribe(function() { + that.team.fetchDetails(recid); + }); + } + this.team.queue("record").subscribe(function(data) { + console.log(data); + if ($.inArray(recid, data.recid) > -1) { + var template = that.team.loadTemplate(that.config.template || "Record"); + that.node.html(template(data)); + } + }); + that.autosearch(); +}); mkws.registerWidgetType('Records', function() { var that = this;