-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Updated client_code/MenuForm/NetworkMenu/Con
- Loading branch information
1 parent
811a7ee
commit 7897cfc
Showing
1 changed file
with
38 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,45 @@ | ||
from ._anvil_designer import ConnectionsTemplate | ||
from anvil import * | ||
from .... import network_controller as nc | ||
from .... import helper as h | ||
|
||
from .... import glob | ||
from .... import helper as h | ||
from .... import network_controller as nc | ||
from ._anvil_designer import ConnectionsTemplate | ||
|
||
|
||
class Connections(ConnectionsTemplate): | ||
item_keys = {'user_id'} | ||
|
||
def __init__(self, **properties): | ||
# Set Form properties and Data Bindings. | ||
self.init_components(**properties) | ||
item_keys = {"user_id"} | ||
|
||
def __init__(self, **properties): | ||
# Set Form properties and Data Bindings. | ||
self.init_components(**properties) | ||
|
||
# Any code you write here will run when the form opens. | ||
self.repeating_panel_1.set_event_handler("x-reset", self.reset) | ||
self.update() | ||
|
||
# Any code you write here will run when the form opens. | ||
self.repeating_panel_1.set_event_handler('x-reset', self.reset) | ||
self.update() | ||
|
||
def update(self): | ||
items = nc.get_connections(self.item['user_id']) | ||
items.sort(key=lambda pu: (pu.distance_str_or_groups, h.reverse_compare(pu['last_active']))) | ||
self.repeating_panel_1.items = items | ||
has_degrees = any([item.distance_str for item in items]) | ||
has_groups = any([not item.distance_str and item.common_group_names for item in items]) | ||
if not has_degrees or not has_groups: | ||
columns = list(self.data_grid_1.columns) | ||
[degree_column] = [column for column in columns if column['data_key'] == "degree"] | ||
degree_index = columns.index(degree_column) | ||
columns[degree_index]['title'] = "Degree" if has_degrees else "Group(s)" | ||
self.data_grid_1.columns = columns | ||
self.refresh_data_bindings() | ||
def update(self): | ||
items = nc.get_connections(self.item["user_id"]) | ||
items.sort( | ||
key=lambda pu: ( | ||
pu.distance_str_or_groups, | ||
h.reverse_compare(pu["last_active"]), | ||
) | ||
) | ||
self.repeating_panel_1.items = items | ||
has_degrees = any([item.distance_str for item in items]) | ||
has_groups = any( | ||
[not item.distance_str and item.common_group_names for item in items] | ||
) | ||
if not has_degrees or not has_groups: | ||
columns = list(self.data_grid_1.columns) | ||
[degree_column] = [ | ||
column for column in columns if column["data_key"] == "degree" | ||
] | ||
degree_index = columns.index(degree_column) | ||
columns[degree_index]["title"] = "Degree" if has_degrees else "Group(s)" | ||
self.data_grid_1.columns = columns | ||
self.refresh_data_bindings() | ||
|
||
def reset(self, **event_args): | ||
glob.update_lazy_vars() | ||
self.update() | ||
|
||
def reset(self, **event_args): | ||
glob.update_lazy_vars() | ||
self.update() |