summaryrefslogtreecommitdiff
path: root/www
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-09-16 00:39:59 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-09-16 00:42:14 (GMT)
commit8345e332cceaac0c99c6473f1d0cfb3e9fba499e (patch)
treea1aa04f9f862dfbfe4c0b7548707d6f5547122c3 /www
parentc22d049b1f6e216fa0f43d7c0af9d4207bb8e910 (diff)
jingles are now activate/deactivated via evergreen flag
Diffstat (limited to 'www')
-rw-r--r--www/js/jingles.js49
-rw-r--r--www/js/rdxport.rh.js15
-rw-r--r--www/js/router.js1
3 files changed, 31 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();
});
};
diff --git a/www/js/rdxport.rh.js b/www/js/rdxport.rh.js
index b5b58c9..868deeb 100644
--- a/www/js/rdxport.rh.js
+++ b/www/js/rdxport.rh.js
@@ -38,6 +38,10 @@ Rdxport.Rdxport.prototype.setListDropboxesEndpoint = function(listDropboxesEndpo
this.listDropboxesEndpoint = listDropboxesEndpoint;
};
+Rdxport.Rdxport.prototype.setCutEvergreenEndpoint = function(cutEvergreenEndpoint) {
+ this.cutEvergreenEndpoint = cutEvergreenEndpoint;
+};
+
Rdxport.Rdxport.prototype.setMusicgridEndpoint = function(musicgridEndpoint) {
this.musicgridEndpoint = musicgridEndpoint;
};
@@ -97,6 +101,17 @@ Rdxport.Rdxport.prototype.addAndEditCart = function(groupName, type, cartNumber,
return $.post(this.endpoint, options, success, 'xml');
};
+Rdxport.Rdxport.prototype.setCutEvergreen = function(cartNumber, cutNumber, value, success) {
+ var command = {
+ LOGIN_NAME: this.username,
+ PASSWORD: this.token,
+ CART_NUMBER: cartNumber,
+ CUT_NUMBER: cutNumber,
+ VALUE: value
+ };
+ return $.post(this.cutEvergreenEndpoint, command, success, "xml");
+};
+
Rdxport.Rdxport.prototype.getMusicgrid = function(success) {
var command = {
LOGIN_NAME: this.username,
diff --git a/www/js/router.js b/www/js/router.js
index 9e11383..cbd453c 100644
--- a/www/js/router.js
+++ b/www/js/router.js
@@ -66,6 +66,7 @@ Rdxport.Router.prototype.route = function(page, subpage) {
if (!rdxport) {
rdxport = new Rdxport.Rdxport(this.auth.username, this.auth.token, '/rd-bin/rdxport.cgi');
rdxport.setListDropboxesEndpoint('/rh-bin/listdropboxes.cgi');
+ rdxport.setCutEvergreenEndpoint('/rh-bin/cutevergreen.cgi');
rdxport.setMusicgridEndpoint('/rh-bin/musicgrid.cgi');
}