hightlight "new profile" link

This commit is contained in:
Jakob Ketterl 2021-03-05 17:51:19 +01:00
parent 190c90ccdf
commit 45e9bd12a5

View File

@ -126,13 +126,14 @@ class SdrFormController(SettingsFormController, metaclass=ABCMeta):
</li>
{profile_tabs}
<li class="nav-item">
<a href="{new_profile_link}" class="nav-link">New profile</a>
<a href="{new_profile_link}" class="nav-link {new_profile_active}">New profile</a>
</li>
</ul>
""".format(
device_link="{}settings/sdr/{}".format(self.get_document_root(), quote(self.device_id)),
device_name=self.device["name"],
device_active="active" if self.isDeviceActive() else "",
new_profile_active="active" if self.isNewProfileActive() else "",
new_profile_link="{}settings/sdr/{}/newprofile".format(self.get_document_root(), quote(self.device_id)),
profile_tabs="".join(
"""
@ -156,6 +157,9 @@ class SdrFormController(SettingsFormController, metaclass=ABCMeta):
def isProfileActive(self, profile_id) -> bool:
return False
def isNewProfileActive(self) -> bool:
return False
def store(self):
# need to overwrite the existing key in the config since the layering won't capture the changes otherwise
config = Config.get()
@ -383,6 +387,9 @@ class NewProfileController(SdrFormController):
def getTitle(self):
return "New profile"
def isNewProfileActive(self) -> bool:
return True
def store(self):
if self.stack["id"] in self.device["profiles"]:
raise ValueError("Profile {} already exists!".format(self.stack["id"]))