|
| 1 | +/* |
| 2 | + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 3 | + * ~ Copyright 2023 Adobe |
| 4 | + * ~ |
| 5 | + * ~ Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * ~ you may not use this file except in compliance with the License. |
| 7 | + * ~ You may obtain a copy of the License at |
| 8 | + * ~ |
| 9 | + * ~ http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * ~ |
| 11 | + * ~ Unless required by applicable law or agreed to in writing, software |
| 12 | + * ~ distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * ~ See the License for the specific language governing permissions and |
| 15 | + * ~ limitations under the License. |
| 16 | + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 17 | + */ |
| 18 | + |
| 19 | +package com.adobe.cq.forms.core.components.internal.models.v2.form; |
| 20 | + |
| 21 | +import java.util.Map; |
| 22 | + |
| 23 | +import org.apache.sling.api.SlingHttpServletRequest; |
| 24 | +import org.apache.sling.api.resource.Resource; |
| 25 | +import org.apache.sling.models.annotations.Default; |
| 26 | +import org.apache.sling.models.annotations.Exporter; |
| 27 | +import org.apache.sling.models.annotations.Model; |
| 28 | +import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy; |
| 29 | +import org.apache.sling.models.annotations.injectorspecific.ValueMapValue; |
| 30 | +import org.jetbrains.annotations.NotNull; |
| 31 | + |
| 32 | +import com.adobe.cq.export.json.ComponentExporter; |
| 33 | +import com.adobe.cq.export.json.ExporterConstants; |
| 34 | +import com.adobe.cq.forms.core.components.internal.form.FormConstants; |
| 35 | +import com.adobe.cq.forms.core.components.internal.models.v1.form.FileInputImpl; |
| 36 | +import com.adobe.cq.forms.core.components.models.form.FileInput; |
| 37 | +import com.fasterxml.jackson.annotation.JsonIgnore; |
| 38 | + |
| 39 | +@Model( |
| 40 | + adaptables = { SlingHttpServletRequest.class, Resource.class }, |
| 41 | + adapters = { FileInput.class, |
| 42 | + ComponentExporter.class }, |
| 43 | + resourceType = { FormConstants.RT_FD_FORM_FILE_INPUT_V2 }) |
| 44 | +@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION) |
| 45 | +public class FileInputImplV2 extends FileInputImpl { |
| 46 | + |
| 47 | + private static final String FILE_INPUT_DRAG_DROP_TEXT = "fileInputDragDropText"; |
| 48 | + |
| 49 | + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "fileInputDragDropText") |
| 50 | + @Default(values = FileInput.DEFAULT_FILE_DRAGDROP_TEXT) |
| 51 | + protected String fileInputDragDropText; |
| 52 | + |
| 53 | + @JsonIgnore |
| 54 | + public String getFileInputDragDropText() { |
| 55 | + return fileInputDragDropText; |
| 56 | + } |
| 57 | + |
| 58 | + @Override |
| 59 | + public @NotNull Map<String, Object> getProperties() { |
| 60 | + Map<String, Object> customProperties = super.getProperties(); |
| 61 | + customProperties.put(FILE_INPUT_DRAG_DROP_TEXT, getFileInputDragDropText()); |
| 62 | + return customProperties; |
| 63 | + } |
| 64 | +} |
0 commit comments