summaryrefslogtreecommitdiff
path: root/www/js
diff options
context:
space:
mode:
authorPeter Grassberger <petertheone@gmail.com>2016-02-01 15:55:49 (GMT)
committerPeter Grassberger <petertheone@gmail.com>2016-02-01 15:55:49 (GMT)
commitada31015e989d062ac68d58c94701e2df253b21e (patch)
treeacb26e71e525656c7b24d4f30f1888df8c81c29d /www/js
parent59fc2787322aea11bd2a09fc2254ebb26161b729 (diff)
musicpools: add delete button to carts
Diffstat (limited to 'www/js')
-rw-r--r--www/js/jingles.js6
-rw-r--r--www/js/musicpools.js18
-rw-r--r--www/js/rivendell.js13
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) {