nova-trame 0.19.0.dev2__py3-none-any.whl → 0.19.0.dev4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -129,6 +129,17 @@ class DataSelectorModel:
129
129
 
130
130
  return sorted(experiments)
131
131
 
132
+ def sort_directories(self, directories: List[Any]) -> List[Any]:
133
+ # Sort the current level of dictionaries
134
+ sorted_dirs = sorted(directories, key=lambda x: x["title"])
135
+
136
+ # Process each sorted item to sort their children
137
+ for item in sorted_dirs:
138
+ if "children" in item and isinstance(item["children"], list):
139
+ item["children"] = self.sort_directories(item["children"])
140
+
141
+ return sorted_dirs
142
+
132
143
  def get_directories(self) -> List[Any]:
133
144
  if not self.state.experiment:
134
145
  return []
@@ -162,7 +173,7 @@ class DataSelectorModel:
162
173
  except OSError:
163
174
  pass
164
175
 
165
- return directories
176
+ return self.sort_directories(directories)
166
177
 
167
178
  def get_datafiles(self) -> List[str]:
168
179
  datafiles = []
@@ -78,66 +78,72 @@ class DataSelector(vuetify.VDataTable):
78
78
  self.create_ui(facility, instrument, **kwargs)
79
79
 
80
80
  def create_ui(self, facility: str, instrument: str, **kwargs: Any) -> None:
81
- with GridLayout(columns=3):
82
- columns = 3
83
- if facility == "":
84
- columns -= 1
85
- InputField(v_model=f"{self._state_name}.facility", items=(self._facilities_name,), type="autocomplete")
86
- if instrument == "":
87
- columns -= 1
81
+ with html.Div():
82
+ with GridLayout(columns=3):
83
+ columns = 3
84
+ if facility == "":
85
+ columns -= 1
86
+ InputField(
87
+ v_model=f"{self._state_name}.facility", items=(self._facilities_name,), type="autocomplete"
88
+ )
89
+ if instrument == "":
90
+ columns -= 1
91
+ InputField(
92
+ v_model=f"{self._state_name}.instrument", items=(self._instruments_name,), type="autocomplete"
93
+ )
88
94
  InputField(
89
- v_model=f"{self._state_name}.instrument", items=(self._instruments_name,), type="autocomplete"
95
+ v_model=f"{self._state_name}.experiment",
96
+ column_span=columns,
97
+ items=(self._experiments_name,),
98
+ type="autocomplete",
99
+ )
100
+
101
+ with GridLayout(columns=3, height="500px", valign="start"):
102
+ if not self._prefix:
103
+ with html.Div(classes="overflow-y-auto", style="max-height: 500px"):
104
+ vuetify.VListSubheader("Available Directories", classes="justify-center px-0")
105
+ vuetify.VTreeview(
106
+ v_if=(f"{self._directories_name}.length > 0",),
107
+ activatable=True,
108
+ active_strategy="single-independent",
109
+ item_value="path",
110
+ items=(self._directories_name,),
111
+ update_activated=(self._vm.set_directory, "$event"),
112
+ )
113
+ vuetify.VListItem("No directories found", v_else=True)
114
+
115
+ super().__init__(
116
+ v_model=self._v_model,
117
+ column_span=3 if self._prefix else 2,
118
+ headers=("[{ align: 'center', key: 'title', title: 'Available Datafiles' }]",),
119
+ item_title="title",
120
+ item_value="path",
121
+ select_strategy=self._select_strategy,
122
+ show_select=True,
123
+ **kwargs,
90
124
  )
91
- InputField(
92
- v_model=f"{self._state_name}.experiment",
93
- column_span=columns,
94
- items=(self._experiments_name,),
95
- type="autocomplete",
96
- )
97
-
98
- with GridLayout(columns=3, valign="start"):
99
- if not self._prefix:
100
- with html.Div():
101
- vuetify.VListSubheader("Available Directories", classes="justify-center px-0")
102
- vuetify.VTreeview(
103
- v_if=(f"{self._directories_name}.length > 0",),
104
- activatable=True,
105
- active_strategy="single-independent",
106
- item_value="path",
107
- items=(self._directories_name,),
108
- update_activated=(self._vm.set_directory, "$event"),
125
+ self.items = (self._datafiles_name,)
126
+ if "update_modelValue" not in kwargs:
127
+ self.update_modelValue = f"flushState('{self._v_model.split('.')[0]}')"
128
+
129
+ with cast(
130
+ vuetify.VSelect,
131
+ InputField(
132
+ v_show=f"{self._v_model}.length > 0",
133
+ v_model=self._v_model,
134
+ classes="nova-readonly",
135
+ clearable=True,
136
+ label=self._label,
137
+ readonly=True,
138
+ type="select",
139
+ click_clear=f"{self._v_model} = []; flushState('{self._v_model.split('.')[0]}');",
140
+ ),
141
+ ):
142
+ with vuetify.Template(raw_attrs=['v-slot:selection="{ item, index }"']):
143
+ vuetify.VChip("{{ item.title }}", v_if="index < 2")
144
+ html.Span(
145
+ f"(+{{{{ {self._v_model}.length - 2 }}}} others)", v_if="index === 2", classes="text-caption"
109
146
  )
110
- vuetify.VListItem("No directories found", v_else=True)
111
-
112
- super().__init__(
113
- v_model=self._v_model,
114
- column_span=3 if self._prefix else 2,
115
- headers=("[{ align: 'center', key: 'title', title: 'Available Datafiles' }]",),
116
- item_title="title",
117
- item_value="path",
118
- select_strategy=self._select_strategy,
119
- show_select=True,
120
- **kwargs,
121
- )
122
- self.items = (self._datafiles_name,)
123
- if "update_modelValue" not in kwargs:
124
- self.update_modelValue = f"flushState('{self._v_model.split('.')[0]}')"
125
-
126
- with cast(
127
- vuetify.VSelect,
128
- InputField(
129
- v_if=f"{self._v_model}.length > 0",
130
- v_model=self._v_model,
131
- classes="nova-readonly",
132
- clearable=True,
133
- label=self._label,
134
- readonly=True,
135
- type="select",
136
- ),
137
- ):
138
- with vuetify.Template(raw_attrs=['v-slot:selection="{ item, index }"']):
139
- vuetify.VChip("{{ item.title }}", v_if="index < 2")
140
- html.Span(f"(+{{{{ {self._v_model}.length - 2 }}}} others)", v_if="index === 2", classes="text-caption")
141
147
 
142
148
  def create_model(self, facility: str, instrument: str) -> None:
143
149
  self._model = DataSelectorModel(facility, instrument, self._prefix)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: nova-trame
3
- Version: 0.19.0.dev2
3
+ Version: 0.19.0.dev4
4
4
  Summary: A Python Package for injecting curated themes and custom components into Trame applications
5
5
  License: MIT
6
6
  Keywords: NDIP,Python,Trame,Vuetify
@@ -1,9 +1,9 @@
1
1
  nova/__init__.py,sha256=ED6jHcYiuYpr_0vjGz0zx2lrrmJT9sDJCzIljoDfmlM,65
2
2
  nova/trame/__init__.py,sha256=gFrAg1qva5PIqR5TjvPzAxLx103IKipJLqp3XXvrQL8,59
3
- nova/trame/model/data_selector.py,sha256=8BnnPvdYZTmCOJFuWOs_RhQ1NvYqWFdPmWP09WWP5oA,6689
3
+ nova/trame/model/data_selector.py,sha256=6tH5E7PmPMc6Cc7utFqe7MUpKsUP15_2jU0plygeqn0,7168
4
4
  nova/trame/model/remote_file_input.py,sha256=9KAf31ZHzpsh_aXUrNcF81Q5jvUZDWCzW1QATKls-Jk,3675
5
5
  nova/trame/view/components/__init__.py,sha256=u8yzshFp_TmuC1g9TRxKjy_BdGWMIzPQouI52hzcr2U,234
6
- nova/trame/view/components/data_selector.py,sha256=vRbN2FlcfnUWpmL4MFfRqrbhXQWip2_QLMoMg9KFXCs,7584
6
+ nova/trame/view/components/data_selector.py,sha256=L9AzHrg1IH_SwlOTjQiZNeN_mEVsCj0xgKIeYLVnFH4,8102
7
7
  nova/trame/view/components/file_upload.py,sha256=XbiSx2txpdohwxGyP-ecTbIgMPv6siUARJ7nXhXaiAc,2827
8
8
  nova/trame/view/components/input_field.py,sha256=ncVVSzdJwH_-KP24I2rCqcb6v3J2hPhNTXr8Lb1EZ_U,15931
9
9
  nova/trame/view/components/remote_file_input.py,sha256=lFchhhoMo9EgSr7pSlh2LEm8NZO1XXrBcfh_BLGZBV0,9492
@@ -25,8 +25,8 @@ nova/trame/view/theme/theme.py,sha256=OFUtq1IWriFcDu-346J67ZrSES8IOI9PTY_4Vwg7bZ
25
25
  nova/trame/view/utilities/local_storage.py,sha256=vD8f2VZIpxhIKjZwEaD7siiPCTZO4cw9AfhwdawwYLY,3218
26
26
  nova/trame/view_model/data_selector.py,sha256=Bpkfjd78ZIkexHNF_aA9PfizRBzkeOuoSE7ZsBFcSOs,1749
27
27
  nova/trame/view_model/remote_file_input.py,sha256=ojEOJ8ZPkajpbAaZi9VLj7g-uBjhb8BMrTdMmwf_J6A,3367
28
- nova_trame-0.19.0.dev2.dist-info/LICENSE,sha256=Iu5QiDbwNbREg75iYaxIJ_V-zppuv4QFuBhAW-qiAlM,1061
29
- nova_trame-0.19.0.dev2.dist-info/METADATA,sha256=7HZZEW7-Vs_z1Oo0T1AUeIUOodsk5Z0sE60yloyGXns,1451
30
- nova_trame-0.19.0.dev2.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
31
- nova_trame-0.19.0.dev2.dist-info/entry_points.txt,sha256=J2AmeSwiTYZ4ZqHHp9HO6v4MaYQTTBPbNh6WtoqOT58,42
32
- nova_trame-0.19.0.dev2.dist-info/RECORD,,
28
+ nova_trame-0.19.0.dev4.dist-info/LICENSE,sha256=Iu5QiDbwNbREg75iYaxIJ_V-zppuv4QFuBhAW-qiAlM,1061
29
+ nova_trame-0.19.0.dev4.dist-info/METADATA,sha256=_hm3UBkHt6w5rNkzy_v089JWk_nn94RocwvVNtrsnys,1451
30
+ nova_trame-0.19.0.dev4.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
31
+ nova_trame-0.19.0.dev4.dist-info/entry_points.txt,sha256=J2AmeSwiTYZ4ZqHHp9HO6v4MaYQTTBPbNh6WtoqOT58,42
32
+ nova_trame-0.19.0.dev4.dist-info/RECORD,,