diff options
Diffstat (limited to 'www/js/musicpools.js')
-rw-r--r-- | www/js/musicpools.js | 73 |
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)); +}; + |