From 4f3b5159539d76ba68c07ed7fef684045197d276 Mon Sep 17 00:00:00 2001 From: Casey Cesari Date: Tue, 15 Aug 2017 12:15:08 -0400 Subject: [PATCH] Implement details view for BiG CZ Clicking on a search result in the BiG CZ results pane will open a pane with the details for that result. Only the fields that were common between all three APIs were added. Refs #1934 --- .../data_catalog/templates/resultDetails.html | 35 ++++++++++ .../js/src/data_catalog/templates/window.html | 2 + src/mmw/js/src/data_catalog/views.js | 70 ++++++++++++++++++- src/mmw/sass/pages/_data-catalog.scss | 25 +++++++ 4 files changed, 129 insertions(+), 3 deletions(-) create mode 100644 src/mmw/js/src/data_catalog/templates/resultDetails.html diff --git a/src/mmw/js/src/data_catalog/templates/resultDetails.html b/src/mmw/js/src/data_catalog/templates/resultDetails.html new file mode 100644 index 000000000..4adf94021 --- /dev/null +++ b/src/mmw/js/src/data_catalog/templates/resultDetails.html @@ -0,0 +1,35 @@ +
+
+

+ {{ title }} +

+ + Zoom to extent +
+
+ {% if author %} +

+ {{ author }} +

+ {% endif %} + {% if activeCatalog != 'cuahsi' %} +

+ {{ created_at|toDateFullYear }} +

+ {% else %} + {% if begin_date == end_date %} +

+ {{ begin_date|toDateWithoutTime }} +

+ {% else %} +

+ {{ begin_date|toDateWithoutTime }} - {{ end_date|toDateWithoutTime }} +

+ {% endif %} + {% endif %} +

+ {{ description }} +

+
diff --git a/src/mmw/js/src/data_catalog/templates/window.html b/src/mmw/js/src/data_catalog/templates/window.html index 939646c84..e4ac65b20 100644 --- a/src/mmw/js/src/data_catalog/templates/window.html +++ b/src/mmw/js/src/data_catalog/templates/window.html @@ -1,3 +1,5 @@ +
+

Data sources

diff --git a/src/mmw/js/src/data_catalog/views.js b/src/mmw/js/src/data_catalog/views.js index e93aea984..3d6bbdb77 100644 --- a/src/mmw/js/src/data_catalog/views.js +++ b/src/mmw/js/src/data_catalog/views.js @@ -17,6 +17,7 @@ var $ = require('jquery'), tabPanelTmpl = require('./templates/tabPanel.html'), headerTmpl = require('./templates/header.html'), windowTmpl = require('./templates/window.html'), + resultDetailsTmpl = require('./templates/resultDetails.html'), resultsWindowTmpl = require('./templates/resultsWindow.html'); var ENTER_KEYCODE = 13, @@ -77,12 +78,15 @@ var DataCatalogWindow = Marionette.LayoutView.extend({ regions: { formRegion: '.form-region', panelsRegion: '.tab-panels-region', - contentsRegion: '.tab-contents-region' + contentsRegion: '.tab-contents-region', + detailsRegion: '.result-details-region' }, childEvents: { 'search': 'doSearch', - 'selectCatalog': 'onSelectCatalog' + 'selectCatalog': 'onSelectCatalog', + 'selectResult': 'onSelectResult', + 'closeDetails': 'onCloseDetails' }, collectionEvents: { @@ -96,7 +100,7 @@ var DataCatalogWindow = Marionette.LayoutView.extend({ this.panelsRegion.show(new TabPanelsView({ collection: this.collection })); - this.contentsRegion.show(new TabContentsView({ + this.showChildView('contentsRegion', new TabContentsView({ collection: this.collection })); }, @@ -119,6 +123,19 @@ var DataCatalogWindow = Marionette.LayoutView.extend({ this.doSearch(); }, + onSelectResult: function(childView, result) { + var activeCatalog = this.getActiveCatalog(); + + this.detailsRegion.show(new ResultDetailsView({ + model: result, + activeCatalog: activeCatalog.id + })); + }, + + onCloseDetails: function() { + this.detailsRegion.empty(); + }, + doSearch: function() { var catalog = this.getActiveCatalog(), query = this.model.get('query'), @@ -303,6 +320,14 @@ var TabContentView = Marionette.LayoutView.extend({ 'change:active': 'toggleActiveClass', }, + childEvents: { + 'selectResult': 'handleChildSelectResult' + }, + + handleChildSelectResult: function(view, result) { + this.triggerMethod('selectResult', result); + }, + onShow: function() { this.toggleActiveClass(); @@ -363,6 +388,11 @@ var ResultView = Marionette.ItemView.extend({ events: { 'mouseover': 'highlightResult', 'mouseout': 'unHighlightResult', + 'click': 'selectResult' + }, + + selectResult: function() { + this.triggerMethod('selectResult', this.model); }, highlightResult: function() { @@ -383,11 +413,45 @@ var ResultsView = Marionette.CollectionView.extend({ }; }, + childEvents: { + 'selectResult': 'handleChildSelectResult' + }, + + handleChildSelectResult: function(view, result) { + this.triggerMethod('selectResult', result); + }, + modelEvents: { 'sync error': 'render' } }); +var ResultDetailsView = Marionette.ItemView.extend({ + template: resultDetailsTmpl, + + ui: { + closeDetails: '.close' + }, + + events: { + 'click @ui.closeDetails': 'closeDetails' + }, + + initialize: function(options) { + this.activeCatalog = options.activeCatalog; + }, + + templateHelpers: function() { + return { + activeCatalog: this.activeCatalog + }; + }, + + closeDetails: function() { + this.triggerMethod('closeDetails'); + } +}); + var PagerView = Marionette.ItemView.extend({ template: pagerTmpl, diff --git a/src/mmw/sass/pages/_data-catalog.scss b/src/mmw/sass/pages/_data-catalog.scss index 8d437cb3c..225612c5b 100644 --- a/src/mmw/sass/pages/_data-catalog.scss +++ b/src/mmw/sass/pages/_data-catalog.scss @@ -15,6 +15,31 @@ position: relative; } + .result-details-region { + .result { + padding: 10px; + bottom: 0px; + top: 0px; + width: 100%; + position: absolute; + z-index: 10000; + background-color: #fff; + overflow: auto; + + .result-detail-header { + h2 { + display: inline-block; + margin: 4px 0; + max-width: 95%; + } + + a { + display: block; + } + } + } + } + .result-region { height: auto !important; width: auto !important;