Refactors Dataset "Field" from String to Object.
This commit is contained in:
parent
816ed4dd65
commit
6cedc40339
|
@ -25,7 +25,6 @@ import java.math.BigInteger;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class WordBuilder {
|
public class WordBuilder {
|
||||||
|
|
||||||
|
@ -132,13 +131,13 @@ public class WordBuilder {
|
||||||
return document;
|
return document;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createPages(List<DatasetProfilePage> datasetProfilePages, XWPFDocument mainDocumentPart, Boolean createListing, VisibilityRuleService visibilityRuleService) {
|
private void createPages(List<DatasetProfilePage> datasetProfilePages, XWPFDocument mainDocumentPart, Boolean createListing, VisibilityRuleService visibilityRuleService) {
|
||||||
datasetProfilePages.forEach(item -> {
|
datasetProfilePages.forEach(item -> {
|
||||||
createSections(item.getSections(), mainDocumentPart, ParagraphStyle.HEADER4, 0, createListing, visibilityRuleService);
|
createSections(item.getSections(), mainDocumentPart, ParagraphStyle.HEADER4, 0, createListing, visibilityRuleService);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createSections(List<Section> sections, XWPFDocument mainDocumentPart, ParagraphStyle style, Integer indent, Boolean createListing, VisibilityRuleService visibilityRuleService) {
|
private void createSections(List<Section> sections, XWPFDocument mainDocumentPart, ParagraphStyle style, Integer indent, Boolean createListing, VisibilityRuleService visibilityRuleService) {
|
||||||
if (createListing) this.addListing(mainDocumentPart, indent, false, true);
|
if (createListing) this.addListing(mainDocumentPart, indent, false, true);
|
||||||
sections.forEach(section -> {
|
sections.forEach(section -> {
|
||||||
if (visibilityRuleService.isElementVisible(section.getId())) {
|
if (visibilityRuleService.isElementVisible(section.getId())) {
|
||||||
|
@ -153,7 +152,7 @@ public class WordBuilder {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createCompositeFields(List<FieldSet> compositeFields, XWPFDocument mainDocumentPart, Integer indent, Boolean createListing, VisibilityRuleService visibilityRuleService) {
|
private void createCompositeFields(List<FieldSet> compositeFields, XWPFDocument mainDocumentPart, Integer indent, Boolean createListing, VisibilityRuleService visibilityRuleService) {
|
||||||
if (createListing) this.addListing(mainDocumentPart, indent, true, true);
|
if (createListing) this.addListing(mainDocumentPart, indent, true, true);
|
||||||
compositeFields.forEach(compositeField -> {
|
compositeFields.forEach(compositeField -> {
|
||||||
if (visibilityRuleService.isElementVisible(compositeField.getId()) && hasVisibleFields(compositeField, visibilityRuleService)) {
|
if (visibilityRuleService.isElementVisible(compositeField.getId()) && hasVisibleFields(compositeField, visibilityRuleService)) {
|
||||||
|
@ -177,7 +176,7 @@ public class WordBuilder {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createFields(List<Field> fields, XWPFDocument mainDocumentPart, Integer indent, Boolean createListing, VisibilityRuleService visibilityRuleService) {
|
private void createFields(List<Field> fields, XWPFDocument mainDocumentPart, Integer indent, Boolean createListing, VisibilityRuleService visibilityRuleService) {
|
||||||
if (createListing) this.addListing(mainDocumentPart, indent, false, false);
|
if (createListing) this.addListing(mainDocumentPart, indent, false, false);
|
||||||
fields.forEach(field -> {
|
fields.forEach(field -> {
|
||||||
if (visibilityRuleService.isElementVisible(field.getId())) {
|
if (visibilityRuleService.isElementVisible(field.getId())) {
|
||||||
|
@ -202,7 +201,7 @@ public class WordBuilder {
|
||||||
return paragraph;
|
return paragraph;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addListing(XWPFDocument document, int indent, Boolean question, Boolean hasIndication) {
|
private void addListing(XWPFDocument document, int indent, Boolean question, Boolean hasIndication) {
|
||||||
CTLvl cTLvl = this.cTAbstractNum.addNewLvl();
|
CTLvl cTLvl = this.cTAbstractNum.addNewLvl();
|
||||||
|
|
||||||
String textLevel = "";
|
String textLevel = "";
|
||||||
|
@ -222,7 +221,7 @@ public class WordBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String formatter(Field field) throws IOException {
|
private String formatter(Field field) throws IOException {
|
||||||
switch (field.getViewStyle().getRenderStyle()) {
|
switch (field.getViewStyle().getRenderStyle()) {
|
||||||
case "combobox": {
|
case "combobox": {
|
||||||
String comboboxType = ((ComboBoxData) field.getData()).getType();
|
String comboboxType = ((ComboBoxData) field.getData()).getType();
|
||||||
|
@ -232,7 +231,7 @@ public class WordBuilder {
|
||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
if (!field.getValue().equals("")) {
|
if (!field.getValue().equals("")) {
|
||||||
try {
|
try {
|
||||||
JSONArray jsonarray = new JSONArray(field.getValue());
|
JSONArray jsonarray = new JSONArray(field.getValue().toString());
|
||||||
for (int i = 0; i < jsonarray.length(); i++) {
|
for (int i = 0; i < jsonarray.length(); i++) {
|
||||||
JSONObject jsonobject = jsonarray.getJSONObject(i);
|
JSONObject jsonobject = jsonarray.getJSONObject(i);
|
||||||
String id = jsonobject.getString("id");
|
String id = jsonobject.getString("id");
|
||||||
|
@ -242,36 +241,38 @@ public class WordBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Map<String, String> exMap = mapper.readValue(field.getValue(), new TypeReference<Map<String, String>>() {
|
Map<String, String> exMap = mapper.readValue(field.getValue().toString(), new TypeReference<Map<String, String>>() {
|
||||||
});
|
});
|
||||||
return exMap.get("label");
|
return exMap.get("label");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
int index = 0;
|
||||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||||
sb.append("\n");
|
|
||||||
sb.append(entry.getValue());
|
sb.append(entry.getValue());
|
||||||
|
if (index != map.size() - 1) sb.append(", ");
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
} else if (comboboxType.equals("wordlist")) {
|
} else if (comboboxType.equals("wordlist")) {
|
||||||
return field.getValue();
|
return field.getValue().toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "booleanDecision":
|
case "booleanDecision":
|
||||||
if (field.getValue() != null && field.getValue().equals("true")) return "Yes";
|
if (field.getValue() != null && field.getValue().equals("true")) return "Yes";
|
||||||
else return "No";
|
else return "No";
|
||||||
case "radiobox":
|
case "radiobox":
|
||||||
return field.getValue();
|
return field.getValue().toString();
|
||||||
case "checkBox":
|
case "checkBox":
|
||||||
CheckBoxData data = (CheckBoxData) field.getData();
|
CheckBoxData data = (CheckBoxData) field.getData();
|
||||||
if (field.getValue() == null || field.getValue().equals("false")) return null;
|
if (field.getValue() == null || field.getValue().equals("false")) return null;
|
||||||
return data.getLabel();
|
return data.getLabel();
|
||||||
case "freetext":
|
case "freetext":
|
||||||
return field.getValue();
|
return field.getValue().toString();
|
||||||
case "textarea":
|
case "textarea":
|
||||||
return field.getValue();
|
return field.getValue().toString();
|
||||||
case "datepicker":
|
case "datepicker":
|
||||||
return field.getValue();
|
return field.getValue().toString();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@ import eu.eudat.models.data.user.components.datasetprofile.FieldSet;
|
||||||
import eu.eudat.models.data.user.components.datasetprofile.Section;
|
import eu.eudat.models.data.user.components.datasetprofile.Section;
|
||||||
import eu.eudat.models.data.user.composite.DatasetProfilePage;
|
import eu.eudat.models.data.user.composite.DatasetProfilePage;
|
||||||
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONException;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
@ -17,9 +19,6 @@ import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by ikalyvas on 3/5/2018.
|
|
||||||
*/
|
|
||||||
public class ExportXmlBuilder {
|
public class ExportXmlBuilder {
|
||||||
|
|
||||||
public File build(PagedDatasetProfile pagedDatasetProfile, UUID datasetProfileId, VisibilityRuleService visibilityRuleService) throws IOException {
|
public File build(PagedDatasetProfile pagedDatasetProfile, UUID datasetProfileId, VisibilityRuleService visibilityRuleService) throws IOException {
|
||||||
|
@ -49,7 +48,7 @@ public class ExportXmlBuilder {
|
||||||
return pages;
|
return pages;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Element createSections(List<Section> sections, VisibilityRuleService visibilityRuleService, Document element) {
|
private Element createSections(List<Section> sections, VisibilityRuleService visibilityRuleService, Document element) {
|
||||||
Element elementSections = element.createElement("sections");
|
Element elementSections = element.createElement("sections");
|
||||||
sections.forEach(section -> {
|
sections.forEach(section -> {
|
||||||
Element elementSection = element.createElement("section");
|
Element elementSection = element.createElement("section");
|
||||||
|
@ -62,7 +61,7 @@ public class ExportXmlBuilder {
|
||||||
return elementSections;
|
return elementSections;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Element createCompositeFields(List<FieldSet> compositeFields, VisibilityRuleService visibilityRuleService, Document element) {
|
private Element createCompositeFields(List<FieldSet> compositeFields, VisibilityRuleService visibilityRuleService, Document element) {
|
||||||
Element elementComposites = element.createElement("composite-fields");
|
Element elementComposites = element.createElement("composite-fields");
|
||||||
compositeFields.forEach(compositeField -> {
|
compositeFields.forEach(compositeField -> {
|
||||||
if (visibilityRuleService.isElementVisible(compositeField.getId()) && hasVisibleFields(compositeField, visibilityRuleService)) {
|
if (visibilityRuleService.isElementVisible(compositeField.getId()) && hasVisibleFields(compositeField, visibilityRuleService)) {
|
||||||
|
@ -86,15 +85,25 @@ public class ExportXmlBuilder {
|
||||||
return elementComposites;
|
return elementComposites;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Element createFields(List<Field> fields, VisibilityRuleService visibilityRuleService, Document element) {
|
private Element createFields(List<Field> fields, VisibilityRuleService visibilityRuleService, Document element) {
|
||||||
Element elementFields = element.createElement("fields");
|
Element elementFields = element.createElement("fields");
|
||||||
fields.forEach(field -> {
|
fields.forEach(field -> {
|
||||||
if (visibilityRuleService.isElementVisible(field.getId())) {
|
if (visibilityRuleService.isElementVisible(field.getId())) {
|
||||||
Element elementField = element.createElement("field");
|
Element elementField = element.createElement("field");
|
||||||
elementField.setAttribute("id", field.getId());
|
elementField.setAttribute("id", field.getId());
|
||||||
if (field.getValue() != null && !field.getValue().isEmpty()) {
|
if (field.getValue() != null) {
|
||||||
Element valueField = element.createElement("value");
|
Element valueField = element.createElement("value");
|
||||||
valueField.setTextContent(field.getValue());
|
try {
|
||||||
|
JSONArray jsonArray = new JSONArray(field.getValue().toString());
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (int i = 0; i < jsonArray.length(); i++) {
|
||||||
|
sb.append(jsonArray.getJSONObject(i).get("label").toString());
|
||||||
|
if (i != jsonArray.length() - 1) sb.append(", ");
|
||||||
|
}
|
||||||
|
valueField.setTextContent(sb.toString());
|
||||||
|
} catch (JSONException ex) {
|
||||||
|
valueField.setTextContent(field.getValue().toString());
|
||||||
|
}
|
||||||
elementField.appendChild(valueField);
|
elementField.appendChild(valueField);
|
||||||
}
|
}
|
||||||
elementFields.appendChild(elementField);
|
elementFields.appendChild(elementField);
|
||||||
|
|
|
@ -9,6 +9,9 @@ import eu.eudat.models.data.user.composite.PropertiesModelBuilder;
|
||||||
import eu.eudat.logic.utilities.interfaces.ViewStyleDefinition;
|
import eu.eudat.logic.utilities.interfaces.ViewStyleDefinition;
|
||||||
import eu.eudat.logic.utilities.builders.ModelBuilder;
|
import eu.eudat.logic.utilities.builders.ModelBuilder;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONException;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -17,7 +20,7 @@ import java.util.stream.Collectors;
|
||||||
public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefinition<eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field>, PropertiesGenerator {
|
public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefinition<eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field>, PropertiesGenerator {
|
||||||
private String id;
|
private String id;
|
||||||
private Integer ordinal;
|
private Integer ordinal;
|
||||||
private String value;
|
private Object value;
|
||||||
private ViewStyle viewStyle;
|
private ViewStyle viewStyle;
|
||||||
private String datatype;
|
private String datatype;
|
||||||
private String numbering;
|
private String numbering;
|
||||||
|
@ -58,11 +61,11 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin
|
||||||
this.ordinal = ordinal;
|
this.ordinal = ordinal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValue() {
|
public Object getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValue(String value) {
|
public void setValue(Object value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +149,7 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin
|
||||||
this.rdaProperty = rdaProperty;
|
this.rdaProperty = rdaProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Field cloneForMultiplicity(String key, Map<String, Object> properties) {
|
Field cloneForMultiplicity(String key, Map<String, Object> properties) {
|
||||||
Field newField = new Field();
|
Field newField = new Field();
|
||||||
newField.id = key;
|
newField.id = key;
|
||||||
newField.ordinal = this.ordinal;
|
newField.ordinal = this.ordinal;
|
||||||
|
@ -189,13 +192,21 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromJsonObject(Map<String, Object> properties) {
|
public void fromJsonObject(Map<String, Object> properties) {
|
||||||
|
try {
|
||||||
|
JSONArray jsonArray = new JSONArray(properties.get(this.id).toString());
|
||||||
|
List<String> stringList = new LinkedList<>();
|
||||||
|
for (int i = 0; i < jsonArray.length(); i++) {
|
||||||
|
stringList.add(jsonArray.getJSONObject(i).toString());
|
||||||
|
}
|
||||||
|
this.value = stringList;
|
||||||
|
} catch (JSONException e) {
|
||||||
this.value = (String) properties.get(this.id);
|
this.value = (String) properties.get(this.id);
|
||||||
this.multiplicityItems = new LinkedList<Field>();
|
}
|
||||||
|
this.multiplicityItems = new LinkedList<>();
|
||||||
List<String> compositeKeys = properties.keySet().stream().filter(keys -> keys.startsWith("multiple_" + this.getId())).collect(Collectors.toList());
|
List<String> compositeKeys = properties.keySet().stream().filter(keys -> keys.startsWith("multiple_" + this.getId())).collect(Collectors.toList());
|
||||||
for (String key : compositeKeys) {
|
for (String key : compositeKeys) {
|
||||||
this.multiplicityItems.add(this.cloneForMultiplicity(key, properties));
|
this.multiplicityItems.add(this.cloneForMultiplicity(key, properties));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -210,7 +221,11 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toMap(Map<String, Object> fieldValues) {
|
public void toMap(Map<String, Object> fieldValues) {
|
||||||
fieldValues.put(this.id, this.value);
|
if (this.value != null) {
|
||||||
|
fieldValues.put(this.id, this.value.toString());
|
||||||
|
} else {
|
||||||
|
fieldValues.put(this.id, "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
<mat-form-field class="col-md-12" *ngIf="form.get('data').value.type === datasetProfileComboBoxTypeEnum.Autocomplete">
|
<mat-form-field class="col-md-12" *ngIf="form.get('data').value.type === datasetProfileComboBoxTypeEnum.Autocomplete">
|
||||||
<div *ngIf="form.get('data').value.multiAutoComplete">
|
<div *ngIf="form.get('data').value.multiAutoComplete">
|
||||||
<app-multiple-auto-complete placeholder="{{ form.get('data').value.label | translate }}" [formControl]="form.get('value')"
|
<app-multiple-auto-complete placeholder="{{ form.get('data').value.label | translate }}" [formControl]="form.get('value')"
|
||||||
[configuration]="multipleAutoCompleteConfiguration" (optionRemoved)="_optionRemove($event)">
|
[configuration]="multipleAutoCompleteConfiguration">
|
||||||
</app-multiple-auto-complete>
|
</app-multiple-auto-complete>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="!(form.get('data').value.multiAutoComplete)">
|
<div *ngIf="!(form.get('data').value.multiAutoComplete)">
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
<mat-form-field class="col-md-12" *ngIf="form.get('data').value.type === this.datasetProfileInternalDmpEntitiesTypeEnum.Researchers">
|
<mat-form-field class="col-md-12" *ngIf="form.get('data').value.type === this.datasetProfileInternalDmpEntitiesTypeEnum.Researchers">
|
||||||
<div *ngIf="form.get('data').value.multiAutoComplete">
|
<div *ngIf="form.get('data').value.multiAutoComplete">
|
||||||
<app-multiple-auto-complete placeholder="{{ form.get('data').value.label | translate }}" [formControl]="form.get('value')"
|
<app-multiple-auto-complete placeholder="{{ form.get('data').value.label | translate }}" [formControl]="form.get('value')"
|
||||||
[configuration]="multipleAutoCompleteConfiguration" (optionRemoved)="_optionRemove($event)">
|
[configuration]="multipleAutoCompleteConfiguration">
|
||||||
</app-multiple-auto-complete>
|
</app-multiple-auto-complete>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="!(form.get('data').value.multiAutoComplete)">
|
<div *ngIf="!(form.get('data').value.multiAutoComplete)">
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
<mat-form-field class="col-md-12" *ngIf="form.get('data').value.type === this.datasetProfileInternalDmpEntitiesTypeEnum.Datasets">
|
<mat-form-field class="col-md-12" *ngIf="form.get('data').value.type === this.datasetProfileInternalDmpEntitiesTypeEnum.Datasets">
|
||||||
<div *ngIf="form.get('data').value.multiAutoComplete">
|
<div *ngIf="form.get('data').value.multiAutoComplete">
|
||||||
<app-multiple-auto-complete placeholder="{{ form.get('data').value.label | translate }}" [formControl]="form.get('value')"
|
<app-multiple-auto-complete placeholder="{{ form.get('data').value.label | translate }}" [formControl]="form.get('value')"
|
||||||
[configuration]="multipleAutoCompleteConfiguration" (optionRemoved)="_optionRemove($event)">
|
[configuration]="multipleAutoCompleteConfiguration">
|
||||||
</app-multiple-auto-complete>
|
</app-multiple-auto-complete>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="!(form.get('data').value.multiAutoComplete)">
|
<div *ngIf="!(form.get('data').value.multiAutoComplete)">
|
||||||
|
@ -77,7 +77,7 @@
|
||||||
<mat-form-field class="col-md-12" *ngIf="form.get('data').value.type === this.datasetProfileInternalDmpEntitiesTypeEnum.Dmps">
|
<mat-form-field class="col-md-12" *ngIf="form.get('data').value.type === this.datasetProfileInternalDmpEntitiesTypeEnum.Dmps">
|
||||||
<div *ngIf="form.get('data').value.multiAutoComplete">
|
<div *ngIf="form.get('data').value.multiAutoComplete">
|
||||||
<app-multiple-auto-complete placeholder="{{ form.get('data').value.label | translate }}" [formControl]="form.get('value')"
|
<app-multiple-auto-complete placeholder="{{ form.get('data').value.label | translate }}" [formControl]="form.get('value')"
|
||||||
[configuration]="multipleAutoCompleteConfiguration" (optionRemoved)="_optionRemove($event)">
|
[configuration]="multipleAutoCompleteConfiguration">
|
||||||
</app-multiple-auto-complete>
|
</app-multiple-auto-complete>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="!(form.get('data').value.multiAutoComplete)">
|
<div *ngIf="!(form.get('data').value.multiAutoComplete)">
|
||||||
|
|
|
@ -100,16 +100,16 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_optionRemove(event) {
|
// _optionRemove(event) {
|
||||||
const array = JSON.parse(this.form.get('value').value);
|
// const array = JSON.parse(this.form.get('value').value);
|
||||||
if (array) {
|
// if (array) {
|
||||||
const index = array.map(x => x.id).indexOf(event.id);
|
// const index = array.map(x => x.id).indexOf(event.id);
|
||||||
if (index >= 0) {
|
// if (index >= 0) {
|
||||||
array.splice(index, 1);
|
// array.splice(index, 1);
|
||||||
}
|
// }
|
||||||
this.form.get('value').patchValue(JSON.stringify(array));
|
// this.form.get('value').patchValue(JSON.stringify(array));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
_transformValue(item: any) {
|
_transformValue(item: any) {
|
||||||
if (!item) return [];
|
if (!item) return [];
|
||||||
|
|
Loading…
Reference in New Issue