Skip to content

Commit

Permalink
Add confirm methods to structure and configuration models
Browse files Browse the repository at this point in the history
  • Loading branch information
edan-bainglass committed Oct 30, 2024
1 parent 2a301e6 commit 45022e9
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/aiidalab_qe/app/configuration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def is_saved(self):
return self._model.confirmed

def confirm(self, _=None):
self._model.confirmed = True
self._model.confirm()

def reset(self):
self._model.reset()
Expand Down
3 changes: 3 additions & 0 deletions src/aiidalab_qe/app/configuration/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ def set_model_state(self, parameters):
if parameters.get(identifier):
model.set_model_state(parameters[identifier])

def confirm(self):
self.confirmed = True

def reset(self):
self.confirmed = False
self.relax_type_help = self._get_default_relax_type_help()
Expand Down
4 changes: 2 additions & 2 deletions src/aiidalab_qe/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,12 @@ def _update_from_process(self, pk):
process = load_node(pk)
self._wizard_app_widget.selected_index = 3
self.structure_model.structure = process.inputs.structure
self.structure_model.confirmed = True
self.structure_model.confirm()
parameters = process.base.extras.get("ui_parameters", {})
if parameters and isinstance(parameters, str):
parameters = deserialize_unsafe(parameters)
self.configure_model.set_model_state(parameters)
self.configure_model.confirmed = True
self.configure_model.confirm()
self.submit_model.process = process
self.submit_model.set_model_state(parameters)
self.submit_step.state = WizardAppWidgetStep.State.SUCCESS
Expand Down
2 changes: 1 addition & 1 deletion src/aiidalab_qe/app/structure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def is_saved(self):
def confirm(self, _=None):
self.manager.store_structure()
self._model.message_area = ""
self._model.confirmed = True
self._model.confirm()

def can_reset(self):
return self._model.confirmed
Expand Down
3 changes: 3 additions & 0 deletions src/aiidalab_qe/app/structure/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def update_widget_text(self):
self.manager_output = ""
self.structure_name = str(self.structure.get_formula())

def confirm(self):
self.confirmed = True

def reset(self):
self.structure = None
self.structure_name = ""
Expand Down
2 changes: 1 addition & 1 deletion tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_selecting_new_structure_unconfirms_model(generate_structure_data):
model = StructureModel()
model.structure = generate_structure_data()
assert model.structure is not None
model.confirmed = True
model.confirm()
model.structure = generate_structure_data()
assert not model.confirmed

Expand Down

0 comments on commit 45022e9

Please sign in to comment.