Skip to content

Commit fbf0d5b

Browse files
committed
Update code docs
1 parent 2b9c541 commit fbf0d5b

4 files changed

Lines changed: 103 additions & 43 deletions

File tree

docs/components_movies_MovieDetails.bs.html

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@
3232
' Observe renderTracking to update gradient after layout is calculated
3333
m.itemDetails.observeField("renderTracking", "onItemDetailsRendered")
3434

35-
' Options button will be created dynamically as needed
35+
' Options and delete buttons will be created dynamically as needed
3636
m.optionsButton = invalid
37+
m.deleteButton = invalid
3738

3839
m.isFirstRun = true
3940
m.allowButtonUpdates = true ' Allow button updates on init and when returning to screen
@@ -420,6 +421,7 @@
420421
' Prevents button changes during playback transition
421422
if m.allowButtonUpdates
422423
manageResumeButton()
424+
manageDeleteButton()
423425
m.allowButtonUpdates = false ' Disable until next OnScreenShown
424426
end if
425427
end if
@@ -737,10 +739,13 @@
737739
m.buttonGrp.removeChild(m.optionsButton)
738740
m.optionsButton = invalid
739741

740-
' Adjust focus index if user was on a button after the removed button
742+
' Adjust focus: if user was on a button after the removed button, shift focus back (clamped to 0)
741743
if isValid(currentFocusIndex) and isValid(optionsButtonIndex) and currentFocusIndex > optionsButtonIndex
742-
m.buttonGrp.buttonFocused = currentFocusIndex - 1
744+
focusIndex = currentFocusIndex - 1
745+
if focusIndex < 0 then focusIndex = 0
746+
m.buttonGrp.buttonFocused = focusIndex
743747
end if
748+
m.buttonGrp.callFunc("focus")
744749
end if
745750
end sub
746751

@@ -758,6 +763,42 @@
758763
return -1
759764
end function
760765

766+
' manageDeleteButton: Add or remove Delete button based on server CanDelete permission
767+
' CanDelete is computed server-side and accounts for global, folder-specific, and admin permissions
768+
'
769+
sub manageDeleteButton()
770+
canDelete = false
771+
if isValid(m.top.itemContent) and isValid(m.top.itemContent.json)
772+
canDelete = m.top.itemContent.json.CanDelete = true
773+
end if
774+
775+
buttonExists = isValid(m.deleteButton)
776+
777+
if canDelete and not buttonExists
778+
' Create and append delete button at end of button group (destructive action goes last)
779+
m.deleteButton = CreateObject("roSGNode", "IconButton")
780+
m.deleteButton.id = "deleteButton"
781+
m.deleteButton.icon = "pkg:/images/icons/delete.png"
782+
m.deleteButton.text = tr("Delete")
783+
m.buttonGrp.appendChild(m.deleteButton)
784+
else if not canDelete and buttonExists
785+
' Remove delete button and adjust focus if needed
786+
currentFocusIndex = m.buttonGrp.buttonFocused
787+
deleteButtonIndex = getButtonIndex("deleteButton")
788+
789+
m.buttonGrp.removeChild(m.deleteButton)
790+
m.deleteButton = invalid
791+
792+
' Adjust focus: if user was on or after delete button, shift focus back (clamped to 0)
793+
if isValid(currentFocusIndex) and isValid(deleteButtonIndex) and currentFocusIndex >= deleteButtonIndex
794+
focusIndex = currentFocusIndex - 1
795+
if focusIndex < 0 then focusIndex = 0
796+
m.buttonGrp.buttonFocused = focusIndex
797+
end if
798+
m.buttonGrp.callFunc("focus")
799+
end if
800+
end sub
801+
761802
function round(f as float) as integer
762803
' BrightScript only has a "floor" round
763804
' This compares floor to floor + 1 to find which is closer

docs/data/search.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/module-MovieDetails.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/source_Main.bs.html

Lines changed: 57 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,12 @@
767767
favoriteButton.selected = true
768768
end if
769769
end if
770+
else if btn.id = "deleteButton"
771+
print "deleteButton pressed"
772+
if isValid(group) and isValid(group.itemContent) and isValid(group.itemContent.json)
773+
m.pendingDeleteItemId = group.itemContent.json.id
774+
m.global.sceneManager.callFunc("optionDialog", tr("Delete"), [tr("Are you sure you want to delete this item? This action cannot be undone.")], [tr("Cancel"), tr("Delete")])
775+
end if
770776
else if btn.id = "playAll"
771777
print "playAll button pressed"
772778
' User has selected playlist of of audio they want us to play
@@ -959,47 +965,60 @@
959965
popupNode = msg.getRoSGNode()
960966
stopLoadingSpinner()
961967
if isValid(popupNode) and isValid(popupNode.returnData)
962-
selectedItem = m.global.queueManager.callFunc("getHold")
963-
m.global.queueManager.callFunc("clearHold")
964-
965-
if isValidAndNotEmpty(selectedItem) and isValid(selectedItem[0])
966-
if popupNode.returnData.indexselected = 0
967-
'Resume video from resume point
968-
startLoadingSpinner()
969-
startingPoint = 0
970-
971-
if isValid(selectedItem[0].UserData) and isValid(selectedItem[0].UserData.PlaybackPositionTicks)
972-
if selectedItem[0].UserData.PlaybackPositionTicks > 0
973-
startingPoint = selectedItem[0].UserData.PlaybackPositionTicks
968+
print "popupNode.returnData = ", popupNode.returnData
969+
' Handle delete confirmation dialog
970+
if isValid(m.pendingDeleteItemId)
971+
if popupNode.returnData.indexSelected = 1 and popupNode.returnData.buttonSelected = tr("Delete")
972+
' User confirmed deletion
973+
api.items.DeleteByID(m.pendingDeleteItemId)
974+
m.pendingDeleteItemId = invalid
975+
m.global.sceneManager.callFunc("popScene")
976+
else
977+
' User cancelled or dialog closed
978+
m.pendingDeleteItemId = invalid
979+
end if
980+
else
981+
selectedItem = m.global.queueManager.callFunc("getHold")
982+
m.global.queueManager.callFunc("clearHold")
983+
984+
if isValidAndNotEmpty(selectedItem) and isValid(selectedItem[0])
985+
if popupNode.returnData.indexselected = 0
986+
'Resume video from resume point
987+
startLoadingSpinner()
988+
startingPoint = 0
989+
990+
if isValid(selectedItem[0].UserData) and isValid(selectedItem[0].UserData.PlaybackPositionTicks)
991+
if selectedItem[0].UserData.PlaybackPositionTicks > 0
992+
startingPoint = selectedItem[0].UserData.PlaybackPositionTicks
993+
end if
974994
end if
975-
end if
976995

977-
selectedItem[0].startingPoint = startingPoint
978-
m.global.queueManager.callFunc("clear")
979-
m.global.queueManager.callFunc("push", selectedItem[0])
980-
m.global.queueManager.callFunc("playQueue")
981-
else if popupNode.returnData.indexselected = 1
982-
'Start Over from beginning selected, set position to 0
983-
startLoadingSpinner()
984-
selectedItem[0].startingPoint = 0
985-
m.global.queueManager.callFunc("clear")
986-
m.global.queueManager.callFunc("push", selectedItem[0])
987-
m.global.queueManager.callFunc("playQueue")
988-
else if popupNode.returnData.indexselected = 2
989-
' User chose Go to series
990-
CreateSeriesDetailsGroup(selectedItem[0].SeriesId)
991-
else if popupNode.returnData.indexselected = 3
992-
' User chose Go to season
993-
if isValid(selectedItem[0].SeriesId) and isValid(selectedItem[0].seasonID)
994-
CreateSeasonDetailsGroupByID(selectedItem[0].SeriesId, selectedItem[0].seasonID)
995-
else
996-
stopLoadingSpinner()
997-
message_dialog(tr("Error loading Season"))
996+
selectedItem[0].startingPoint = startingPoint
997+
m.global.queueManager.callFunc("clear")
998+
m.global.queueManager.callFunc("push", selectedItem[0])
999+
m.global.queueManager.callFunc("playQueue")
1000+
else if popupNode.returnData.indexselected = 1
1001+
'Start Over from beginning selected, set position to 0
1002+
startLoadingSpinner()
1003+
selectedItem[0].startingPoint = 0
1004+
m.global.queueManager.callFunc("clear")
1005+
m.global.queueManager.callFunc("push", selectedItem[0])
1006+
m.global.queueManager.callFunc("playQueue")
1007+
else if popupNode.returnData.indexselected = 2
1008+
' User chose Go to series
1009+
CreateSeriesDetailsGroup(selectedItem[0].SeriesId)
1010+
else if popupNode.returnData.indexselected = 3
1011+
' User chose Go to season
1012+
if isValid(selectedItem[0].SeriesId) and isValid(selectedItem[0].seasonID)
1013+
CreateSeasonDetailsGroupByID(selectedItem[0].SeriesId, selectedItem[0].seasonID)
1014+
else
1015+
stopLoadingSpinner()
1016+
message_dialog(tr("Error loading Season"))
1017+
end if
1018+
else if popupNode.returnData.indexselected = 4
1019+
' User chose Go to episode
1020+
CreateMovieDetailsGroup(selectedItem[0])
9981021
end if
999-
1000-
else if popupNode.returnData.indexselected = 4
1001-
' User chose Go to episode
1002-
CreateMovieDetailsGroup(selectedItem[0])
10031022
end if
10041023
end if
10051024
end if

0 commit comments

Comments
 (0)