Skip to content

Commit

Permalink
Merge pull request #2150 from WikiWatershed/cpc/bigcz-search-result-d…
Browse files Browse the repository at this point in the history
…etails-view

Implement details view for BiG CZ
  • Loading branch information
caseycesari committed Aug 18, 2017
2 parents ce5c406 + 4f3b515 commit 7f7a542
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 3 deletions.
35 changes: 35 additions & 0 deletions src/mmw/js/src/data_catalog/templates/resultDetails.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<div class="result">
<div class="result-detail-header">
<h2>
{{ title }}
</h2>
<button type="button" class="close" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<a href="#"><i class="fa fa-search-plus"></i> Zoom to extent</a>
</div>
<hr>
{% if author %}
<p>
<i class="fa fa-user"></i>{{ author }}
</p>
{% endif %}
{% if activeCatalog != 'cuahsi' %}
<p>
<i class="fa fa-calendar"></i> {{ created_at|toDateFullYear }}
</p>
{% else %}
{% if begin_date == end_date %}
<p>
<i class="fa fa-calendar"></i> {{ begin_date|toDateWithoutTime }}
</p>
{% else %}
<p>
<i class="fa fa-calendar"></i> {{ begin_date|toDateWithoutTime }} - {{ end_date|toDateWithoutTime }}
</p>
{% endif %}
{% endif %}
<p>
{{ description }}
</p>
</div>
2 changes: 2 additions & 0 deletions src/mmw/js/src/data_catalog/templates/window.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<div class="result-details-region"></div>

<h2 class="data-catalog-title">
Data sources
</h2>
Expand Down
70 changes: 67 additions & 3 deletions src/mmw/js/src/data_catalog/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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: {
Expand All @@ -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
}));
},
Expand All @@ -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'),
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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() {
Expand All @@ -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,

Expand Down
25 changes: 25 additions & 0 deletions src/mmw/sass/pages/_data-catalog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7f7a542

Please sign in to comment.