Ability to choose the place in the list to insert new programs.

This commit is contained in:
vexorian 2023-11-17 21:01:26 -04:00
parent de3a64c4c0
commit 447c33027b
4 changed files with 55 additions and 11 deletions

View File

@ -11,7 +11,7 @@ module.exports = function ($timeout, $location, dizquetv, resolutionOptions, get
},
link: {
post: function (scope, element, attrs) {
post: function (scope, $element, attrs) {
scope.screenW = 1920;
scope.screenh = 1080;
@ -326,9 +326,10 @@ module.exports = function ($timeout, $location, dizquetv, resolutionOptions, get
duration: duration,
isOffline: true
}
scope.channel.programs.splice(scope.minProgramIndex, 0, program);
scope.channel.programs.splice(scope.channel.programs.length, 0, program);
scope._selectedOffline = null
scope._addingOffline = null;
scrollToLast();
updateChannelDuration()
}
@ -1077,11 +1078,37 @@ module.exports = function ($timeout, $location, dizquetv, resolutionOptions, get
}
}
scope.importPrograms = (selectedPrograms) => {
function getAllMethods(object) {
return Object.getOwnPropertyNames(object).filter(function (p) {
return typeof object[p] == 'function';
});
}
function scrollToLast() {
var programListElement = document.getElementById("channelConfigProgramList");
$timeout(() => { programListElement.scrollTo(0, 2000000); }, 0)
}
scope.importPrograms = (selectedPrograms, insertPoint) => {
for (let i = 0, l = selectedPrograms.length; i < l; i++) {
delete selectedPrograms[i].commercials;
}
scope.channel.programs = scope.channel.programs.concat(selectedPrograms)
var programListElement = document.getElementById("channelConfigProgramList");
if (insertPoint === "start") {
scope.channel.programs = selectedPrograms.concat(scope.channel.programs);
programListElement.scrollTo(0, 0);
} else if (insertPoint === "current") {
scope.channel.programs = [
...scope.channel.programs.slice(0, scope.currentStartIndex),
...selectedPrograms,
...scope.channel.programs.slice(scope.currentStartIndex)
];
} else {
scope.channel.programs = scope.channel.programs.concat(selectedPrograms)
scrollToLast();
}
updateChannelDuration()
setTimeout(
() => {
@ -1093,7 +1120,9 @@ module.exports = function ($timeout, $location, dizquetv, resolutionOptions, get
}
scope.finishRedirect = (program) => {
if (scope.selectedProgram == -1) {
scope.channel.programs.splice(scope.minProgramIndex, 0, program);
scope.channel.programs.splice(scope.channel.programs.length, 0, program);
scrollToLast();
} else {
scope.channel.programs[ scope.selectedProgram ] = program;
}

View File

@ -6,6 +6,7 @@ module.exports = function (plex, dizquetv, $timeout, commonProgramTools) {
scope: {
onFinish: "=onFinish",
height: "=height",
positionChoice: "=positionChoice",
visible: "=visible",
limit: "=limit",
},
@ -14,6 +15,7 @@ module.exports = function (plex, dizquetv, $timeout, commonProgramTools) {
if ( typeof(scope.limit) == 'undefined') {
scope.limit = 1000000000;
}
scope.insertPoint = "end";
scope.customShows = [];
scope.origins = [];
scope.currentOrigin = undefined;
@ -37,7 +39,7 @@ module.exports = function (plex, dizquetv, $timeout, commonProgramTools) {
updateCustomShows();
}
}
scope._onFinish = (s) => {
scope._onFinish = (s, insertPoint) => {
if (s.length > scope.limit) {
if (scope.limit == 1) {
scope.error = "Please select only one clip.";
@ -45,7 +47,7 @@ module.exports = function (plex, dizquetv, $timeout, commonProgramTools) {
scope.error = `Please select at most ${scope.limit} clips.`;
}
} else {
scope.onFinish(s)
scope.onFinish(s, insertPoint)
scope.selection = []
scope.visible = false
}

View File

@ -170,6 +170,7 @@
ng-init="setUpWatcher()"
ng-if="true"
ng-style="{'max-height':programmingHeight()}"
id="channelConfigProgramList"
>
<div ng-repeat="x in channel.programs track by x.$index"
ng-click="selectProgram(x.$index)"
@ -938,7 +939,7 @@
<frequency-tweak programs="_programFrequencies" message="_frequencyMessage" modified="_frequencyModified" on-done="tweakFrequencies"></frequency-tweak>
<remove-shows program-infos="_removablePrograms" on-done="removeShows" deleted="_deletedProgramNames"></remove-shows>
<flex-config offline-title="Add Flex Time" program="_addingOffline" on-done="finishedAddingOffline"></flex-config>
<plex-library limit="libraryLimit" height="300" visible="displayPlexLibrary" on-finish="importPrograms"></plex-library>
<plex-library limit="libraryLimit" height="300" visible="displayPlexLibrary" position-choice=true on-finish="importPrograms"></plex-library>
<plex-library height="300" limit=1 visible="showFallbackPlexLibrary" on-finish="importFallback"></plex-library>
<channel-redirect visible="_displayRedirect" on-done="finishRedirect" form-title="_redirectTitle" program="_selectedRedirect" ></channel-redirect>
<time-slots-schedule-editor linker="registerTimeSlots" on-done="onTimeSlotsDone"></time-slots-schedule-editor>

View File

@ -145,9 +145,21 @@
</ul>
</div>
<div class='text-danger'>{{error}}</div>
<div class="modal-footer">
<button type="button" class="btn btn-sm btn-link" ng-click="_onFinish([])">Cancel</button>
<button type="button" class="btn btn-sm btn-primary" ng-click="_onFinish(selection);">Done</button>
<div class="modal-footer flex">
<div class="flex-grow-1" ng-show="positionChoice === true"">
<select class="form-select form-select-sm custom-select" ng-model="insertPoint"
id="position-selector">
<option value="end">Insert at the end of list</option>
<option value="start">Insert at the beginning of list</option>
<option value="current">Insert at current scroll position</option>
</select>
</div>
<div><button type="button" class="btn btn-sm btn-link" ng-click="_onFinish([])">Cancel</button></div>
<div><button type="button" class="btn btn-sm btn-primary" ng-click="_onFinish(selection, insertPoint);">Done</button></div>
</div>
</div>
</div>