Merge branch 'ui-redesign' of gitlab.eudat.eu:dmp/OpenAIRE-EUDAT-DMP-service-pilot into ui-redesign

This commit is contained in:
apapachristou 2020-09-10 18:36:53 +03:00
commit 6bc03ccbfc
13 changed files with 73 additions and 20 deletions

View File

@ -122,7 +122,7 @@ public class DatasetProfileManager {
String url = singleData.getUrl();
String mediaType = "";
if (url.contains("openaire")) {
if (url.contains("openaire") || url.contains("zenodo")) {
mediaType = "application/json; charset=utf-8";
url = url.replace("{like}", like.equals("") ? "*" : like);
url = url.replace("%20", " ");

View File

@ -12,6 +12,7 @@ import java.util.Map;
public class WordListData extends ComboBoxData<WordListData> {
private List<Option> options;
private Boolean multiList;
public List<Option> getOptions() {
return options;
@ -21,10 +22,18 @@ public class WordListData extends ComboBoxData<WordListData> {
this.options = options;
}
public Boolean getMultiList() {
return multiList;
}
public void setMultiList(Boolean multiList) {
this.multiList = multiList;
}
@Override
public Element toXml(Document doc) {
Element root = super.toXml(doc);
root.setAttribute("multiList", this.multiList.toString());
Element element = doc.createElement("options");
if (this.options != null) {
for (Option option : this.options) {
@ -50,6 +59,8 @@ public class WordListData extends ComboBoxData<WordListData> {
}
}
}
Boolean temp = Boolean.parseBoolean(item.getAttribute("multiList"));
this.multiList = temp != null ? temp : false;
return this;
}
@ -57,7 +68,6 @@ public class WordListData extends ComboBoxData<WordListData> {
public WordListData fromData(Object data) {
super.fromData(data);
this.options = new LinkedList();
if (data != null) {
List<Map<String, String>> options = ((Map<String, List<Map<String, String>>>) data).get("options");
if (options != null) {
@ -68,8 +78,8 @@ public class WordListData extends ComboBoxData<WordListData> {
this.options.add(newOption);
}
}
this.multiList = (Boolean) ((Map<String, Object>) data).get("multiList");
}
return this;
}

View File

@ -615,6 +615,25 @@
</data>
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
</urlConfig>
<urlConfig>
<key>eosc</key>
<label>EOSC Providers</label>
<ordinal>2</ordinal>
<type>External</type>
<url>https://beta.providers.eosc-portal.eu/api/service/all?query={like}&amp;from={page}&amp;quantity={pageSize}</url>
<firstPage>0</firstPage>
<contenttype>application/json; charset=utf-8</contenttype>
<data>
<path>$['results'][*]</path>
<fields>
<id>'id'</id>
<name>'name'</name>
<uri>'webpage'</uri>
<description>'description'</description>
</fields>
</data>
<paginationpath>$['from','to','total']</paginationpath>
</urlConfig>
<!-- <urlConfig>
<key>openAire</key>
<label>OpenAIRE</label>

View File

@ -41,6 +41,7 @@ export interface TextAreaFieldData extends FieldData {
export interface WordListFieldData extends FieldData {
type: DatasetProfileComboBoxType;
options: Array<FieldDataOption>;
multiList: boolean;
}
export interface FieldDataOption extends FieldData {

View File

@ -7,11 +7,13 @@ import { FieldDataOptionEditorModel } from './field-data-option-editor-model';
export class WordListFieldDataEditorModel extends FieldDataEditorModel<WordListFieldDataEditorModel> {
public type: DatasetProfileComboBoxType = DatasetProfileComboBoxType.WordList;
public options: Array<FieldDataOptionEditorModel>;
public multipleList: boolean;
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
const formGroup = this.formBuilder.group({
type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('WordListFieldDataEditorModel.type')) }],
label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('WordListFieldDataEditorModel.label')) }]
label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('WordListFieldDataEditorModel.label')) }],
multiList: [{ value: this.multipleList, disabled: (disabled && !skipDisable.includes('WordListFieldDataEditorModel.multipleList'))}]
});
const optionsFormArray = new Array<FormGroup>();
if (this.options) {
@ -29,6 +31,7 @@ export class WordListFieldDataEditorModel extends FieldDataEditorModel<WordListF
this.type = item.type;
if (item.options) { this.options = item.options.map(x => new FieldDataOptionEditorModel().fromModel(x)); }
this.label = item.label;
this.multipleList = item.multiList;
return this;
}
}

View File

@ -2,6 +2,9 @@
<h5 style="font-weight: bold" class="col-12">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-WORD-LIST-TITLE'
| translate}}</h5>
<mat-checkbox class="col-auto" [formControl]="this.form.get('data').get('multiList')">
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-WORDLIST' | translate}}
</mat-checkbox>
<mat-form-field class="col-12">
<input matInput type="string"
@ -30,4 +33,4 @@
<div class="col-auto"><button mat-icon-button (click)="addNewRow()">
<mat-icon>add</mat-icon>
</button></div>
</div>
</div>

View File

@ -32,7 +32,7 @@
<mat-hint>{{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }}</mat-hint>
</mat-form-field>
<mat-form-field *ngIf="form.get('data').value.type === datasetProfileComboBoxTypeEnum.WordList" class="col-md-12">
<mat-select [formControl]="form.get('value')" placeholder="{{ form.get('data').value.label | translate }}" [required]="form.get('validationRequired').value">
<mat-select [formControl]="form.get('value')" placeholder="{{ form.get('data').value.label | translate }}" [required]="form.get('validationRequired').value" [multiple]="form.get('data').value.multiList">
<mat-option *ngFor="let opt of form.get('data').value.options" [value]="opt.value">{{opt.label}}
</mat-option>
</mat-select>

View File

@ -93,6 +93,18 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
this.visibilityRulesService.updateValueAndVisibility(this.form.get('id').value, this.form.get('value').value);
}
if (this.form.get('viewStyle').value.renderStyle === DatasetProfileFieldViewStyle.ComboBox && this.form.get('data').value.type === DatasetProfileComboBoxType.WordList) {
if (this.form.get('data').value.multiList) {
const originalValue = <string>this.form.get('value').value;
let values = (<string>this.form.get('value').value).slice(1, -1).split(', ');
if (!originalValue.startsWith('[') && !originalValue.endsWith(']')) {
values = undefined;
values = [originalValue];
}
this.form.patchValue({ 'value': values });
}
}
// Setup autocomplete configuration if needed
if (this.form.get('viewStyle').value.renderStyle === DatasetProfileFieldViewStyle.ComboBox && this.form.get('data').value.type === DatasetProfileComboBoxType.Autocomplete) {
if (!(this.form.controls['data'].value.multiAutoComplete)) {
@ -134,7 +146,7 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
initialItems: () => this.searchDatasetExternalDataRepositories(''),
displayFn: (item) => typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name,
titleFn: (item) => typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name,
subtitleFn: (item) => item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE'),
subtitleFn: (item) => item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE'),
valueAssign: (item) => typeof (item) == 'string' ? item : JSON.stringify(item)
};
break;
@ -188,14 +200,14 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
this.datasetIdInitialized = true;
break;
case DatasetProfileFieldViewStyle.Currency:
this.currencyAutoCompleteConfiguration = {
filterFn: this.searchCurrency.bind(this),
initialItems: () => this.searchCurrency(''),
displayFn: (item) => typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name,
titleFn: (item) => typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name,
valueAssign: (item) => typeof (item) == 'string' ? item : JSON.stringify(item)
};
break;
this.currencyAutoCompleteConfiguration = {
filterFn: this.searchCurrency.bind(this),
initialItems: () => this.searchCurrency(''),
displayFn: (item) => typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name,
titleFn: (item) => typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name,
valueAssign: (item) => typeof (item) == 'string' ? item : JSON.stringify(item)
};
break;
}
if (this.form.get('viewStyle').value.renderStyle === DatasetProfileFieldViewStyle.InternalDmpEntities) {

View File

@ -334,7 +334,8 @@
"FIELD-DATE-PICKER-PLACEHOLDER": "Input Placeholder",
"FIELD-DATE-PICKER-LABEL": "Label",
"FIELD-DATE-PICKER-VALUE": "Value",
"FIELD-MULTIPLE-AUTOCOMPLETE": "Multiple Autocomplete"
"FIELD-MULTIPLE-AUTOCOMPLETE": "Multiple Autocomplete",
"FIELD-MULTIPLE-WORDLIST": "Multiple Selection"
},
"DEFAULT-VALUES": {
"NONE": "Keine",

View File

@ -354,7 +354,8 @@
"FIELD-DATE-PICKER-PLACEHOLDER": "Input Placeholder",
"FIELD-DATE-PICKER-LABEL": "Label",
"FIELD-DATE-PICKER-VALUE": "Value",
"FIELD-MULTIPLE-AUTOCOMPLETE": "Multiple Autocomplete"
"FIELD-MULTIPLE-AUTOCOMPLETE": "Multiple Autocomplete",
"FIELD-MULTIPLE-WORDLIST": "Multiple Selection"
},
"DEFAULT-VALUES": {
"NONE": "None",

View File

@ -354,7 +354,8 @@
"FIELD-DATE-PICKER-PLACEHOLDER": "Marcador de entrada",
"FIELD-DATE-PICKER-LABEL": "Etiqueta",
"FIELD-DATE-PICKER-VALUE": "Valor",
"FIELD-MULTIPLE-AUTOCOMPLETE": "Autocompeltado múltiple"
"FIELD-MULTIPLE-AUTOCOMPLETE": "Autocompeltado múltiple",
"FIELD-MULTIPLE-WORDLIST": "Multiple Selection"
},
"DEFAULT-VALUES": {
"NONE": "Ninguno",

View File

@ -351,7 +351,8 @@
"FIELD-DATE-PICKER-PLACEHOLDER": "Τοποθέτηση placeholder",
"FIELD-DATE-PICKER-LABEL": "Ετικέτα",
"FIELD-DATE-PICKER-VALUE": "Τιμή",
"FIELD-MULTIPLE-AUTOCOMPLETE": "Πολλαπλή Αυτόματη Συμπλήρωση"
"FIELD-MULTIPLE-AUTOCOMPLETE": "Πολλαπλή Αυτόματη Συμπλήρωση",
"FIELD-MULTIPLE-WORDLIST": "Multiple Selection"
},
"DEFAULT-VALUES": {
"NONE": "Κανένα",

View File

@ -351,7 +351,8 @@
"FIELD-DATE-PICKER-PLACEHOLDER": "Girdi Yer tutucu",
"FIELD-DATE-PICKER-LABEL": "Etiket",
"FIELD-DATE-PICKER-VALUE": "Değer",
"FIELD-MULTIPLE-AUTOCOMPLETE": "Çoklu Otomatik Tamamlama"
"FIELD-MULTIPLE-AUTOCOMPLETE": "Çoklu Otomatik Tamamlama",
"FIELD-MULTIPLE-WORDLIST": "Multiple Selection"
},
"DEFAULT-VALUES": {
"NONE": "Hiç",