diff --git a/web/directives/channel-config.js b/web/directives/channel-config.js index 3c9fca1..0a53965 100644 --- a/web/directives/channel-config.js +++ b/web/directives/channel-config.js @@ -110,18 +110,23 @@ module.exports = function ($timeout, $location, dizquetv) { scope._selectedProgram = null updateChannelDuration() } - scope.dropFunction = (dropIndex, index, program) => { - if (scope.channel.programs[index].start == program.start) { - return false; + scope.dropFunction = (dropIndex, program) => { + let y = program.$index; + let z = dropIndex + scope.currentStartIndex - 1; + scope.channel.programs.splice(y, 1); + if (z >= y) { + z--; } - - setTimeout( () => { - scope.channel.programs.splice(dropIndex + index, 0, program); - updateChannelDuration() - scope.$apply(); - }, 1); - return true; + scope.channel.programs.splice(z, 0, program ); + updateChannelDuration(); + $timeout(); + return false; } + scope.setUpWatcher = function setupWatchers() { + this.$watch('vsRepeat.startIndex', function(val) { + scope.currentStartIndex = val; + }); + }; let fixFillerCollection = (f) => { return { diff --git a/web/directives/filler-config.js b/web/directives/filler-config.js index 5b6bc3a..f5c89f5 100644 --- a/web/directives/filler-config.js +++ b/web/directives/filler-config.js @@ -26,16 +26,15 @@ module.exports = function ($timeout) { } scope.dropFunction = (dropIndex, program) => { - setTimeout( () => { - if (program.$index < dropIndex) { - scope.content.splice(scope.currentStartIndex + dropIndex-2, 0, program); - } else { - scope.content.splice(scope.currentStartIndex + dropIndex-1, 0, program); - } - refreshContentIndexes(); - scope.$apply(); - }, 1); - return true; + let y = program.$index; + let z = dropIndex + scope.currentStartIndex - 1; + scope.content.splice(y, 1); + if (z >= y) { + z--; + } + scope.content.splice(z, 0, program ); + $timeout(); + return false; } scope.setUpWatcher = function setupWatchers() { this.$watch('vsRepeat.startIndex', function(val) { @@ -44,7 +43,7 @@ module.exports = function ($timeout) { }; scope.movedFunction = (index) => { - scope.content.splice(index, 1); + console.log("movedFunction(" + index + ")"); } diff --git a/web/public/templates/channel-config.html b/web/public/templates/channel-config.html index f6fdc75..8e38fa3 100644 --- a/web/public/templates/channel-config.html +++ b/web/public/templates/channel-config.html @@ -432,11 +432,12 @@
-
-
+
+
-
+
{{ dateForGuide(x.start) }}