|
|
@ -15,6 +15,9 @@ from .pattern_delete_screen import PatternDeleteScreen
|
|
|
|
from .show_controller import ShowController
|
|
|
|
from .show_controller import ShowController
|
|
|
|
from .pattern_controller import PatternController
|
|
|
|
from .pattern_controller import PatternController
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from .show_descriptor import ShowDescriptor
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Screen[dict[int, str, int]]
|
|
|
|
# Screen[dict[int, str, int]]
|
|
|
|
class ShowDetailsScreen(Screen):
|
|
|
|
class ShowDetailsScreen(Screen):
|
|
|
|
|
|
|
|
|
|
|
@ -79,7 +82,7 @@ class ShowDetailsScreen(Screen):
|
|
|
|
self.__sc = ShowController(context = self.context)
|
|
|
|
self.__sc = ShowController(context = self.context)
|
|
|
|
self.__pc = PatternController(context = self.context)
|
|
|
|
self.__pc = PatternController(context = self.context)
|
|
|
|
|
|
|
|
|
|
|
|
self.show_obj = self.__sc.getShowDescriptor(showId) if showId is not None else {}
|
|
|
|
self.__showDescriptor = self.__sc.getShowDescriptor(showId) if showId is not None else None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def loadPatterns(self, show_id : int):
|
|
|
|
def loadPatterns(self, show_id : int):
|
|
|
@ -98,18 +101,18 @@ class ShowDetailsScreen(Screen):
|
|
|
|
|
|
|
|
|
|
|
|
def on_mount(self):
|
|
|
|
def on_mount(self):
|
|
|
|
|
|
|
|
|
|
|
|
if self.show_obj:
|
|
|
|
if not self.__showDescriptor is None:
|
|
|
|
|
|
|
|
|
|
|
|
self.query_one("#id_wdg", Static).update(str(self.show_obj['id']))
|
|
|
|
self.query_one("#id_wdg", Static).update(str(self.__showDescriptor.getId()))
|
|
|
|
self.query_one("#name_input", Input).value = str(self.show_obj['name'])
|
|
|
|
self.query_one("#name_input", Input).value = str(self.__showDescriptor.getName())
|
|
|
|
self.query_one("#year_input", Input).value = str(self.show_obj['year'])
|
|
|
|
self.query_one("#year_input", Input).value = str(self.__showDescriptor.getYear())
|
|
|
|
|
|
|
|
|
|
|
|
self.query_one("#index_season_digits_input", Input).value = str(self.show_obj['index_season_digits'])
|
|
|
|
self.query_one("#index_season_digits_input", Input).value = str(self.__showDescriptor.getIndexSeasonDigits())
|
|
|
|
self.query_one("#index_episode_digits_input", Input).value = str(self.show_obj['index_episode_digits'])
|
|
|
|
self.query_one("#index_episode_digits_input", Input).value = str(self.__showDescriptor.getIndexEpisodeDigits())
|
|
|
|
self.query_one("#indicator_season_digits_input", Input).value = str(self.show_obj['indicator_season_digits'])
|
|
|
|
self.query_one("#indicator_season_digits_input", Input).value = str(self.__showDescriptor.getIndicatorSeasonDigits())
|
|
|
|
self.query_one("#indicator_episode_digits_input", Input).value = str(self.show_obj['indicator_episode_digits'])
|
|
|
|
self.query_one("#indicator_episode_digits_input", Input).value = str(self.__showDescriptor.getIndicatorEpisodeDigits())
|
|
|
|
|
|
|
|
|
|
|
|
showId = int(self.show_obj['id'])
|
|
|
|
showId = int(self.__showDescriptor.getId())
|
|
|
|
#raise click.ClickException(f"show_id {showId}")
|
|
|
|
#raise click.ClickException(f"show_id {showId}")
|
|
|
|
patternList = self.loadPatterns(showId)
|
|
|
|
patternList = self.loadPatterns(showId)
|
|
|
|
# raise click.ClickException(f"patternList {patternList}")
|
|
|
|
# raise click.ClickException(f"patternList {patternList}")
|
|
|
@ -138,7 +141,7 @@ class ShowDetailsScreen(Screen):
|
|
|
|
if row_key is not None:
|
|
|
|
if row_key is not None:
|
|
|
|
selected_row_data = self.patternTable.get_row(row_key)
|
|
|
|
selected_row_data = self.patternTable.get_row(row_key)
|
|
|
|
|
|
|
|
|
|
|
|
selectedPattern['show_id'] = self.show_obj['id']
|
|
|
|
selectedPattern['show_id'] = self.__showDescriptor.getId()
|
|
|
|
selectedPattern['pattern'] = str(selected_row_data[0])
|
|
|
|
selectedPattern['pattern'] = str(selected_row_data[0])
|
|
|
|
|
|
|
|
|
|
|
|
except CellDoesNotExist:
|
|
|
|
except CellDoesNotExist:
|
|
|
@ -151,8 +154,8 @@ class ShowDetailsScreen(Screen):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def action_add_pattern(self):
|
|
|
|
def action_add_pattern(self):
|
|
|
|
if self.show_obj:
|
|
|
|
if not self.__showDescriptor is None:
|
|
|
|
self.app.push_screen(PatternDetailsScreen(showId = self.show_obj['id']), self.handle_add_pattern) # <-
|
|
|
|
self.app.push_screen(PatternDetailsScreen(showId = self.__showDescriptor.getId()), self.handle_add_pattern) # <-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def handle_add_pattern(self, screenResult):
|
|
|
|
def handle_add_pattern(self, screenResult):
|
|
|
@ -172,7 +175,7 @@ class ShowDetailsScreen(Screen):
|
|
|
|
if selectedPatternId is None:
|
|
|
|
if selectedPatternId is None:
|
|
|
|
raise click.ClickException(f"ShowDetailsScreen.action_edit_pattern(): Pattern to edit has no id")
|
|
|
|
raise click.ClickException(f"ShowDetailsScreen.action_edit_pattern(): Pattern to edit has no id")
|
|
|
|
|
|
|
|
|
|
|
|
self.app.push_screen(PatternDetailsScreen(patternId = selectedPatternId, showId = self.show_obj['id']), self.handle_edit_pattern) # <-
|
|
|
|
self.app.push_screen(PatternDetailsScreen(patternId = selectedPatternId, showId = self.__showDescriptor.getId()), self.handle_edit_pattern) # <-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def handle_edit_pattern(self, screenResult):
|
|
|
|
def handle_edit_pattern(self, screenResult):
|
|
|
@ -197,7 +200,7 @@ class ShowDetailsScreen(Screen):
|
|
|
|
if selectedPatternId is None:
|
|
|
|
if selectedPatternId is None:
|
|
|
|
raise click.ClickException(f"ShowDetailsScreen.action_remove_pattern(): Pattern to remove has no id")
|
|
|
|
raise click.ClickException(f"ShowDetailsScreen.action_remove_pattern(): Pattern to remove has no id")
|
|
|
|
|
|
|
|
|
|
|
|
self.app.push_screen(PatternDeleteScreen(patternId = selectedPatternId, showId = self.show_obj['id']), self.handle_remove_pattern)
|
|
|
|
self.app.push_screen(PatternDeleteScreen(patternId = selectedPatternId, showId = self.__showDescriptor.getId()), self.handle_remove_pattern)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def handle_remove_pattern(self, screenResult):
|
|
|
|
def handle_remove_pattern(self, screenResult):
|
|
|
@ -225,11 +228,11 @@ class ShowDetailsScreen(Screen):
|
|
|
|
with Grid():
|
|
|
|
with Grid():
|
|
|
|
|
|
|
|
|
|
|
|
# 1
|
|
|
|
# 1
|
|
|
|
yield Static("Show" if self.show_obj else "New Show", id="toplabel", classes="five")
|
|
|
|
yield Static("Show" if not self.__showDescriptor is None else "New Show", id="toplabel", classes="five")
|
|
|
|
|
|
|
|
|
|
|
|
# 2
|
|
|
|
# 2
|
|
|
|
yield Static("ID")
|
|
|
|
yield Static("ID")
|
|
|
|
if self.show_obj:
|
|
|
|
if not self.__showDescriptor is None:
|
|
|
|
yield Static("", id="id_wdg", classes="four")
|
|
|
|
yield Static("", id="id_wdg", classes="four")
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
yield Input(type="integer", id="id_wdg", classes="four")
|
|
|
|
yield Input(type="integer", id="id_wdg", classes="four")
|
|
|
@ -282,22 +285,23 @@ class ShowDetailsScreen(Screen):
|
|
|
|
|
|
|
|
|
|
|
|
def getShowDescriptorFromInput(self):
|
|
|
|
def getShowDescriptorFromInput(self):
|
|
|
|
|
|
|
|
|
|
|
|
showDescriptor = {}
|
|
|
|
kwargs = {}
|
|
|
|
|
|
|
|
|
|
|
|
if self.show_obj:
|
|
|
|
if self.__showDescriptor:
|
|
|
|
showDescriptor['id'] = int(self.show_obj['id'])
|
|
|
|
kwargs[ShowDescriptor.ID_KEY] = int(self.__showDescriptor.getId())
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
showDescriptor['id'] = int(self.query_one("#id_wdg", Input).value)
|
|
|
|
kwargs[ShowDescriptor.ID_KEY] = int(self.query_one("#id_wdg", Input).value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
showDescriptor['name'] = str(self.query_one("#name_input", Input).value)
|
|
|
|
kwargs[ShowDescriptor.NAME_KEY] = str(self.query_one("#name_input", Input).value)
|
|
|
|
showDescriptor['year'] = int(self.query_one("#year_input", Input).value)
|
|
|
|
kwargs[ShowDescriptor.YEAR_KEY] = int(self.query_one("#year_input", Input).value)
|
|
|
|
|
|
|
|
|
|
|
|
showDescriptor['index_season_digits'] = int(self.query_one("#index_season_digits_input", Input).value)
|
|
|
|
kwargs[ShowDescriptor.INDEX_SEASON_DIGITS_KEY] = int(self.query_one("#index_season_digits_input", Input).value)
|
|
|
|
showDescriptor['index_episode_digits'] = int(self.query_one("#index_episode_digits_input", Input).value)
|
|
|
|
kwargs[ShowDescriptor.INDEX_EPISODE_DIGITS_KEY] = int(self.query_one("#index_episode_digits_input", Input).value)
|
|
|
|
showDescriptor['indicator_season_digits'] = int(self.query_one("#indicator_season_digits_input", Input).value)
|
|
|
|
kwargs[ShowDescriptor.INDICATOR_SEASON_DIGITS_KEY] = int(self.query_one("#indicator_season_digits_input", Input).value)
|
|
|
|
showDescriptor['indicator_episode_digits'] = int(self.query_one("#indicator_episode_digits_input", Input).value)
|
|
|
|
kwargs[ShowDescriptor.INDICATOR_EPISODE_DIGITS_KEY] = int(self.query_one("#indicator_episode_digits_input", Input).value)
|
|
|
|
|
|
|
|
|
|
|
|
return showDescriptor
|
|
|
|
return ShowDescriptor(**kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Event handler for button press
|
|
|
|
# Event handler for button press
|
|
|
|