summaryrefslogtreecommitdiff
path: root/www/js/musicpools.js
diff options
context:
space:
mode:
authorPeter Grassberger <petertheone@gmail.com>2016-01-31 16:52:43 (GMT)
committerPeter Grassberger <petertheone@gmail.com>2016-01-31 16:52:43 (GMT)
commite17fe1ce46af9990862f2e5f93064f4a9e4cbfd8 (patch)
tree061d2f949fb303e153f8e52d612b5a9cc1a8c8a6 /www/js/musicpools.js
parentf306d3578d0ec18e34df3b7ed30e20fa71339bf6 (diff)
musicpools: show carts/cuts, actions still missing
Diffstat (limited to 'www/js/musicpools.js')
-rw-r--r--www/js/musicpools.js73
1 files changed, 60 insertions, 13 deletions
diff --git a/www/js/musicpools.js b/www/js/musicpools.js
index 1e9025f..b9f9107 100644
--- a/www/js/musicpools.js
+++ b/www/js/musicpools.js
@@ -102,10 +102,10 @@ Rivendell.MusicpoolsView.prototype.updateSelector = function() {
$musicpoolSelector.on('change', function() {
self.setCurrentPoolId($('option:selected', $musicpoolSelector).attr('value'));
- self.getCurrentPoolView().render();
+ self.getCurrentPoolView().model.fetchCarts();
});
- this.getCurrentPoolView().render();
+ this.getCurrentPoolView().model.fetchCarts();
};
Rivendell.Musicpool = function(groupName, description, lowcart, highcart, normlevel, trimlevel, title, clock) {
@@ -124,30 +124,77 @@ Rivendell.Musicpool.prototype.constructor = Rivendell.Musicpool;
Rivendell.MusicpoolView = function(model) {
this.model = model;
+ this.cartViews = [];
this.$el = null;
+
+ var self = this;
+ $(this.model).on('update', function() {
+ self.render();
+ });
};
Rivendell.MusicpoolView.prototype.render = function() {
var self = this;
- $(this.model).on('update', function() {
- self.$el = $('#hiddenTemplates .musicpoolTemplate').clone().removeClass('musicpoolTemplate');
- $('#app-musicpools .musicpoolContainer').html(self.$el);
- $('h2', self.$el).html(self.model.title);
- $('table tbody tr', self.$el).remove();
+ this.$el = $('#hiddenTemplates .musicpoolTemplate').clone().removeClass('musicpoolTemplate');
+ $('#app-musicpools .musicpoolContainer').html(this.$el);
- // todo
- $('.uploadButton', self.$el).on('click', function() {
- importer.openModal(self.model, true);
- });
+ $('h2', this.$el).html(this.model.title);
+ $('table tbody tr', this.$el).remove();
+
+ this.cartViews = [];
+ $(this.model.carts).each(function(index, cart) {
+ var cartView = new Rivendell.MusicpoolCartView(cart);
+ self.cartViews.push(cartView);
+ $('table > tbody', self.$el).append(cartView.$el);
+ });
+
+ // todo
+ $('.uploadButton', this.$el).on('click', function() {
+ importer.openModal(self.model, true, true);
});
- this.model.fetchCarts();
};
-Rivendell.MusicpoolCutView = function(model) {
+Rivendell.MusicpoolCartView = function(model) {
this.model = model;
this.$el = null;
+
+ this.render();
};
+
+Rivendell.MusicpoolCartView.prototype.render = function() {
+ var number = this.model.number;
+ var title = this.model.title;
+
+ var length = '-';
+ var imported = '-';
+ var playcnt = '-';
+ var lastplayed = '-';
+
+ if (this.model.cuts.length > 0) {
+ var cut = this.model.cuts[0];
+
+ //title = this.model.cuts[0].description;
+
+ length = msToTimeString(Number(cut.length));
+ imported = format_datetime(new Date(cut.originDatetime));
+ playcnt = cut.playcnt;
+ lastplayed = format_datetime(new Date(cut.lastPlayDatetime));
+ }
+
+ //todo
+ var actions = '';
+
+ this.$el = $('<tr>')
+ .append($('<td>').text(number))
+ .append($('<td>').text(title))
+ .append($('<td>').text(length))
+ .append($('<td>').text(imported))
+ .append($('<td>').text(playcnt))
+ .append($('<td>').text(lastplayed))
+ .append($('<td>').text(actions));
+};
+