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
|
@ControllerAction
|
||||||
void previous() {
|
void previous() {
|
||||||
model.currentStep--
|
model.currentStep--
|
||||||
recalcButtons()
|
|
||||||
view.updateLayout()
|
view.updateLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ControllerAction
|
@ControllerAction
|
||||||
void next() {
|
void next() {
|
||||||
def errors = model.steps[model.currentStep].validate()
|
def errors = model.steps[model.currentStep].validate()
|
||||||
if (errors) {
|
if (errors != null && !errors.isEmpty()) {
|
||||||
String errorMessage = String.join("\n", errors)
|
String errorMessage = String.join("\n", errors)
|
||||||
JOptionPane.showMessageDialog(model.parent, errorMessage, "Invalid Input", JOptionPane.ERROR_MESSAGE)
|
JOptionPane.showMessageDialog(model.parent, errorMessage, "Invalid Input", JOptionPane.ERROR_MESSAGE)
|
||||||
} else {
|
} else {
|
||||||
model.currentStep++
|
model.currentStep++
|
||||||
recalcButtons()
|
|
||||||
view.updateLayout()
|
view.updateLayout()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,10 +46,4 @@ class WizardController {
|
||||||
model.finished['applied'] = false
|
model.finished['applied'] = false
|
||||||
view.hide()
|
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() {
|
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()
|
String constraints = model.steps[model.currentStep].getConstraint()
|
||||||
def cardsPanel = builder.getVariable("cards-panel")
|
def cardsPanel = builder.getVariable("cards-panel")
|
||||||
cardsPanel.getLayout().show(cardsPanel, constraints)
|
cardsPanel.getLayout().show(cardsPanel, constraints)
|
||||||
|
|
Loading…
Reference in New Issue