Skip to content

Commit

Permalink
Remove alt text from videoSet
Browse files Browse the repository at this point in the history
  • Loading branch information
eschleb committed Mar 15, 2024
1 parent 4550ca4 commit 0ada4ab
Show file tree
Hide file tree
Showing 15 changed files with 12 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

public abstract class AbstractVideoSetDefinitionBuilder<B extends AbstractVideoSetDefinitionBuilder<B>> extends AbstractConfiguredComplexPropertyDefinitionBuilder<Node, VideoSetDefinition, B> {
public static final String SELECTION_SUFFIX = "_selection";
public static final String ALT_TEXT_SUFFIX = "_alt";
public static final String PREVIEW_IMAGE_SUFFIX = "_previewImage";
private final AbstractImageSetDefinitionBuilder<?> imageSetDefinitionBuilder;
private final String labelPrefix;
Expand Down Expand Up @@ -110,9 +109,6 @@ public VideoSetDefinition build(final String name) {
.fieldOptions(Stream.ofNullable(videoOptions).flatMap(Collection::stream).map(this::createFieldOption).collect(Collectors.toList()))
.label(labelPrefix + "video.label")
.build(name),
new TextFieldDefinitionBuilder()
.label(labelPrefix + "altText.label")
.build(name + ALT_TEXT_SUFFIX),
imageSetDefinitionBuilder
.label(labelPrefix + "previewImage.label")
.build(name + PREVIEW_IMAGE_SUFFIX)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# VideoSet
A videoSet groups the fields video-source, alternative-text and previewImage [imageSet](../imageset/README.md) for different video types, from which the author can choose from.
A videoSet groups the fields video-source and previewImage [imageSet](../imageset/README.md) for different video types, from which the author can choose from.

## Usage
### Dialog
Expand Down Expand Up @@ -154,8 +154,7 @@ Vimeo video, specified by ID.
@Override
public Optional<VideoModel.VideoSource> transform(final Locale locale, final String assetId) {
return Optional.of(new VideoModel.VideoSource(
"https://aprimo.com/asset/"+assetId,
null
"https://aprimo.com/asset/"+assetId
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

public class VideoSetDefinition extends ConfiguredComplexPropertyDefinition<Node> implements FormDefinition<Node> {
private final SwitchableDefinition video;
private final TextFieldDefinition altText;
private final ImageSetDefinition previewImage;
private boolean readOnly;
private boolean required;
Expand All @@ -27,11 +26,9 @@ public class VideoSetDefinition extends ConfiguredComplexPropertyDefinition<Node

public VideoSetDefinition(
final SwitchableDefinition video,
final TextFieldDefinition altText,
final ImageSetDefinition previewImage
) {
this.video = video;
this.altText = altText;
this.previewImage = previewImage;
setImplementationClass((Class) FormView.class);
setItemProvider(new CurrentItemProviderDefinition<>());
Expand All @@ -41,17 +38,13 @@ public SwitchableDefinition getVideo() {
return video;
}

public TextFieldDefinition getAltTextField() {
return altText;
}

public ImageSetDefinition getPreviewImage() {
return previewImage;
}

@Override
public List<EditorPropertyDefinition> getProperties() {
return List.of(video, altText, previewImage);
return List.of(video, previewImage);
}

@Override
Expand All @@ -63,14 +56,12 @@ public FieldLayoutDefinition<?> getLayout() {
public void setI18n(final boolean i18n) {
super.setI18n(i18n);
video.setI18n(i18n);
altText.setI18n(i18n);
previewImage.setI18n(i18n);
}

public void setReadOnly(final boolean readOnly) {
this.readOnly = readOnly;
video.setReadOnly(readOnly);
altText.setReadOnly(readOnly);
previewImage.setReadOnly(readOnly);
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public boolean test(final VideoType videoType) {
@Override
public Optional<VideoSource> transform(final Locale locale, final String src) {
return Optional.ofNullable(damTemplatingFunctions.getAsset(src)).map(asset ->
new VideoSource(asset.getLink(), asset.getCaption())
new VideoSource(asset.getLink())
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,15 @@ public class VideoModel {
private final String src;
private final VideoType videoType;
@Nullable
private final String altText;
@Nullable
private final ImageReferenceModel previewImage;

public VideoModel(
final String src,
final VideoType videoType,
@Nullable final String altText,
@Nullable final ImageReferenceModel previewImage
) {
this.src = src;
this.videoType = videoType;
this.altText = altText;
this.previewImage = previewImage;
}

Expand All @@ -42,9 +38,6 @@ public VideoType getVideoType() {
return videoType;
}

public Optional<String> getAltText() {
return Optional.ofNullable(altText);
}

public Optional<ImageReferenceModel> getPreviewImage() {
return Optional.ofNullable(previewImage);
Expand All @@ -54,21 +47,20 @@ public Optional<ImageReferenceModel> getPreviewImage() {
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
VideoModel video = (VideoModel) o;
return Objects.equals(src, video.src) && Objects.equals(videoType, video.videoType) && Objects.equals(altText, video.altText) && Objects.equals(previewImage, video.previewImage);
VideoModel that = (VideoModel) o;
return Objects.equals(src, that.src) && Objects.equals(videoType, that.videoType) && Objects.equals(previewImage, that.previewImage);
}

@Override
public int hashCode() {
return Objects.hash(src, videoType, altText, previewImage);
return Objects.hash(src, videoType, previewImage);
}

@Override
public String toString() {
return "Video{" +
"src='" + src + '\'' +
", videoType=" + videoType +
", altText='" + altText + '\'' +
", previewImage=" + previewImage +
'}';
}
Expand Down Expand Up @@ -104,7 +96,6 @@ public Optional<VideoModel> create(final Locale locale, final VideoReferenceMode
new VideoModel(
videoSource.src,
videoReference.getVideoType(),
videoReference.getAltText().orElse(videoSource.altText),
videoReference.getPreviewImage().orElse(null)
)
);
Expand All @@ -125,12 +116,9 @@ public interface VideoSourceTransformer extends Predicate<VideoType> {

public static class VideoSource {
private final String src;
@Nullable
private final String altText;

public VideoSource(final String src, @Nullable final String altText) {
public VideoSource(final String src) {
this.src = src;
this.altText = altText;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,15 @@ public class VideoReferenceModel {
private final String assetId;
private final VideoType videoType;
@Nullable
private final String altText;
@Nullable
private final ImageReferenceModel previewImage;

public VideoReferenceModel(
final String assetId,
final VideoType videoType,
@Nullable final String altText,
@Nullable final ImageReferenceModel previewImage
) {
this.assetId = assetId;
this.videoType = videoType;
this.altText = altText;
this.previewImage = previewImage;
}

Expand All @@ -42,10 +38,6 @@ public VideoType getVideoType() {
return videoType;
}

public Optional<String> getAltText() {
return Optional.ofNullable(altText);
}

public Optional<ImageReferenceModel> getPreviewImage() {
return Optional.ofNullable(previewImage);
}
Expand All @@ -55,20 +47,19 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
VideoReferenceModel that = (VideoReferenceModel) o;
return Objects.equals(assetId, that.assetId) && Objects.equals(videoType, that.videoType) && Objects.equals(altText, that.altText) && Objects.equals(previewImage, that.previewImage);
return Objects.equals(assetId, that.assetId) && Objects.equals(videoType, that.videoType) && Objects.equals(previewImage, that.previewImage);
}

@Override
public int hashCode() {
return Objects.hash(assetId, videoType, altText, previewImage);
return Objects.hash(assetId, videoType, previewImage);
}

@Override
public String toString() {
return "VideoReference{" +
"assetId='" + assetId + '\'' +
", videoType=" + videoType +
", altText='" + altText + '\'' +
", previewImage=" + previewImage +
'}';
}
Expand Down Expand Up @@ -99,7 +90,6 @@ public Optional<VideoReferenceModel> create(final String propertyName, final Loc
new VideoReferenceModel(
assetId,
videoType,
video.getProperty(propertyName + VideoSetDefinitionBuilder.ALT_TEXT_SUFFIX, dialogLocale, ValueConverter::getString).orElse(null),
imageReferenceFactory
.create(propertyName + VideoSetDefinitionBuilder.PREVIEW_IMAGE_SUFFIX, dialogLocale, video)
.orElse(null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public boolean test(final VideoType videoType) {
@Override
public Optional<VideoSource> transform(final Locale locale, final String src) {
if (StringUtils.startsWith(src, VimeoTextValueConverter.PREFIX)) {
return Optional.of(new VideoSource(StringUtils.removeStart(src, VimeoTextValueConverter.PREFIX), null));
return Optional.of(new VideoSource(StringUtils.removeStart(src, VimeoTextValueConverter.PREFIX)));
}
return Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public boolean test(final VideoType videoType) {
@Override
public Optional<VideoSource> transform(final Locale locale, final String src) {
if (StringUtils.startsWith(src, YoutubeTextValueConverter.PREFIX)) {
return Optional.of(new VideoSource(StringUtils.removeStart(src, YoutubeTextValueConverter.PREFIX), null));
return Optional.of(new VideoSource(StringUtils.removeStart(src, YoutubeTextValueConverter.PREFIX)));
}
return Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ merkle.customDefinitions.videoSet.videoType.dam.label=Magnolia
merkle.customDefinitions.videoSet.videoType.youtube.label=Youtube
merkle.customDefinitions.videoSet.videoType.vimeo.label=Vimeo
merkle.customDefinitions.videoSet.video.label=Video source
merkle.customDefinitions.videoSet.altText.label=Alternative text
merkle.customDefinitions.videoSet.previewImage.label=Preview image

validators.mimeTypeValidator.errorMessage=Invalid mime type! Must be one of [{0}].
Expand Down

0 comments on commit 0ada4ab

Please sign in to comment.