2 * A view which displays a list of reviews for a specified book.
3 * @extends Ext.view.View
5 Ext.define('Books.view.review.List', {
6 alias: 'widget.reviewlist',
7 extend: 'Ext.panel.Panel',
9 requires: ['Ext.layout.container.Card'],
11 initComponent: function() {
12 this.dataview = Ext.create('Ext.view.View', {
19 store: 'Books.store.Review',
20 itemSelector: '.review',
21 tpl: new Ext.XTemplate(
23 '<div class="review {[xindex === 1 ? "first-review" : ""]}">',
24 '<div class="title">{title} {[this.stars(values)]}</div>',
25 '<div class="author">By <span>{author}</span> - {date}</div>',
26 '<div class="comment">{comment}</div>',
30 stars: function(values) {
33 //print out the stars for each of the ratings
34 for (var i = 0; i < values.rating; i++) {
35 res += '<img src="./resources/images/star.' + ((Ext.isIE6) ? 'gif' : 'png') + '" />';
38 //print out transparent stars for the rest (up to 5)
40 res += '<img src="./resources/images/star_no.' + ((Ext.isIE6) ? 'gif' : 'png') + '" />';
58 Ext.create('Books.view.Header', {
65 Ext.create('widget.panel', {
72 this.callParent(arguments);
76 * Used to bind a store to this dataview.
77 * Delegates to bindStore and also shows this view
78 * @param {Ext.data.Model} record The record to bind
79 * @param {Ext.data.Store} store The reviews store used by the application
81 bind: function(record, store) {
82 //put the reviews into the store and bind the store to thie dataview
83 store.loadData(record.data.reviews || []);
84 this.dataview.bindStore(store);