add/edit tag to ui
parent
7d7e43c6f0
commit
a03449a32b
@ -0,0 +1,142 @@
|
||||
import click
|
||||
|
||||
from textual import events
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.screen import Screen
|
||||
from textual.widgets import Header, Footer, Placeholder, Label, ListView, ListItem, Static, DataTable, Button, Input
|
||||
from textual.containers import Grid, Horizontal
|
||||
|
||||
from ffx.model.pattern import Pattern
|
||||
from ffx.track_descriptor import TrackDescriptor
|
||||
|
||||
# from .show_controller import ShowController
|
||||
# from .pattern_controller import PatternController
|
||||
from .track_controller import TrackController
|
||||
|
||||
from .track_type import TrackType
|
||||
|
||||
# Screen[dict[int, str, int]]
|
||||
class TrackDeleteScreen(Screen):
|
||||
|
||||
CSS = """
|
||||
|
||||
Grid {
|
||||
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;
|
||||
}
|
||||
|
||||
Input {
|
||||
border: none;
|
||||
}
|
||||
Button {
|
||||
border: none;
|
||||
}
|
||||
#toplabel {
|
||||
height: 1;
|
||||
}
|
||||
|
||||
.two {
|
||||
column-span: 2;
|
||||
}
|
||||
.three {
|
||||
column-span: 3;
|
||||
}
|
||||
.four {
|
||||
column-span: 4;
|
||||
}
|
||||
|
||||
.box {
|
||||
height: 100%;
|
||||
border: solid green;
|
||||
}
|
||||
"""
|
||||
|
||||
def __init__(self, trackDescriptor : TrackDescriptor):
|
||||
super().__init__()
|
||||
|
||||
self.context = self.app.getContext()
|
||||
self.Session = self.context['database']['session'] # convenience
|
||||
|
||||
if type(trackDescriptor) is not TrackDescriptor:
|
||||
raise click.ClickException('TrackDeleteScreen.init(): trackDescriptor is required to be of type TrackDescriptor')
|
||||
|
||||
self.__tc = TrackController(context = self.context)
|
||||
|
||||
self.__trackDescriptor = trackDescriptor
|
||||
|
||||
|
||||
def on_mount(self):
|
||||
|
||||
self.query_one("#subindexlabel", Static).update(str(self.__trackDescriptor.getSubIndex()))
|
||||
self.query_one("#patternlabel", Static).update(str(self.__trackDescriptor.getPatternId()))
|
||||
self.query_one("#languagelabel", Static).update(str(self.__trackDescriptor.getLanguage().label()))
|
||||
self.query_one("#titlelabel", Static).update(str(str(self.__trackDescriptor.getTitle())))
|
||||
|
||||
|
||||
def compose(self):
|
||||
|
||||
yield Header()
|
||||
|
||||
with Grid():
|
||||
|
||||
#1
|
||||
yield Static(f"Are you sure to delete the following {self.__trackDescriptor.getType().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")
|
||||
|
||||
#5
|
||||
yield Static("Language")
|
||||
yield Static(" ", id="languagelabel", classes="three")
|
||||
|
||||
#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")
|
||||
|
||||
yield Footer()
|
||||
|
||||
|
||||
# Event handler for button press
|
||||
def on_button_pressed(self, event: Button.Pressed) -> None:
|
||||
|
||||
if event.button.id == "delete_button":
|
||||
|
||||
track = self.__tc.findTrack(self.__trackDescriptor.getPatternId(), self.__trackDescriptor.getType(), self.__trackDescriptor.getSubIndex())
|
||||
|
||||
if track is None:
|
||||
raise click.ClickException(f"Track is none: patternId={self.__trackDescriptor.getPatternId()} type={self.__trackDescriptor.getType()} subIndex={self.__trackDescriptor.getSubIndex()}")
|
||||
|
||||
if track is not None:
|
||||
|
||||
if self.__tc.deleteTrack(track.getId()):
|
||||
self.dismiss(self.__trackDescriptor)
|
||||
|
||||
else:
|
||||
#TODO: Meldung
|
||||
self.app.pop_screen()
|
||||
|
||||
if event.button.id == "cancel_button":
|
||||
self.app.pop_screen()
|
||||
|
@ -0,0 +1,125 @@
|
||||
import click, time
|
||||
|
||||
from textual import events
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.screen import Screen
|
||||
from textual.widgets import Header, Footer, Placeholder, Label, ListView, ListItem, Static, DataTable, Button, Input, Checkbox, SelectionList, Select
|
||||
from textual.containers import Grid, Horizontal
|
||||
|
||||
# Screen[dict[int, str, int]]
|
||||
class TagDetailsScreen(Screen):
|
||||
|
||||
CSS = """
|
||||
|
||||
Grid {
|
||||
grid-size: 5 20;
|
||||
grid-rows: 2 2 2 2 2 3 2 2 2 2 2 6 2 2 6 2 2 2 2 6;
|
||||
grid-columns: 25 25 25 25 225;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
padding: 1;
|
||||
}
|
||||
|
||||
Input {
|
||||
border: none;
|
||||
}
|
||||
Button {
|
||||
border: none;
|
||||
}
|
||||
SelectionList {
|
||||
border: none;
|
||||
min-height: 6;
|
||||
}
|
||||
Select {
|
||||
border: none;
|
||||
}
|
||||
DataTable {
|
||||
min-height: 6;
|
||||
}
|
||||
|
||||
#toplabel {
|
||||
height: 1;
|
||||
}
|
||||
|
||||
.two {
|
||||
column-span: 2;
|
||||
}
|
||||
.three {
|
||||
column-span: 3;
|
||||
}
|
||||
|
||||
.four {
|
||||
column-span: 4;
|
||||
}
|
||||
.five {
|
||||
column-span: 5;
|
||||
}
|
||||
|
||||
.box {
|
||||
height: 100%;
|
||||
border: solid green;
|
||||
}
|
||||
"""
|
||||
|
||||
def __init__(self, key=None, value=None):
|
||||
super().__init__()
|
||||
self.__key = key
|
||||
self.__value = value
|
||||
|
||||
|
||||
|
||||
def on_mount(self):
|
||||
|
||||
if self.__key is not None:
|
||||
self.query_one("#key_input", Input).value = str(self.__key)
|
||||
|
||||
if self.__value is not None:
|
||||
self.query_one("#value_input", Input).value = str(self.__value)
|
||||
|
||||
|
||||
def compose(self):
|
||||
|
||||
yield Header()
|
||||
|
||||
with Grid():
|
||||
|
||||
# 8
|
||||
yield Static("Key")
|
||||
yield Input(id="key_input", classes="four")
|
||||
|
||||
yield Static("Value")
|
||||
yield Input(id="value_input", classes="four")
|
||||
|
||||
# 17
|
||||
yield Static(" ", classes="five")
|
||||
|
||||
# 18
|
||||
yield Button("Save", id="save_button")
|
||||
yield Button("Cancel", id="cancel_button")
|
||||
|
||||
# 19
|
||||
yield Static(" ", classes="five")
|
||||
|
||||
# 20
|
||||
yield Static(" ", classes="five", id="messagestatic")
|
||||
|
||||
yield Footer(id="footer")
|
||||
|
||||
|
||||
def getTagFromInput(self):
|
||||
|
||||
tagKey = self.query_one("#key_input", Input).value
|
||||
tagValue = self.query_one("#value_input", Input).value
|
||||
|
||||
return (tagKey, tagValue)
|
||||
|
||||
|
||||
# Event handler for button press
|
||||
def on_button_pressed(self, event: Button.Pressed) -> None:
|
||||
|
||||
# Check if the button pressed is the one we are interested in
|
||||
if event.button.id == "save_button":
|
||||
self.dismiss(self.getTagFromInput())
|
||||
|
||||
if event.button.id == "cancel_button":
|
||||
self.app.pop_screen()
|
Loading…
Reference in New Issue