|
|
|
@ -20,9 +20,9 @@ class TrackDeleteScreen(Screen):
|
|
|
|
|
CSS = """
|
|
|
|
|
|
|
|
|
|
Grid {
|
|
|
|
|
grid-size: 2;
|
|
|
|
|
grid-rows: 2 auto;
|
|
|
|
|
grid-columns: 30 330;
|
|
|
|
|
grid-size: 4 9;
|
|
|
|
|
grid-rows: 2 2 2 2 2 2 2 2 2;
|
|
|
|
|
grid-columns: 30 30 30 30;
|
|
|
|
|
height: 100%;
|
|
|
|
|
width: 100%;
|
|
|
|
|
padding: 1;
|
|
|
|
@ -41,6 +41,12 @@ class TrackDeleteScreen(Screen):
|
|
|
|
|
.two {
|
|
|
|
|
column-span: 2;
|
|
|
|
|
}
|
|
|
|
|
.three {
|
|
|
|
|
column-span: 3;
|
|
|
|
|
}
|
|
|
|
|
.four {
|
|
|
|
|
column-span: 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.box {
|
|
|
|
|
height: 100%;
|
|
|
|
@ -48,29 +54,26 @@ class TrackDeleteScreen(Screen):
|
|
|
|
|
}
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def __init__(self, trackType : TrackType, trackId = None):
|
|
|
|
|
def __init__(self, trackId = None):
|
|
|
|
|
super().__init__()
|
|
|
|
|
|
|
|
|
|
self.context = self.app.getContext()
|
|
|
|
|
self.Session = self.context['database_session'] # convenience
|
|
|
|
|
|
|
|
|
|
self.__tc = TrackController(context = self.context)
|
|
|
|
|
# self.__pc = PatternController(context = self.context)
|
|
|
|
|
# self.__sc = ShowController(context = self.context)
|
|
|
|
|
if trackId is None:
|
|
|
|
|
raise click.ClickException('TrackDeleteScreen.init(): trackId is required to be set')
|
|
|
|
|
|
|
|
|
|
# self.pattern_obj = self.__pc.getPatternDescriptor(patternId) if patternId is not None else {}
|
|
|
|
|
# self.show_obj = self.__sc.getShowDesciptor(showId) if showId is not None else {}
|
|
|
|
|
self.__tc = TrackController(context = self.context)
|
|
|
|
|
|
|
|
|
|
self.trackType = trackType
|
|
|
|
|
self.track_obj = {}
|
|
|
|
|
self.track_obj = self.__tc.getTrackDescriptor(trackId)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def on_mount(self):
|
|
|
|
|
pass
|
|
|
|
|
# if self.show_obj:
|
|
|
|
|
# self.query_one("#showlabel", Static).update(f"{self.show_obj['id']} - {self.show_obj['name']} ({self.show_obj['year']})")
|
|
|
|
|
# if self.pattern_obj:
|
|
|
|
|
# self.query_one("#patternlabel", Static).update(str(self.pattern_obj['pattern']))
|
|
|
|
|
|
|
|
|
|
self.query_one("#subindexlabel", Static).update(str(self.track_obj['sub_index']))
|
|
|
|
|
self.query_one("#patternlabel", Static).update(str(self.track_obj['pattern_id']))
|
|
|
|
|
self.query_one("#languagelabel", Static).update(str(self.track_obj['language'].label()))
|
|
|
|
|
self.query_one("#titlelabel", Static).update(str(str(self.track_obj['title'])))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def compose(self):
|
|
|
|
@ -79,20 +82,35 @@ class TrackDeleteScreen(Screen):
|
|
|
|
|
|
|
|
|
|
with Grid():
|
|
|
|
|
|
|
|
|
|
yield Static(f"Are you sure to delete the following {self.trackType.label()} stream?", id="toplabel", classes="two")
|
|
|
|
|
#1
|
|
|
|
|
yield Static(f"Are you sure to delete the following {self.track_obj['type'].label()} track?", id="toplabel", classes="four")
|
|
|
|
|
|
|
|
|
|
#2
|
|
|
|
|
yield Static("sub index")
|
|
|
|
|
yield Static(" ", id="subindexlabel", classes="three")
|
|
|
|
|
|
|
|
|
|
#3
|
|
|
|
|
yield Static("from pattern")
|
|
|
|
|
yield Static(" ", id="patternlabel", classes="three")
|
|
|
|
|
|
|
|
|
|
#4
|
|
|
|
|
yield Static(" ", classes="four")
|
|
|
|
|
|
|
|
|
|
# yield Static("", classes="two")
|
|
|
|
|
#
|
|
|
|
|
# yield Static("Pattern")
|
|
|
|
|
# yield Static("", id="patternlabel")
|
|
|
|
|
#
|
|
|
|
|
# yield Static("", classes="two")
|
|
|
|
|
#
|
|
|
|
|
# yield Static("from show")
|
|
|
|
|
# yield Static("", id="showlabel")
|
|
|
|
|
#5
|
|
|
|
|
yield Static("Language")
|
|
|
|
|
yield Static(" ", id="languagelabel", classes="three")
|
|
|
|
|
|
|
|
|
|
yield Static("", classes="two")
|
|
|
|
|
#6
|
|
|
|
|
yield Static("Title")
|
|
|
|
|
yield Static(" ", id="titlelabel", classes="three")
|
|
|
|
|
|
|
|
|
|
#7
|
|
|
|
|
yield Static(" ", classes="four")
|
|
|
|
|
|
|
|
|
|
#8
|
|
|
|
|
yield Static(" ", classes="four")
|
|
|
|
|
|
|
|
|
|
#9
|
|
|
|
|
yield Button("Delete", id="delete_button")
|
|
|
|
|
yield Button("Cancel", id="cancel_button")
|
|
|
|
|
|
|
|
|
@ -102,20 +120,19 @@ class TrackDeleteScreen(Screen):
|
|
|
|
|
# Event handler for button press
|
|
|
|
|
def on_button_pressed(self, event: Button.Pressed) -> None:
|
|
|
|
|
|
|
|
|
|
# if event.button.id == "delete_button":
|
|
|
|
|
#
|
|
|
|
|
# if self.__pc.deletePattern(self.pattern_obj['id']):
|
|
|
|
|
#
|
|
|
|
|
# screenResult = {}
|
|
|
|
|
# screenResult['show_id'] = self.show_obj['id']
|
|
|
|
|
# screenResult['pattern'] = self.pattern_obj['pattern']
|
|
|
|
|
#
|
|
|
|
|
# self.dismiss(screenResult)
|
|
|
|
|
#
|
|
|
|
|
# else:
|
|
|
|
|
# #TODO: Meldung
|
|
|
|
|
# self.app.pop_screen()
|
|
|
|
|
#
|
|
|
|
|
if event.button.id == "delete_button":
|
|
|
|
|
|
|
|
|
|
trackId = self.__tc.findTrack(self.track_obj['pattern_id'], self.track_obj['type'], self.track_obj['sub_index'])
|
|
|
|
|
|
|
|
|
|
if trackId is not None:
|
|
|
|
|
|
|
|
|
|
if self.__tc.deleteTrack(trackId):
|
|
|
|
|
self.dismiss(self.track_obj)
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
#TODO: Meldung
|
|
|
|
|
self.app.pop_screen()
|
|
|
|
|
|
|
|
|
|
if event.button.id == "cancel_button":
|
|
|
|
|
self.app.pop_screen()
|
|
|
|
|
|
|
|
|
|