Merge branch 'Development' of https://code-repo.d4science.org/MaDgiK-CITE/argos into Development

This commit is contained in:
Bernaldo Mihasi 2022-02-11 13:11:40 +02:00
commit bf77a85acb
9 changed files with 52 additions and 51 deletions

View File

@ -15,6 +15,7 @@ import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
import eu.eudat.logic.security.claims.ClaimedAuthorities; import eu.eudat.logic.security.claims.ClaimedAuthorities;
import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.forms.VisibilityRuleService; import eu.eudat.logic.services.forms.VisibilityRuleService;
import eu.eudat.logic.services.forms.VisibilityRuleServiceImpl;
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope; import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
import eu.eudat.logic.utilities.documents.pdf.PDFUtils; import eu.eudat.logic.utilities.documents.pdf.PDFUtils;
import eu.eudat.models.data.dataset.DatasetOverviewModel; import eu.eudat.models.data.dataset.DatasetOverviewModel;
@ -126,11 +127,11 @@ public class Datasets extends BaseController {
public @ResponseBody public @ResponseBody
ResponseEntity getSingle(@PathVariable String id, @RequestHeader("Content-Type") String contentType, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IllegalAccessException, IOException, InstantiationException { ResponseEntity getSingle(@PathVariable String id, @RequestHeader("Content-Type") String contentType, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IllegalAccessException, IOException, InstantiationException {
try { try {
VisibilityRuleService visibilityRuleService = new VisibilityRuleServiceImpl();
if (contentType.equals("application/xml")) { if (contentType.equals("application/xml")) {
VisibilityRuleService visibilityRuleService = this.getApiContext().getUtilitiesService().getVisibilityRuleService();
return this.datasetManager.getDocument(id, visibilityRuleService, contentType, principal); return this.datasetManager.getDocument(id, visibilityRuleService, contentType, principal);
} else if (contentType.equals("application/msword")) { } else if (contentType.equals("application/msword")) {
FileEnvelope file = datasetManager.getWordDocumentFile(this.configLoader, id, this.getApiContext().getUtilitiesService().getVisibilityRuleService(), principal); FileEnvelope file = datasetManager.getWordDocumentFile(this.configLoader, id, visibilityRuleService, principal);
InputStream resource = new FileInputStream(file.getFile()); InputStream resource = new FileInputStream(file.getFile());
HttpHeaders responseHeaders = new HttpHeaders(); HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentLength(file.getFile().length()); responseHeaders.setContentLength(file.getFile().length());
@ -218,7 +219,7 @@ public class Datasets extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = {"/getPDF/{id}"}) @RequestMapping(method = RequestMethod.GET, value = {"/getPDF/{id}"})
public @ResponseBody public @ResponseBody
ResponseEntity<byte[]> getPDFDocument(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IllegalAccessException, IOException, InstantiationException, InterruptedException { ResponseEntity<byte[]> getPDFDocument(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IllegalAccessException, IOException, InstantiationException, InterruptedException {
FileEnvelope file = datasetManager.getWordDocumentFile(this.configLoader, id, this.getApiContext().getUtilitiesService().getVisibilityRuleService(), principal); FileEnvelope file = datasetManager.getWordDocumentFile(this.configLoader, id, new VisibilityRuleServiceImpl(), principal);
String fileName = file.getFilename().replace(" ", "_").replace(",", "_"); String fileName = file.getFilename().replace(" ", "_").replace(",", "_");
if (fileName.endsWith(".docx")){ if (fileName.endsWith(".docx")){
fileName = fileName.substring(0, fileName.length() - 5); fileName = fileName.substring(0, fileName.length() - 5);

View File

@ -1,7 +1,5 @@
package eu.eudat.logic.managers; package eu.eudat.logic.managers;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration; import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration;
import eu.eudat.configurations.dynamicgrant.entities.Property; import eu.eudat.configurations.dynamicgrant.entities.Property;
@ -33,6 +31,7 @@ import eu.eudat.logic.mapper.elastic.criteria.DmpCriteriaMapper;
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader; import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.forms.VisibilityRuleService; import eu.eudat.logic.services.forms.VisibilityRuleService;
import eu.eudat.logic.services.forms.VisibilityRuleServiceImpl;
import eu.eudat.logic.services.operations.DatabaseRepository; import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.logic.services.utilities.UtilitiesService; import eu.eudat.logic.services.utilities.UtilitiesService;
import eu.eudat.logic.utilities.builders.XmlBuilder; import eu.eudat.logic.utilities.builders.XmlBuilder;
@ -106,7 +105,6 @@ public class DataManagementPlanManager {
private ApiContext apiContext; private ApiContext apiContext;
private DatasetManager datasetManager; private DatasetManager datasetManager;
private UtilitiesService utilitiesService;
private DatabaseRepository databaseRepository; private DatabaseRepository databaseRepository;
private Environment environment; private Environment environment;
private RDAManager rdaManager; private RDAManager rdaManager;
@ -117,7 +115,6 @@ public class DataManagementPlanManager {
public DataManagementPlanManager(ApiContext apiContext, DatasetManager datasetManager, Environment environment, RDAManager rdaManager, UserManager userManager, MetricsManager metricsManager) { public DataManagementPlanManager(ApiContext apiContext, DatasetManager datasetManager, Environment environment, RDAManager rdaManager, UserManager userManager, MetricsManager metricsManager) {
this.apiContext = apiContext; this.apiContext = apiContext;
this.datasetManager = datasetManager; this.datasetManager = datasetManager;
this.utilitiesService = apiContext.getUtilitiesService();
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository(); this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
this.environment = environment; this.environment = environment;
this.rdaManager = rdaManager; this.rdaManager = rdaManager;
@ -1172,7 +1169,7 @@ public class DataManagementPlanManager {
public FileEnvelope getWordDocument(String id, Principal principal, ConfigLoader configLoader, Boolean versioned) throws IOException { public FileEnvelope getWordDocument(String id, Principal principal, ConfigLoader configLoader, Boolean versioned) throws IOException {
WordBuilder wordBuilder = new WordBuilder(); WordBuilder wordBuilder = new WordBuilder();
VisibilityRuleService visibilityRuleService = this.utilitiesService.getVisibilityRuleService(); VisibilityRuleService visibilityRuleService = new VisibilityRuleServiceImpl();
DatasetWizardModel dataset = new DatasetWizardModel(); DatasetWizardModel dataset = new DatasetWizardModel();
XWPFDocument document = configLoader.getDocument(); XWPFDocument document = configLoader.getDocument();
@ -1341,7 +1338,7 @@ public class DataManagementPlanManager {
private FileEnvelope getXmlDocument(String id, Principal principal) throws InstantiationException, IllegalAccessException, IOException { private FileEnvelope getXmlDocument(String id, Principal principal) throws InstantiationException, IllegalAccessException, IOException {
ExportXmlBuilder xmlBuilder = new ExportXmlBuilder(); ExportXmlBuilder xmlBuilder = new ExportXmlBuilder();
VisibilityRuleService visibilityRuleService = utilitiesService.getVisibilityRuleService(); VisibilityRuleService visibilityRuleService = new VisibilityRuleServiceImpl();
eu.eudat.data.entities.DMP dmp = databaseRepository.getDmpDao().find(UUID.fromString(id)); eu.eudat.data.entities.DMP dmp = databaseRepository.getDmpDao().find(UUID.fromString(id));
if (!dmp.isPublic() && dmp.getUsers().stream().filter(userInfo -> userInfo.getUser().getId() == principal.getId()).collect(Collectors.toList()).size() == 0) if (!dmp.isPublic() && dmp.getUsers().stream().filter(userInfo -> userInfo.getUser().getId() == principal.getId()).collect(Collectors.toList()).size() == 0)
throw new UnauthorisedException(); throw new UnauthorisedException();

View File

@ -26,6 +26,7 @@ import eu.eudat.logic.mapper.elastic.criteria.DmpCriteriaMapper;
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader; import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.forms.VisibilityRuleService; import eu.eudat.logic.services.forms.VisibilityRuleService;
import eu.eudat.logic.services.forms.VisibilityRuleServiceImpl;
import eu.eudat.logic.services.operations.DatabaseRepository; import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope; import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
import eu.eudat.logic.utilities.documents.types.ParagraphStyle; import eu.eudat.logic.utilities.documents.types.ParagraphStyle;
@ -49,7 +50,6 @@ import eu.eudat.models.data.user.composite.PagedDatasetProfile;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import eu.eudat.types.Authorities; import eu.eudat.types.Authorities;
import eu.eudat.types.MetricNames; import eu.eudat.types.MetricNames;
import org.apache.commons.io.IOUtils;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor; import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph; import org.apache.poi.xwpf.usermodel.XWPFParagraph;
@ -60,11 +60,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.core.io.FileSystemResource; import org.springframework.http.HttpHeaders;
import org.springframework.http.*; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
@ -91,8 +91,6 @@ import java.time.temporal.ChronoUnit;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@Component @Component
public class DatasetManager { public class DatasetManager {
@ -527,7 +525,7 @@ public class DatasetManager {
public String getWordDocumentText (Dataset datasetEntity) throws Exception { public String getWordDocumentText (Dataset datasetEntity) throws Exception {
DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(datasetEntity); DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(datasetEntity);
datasetWizardModel.setDatasetProfileDefinition(this.getPagedProfile(datasetWizardModel, datasetEntity)); datasetWizardModel.setDatasetProfileDefinition(this.getPagedProfile(datasetWizardModel, datasetEntity));
XWPFDocument document = getLightWordDocument(this.configLoader, datasetWizardModel, this.apiContext.getUtilitiesService().getVisibilityRuleService()); XWPFDocument document = getLightWordDocument(this.configLoader, datasetWizardModel, new VisibilityRuleServiceImpl());
XWPFWordExtractor extractor = new XWPFWordExtractor(document); XWPFWordExtractor extractor = new XWPFWordExtractor(document);
return extractor.getText();/*.replaceAll("\n\\s*", " ");*/ return extractor.getText();/*.replaceAll("\n\\s*", " ");*/
} }
@ -657,7 +655,7 @@ public class DatasetManager {
JSONObject obj = new JSONObject(dataset.getProperties()); JSONObject obj = new JSONObject(dataset.getProperties());
VisibilityRuleService visibilityRuleService = this.apiContext.getUtilitiesService().getVisibilityRuleService(); VisibilityRuleService visibilityRuleService = new VisibilityRuleServiceImpl();
visibilityRuleService.setProperties(obj.toMap()); visibilityRuleService.setProperties(obj.toMap());
dataset.setProfile(profile); dataset.setProfile(profile);
@ -666,12 +664,16 @@ public class DatasetManager {
for (String validator : datasetProfileValidators) { for (String validator : datasetProfileValidators) {
if ((obj.has(validator) && (obj.getString(validator) == null || obj.getString(validator).trim().isEmpty())) && isElementVisible(nodeList, validator, visibilityRuleService)) { if (obj.has(validator) && isNullOrEmpty(obj.getString(validator)) && isElementVisible(nodeList, validator, visibilityRuleService)) {
throw new Exception("Field value of " + validator + " must be filled."); throw new Exception("Field value of " + validator + " must be filled.");
} }
} }
} }
private boolean isNullOrEmpty(String value) {
return value == null || value.trim().isEmpty();
}
private boolean isElementVisible(NodeList nodeList, String id, VisibilityRuleService visibilityRuleService) { private boolean isElementVisible(NodeList nodeList, String id, VisibilityRuleService visibilityRuleService) {
Element fieldSet = null; Element fieldSet = null;
for (int i = 0; i < nodeList.getLength(); i++) { for (int i = 0; i < nodeList.getLength(); i++) {

View File

@ -1,30 +1,26 @@
package eu.eudat.logic.services.forms; package eu.eudat.logic.services.forms;
import eu.eudat.models.data.user.components.commons.Rule; import eu.eudat.models.data.user.components.commons.Rule;
import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
/** /**
* Created by ikalyvas on 3/5/2018. * Created by ikalyvas on 3/5/2018.
*/ */
@Service("visibilityRuleService")
public class VisibilityRuleServiceImpl implements VisibilityRuleService { public class VisibilityRuleServiceImpl implements VisibilityRuleService {
private Map<String, Boolean> elementVisibility = new HashMap<>(); private final Map<String, Boolean> elementVisibility = new HashMap<>();
private VisibilityContext visibilityContext;
private Map<String, Object> properties; private Map<String, Object> properties;
public boolean isElementVisible(String id) { public boolean isElementVisible(String id) {
if (!this.elementVisibility.containsKey(id) || this.elementVisibility.get(id)) return true; return !this.elementVisibility.containsKey(id) || this.elementVisibility.get(id);
return false;
} }
public void setProperties(Map<String, Object> properties) { public void setProperties(Map<String, Object> properties) {
this.properties = properties; this.properties = properties;
this.properties.entrySet().stream() this.properties.entrySet().stream()
.filter(stringObjectEntry -> stringObjectEntry.getValue() instanceof String && ((String) stringObjectEntry.getValue()).startsWith("[") && ((String) stringObjectEntry.getValue()).endsWith("]")).forEach(stringObjectEntry -> { .filter(stringObjectEntry -> stringObjectEntry.getValue() instanceof String && ((String) stringObjectEntry.getValue()).startsWith("[")
stringObjectEntry.setValue(parseArray((String) stringObjectEntry.getValue())); && ((String) stringObjectEntry.getValue()).endsWith("]"))
}); .forEach(stringObjectEntry -> stringObjectEntry.setValue(parseArray((String) stringObjectEntry.getValue())));
} }
private List<String> parseArray(String original) { private List<String> parseArray(String original) {
@ -33,22 +29,20 @@ public class VisibilityRuleServiceImpl implements VisibilityRuleService {
} }
public void buildVisibilityContext(List<Rule> sources) { public void buildVisibilityContext(List<Rule> sources) {
this.visibilityContext = new VisibilityContext(); VisibilityContext visibilityContext = new VisibilityContext();
this.visibilityContext.buildVisibilityContext(sources); visibilityContext.buildVisibilityContext(sources);
this.visibilityContext.getVisibilityRules().forEach(item-> this.evaluateVisibility(item)); visibilityContext.getVisibilityRules().forEach(this::evaluateVisibility);
} }
private void evaluateVisibility(VisibilityRule rule) { private void evaluateVisibility(VisibilityRule rule) {
List<VisibilityRuleSource> sources = rule.getVisibilityRuleSources(); List<VisibilityRuleSource> sources = rule.getVisibilityRuleSources();
for(int i = 0; i < sources.size(); i++){ for(VisibilityRuleSource source: sources){
if (properties.containsKey(sources.get(i).getVisibilityRuleSourceId()) && (isContained(properties.get(sources.get(i).getVisibilityRuleSourceId()), sources.get(i).getVisibilityRuleSourceValue()) || properties.get(sources.get(i).getVisibilityRuleSourceId()).equals(sources.get(i).getVisibilityRuleSourceValue()))) { if (properties.containsKey(source.getVisibilityRuleSourceId())
&& isContained(properties.get(source.getVisibilityRuleSourceId()), source.getVisibilityRuleSourceValue())) {
this.elementVisibility.put(rule.getVisibilityRuleTargetId(), true); this.elementVisibility.put(rule.getVisibilityRuleTargetId(), true);
} else { } else {
if (this.elementVisibility.containsKey(rule.getVisibilityRuleTargetId())) { this.elementVisibility.put(rule.getVisibilityRuleTargetId(),
this.elementVisibility.put(rule.getVisibilityRuleTargetId(), this.elementVisibility.get(rule.getVisibilityRuleTargetId()) || false); this.elementVisibility.getOrDefault(rule.getVisibilityRuleTargetId(), false));
} else {
this.elementVisibility.put(rule.getVisibilityRuleTargetId(), false);
}
} }
} }
} }
@ -56,7 +50,8 @@ public class VisibilityRuleServiceImpl implements VisibilityRuleService {
private Boolean isContained(Object values, String source) { private Boolean isContained(Object values, String source) {
if (values instanceof List) { if (values instanceof List) {
return ((Collection<?>) values).contains(source); return ((Collection<?>) values).contains(source);
} else {
return values.equals(source);
} }
return false;
} }
} }

View File

@ -11,7 +11,5 @@ public interface UtilitiesService {
MailService getMailService(); MailService getMailService();
VisibilityRuleService getVisibilityRuleService();
ConfirmationEmailService getConfirmationEmailService(); ConfirmationEmailService getConfirmationEmailService();
} }

View File

@ -1,6 +1,7 @@
package eu.eudat.logic.services.utilities; package eu.eudat.logic.services.utilities;
import eu.eudat.logic.services.forms.VisibilityRuleService; import eu.eudat.logic.services.forms.VisibilityRuleService;
import eu.eudat.logic.services.forms.VisibilityRuleServiceImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -12,22 +13,15 @@ public class UtilitiesServiceImpl implements UtilitiesService {
private InvitationService invitationService; private InvitationService invitationService;
private MailService mailService; private MailService mailService;
private VisibilityRuleService visibilityRuleService;
private ConfirmationEmailService confirmationEmailService; private ConfirmationEmailService confirmationEmailService;
@Autowired @Autowired
public UtilitiesServiceImpl(InvitationService invitationService, MailService mailService, VisibilityRuleService visibilityRuleService, ConfirmationEmailService confirmationEmailService) { public UtilitiesServiceImpl(InvitationService invitationService, MailService mailService, ConfirmationEmailService confirmationEmailService) {
this.invitationService = invitationService; this.invitationService = invitationService;
this.mailService = mailService; this.mailService = mailService;
this.visibilityRuleService = visibilityRuleService;
this.confirmationEmailService = confirmationEmailService; this.confirmationEmailService = confirmationEmailService;
} }
@Override
public VisibilityRuleService getVisibilityRuleService() {
return visibilityRuleService;
}
@Override @Override
public ConfirmationEmailService getConfirmationEmailService() { public ConfirmationEmailService getConfirmationEmailService() {
return confirmationEmailService; return confirmationEmailService;

View File

@ -27,7 +27,9 @@ import java.io.IOException;
import java.math.BigInteger; import java.math.BigInteger;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException; import java.time.format.DateTimeParseException;
import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAccessor;
@ -397,7 +399,7 @@ public class WordBuilder {
try { try {
instant = Instant.parse((String) field.getValue()); instant = Instant.parse((String) field.getValue());
} catch (DateTimeParseException ex) { } catch (DateTimeParseException ex) {
instant = Instant.from(DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault()).parse((String) field.getValue())); instant = LocalDate.parse((String) field.getValue()).atStartOfDay().toInstant(ZoneOffset.UTC);
} }
return field.getValue() != null ? DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault()).format(instant) : ""; return field.getValue() != null ? DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault()).format(instant) : "";
} }

View File

@ -9,6 +9,7 @@
//} //}
.editor-wrapper { .editor-wrapper {
position: relative;
border: 1px solid transparent !important; border: 1px solid transparent !important;
border-radius: 5px; border-radius: 5px;
} }
@ -40,6 +41,14 @@
border: 1px solid #f44336 !important; border: 1px solid #f44336 !important;
} }
.clear {
position: absolute;
right: 5px;
bottom: 5px;
transform: translate(-50%, -50%);
cursor: pointer;
}
.full-width { .full-width {
width: 100%; width: 100%;
} }

View File

@ -1,5 +1,6 @@
import {Component, Input} from "@angular/core"; import {Component, Input} from "@angular/core";
import {AngularEditorConfig} from "@kolkov/angular-editor"; import {AngularEditorConfig} from "@kolkov/angular-editor";
import {FormControl} from "@angular/forms";
@Component({ @Component({
selector: 'rich-text-editor-component', selector: 'rich-text-editor-component',
@ -7,6 +8,7 @@ import {AngularEditorConfig} from "@kolkov/angular-editor";
<div class="editor-wrapper" [class]="wrapperClasses" [formGroup]="parentFormGroup"> <div class="editor-wrapper" [class]="wrapperClasses" [formGroup]="parentFormGroup">
<angular-editor class="full-width editor" [id]="id" [config]="editorConfig" [formControlName]="controlName" <angular-editor class="full-width editor" [id]="id" [config]="editorConfig" [formControlName]="controlName"
placeholder="{{(placeholder? (placeholder | translate) : '') + (required ? ' *': '')}}"></angular-editor> placeholder="{{(placeholder? (placeholder | translate) : '') + (required ? ' *': '')}}"></angular-editor>
<mat-icon *ngIf="formInput.value" (click)="formInput.patchValue('')" class="clear">close</mat-icon>
</div> </div>
`, `,
styleUrls: ['./rich-text-editor.component.scss'] styleUrls: ['./rich-text-editor.component.scss']
@ -53,6 +55,7 @@ export class RichTextEditorComponent {
] ]
}; };
constructor() { get formInput(): FormControl {
return this.parentFormGroup.get(this.controlName);
} }
} }