diff --git a/README.md b/README.md index be7e8ce6..fc65ceb0 100755 --- a/README.md +++ b/README.md @@ -35,6 +35,8 @@ Possible breaking changes: * State only stores backend (name) and dataset url (in url field) rather than entire dataset object * Backends heavily reorganized +* Rename Document -> Record +* Rename DataExplorer view to MultiView ### v0.4 - April 26th 2012 diff --git a/_includes/recline-deps.html b/_includes/recline-deps.html index ad77703a..d5066d74 100644 --- a/_includes/recline-deps.html +++ b/_includes/recline-deps.html @@ -5,10 +5,10 @@ - + diff --git a/app/index.html b/app/index.html index 0c56105f..6fd4dc9a 100644 --- a/app/index.html +++ b/app/index.html @@ -19,11 +19,11 @@ - + @@ -49,7 +49,6 @@ - @@ -58,13 +57,18 @@ - + + - + + + + + diff --git a/app/js/app.js b/app/js/app.js index 990be82a..fb8d375e 100755 --- a/app/js/app.js +++ b/app/js/app.js @@ -21,7 +21,7 @@ var ExplorerApp = Backbone.View.extend({ this.router.route(/explorer/, 'explorer', this.viewExplorer); Backbone.history.start(); - var state = recline.Util.parseQueryString(decodeURIComponent(window.location.search)); + var state = recline.View.parseQueryString(decodeURIComponent(window.location.search)); if (state) { _.each(state, function(value, key) { try { @@ -108,7 +108,7 @@ var ExplorerApp = Backbone.View.extend({ } ]; - this.dataExplorer = new recline.View.DataExplorer({ + this.dataExplorer = new recline.View.MultiView({ model: dataset, el: $el, state: state, @@ -145,7 +145,7 @@ var ExplorerApp = Backbone.View.extend({ }, makePermaLink: function(state) { - var qs = recline.Util.composeQueryString(state.toJSON()); + var qs = recline.View.composeQueryString(state.toJSON()); return window.location.origin + window.location.pathname + qs; }, diff --git a/css/data-explorer.css b/css/multiview.css similarity index 82% rename from css/data-explorer.css rename to css/multiview.css index d1a6a94f..dee4edd5 100644 --- a/css/data-explorer.css +++ b/css/multiview.css @@ -27,7 +27,7 @@ .header .recline-results-info { line-height: 28px; margin-left: 20px; - display: inline; + float: left; } /********************************************************** @@ -39,42 +39,54 @@ height: 30px; } -.header .recline-query-editor .input-prepend { +.header .input-prepend { margin-bottom: auto; } -.recline-query-editor .add-on { +.header .add-on { float: left; } /* needed for Chrome but not FF */ -.header .recline-query-editor .add-on { +.header .add-on { margin-left: -27px; } /* needed for FF but not chrome */ -.header .recline-query-editor .input-prepend { +.header .input-prepend { vertical-align: top; } -.header .recline-query-editor .pagination input { - width: 30px; - height: 18px; - padding: 2px 4px; - margin-top: -4px; -} - -.header .recline-query-editor .pagination a { - line-height: 26px; - padding: 0 6px; -} - .header .recline-query-editor form button { vertical-align: top; } /********************************************************** - * Query Editor + * Pager + *********************************************************/ + +.header .recline-pager { + float: left; + margin: auto; + display: block; + margin-left: 20px; +} + +.header .recline-pager .pagination input { + width: 30px; + height: 18px; + padding: 2px 4px; + margin: 0; + margin-top: -4px; +} + +.header .recline-pager .pagination a { + line-height: 26px; + padding: 0 6px; +} + +/********************************************************** + * Filter Editor *********************************************************/ .recline-filter-editor .filter-term .input-append a { diff --git a/library-view.markdown b/library-view.markdown new file mode 100644 index 00000000..96ab9353 --- /dev/null +++ b/library-view.markdown @@ -0,0 +1,100 @@ +--- +layout: container +title: Library - Views +--- + + + +Recline Views are instances of Backbone Views and they act as 'WUI' (web user +interface) component displaying some model object in the DOM. Like all Backbone +views they have a pointer to a model (or a collection) and have an associated +DOM-style element (usually this element will be bound into the page at some +point). + +Views provided by core Recline are crudely divided into two types: + +* Dataset Views: a View intended for displaying a recline.Model.Dataset in some + fashion. Examples are the Grid, Graph and Map views. +* Widget Views: a widget used for displaying some specific (and smaller) aspect + of a dataset or the application. Examples are QueryEditor and FilterEditor + which both provide a way for editing (a part of) a `recline.Model.Query` + associated to a Dataset. + +## Dataset View + +These views are just Backbone views with a few additional conventions: + +1. The model passed to the View should always be a recline.Model.Dataset + instance +2. Views should generate their own root element rather than having it passed + in. +3. Views should apply a css class named 'recline-{view-name-lower-cased} to the + root element (and for all CSS for this view to be qualified using this CSS + class) +4. Read-only mode: CSS for this view should respect/utilize a parent + recline-read-only class in order to trigger read-only behaviour (this class + will usually be set on some parent element of the view's root element). +5. State: state (configuration) information for the view should be stored on an + attribute named state that is an instance of a Backbone Model (or, more + speficially, be an instance of `recline.Model.ObjectState`). In addition, a + state attribute may be specified in the Hash passed to a View on + iniitialization and this information should be used to set the initial state + of the view. + + Example of state would be the set of fields being plotted in a graph view. + + More information about State can be found below. + +To summarize some of this, the initialize function for a Dataset View should +look like: + +
+   initialize: {
+       model: {a recline.Model.Dataset instance}
+       // el: {do not specify - instead view should create}
+       state: {(optional) Object / Hash specifying initial state}
+       ...
+   }
+
+ +Note: Dataset Views in core Recline have a common layout on disk as follows, +where ViewName is the named of View class: + +
+src/view-{lower-case-ViewName}.js
+css/{lower-case-ViewName}.css
+test/view-{lower-case-ViewName}.js
+
+ +### State + +State information exists in order to support state serialization into the url +or elsewhere and reloading of application from a stored state. + +State is available not only for individual views (as described above) but for +the dataset (e.g. the current query). For an example of pulling together state +from across multiple components see `recline.View.DataExplorer`. + +### Flash Messages / Notifications + +To send 'flash messages' or notifications the convention is that views should +fire an event named `recline:flash` with a payload that is a flash object with +the following attributes (all optional): + +* message: message to show. +* category: warning (default), success, error +* persist: if true alert is persistent, o/w hidden after 3s (default=false) +* loader: if true show a loading message + +Objects or views wishing to bind to flash messages may then subscribe to these +events and take some action such as displaying them to the user. For an example +of such behaviour see the DataExplorer view. + +### Writing your own Views + +See the existing Views. + diff --git a/library.html b/library.html index 7d654861..850afcf3 100644 --- a/library.html +++ b/library.html @@ -13,7 +13,7 @@ title: Library - Home

Building on Backbone, Recline supplies components and structure to data-heavy applications by providing a - set of models (Dataset, Document/Row, Field) and views (Grid, Map, Graph + set of models (Dataset, Record/Row, Field) and views (Grid, Map, Graph etc).

Examples

@@ -52,7 +52,7 @@ title: Library - Home

Create a new Backend

-

Create a Custom Document Object

+

Create a Custom Record Object

@@ -70,10 +70,10 @@ title: Library - Home

There are two main model objects:

@@ -84,7 +84,7 @@ title: Library - Home
  • Query: an object to encapsulate a query to the backend (useful both for creating queries and for storing and manipulating query state - e.g. from a query editor).
  • -
  • Facet: Object to store Facet +
  • Facet: Object to store Facet information, that is summary information (e.g. values and counts) about a field obtained by some faceting method on the backend.
  • @@ -97,13 +97,13 @@ title: Library - Home

    Backends

    -

    Backends connect Dataset and Documents to data from a +

    Backends connect Dataset and Records to data from a specific 'Backend' data source. They provide methods for loading and saving - Datasets and individuals Documents as well as for bulk loading via a query API + Datasets and individuals Records as well as for bulk loading via a query API and doing bulk transforms on the backend.

    A template Base class can be found in the - Backend base module of the source docs. It documents both the relevant + Backend base module of the source docs. It records both the relevant methods a Backend must have and (optionally) provides a base 'class' for inheritance. You can also find detailed examples of backend implementations in the source documentation below.

    @@ -112,7 +112,7 @@ title: Library - Home

    Complementing the model are various Views (you can also easily write your own). Each view holds a pointer to a Dataset: