From aa4916dc2005d71d36bca9a7b58713e6d5fbc004 Mon Sep 17 00:00:00 2001 From: Rufus Pollock Date: Mon, 9 Jul 2012 11:03:23 +0100 Subject: [PATCH] [build][s]: usual build. --- dist/recline.css | 17 +---- dist/recline.dataset.js | 41 +++++++---- dist/recline.js | 153 ++++++++-------------------------------- 3 files changed, 62 insertions(+), 149 deletions(-) diff --git a/dist/recline.css b/dist/recline.css index fe26df10..cc0c58e0 100644 --- a/dist/recline.css +++ b/dist/recline.css @@ -39,12 +39,9 @@ table.recline-grid { white-space: normal; } -.recline-grid td { +.recline-grid tbody tr { vertical-align: top; -} - -.recline-grid tr td:first-child, .recline-grid tr th:first-child { - width: 20px; + border-bottom: solid 1px #ccc; } .recline-grid tbody tr:last-child { @@ -56,9 +53,7 @@ table.recline-grid { } /* direct borrowing from twitter buttons */ -.recline-grid th, -.transform-column-view .expression-preview-table-wrapper th -{ +.recline-grid th { background-color: #e6e6e6; background-repeat: no-repeat; background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), color-stop(25%, #ffffff), to(#e6e6e6)); @@ -208,12 +203,6 @@ div.data-table-cell-content-numeric > a.data-table-cell-edit { * Read-only mode *********************************************************/ -.recline-read-only .recline-grid.no-hidden tr td:first-child, -.recline-read-only .recline-grid.no-hidden tr th:first-child -{ - display: none; -} - .recline-read-only .recline-grid .write-op, .recline-read-only .recline-grid a.data-table-cell-edit { diff --git a/dist/recline.dataset.js b/dist/recline.dataset.js index 0b413101..4054a254 100644 --- a/dist/recline.dataset.js +++ b/dist/recline.dataset.js @@ -202,6 +202,7 @@ my.Dataset = Backbone.Model.extend({ self.recordCount = queryResult.total; var docs = _.map(queryResult.hits, function(hit) { var _doc = new my.Record(hit); + _doc.fields = self.fields; _doc.bind('change', function(doc) { self._changes.updates.push(doc.toJSON()); }); @@ -254,18 +255,9 @@ my.Dataset = Backbone.Model.extend({ return dfd.promise(); }, - // ### recordSummary - // - // Get a simple html summary of a Dataset record in form of key/value list + // Deprecated (as of v0.5) - use record.summary() recordSummary: function(record) { - var html = '
'; - this.fields.each(function(field) { - if (field.id != 'id') { - html += '
' + field.get('label') + ': ' + record.getFieldValue(field) + '
'; - } - }); - html += '
'; - return html; + return record.summary(); }, // ### _backendFromString(backendString) @@ -329,14 +321,22 @@ my.Dataset.restore = function(state) { return dataset; }; -// ## A Record (aka Row) +// ## A Record // -// A single entry or row in the dataset +// A single record (or row) in the dataset my.Record = Backbone.Model.extend({ constructor: function Record() { Backbone.Model.prototype.constructor.apply(this, arguments); }, + // ### initialize + // + // Create a Record + // + // You usually will not do this directly but will have records created by + // Dataset e.g. in query method + // + // Certain methods require presence of a fields attribute (identical to that on Dataset) initialize: function() { _.bindAll(this, 'getFieldValue'); }, @@ -365,6 +365,21 @@ my.Record = Backbone.Model.extend({ return val; }, + // ### summary + // + // Get a simple html summary of this record in form of key/value list + summary: function(record) { + var self = this; + var html = '
'; + this.fields.each(function(field) { + if (field.id != 'id') { + html += '
' + field.get('label') + ': ' + self.getFieldValue(field) + '
'; + } + }); + html += '
'; + return html; + }, + // Override Backbone save, fetch and destroy so they do nothing // Instead, Dataset object that created this Record should take care of // handling these changes (discovery will occur via event notifications) diff --git a/dist/recline.js b/dist/recline.js index b18447e5..6a052346 100644 --- a/dist/recline.js +++ b/dist/recline.js @@ -39,7 +39,7 @@ this.recline.Backend.CSV = this.recline.Backend.CSV || {}; }); } else if (dataset.url) { $.get(dataset.url).done(function(data) { - var rows = my.parseCSV(dataset.data, dataset); + var rows = my.parseCSV(data, dataset); dfd.resolve({ records: rows, useMemoryStore: true @@ -1086,6 +1086,7 @@ my.Dataset = Backbone.Model.extend({ self.recordCount = queryResult.total; var docs = _.map(queryResult.hits, function(hit) { var _doc = new my.Record(hit); + _doc.fields = self.fields; _doc.bind('change', function(doc) { self._changes.updates.push(doc.toJSON()); }); @@ -1138,18 +1139,9 @@ my.Dataset = Backbone.Model.extend({ return dfd.promise(); }, - // ### recordSummary - // - // Get a simple html summary of a Dataset record in form of key/value list + // Deprecated (as of v0.5) - use record.summary() recordSummary: function(record) { - var html = '
'; - this.fields.each(function(field) { - if (field.id != 'id') { - html += '
' + field.get('label') + ': ' + record.getFieldValue(field) + '
'; - } - }); - html += '
'; - return html; + return record.summary(); }, // ### _backendFromString(backendString) @@ -1213,14 +1205,22 @@ my.Dataset.restore = function(state) { return dataset; }; -// ## A Record (aka Row) +// ## A Record // -// A single entry or row in the dataset +// A single record (or row) in the dataset my.Record = Backbone.Model.extend({ constructor: function Record() { Backbone.Model.prototype.constructor.apply(this, arguments); }, + // ### initialize + // + // Create a Record + // + // You usually will not do this directly but will have records created by + // Dataset e.g. in query method + // + // Certain methods require presence of a fields attribute (identical to that on Dataset) initialize: function() { _.bindAll(this, 'getFieldValue'); }, @@ -1249,6 +1249,21 @@ my.Record = Backbone.Model.extend({ return val; }, + // ### summary + // + // Get a simple html summary of this record in form of key/value list + summary: function(record) { + var self = this; + var html = '
'; + this.fields.each(function(field) { + if (field.id != 'id') { + html += '
' + field.get('label') + ': ' + self.getFieldValue(field) + '
'; + } + }); + html += '
'; + return html; + }, + // Override Backbone save, fetch and destroy so they do nothing // Instead, Dataset object that created this Record should take care of // handling these changes (discovery will occur via event notifications) @@ -1940,10 +1955,6 @@ my.Grid = Backbone.View.extend({ }, events: { - 'click .column-header-menu .data-table-menu li a': 'onColumnHeaderClick', - 'click .row-header-menu': 'onRowHeaderClick', - 'click .root-header-menu': 'onRootHeaderClick', - 'click .data-table-menu li a': 'onMenuClick', // does not work here so done at end of render function // 'scroll .recline-grid tbody': 'onHorizontalScroll' }, @@ -1951,74 +1962,6 @@ my.Grid = Backbone.View.extend({ // ====================================================== // Column and row menus - onColumnHeaderClick: function(e) { - this.tempState.currentColumn = $(e.target).closest('.column-header').attr('data-field'); - }, - - onRowHeaderClick: function(e) { - this.tempState.currentRow = $(e.target).parents('tr:first').attr('data-id'); - }, - - onRootHeaderClick: function(e) { - var tmpl = ' \ - {{#columns}} \ -
  • Show column: {{.}}
  • \ - {{/columns}}'; - var tmp = Mustache.render(tmpl, {'columns': this.state.get('hiddenFields')}); - this.el.find('.root-header-menu .dropdown-menu').html(tmp); - }, - - onMenuClick: function(e) { - var self = this; - e.preventDefault(); - var actions = { - bulkEdit: function() { self.showTransformColumnDialog('bulkEdit', {name: self.tempState.currentColumn}); }, - facet: function() { - self.model.queryState.addFacet(self.tempState.currentColumn); - }, - facet_histogram: function() { - self.model.queryState.addHistogramFacet(self.tempState.currentColumn); - }, - filter: function() { - self.model.queryState.addTermFilter(self.tempState.currentColumn, ''); - }, - sortAsc: function() { self.setColumnSort('asc'); }, - sortDesc: function() { self.setColumnSort('desc'); }, - hideColumn: function() { self.hideColumn(); }, - showColumn: function() { self.showColumn(e); }, - deleteRow: function() { - var self = this; - var doc = _.find(self.model.records.models, function(doc) { - // important this is == as the currentRow will be string (as comes - // from DOM) while id may be int - return doc.id == self.tempState.currentRow; - }); - doc.destroy().then(function() { - self.model.records.remove(doc); - self.trigger('recline:flash', {message: "Row deleted successfully"}); - }).fail(function(err) { - self.trigger('recline:flash', {message: "Errorz! " + err}); - }); - } - }; - actions[$(e.target).attr('data-action')](); - }, - - showTransformColumnDialog: function() { - var self = this; - var view = new my.ColumnTransform({ - model: this.model - }); - // pass the flash message up the chain - view.bind('recline:flash', function(flash) { - self.trigger('recline:flash', flash); - }); - view.state = this.tempState; - view.render(); - this.el.append(view.el); - view.el.modal(); - }, - setColumnSort: function(order) { var sort = [{}]; sort[0][this.tempState.currentColumn] = {order: order}; @@ -2052,33 +1995,8 @@ my.Grid = Backbone.View.extend({ \ \ \ - {{#notEmpty}} \ - \ - {{/notEmpty}} \ {{#fields}} \ - \ {{/fields}} \ @@ -2181,14 +2099,6 @@ my.GridRow = Backbone.View.extend({ }, template: ' \ - \ {{#cells}} \
    \ -
    \ - \ - \ -
    \ - \ -
    \ - \ + \ {{label}} \ \ -
    \ - \ - \ -
    \ -
    \
    \ @@ -3721,7 +3631,7 @@ my.Timeline = Backbone.View.extend({ "startDate": start, "endDate": end, "headline": String(record.get('title') || ''), - "text": record.get('description') || this.model.recordSummary(record) + "text": record.get('description') || record.summary() }; return tlEntry; } else { @@ -4365,7 +4275,6 @@ my.QueryEditor = Backbone.View.extend({ }, render: function() { var tmplData = this.model.toJSON(); - tmplData.to = this.model.get('from') + this.model.get('size'); var templated = Mustache.render(this.template, tmplData); this.el.html(templated); }