Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement details view for BiG CZ #2150

Merged
merged 1 commit into from
Aug 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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' %}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also check if there's begin_date instead of checking on the active catalog.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried something similar, but there is a bit of an overlap in fields between the two catalogs, so I wanted to be more explicit. We may end up having to change this in the future too depending on how much the detail panes diverge between the catalogs.

<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