Skip to content

Commit

Permalink
EZP-28322: No space between validation message and field label
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Nalepa committed Dec 13, 2017
1 parent 4fe3505 commit e67ef6a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
12 changes: 11 additions & 1 deletion src/bundle/Resources/public/js/scripts/fieldType/ezimage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const SELECTOR_INPUT_FILE = 'input[type="file"]';
const SELECTOR_LABEL_WRAPPER = '.ez-field-edit__label-wrapper';
const SELECTOR_ALT_WRAPPER = '.ez-field-edit-preview__image-alt';
const SELECTOR_INPUT_ALT = '.ez-field-edit-preview__image-alt .ez-data-source__input';

class EzImageFilePreviewField extends global.eZ.BasePreviewField {
/**
Expand Down Expand Up @@ -42,6 +43,7 @@
sizeContainer.title = fileSize;

preview.querySelector('.ez-field-edit-preview__action--preview').href = URL.createObjectURL(files[0]);
this.fieldContainer.querySelector(SELECTOR_INPUT_ALT).dispatchEvent(new CustomEvent('cancelErrors'));
}
}

Expand Down Expand Up @@ -81,7 +83,7 @@
errorNodeSelectors: [SELECTOR_LABEL_WRAPPER],
},
{
selector: `${SELECTOR_ALT_WRAPPER} .ez-data-source__input`,
selector: SELECTOR_INPUT_ALT,
eventName: 'blur',
callback: 'validateAltInput',
invalidStateSelectors: ['.ez-data-source__field--alternativeText'],
Expand All @@ -94,6 +96,14 @@
callback: 'showFileSizeError',
errorNodeSelectors: [SELECTOR_LABEL_WRAPPER],
},
{
isValueValidator: false,
selector: SELECTOR_INPUT_ALT,
eventName: 'cancelErrors',
callback: 'cancelErrors',
invalidStateSelectors: ['.ez-data-source__field--alternativeText'],
errorNodeSelectors: [`${SELECTOR_ALT_WRAPPER} .ez-data-source__label-wrapper`],
}
],
});
const previewField = new EzImageFilePreviewField({
Expand Down
5 changes: 5 additions & 0 deletions src/bundle/Resources/public/scss/fieldType/_base-field.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,9 @@
}
}
}

&__error {
display: inline-block;
margin-left: 8px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

.ez-data-source__input {
border: 1px solid $ez-color-danger;
background: #fceaec;
background: $ez-color-warning-pale;
}
}
}
Expand Down
21 changes: 15 additions & 6 deletions src/bundle/Resources/public/scss/fieldType/_ezimage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,22 @@
border-bottom-left-radius: 5px;
}
}
}

.ez-data-source__field--alternativeText {
&.is-invalid {
.ez-data-source__label-wrapper,
.ez-data-source__label-wrapper .form-control-label {
color: $ez-color-danger;
}

.ez-field-edit__error {
margin-left: 8px;
display: inline-block;
}

.ez-data-source__field--alternativeText {
&.is-invalid {
.ez-data-source__label-wrapper,
.ez-data-source__label-wrapper .form-control-label {
color: $ez-color-danger;
}
.ez-data-source__input {
background: $ez-color-warning-pale;
}
}
}
Expand Down

0 comments on commit e67ef6a

Please # to comment.