Commit 07850c80 authored by alexandre's avatar alexandre

Changed backgrid for regular collection views

parent d88f4a90
......@@ -93,4 +93,4 @@ class ScoreLightSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Score
fields = ('id', 'title', 'tags', 'language', 'created_at', 'updated_at')
fields = ('id', 'title', 'tags', 'language', 'created_at', 'updated_at', 'score_author')
......@@ -1513,3 +1513,11 @@ li .icon--tag { color: white } */
}
.search__submit {
}
.score-list-foo li + li {
margin-top: 21px;
}
.score-list-foo__meta {
font-size: 85%;
}
......@@ -2170,6 +2170,35 @@ window.W = window.W || {};
});
W.ScoreItemView = Marionette.View.extend({
template: '#score-item-template',
templateContext: function () {
moment.locale('fr');
var humanDate = moment(this.model.get('updated_at')).format('Do MMMM YYYY');
return {
humanDate: humanDate,
}
},
tagName: 'li',
});
W.ScoreListFooView = Marionette.CollectionView.extend({
tagName: 'ol',
attributes: { class: 'score-list-foo' },
childView: W.ScoreItemView,
initialize: function () {
this.listenTo(this.collection, 'sync', this.render);
}
});
W.ScoreListView = Marionette.View.extend({
template: '#score-list-template',
......@@ -2177,7 +2206,7 @@ window.W = window.W || {};
regions: {
list: '#list',
pagination: '#pagination',
// pagination: '#pagination',
panel: {
el: '#search-panel',
replaceElement: true
......@@ -2191,7 +2220,7 @@ window.W = window.W || {};
// All the `state` and `queryParams` key value pairs are merged with
// the defaults too.
state: {
pageSize: 25,
pageSize: null,
firstPage: 1,
currentPage: 1,
sortKey: "title",
......@@ -2200,52 +2229,56 @@ window.W = window.W || {};
});
// Provide Marionette event functions on Backgrid's grid
var myListView = new MarionetteGrid({
columns: columns,
// var myListView = new MarionetteGrid({
// columns: columns,
// collection: scoreCollection
// });
//
var myListView = new W.ScoreListFooView({
collection: scoreCollection
});
// Provide Marionette event functions on Backgrid's paginator
var myPaginationView = new MarionettePaginator({
controls : {
rewind: {
label: "",
title: "First"
},
back: {
label: "",
title: "Previous"
},
forward: {
label: "",
title: "Next"
},
fastForward: {
label: "",
title: "Last"
}
},
// If you anticipate a large number of pages, you can adjust
// the number of page handles to show. The sliding window
// will automatically show the next set of page handles when
// you click next at the end of a window.
windowSize: 20, // Default is 10
// Used to multiple windowSize to yield a number of pages to slide,
// in the case the number is 5
slideScale: 0.25, // Default is 0.5
// Whether sorting should go back to the first page
goBackFirstOnSort: false, // Default is true
collection: scoreCollection
});
// var myPaginationView = new MarionettePaginator({
// controls : {
// rewind: {
// label: "《",
// title: "First"
// },
// back: {
// label: "〈",
// title: "Previous"
// },
// forward: {
// label: "〉",
// title: "Next"
// },
// fastForward: {
// label: "》",
// title: "Last"
// }
// },
// // If you anticipate a large number of pages, you can adjust
// // the number of page handles to show. The sliding window
// // will automatically show the next set of page handles when
// // you click next at the end of a window.
// windowSize: 20, // Default is 10
// // Used to multiple windowSize to yield a number of pages to slide,
// // in the case the number is 5
// slideScale: 0.25, // Default is 0.5
// // Whether sorting should go back to the first page
// goBackFirstOnSort: false, // Default is true
// collection: scoreCollection
// });
var mySearchPanelView = new W.SearchPanelView({collection: scoreCollection});
this.showChildView('list', myListView);
this.showChildView('pagination', myPaginationView);
// this.showChildView('pagination', myPaginationView);
this.showChildView('panel', mySearchPanelView);
scoreCollection.fetch();
......@@ -2295,8 +2328,12 @@ window.W = window.W || {};
});
var myListView = new MarionetteGrid({
columns: columns,
// var myListView = new MarionetteGrid({
// columns: columns,
// collection: scoreCollection
// });
var myListView = new W.ScoreListFooView({
collection: scoreCollection
});
......@@ -2497,8 +2534,11 @@ window.W = window.W || {};
scoreCollection.queryParams.is_featured=true;
var myListView = new MarionetteGrid({
columns: columns,
// var myListView = new MarionetteGrid({
// columns: columns,
// collection: scoreCollection
// });
var myListView = new W.ScoreListFooView({
collection: scoreCollection
});
......@@ -2522,8 +2562,11 @@ window.W = window.W || {};
scoreCollection2.queryParams.shared_with=true;
var myListView2 = new MarionetteGrid({
columns: columns,
// var myListView2 = new MarionetteGrid({
// columns: columns,
// collection: scoreCollection2
// });
var myListView2 = new W.ScoreListFooView({
collection: scoreCollection2
});
......
......@@ -113,6 +113,10 @@
{% include "playground/underscore/register.mtpl" %}
</script>
<script id="score-item-template" type="text/template">
{% include "playground/underscore/score-item.mtpl" %}
</script>
<script id="score-template-form" type="text/template">
{% include "playground/underscore/score-form.mtpl" %}
</script>
......
<a href="/partitions/<%- id %>"><%- title %></a>,
<span class="score-list-foo__meta">
par <%- score_author %>,
le <%- humanDate %>
<br>
<% for (var i = 0; i < tags.length; i++) { %>
#<%- tags[i] %>
<% } %>
</span>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment