diff options
author | Peter Grassberger <petertheone@gmail.com> | 2016-02-01 15:55:49 (GMT) |
---|---|---|
committer | Peter Grassberger <petertheone@gmail.com> | 2016-02-01 15:55:49 (GMT) |
commit | ada31015e989d062ac68d58c94701e2df253b21e (patch) | |
tree | acb26e71e525656c7b24d4f30f1888df8c81c29d /www | |
parent | 59fc2787322aea11bd2a09fc2254ebb26161b729 (diff) |
musicpools: add delete button to carts
Diffstat (limited to 'www')
-rw-r--r-- | www/js/jingles.js | 6 | ||||
-rw-r--r-- | www/js/musicpools.js | 18 | ||||
-rw-r--r-- | www/js/rivendell.js | 13 |
3 files changed, 31 insertions, 6 deletions
diff --git a/www/js/jingles.js b/www/js/jingles.js index 8d6ae38..960dd25 100644 --- a/www/js/jingles.js +++ b/www/js/jingles.js @@ -166,7 +166,7 @@ Rivendell.JingleCutView.prototype.render = function() { self.toggleActive(); }); deleteButton.on('click', function() { - self.removeSelf(); + self.delete(); }); this.$el = $('<tr>') @@ -222,10 +222,10 @@ Rivendell.JingleCutView.prototype.toggleActive = function() { }); }; -Rivendell.JingleCutView.prototype.removeSelf = function() { +Rivendell.JingleCutView.prototype.delete = function() { var self = this; rivendell.removeCut(this.model.cartNumber, this.model.number, function() { - self.model.cart.removeCut(this); + self.model.cart.removeCut(self.model); self.$el.remove(); }); }; diff --git a/www/js/musicpools.js b/www/js/musicpools.js index b9f9107..27de48e 100644 --- a/www/js/musicpools.js +++ b/www/js/musicpools.js @@ -185,8 +185,13 @@ Rivendell.MusicpoolCartView.prototype.render = function() { lastplayed = format_datetime(new Date(cut.lastPlayDatetime)); } - //todo - var actions = ''; + var deleteButton = $('<button class="btn btn-danger btn-mini"><i class="icon-trash icon-white"></i> Löschen</button>'); + + var self = this; + deleteButton.on('click', function() { + self.delete(); + }); + this.$el = $('<tr>') .append($('<td>').text(number)) @@ -195,6 +200,13 @@ Rivendell.MusicpoolCartView.prototype.render = function() { .append($('<td>').text(imported)) .append($('<td>').text(playcnt)) .append($('<td>').text(lastplayed)) - .append($('<td>').text(actions)); + .append($('<td>').append(deleteButton)); }; +Rivendell.MusicpoolCartView.prototype.delete = function() { + var self = this; + rivendell.removeCart(this.model.number, function() { + self.model.group.removeCart(self.model); + self.$el.remove(); + }); +}; diff --git a/www/js/rivendell.js b/www/js/rivendell.js index 1a00f07..0f4bcda 100644 --- a/www/js/rivendell.js +++ b/www/js/rivendell.js @@ -380,6 +380,19 @@ Rivendell.Group = function(groupName, description, lowcart, highcart, normlevel, this.carts = []; }; +Rivendell.Group.prototype.addCart = function(cart) { + this.carts.push(cart); +}; + +Rivendell.Group.prototype.removeCart = function(cart) { + var self = this; + $.each(this.carts, function(index, currentCart){ + if(currentCart === cart) { + self.carts.splice(index, 1); + } + }); +}; + Rivendell.Group.prototype.fetchCarts = function() { var self = this; rivendell.listCarts(this.groupName, 1, function(cartsXml, status, req) { |