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