Skip to content

Commit

Permalink
ActionButtons in the MultiStepDialog should be managed by their actions
Browse files Browse the repository at this point in the history
  • Loading branch information
alansemenov committed Oct 4, 2024
1 parent 1438bc4 commit b77d947
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 26 deletions.
5 changes: 4 additions & 1 deletion src/main/resources/assets/admin/common/js/ui/Action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ export class Action {
}

setClass(value: string): Action {
this.cls = `${value}-action`;
if (value !== `${this.cls}-action`) {
this.cls = `${value}-action`;
this.notifyPropertyChanged();
}
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export class MultiStepDialog

protected headerContent: NamesAndIconView;

private forwardButton: ActionButton;
private forwardAction: Action;

private backButton: ActionButton;
private backAction: Action;

private noStepsBlock?: Element;

Expand All @@ -47,8 +47,8 @@ export class MultiStepDialog

this.steps = this.config.steps;
this.stepsContainer = this.createStepsContainer();
this.backButton = this.addAction(new Action(this.getBackButtonLabel()));
this.forwardButton = this.addAction(new Action(this.getForwardButtonLabel()));
this.addAction(this.backAction = new Action(this.getBackButtonLabel()));
this.addAction(this.forwardAction = new Action(this.getForwardButtonLabel()));
this.headerContent = this.createHeaderContent();
}

Expand Down Expand Up @@ -79,13 +79,13 @@ export class MultiStepDialog
this.handleHidden();
});

this.forwardButton.getAction().onExecuted(() => {
if (this.forwardButton.isEnabled()) {
this.forwardAction.onExecuted(() => {
if (this.forwardAction.isEnabled()) {
this.forwardOrSubmit();
}
});

this.backButton.getAction().onExecuted(() => {
this.backAction.onExecuted(() => {
this.showPreviousStep();
});

Expand Down Expand Up @@ -209,7 +209,7 @@ export class MultiStepDialog
}

private updateForwardButtonLabel(): void {
this.forwardButton.setLabel(this.getForwardButtonLabelDependingOnState());
this.forwardAction.setLabel(this.getForwardButtonLabelDependingOnState());
}

private getForwardButtonLabelDependingOnState(): string {
Expand All @@ -230,13 +230,13 @@ export class MultiStepDialog

private updateForwardButtonEnabledState(): void {
if (this.currentStep.isOptional()) {
this.forwardButton.setEnabled(true);
this.forwardAction.setEnabled(true);
} else {
this.forwardButton.setEnabled(false);
this.forwardAction.setEnabled(false);
this.lock();

this.currentStep.isValid().then((isValid: boolean) => {
this.forwardButton.setEnabled(isValid);
this.forwardAction.setEnabled(isValid);
})
.catch(DefaultErrorHandler.handle)
.finally(() => this.unlock());
Expand Down Expand Up @@ -272,8 +272,8 @@ export class MultiStepDialog
this.noStepsBlock = new DivEl('no-steps-block').setHtml(i18n('dialog.multistep.no.steps'));
}

this.backButton.hide();
this.forwardButton.hide();
this.backAction.setVisible(false);
this.forwardAction.setVisible(false);
this.appendChildToContentPanel(this.noStepsBlock);
}

Expand All @@ -291,8 +291,8 @@ export class MultiStepDialog
this.appendChildToHeader(this.headerContent);
this.stepsContainer.addClass('steps-container');
this.appendChildToContentPanel(this.stepsContainer);
this.backButton.addClass('back');
this.forwardButton.addClass('forward');
this.backAction.setClass('back');
this.forwardAction.setClass('forward');

return rendered;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@

.checkable-item-checkbox {
display: flex;
height: 24px;

label {
.icon();
display: flex;
justify-items: center;
align-items: center;
width: 24px;
padding: 0;
}

Expand All @@ -21,10 +19,12 @@
background-image: none;
}

input[disabled]:checked + label::before {
content: "\e370";
font-size: 10px;
line-height: 14px;
margin-left: 1px;
input[disabled]:checked + label {
text-align: center;
&::before {
content: "\e370";
font-size: 10px;
line-height: 14px;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
max-width: initial;

> input {
height: 37px; // match the option to prevent height bounce
height: 45px; // match the option to prevent height bounce
}

> .@{_COMMON_PREFIX}dropdown-handle {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
width: @input-height-big;
border: 0;
cursor: pointer;
background-color: @admin-white;
background-color: transparent;
display: flex;
justify-content: center;
align-items: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
flex-wrap: wrap;
align-items: center;
width: 100%;
max-width: 540px;
text-align: left;

> input {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.option-filter-input {
height: 100%;
background-color: @admin-white;
padding: 4px 4px 4px 10px;
box-sizing: border-box;
Expand Down

0 comments on commit b77d947

Please sign in to comment.