summaryrefslogtreecommitdiff
path: root/www/js/jingles.js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js/jingles.js')
-rw-r--r--www/js/jingles.js49
1 files changed, 15 insertions, 34 deletions
diff --git a/www/js/jingles.js b/www/js/jingles.js
index 2a269cd..6b66ea4 100644
--- a/www/js/jingles.js
+++ b/www/js/jingles.js
@@ -76,8 +76,7 @@ Rdxport.JingleGroup.prototype.constructor = Rdxport.JingleGroup;
Rdxport.JingleGroupView = function(model) {
this.model = model;
- this.mainCartView = null;
- this.deactivateCartView = null;
+ this.cartView = null;
this.$el = null;
@@ -88,11 +87,8 @@ Rdxport.JingleGroupView = function(model) {
importer.syncUploads('jingles', self, function() {
$('table > tbody', self.$el).empty();
- self.model.mainCart = self.model.carts[0];
- self.mainCartView = new Rdxport.JingleCartView(self.model.mainCart, self, true);
-
- self.model.deactivateCart = self.model.carts[1];
- self.deactivateCartView = new Rdxport.JingleCartView(self.model.deactivateCart, self, false);
+ self.model.cart = self.model.carts[0];
+ self.cartView = new Rdxport.JingleCartView(self.model.cart, self);
});
});
@@ -180,10 +176,9 @@ Rdxport.JingleGroupView.uploadError = function(upload) {
$cut.replaceWith($errorRow);
};
-Rdxport.JingleCartView = function(model, groupView, active) {
+Rdxport.JingleCartView = function(model, groupView) {
this.model = model;
this.groupView = groupView;
- this.active = active;
this.cutViews = [];
@@ -196,8 +191,6 @@ Rdxport.JingleCartView = function(model, groupView, active) {
return 1;
return -1;
}).each(function(index, cut) {
- cut.active = self.active;
-
var cutView = new Rdxport.JingleCutView(cut);
self.cutViews.push(cutView);
@@ -243,16 +236,12 @@ Rdxport.JingleCutView.prototype.render = function() {
var status = $('<span class="label"></span>');
var moveButton = $('<button class="btn btn-info btn-xs"><span class="glyphicon glyphicon-transfer"></span>&nbsp;&nbsp;Verschieben</button>');
var activateButton;
- if (this.model.active) {
+ if (!this.model.isEvergreen) {
activateButton = $('<button class="btn btn-warning btn-xs"><span class="glyphicon glyphicon-ban-circle"></span>&nbsp;&nbsp;Deaktivieren</button>');
- if (!this.model.isEvergreen) {
- status.addClass('label-success').html('<span class="glyphicon glyphicon-star"></span>');
- } else {
- status.addClass('label-info').html('<span class="glyphicon glyphicon-star-empty"></span>');
- }
+ status.addClass('label-success').html('<span class="glyphicon glyphicon-star"></span>');
} else {
activateButton = $('<button class="btn btn-success btn-xs"><span class="glyphicon glyphicon-ok"></span>&nbsp;&nbsp;Aktivieren</button>');
- status.addClass('label-warning').html('<span class="glyphicon glyphicon-ban-circle"></span>');
+ status.addClass('label-default').html('<span class="glyphicon glyphicon-star-empty"></span>');
}
var deleteButton = $('<button class="btn btn-danger btn-xs"><span class="glyphicon glyphicon-trash"></span>&nbsp;&nbsp;Löschen</button>');
@@ -268,7 +257,7 @@ Rdxport.JingleCutView.prototype.render = function() {
self.move();
});
activateButton.on('click', function() {
- self.toggleActive();
+ self.toggleEvergreen();
});
deleteButton.on('click', function() {
self.delete();
@@ -325,14 +314,8 @@ Rdxport.JingleCutView.prototype.move = function() {
// todo: make this work for multiple groups
if (jingleGroupListView.model.groups.length === 2) {
$(jingleGroupListView.model.groups).each(function(index, group) {
- if (self.model.active) {
- if (self.model.cartNumber !== group.mainCart.number) {
- destinationCart = group.mainCart;
- }
- } else {
- if (self.model.cartNumber !== group.deactivateCart.number) {
- destinationCart = group.deactivateCart;
- }
+ if (self.model.cartNumber !== group.cart.number) {
+ destinationCart = group.cart;
}
});
} else {
@@ -346,16 +329,14 @@ Rdxport.JingleCutView.prototype.move = function() {
});
};
-Rdxport.JingleCutView.prototype.toggleActive = function() {
+Rdxport.JingleCutView.prototype.toggleEvergreen = function() {
this.$el.find('td:first').html(this.$spinner);
- var destinationCart = this.model.cartNumber;
- if (this.model.active) {
- destinationCart++;
- } else {
- destinationCart--;
+ var newvalue = 1;
+ if(this.model.isEvergreen) {
+ newvalue = 0;
}
var self = this;
- rdxport.moveCut(this.model.cartNumber, this.model.number, destinationCart, function() {
+ rdxport.setCutEvergreen(this.model.cartNumber, this.model.number, newvalue, function() {
self.model.cart.group.fetchCarts();
});
};