package com.imcode.imcms.domain.dto;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.imcode.imcms.model.LoopEntryRef;
import imcode.util.image.Format;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ImageDTO extends ImageData {

    private static final long serialVersionUID = -3103155597832120014L;
    private Integer index;
    private Integer docId;
    private boolean inText;
    private boolean allLanguages;
    private String alternateText;
    private String linkUrl;

    /**
     * Two-letter language code ISO-639-1
     */
    private String langCode;
    private String name;
    private String path;
    private LoopEntryRefDTO loopEntryRef;
    private String generatedFilePath;

    private int border;
    private String align;
    private String lowResolutionUrl;
    private int verticalSpace;
    private int horizontalSpace;
    private String target;
    private int type;
    private int rotateAngle;
    private Long archiveImageId;

    public ImageDTO(Integer index, Integer docId, LoopEntryRef loopEntryRef, String langCode) {
        this.index = index;
        this.docId = docId;
        this.loopEntryRef = (loopEntryRef == null) ? null : new LoopEntryRefDTO(loopEntryRef);
        this.langCode = langCode;
        this.name = "";
        this.path = "";
        this.linkUrl = "";
        this.generatedFilePath = "";
        this.generatedFilename = "";
        this.alternateText = "";
        this.format = Format.JPEG;
        this.width = 0;
        this.height = 0;
        this.border = 0;
        this.align = "";
        this.lowResolutionUrl = "";
        this.verticalSpace = 0;
        this.horizontalSpace = 0;
        this.target = "";
        this.type = -1;
        this.rotateAngle = 0;
    }

    public ImageDTO(Integer index, Integer docId) {
        this(index, docId, null, "en");
    }

    public ImageDTO(ImageDTO from) {
        this(from.index, from.docId, from.loopEntryRef, from.langCode);
        this.inText = from.inText;
    }
}

@@ -530,37 +530,39 @@
 er docId;%0A    pr
-ivate
+otected
  boolean inText;
@@ -2074,17 +2074,25 @@
     this
-(
+.index = 
 from.ind
@@ -2097,40 +2097,171 @@
 ndex
-, from.docId, from.loopEntryRef,
+;%0A        this.docId = from.docId;%0A        this.loopEntryRef = (from.loopEntryRef == null) ? null : new LoopEntryRefDTO(from.loopEntryRef);%0A        this.langCode =
  fro
@@ -2270,17 +2270,16 @@
 langCode
-)
 ;%0A      
@@ -2303,20 +2303,385 @@
 rom.inText;%0A
+        this.name = from.name;%0A        this.path = from.path;%0A        this.linkUrl = from.linkUrl;%0A        this.generatedFilePath = from.generatedFilePath;%0A        this.generatedFilename = from.generatedFilename;%0A        this.alternateText = from.alternateText;%0A        this.format = from.format;%0A        this.width = from.width;%0A        this.height = from.height;%0A
     %7D%0A%7D%0A

Apply new UI to the admin panel and editors: - Improved ImageDTO class.