mirror of https://github.com/zlatinb/muwire
move the button enabling logic in view
parent
c2044044c0
commit
8c4bafda82
|
@ -17,19 +17,17 @@ class WizardController {
|
|||
@ControllerAction
|
||||
void previous() {
|
||||
model.currentStep--
|
||||
recalcButtons()
|
||||
view.updateLayout()
|
||||
}
|
||||
|
||||
@ControllerAction
|
||||
void next() {
|
||||
def errors = model.steps[model.currentStep].validate()
|
||||
if (errors) {
|
||||
if (errors != null && !errors.isEmpty()) {
|
||||
String errorMessage = String.join("\n", errors)
|
||||
JOptionPane.showMessageDialog(model.parent, errorMessage, "Invalid Input", JOptionPane.ERROR_MESSAGE)
|
||||
} else {
|
||||
model.currentStep++
|
||||
recalcButtons()
|
||||
view.updateLayout()
|
||||
}
|
||||
}
|
||||
|
@ -48,10 +46,4 @@ class WizardController {
|
|||
model.finished['applied'] = false
|
||||
view.hide()
|
||||
}
|
||||
|
||||
private void recalcButtons() {
|
||||
model.previousButtonEnabled = model.currentStep > 0
|
||||
model.nextButtonEnabled = model.steps.size() > (model.currentStep + 1)
|
||||
model.finishButtonEnabled = model.steps.size() == (model.currentStep + 1)
|
||||
}
|
||||
}
|
|
@ -49,6 +49,10 @@ class WizardView {
|
|||
}
|
||||
|
||||
void updateLayout() {
|
||||
model.previousButtonEnabled = model.currentStep > 0
|
||||
model.nextButtonEnabled = model.steps.size() > (model.currentStep + 1)
|
||||
model.finishButtonEnabled = model.steps.size() == (model.currentStep + 1)
|
||||
|
||||
String constraints = model.steps[model.currentStep].getConstraint()
|
||||
def cardsPanel = builder.getVariable("cards-panel")
|
||||
cardsPanel.getLayout().show(cardsPanel, constraints)
|
||||
|
|
Loading…
Reference in New Issue