Merge branch 'ui-refactoring' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot into ui-refactoring
# Conflicts: # dmp-frontend/src/app/ui/quick-wizard/dataset-editor/dataset-editor-wizard.component.ts
This commit is contained in:
commit
e455072536
|
@ -2,6 +2,16 @@ package eu.eudat.data.dao.criteria;
|
|||
|
||||
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DatasetProfileCriteria extends Criteria<DatasetProfile> {
|
||||
private boolean allVersions;
|
||||
private List<UUID> groupIds;
|
||||
|
||||
public boolean getAllVersions() { return allVersions; }
|
||||
public void setAllVersions(boolean allVersions) { this.allVersions = allVersions; }
|
||||
|
||||
public List<UUID> getGroupIds() { return groupIds; }
|
||||
public void setGroupIds(List<UUID> groupIds) { this.groupIds = groupIds; }
|
||||
}
|
||||
|
|
|
@ -14,4 +14,6 @@ public interface DatasetDao extends DatabaseAccessLayer<Dataset, UUID> {
|
|||
|
||||
QueryableList<Dataset> getAuthenticated(QueryableList<Dataset> query, UserInfo principal);
|
||||
|
||||
Dataset isPublicDataset(UUID id);
|
||||
|
||||
}
|
|
@ -3,6 +3,7 @@ package eu.eudat.data.dao.entities;
|
|||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.criteria.DatasetCriteria;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.Dataset;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
@ -20,9 +21,7 @@ import java.util.concurrent.CompletableFuture;
|
|||
public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDao {
|
||||
|
||||
@Autowired
|
||||
public DatasetDaoImpl(DatabaseService<Dataset> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
public DatasetDaoImpl(DatabaseService<Dataset> databaseService) { super(databaseService); }
|
||||
|
||||
@Override
|
||||
public QueryableList<Dataset> getWithCriteria(DatasetCriteria criteria) {
|
||||
|
@ -62,6 +61,14 @@ public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDa
|
|||
return getDatabaseService().getQueryable(Dataset.getHints(), Dataset.class).withHint(hint).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dataset isPublicDataset(UUID id) {
|
||||
QueryableList<Dataset> query = getDatabaseService().getQueryable(Dataset.getHints(), Dataset.class);
|
||||
query.where(((builder, root) -> builder.equal(root.get("id"), id)));
|
||||
|
||||
return query.withHint("datasetListingModel").getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Dataset> getAuthenticated(QueryableList<Dataset> query, UserInfo principal) {
|
||||
if (principal.getId() == null) query.where((builder, root) -> builder.equal(root.get("isPublic"), true));
|
||||
|
|
|
@ -5,10 +5,13 @@ import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
|
|||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.queryable.types.FieldSelectionType;
|
||||
import eu.eudat.queryable.types.SelectionField;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
|
@ -25,6 +28,12 @@ public class DatasetProfileDaoImpl extends DatabaseAccess<DatasetProfile> implem
|
|||
QueryableList<DatasetProfile> query = getDatabaseService().getQueryable(DatasetProfile.class);
|
||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
||||
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"));
|
||||
if (!criteria.getAllVersions())
|
||||
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"),
|
||||
query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("groupId"),
|
||||
nestedRoot.get("groupId")), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class)));
|
||||
if (criteria.getGroupIds() != null && !criteria.getGroupIds().isEmpty())
|
||||
query.where((builder, root) -> root.get("groupId").in(criteria.getGroupIds()));
|
||||
query.where(((builder, root) -> builder.notEqual(root.get("status"), DatasetProfile.Status.DELETED.getValue())));
|
||||
return query;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ public class DatasetProfile implements DataEntity<DatasetProfile,UUID> {
|
|||
private Status(short value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public short getValue() {
|
||||
return value;
|
||||
}
|
||||
|
@ -60,11 +59,9 @@ public class DatasetProfile implements DataEntity<DatasetProfile,UUID> {
|
|||
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = false)
|
||||
private String definition;
|
||||
|
||||
|
||||
@Column(name = "\"Status\"", nullable = false)
|
||||
private Short status;
|
||||
|
||||
|
||||
@Column(name = "\"Created\"")
|
||||
@Convert(converter = DateToUTCConverter.class)
|
||||
private Date created;
|
||||
|
@ -76,90 +73,80 @@ public class DatasetProfile implements DataEntity<DatasetProfile,UUID> {
|
|||
@Column(name = "\"Description\"")
|
||||
private String description;
|
||||
|
||||
@Column(name = "\"GroupId\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||
private UUID groupId;
|
||||
|
||||
@Column(name = "\"Version\"", nullable = false)
|
||||
private Short version;
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
public Short getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
public void setStatus(Short status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
|
||||
public Date getModified() {
|
||||
return modified;
|
||||
}
|
||||
|
||||
|
||||
public void setModified(Date modified) {
|
||||
this.modified = modified;
|
||||
}
|
||||
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
public void setId(UUID id) { this.id = id;}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
|
||||
public String getDefinition() {
|
||||
return definition;
|
||||
}
|
||||
|
||||
public void setDefinition(String definition) {
|
||||
this.definition = definition;
|
||||
}
|
||||
|
||||
|
||||
public Set<Dataset> getDataset() {
|
||||
return dataset;
|
||||
}
|
||||
|
||||
public void setDataset(Set<Dataset> dataset) {
|
||||
this.dataset = dataset;
|
||||
}
|
||||
|
||||
public UUID getGroupId() { return groupId; }
|
||||
public void setGroupId(UUID groupId) { this.groupId = groupId;}
|
||||
|
||||
public Short getVersion() { return version; }
|
||||
public void setVersion(Short version) { this.version = version; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DatasetProfileListingModel [id=" + id + ", label=" + label + ", dataset=" + dataset + ", definition=" + definition + "]";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void update(DatasetProfile entity) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,6 +2,7 @@ package eu.eudat.controllers;
|
|||
|
||||
import eu.eudat.core.logger.Logger;
|
||||
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
|
||||
import eu.eudat.exceptions.datasetprofile.DatasetProfileNewVersionException;
|
||||
import eu.eudat.exceptions.datasetprofile.DatasetProfileWithDatasetsExeption;
|
||||
import eu.eudat.logic.managers.AdminManager;
|
||||
import eu.eudat.logic.managers.DatasetProfileManager;
|
||||
|
@ -67,12 +68,20 @@ public class Admin extends BaseController {
|
|||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.NO_MESSAGE));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/newVersion/{id}"}, produces = "application/json")
|
||||
public ResponseEntity newVersionDatasetProfile(@PathVariable String id, @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
|
||||
try {
|
||||
eu.eudat.data.entities.DatasetProfile modelDefinition = this.datasetProfileManager.createNewVersionDatasetProfile(id, profile);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(modelDefinition.getId());
|
||||
} catch (DatasetProfileNewVersionException exception) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/get/{id}"}, produces = "application/json")
|
||||
public ResponseEntity<ResponseItem<DatasetProfile>> get(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||
eu.eudat.data.entities.DatasetProfile profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||
eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile);
|
||||
datasetprofile.setLabel(profile.getLabel());
|
||||
datasetprofile.setStatus(profile.getStatus());
|
||||
eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = this.datasetProfileManager.getDatasetProfile(id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetProfile>().status(ApiMessageCode.NO_MESSAGE).payload(datasetprofile));
|
||||
}
|
||||
|
||||
|
@ -92,7 +101,7 @@ public class Admin extends BaseController {
|
|||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<PagedDatasetProfile>().status(ApiMessageCode.NO_MESSAGE).payload(pagedDatasetProfile));
|
||||
}
|
||||
|
||||
@org.springframework.transaction.annotation.Transactional
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/datasetprofile/clone/{id}"}, consumes = "application/json", produces = "application/json")
|
||||
public ResponseEntity<ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>> clone(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||
eu.eudat.data.entities.DatasetProfile profile = this.datasetProfileManager.clone(id);
|
||||
|
@ -126,7 +135,6 @@ public class Admin extends BaseController {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/upload"})
|
||||
public ResponseEntity<Object> setDatasetProfileXml(@RequestParam("file") MultipartFile file,
|
||||
@ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws IllegalAccessException, IOException {
|
||||
|
|
|
@ -8,6 +8,7 @@ import eu.eudat.data.dao.entities.DMPDao;
|
|||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.query.items.item.dmp.DataManagementPlanCriteriaRequest;
|
||||
import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
|
||||
import eu.eudat.exceptions.datamanagementplan.DMPNewVersionException;
|
||||
import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsDeleteException;
|
||||
import eu.eudat.logic.managers.DataManagementPlanManager;
|
||||
import eu.eudat.logic.managers.DatasetManager;
|
||||
|
@ -105,8 +106,12 @@ public class DMPs extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.POST, value = {"/new/{id}"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DMP>> newVersion(@PathVariable UUID id, @Valid @RequestBody eu.eudat.models.data.dmp.DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
|
||||
try {
|
||||
this.dataManagementPlanManager.newVersion(id, dataManagementPlan, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.NO_MESSAGE));
|
||||
} catch (DMPNewVersionException exception) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DMP>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/clone/{id}"}, consumes = "application/json", produces = "application/json")
|
||||
|
|
|
@ -80,12 +80,39 @@ public class DatasetWizardController extends BaseController {
|
|||
|
||||
return this.datasetManager.getDocument(id, visibilityRuleService, contentType);
|
||||
}
|
||||
else if (contentType.equals("application/msword")){
|
||||
File file = datasetManager.getWordDocument(this.environment, id, this.getApiContext().getUtilitiesService().getVisibilityRuleService());
|
||||
InputStream resource = new FileInputStream(file);
|
||||
HttpHeaders responseHeaders = new HttpHeaders();
|
||||
responseHeaders.setContentLength(file.length());
|
||||
responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||
responseHeaders.set("Content-Disposition", "attachment;filename=" + file.getName() + ".docx");
|
||||
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
|
||||
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
|
||||
byte[] content = IOUtils.toByteArray(resource);
|
||||
|
||||
return new ResponseEntity<>(content,
|
||||
responseHeaders,
|
||||
HttpStatus.OK);
|
||||
}
|
||||
else {
|
||||
DatasetWizardModel dataset = this.datasetManager.getSingle(id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetWizardModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataset));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/public/{id}"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity getSinglePublic(@PathVariable String id) throws Exception {
|
||||
try {
|
||||
DatasetWizardModel dataset = this.datasetManager.getSinglePublic(id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetWizardModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataset));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DatasetWizardModel>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = {"{id}"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package eu.eudat.exceptions.datamanagementplan;
|
||||
|
||||
public class DMPNewVersionException extends RuntimeException {
|
||||
|
||||
public DMPNewVersionException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package eu.eudat.exceptions.datasetprofile;
|
||||
|
||||
public class DatasetProfileNewVersionException extends RuntimeException {
|
||||
|
||||
public DatasetProfileNewVersionException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
|
@ -9,6 +9,7 @@ import eu.eudat.data.entities.Organisation;
|
|||
import eu.eudat.data.entities.Researcher;
|
||||
import eu.eudat.data.query.items.item.dmp.DataManagementPlanCriteriaRequest;
|
||||
import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
|
||||
import eu.eudat.exceptions.datamanagementplan.DMPNewVersionException;
|
||||
import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsDeleteException;
|
||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||
import eu.eudat.logic.builders.entity.UserInfoBuilder;
|
||||
|
@ -25,6 +26,8 @@ import eu.eudat.models.HintedModelFactory;
|
|||
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||
import eu.eudat.models.data.dmp.*;
|
||||
import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue;
|
||||
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanProfile;
|
||||
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Field;
|
||||
import eu.eudat.models.data.helpermodels.Tuple;
|
||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||
import eu.eudat.models.data.listingmodels.DataManagementPlanListingModel;
|
||||
|
@ -283,6 +286,16 @@ public class DataManagementPlanManager {
|
|||
|
||||
public void newVersion(UUID uuid, DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
|
||||
DMP oldDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(uuid);
|
||||
|
||||
DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
|
||||
LinkedList<UUID> list = new LinkedList<>();
|
||||
list.push(oldDmp.getGroupId());
|
||||
criteria.setGroupIds(list);
|
||||
criteria.setAllVersions(false);
|
||||
QueryableList<DMP> dataManagementPlanQueryableList = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria);
|
||||
List<DMP> latestVersionDMP = dataManagementPlanQueryableList.toList();
|
||||
|
||||
if(latestVersionDMP.get(0).getVersion().equals(oldDmp.getVersion())){
|
||||
DMP newDmp = dataManagementPlan.toDataModel();
|
||||
createOrganisationsIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getOrganisationDao());
|
||||
createResearchersIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao());
|
||||
|
@ -294,6 +307,9 @@ public class DataManagementPlanManager {
|
|||
newDmp.setId(null);
|
||||
newDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
|
||||
copyDatasets(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao());
|
||||
} else {
|
||||
throw new DMPNewVersionException("Version to update not the latest.");
|
||||
}
|
||||
}
|
||||
|
||||
public void clone(UUID uuid, DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
|
||||
|
@ -446,6 +462,9 @@ public class DataManagementPlanManager {
|
|||
Element dmpProfileId = xmlDoc.createElement("dmpProfileId");
|
||||
dmpProfileId.setTextContent(dmpProfile.getId().toString());
|
||||
dmpProfileElement.appendChild(dmpProfileId);
|
||||
Element values = xmlDoc.createElement("values");
|
||||
values.setTextContent(dmpProfile.getDefinition());
|
||||
dmpProfileElement.appendChild(values);
|
||||
}
|
||||
dmpElement.appendChild(dmpProfileElement);
|
||||
|
||||
|
@ -589,9 +608,19 @@ public class DataManagementPlanManager {
|
|||
// Creates new dataManagmentPlan to fill it with the data model that was parsed from the xml.
|
||||
// Creates properties.
|
||||
DataManagementPlan dm = new DataManagementPlan();
|
||||
Tuple tuple = new Tuple();
|
||||
DataManagementPlanProfile dmpProfile = new DataManagementPlanProfile();
|
||||
|
||||
List<Field> fieldList = new LinkedList<>();
|
||||
Field field = new Field();
|
||||
field.setLabel(dataManagementPlans.get(0).getDmpProfile().getDmpProfileName());
|
||||
field.setId(dataManagementPlans.get(0).getDmpProfile().getDmpProfileId());
|
||||
|
||||
fieldList.add(field);
|
||||
dmpProfile.setFields(fieldList);
|
||||
|
||||
/*Tuple tuple = new Tuple();
|
||||
tuple.setId(dataManagementPlans.get(0).getDmpProfile().getDmpProfileId());
|
||||
tuple.setLabel(dataManagementPlans.get(0).getDmpProfile().getDmpProfileName());
|
||||
tuple.setLabel(dataManagementPlans.get(0).getDmpProfile().getDmpProfileName());*/
|
||||
eu.eudat.models.data.project.Project project = new eu.eudat.models.data.project.Project();
|
||||
ProjectImportModels projectImport = dataManagementPlans.get(0).getProjectImport();
|
||||
project.setId(projectImport.getId());
|
||||
|
@ -632,7 +661,7 @@ public class DataManagementPlanManager {
|
|||
dm.setResearchers(researchers); // Sets researchers property.
|
||||
dm.setAssociatedUsers(associatedUsers); // Sets associatedUsers property.
|
||||
dm.setDynamicFields(dynamicFields); // Sets dynamicFields property.
|
||||
dm.setProfile(tuple);
|
||||
dm.setDefinition(dmpProfile);
|
||||
|
||||
createOrUpdate(apiContext, dm, principal);
|
||||
|
||||
|
|
|
@ -160,6 +160,20 @@ public class DatasetManager {
|
|||
return dataset;
|
||||
}
|
||||
|
||||
public DatasetWizardModel getSinglePublic(String id) throws Exception {
|
||||
DatasetWizardModel dataset = new DatasetWizardModel();
|
||||
eu.eudat.data.entities.Dataset datasetEntity = databaseRepository.getDatasetDao().isPublicDataset(UUID.fromString(id));
|
||||
|
||||
if (datasetEntity != null && datasetEntity.getStatus() == 1 && datasetEntity.getDmp().getStatus() == 1){
|
||||
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, datasetEntity));
|
||||
dataset.fromDataModel(datasetEntity);
|
||||
return dataset;
|
||||
}
|
||||
else {
|
||||
throw new Exception("Selected dataset is not public");
|
||||
}
|
||||
}
|
||||
|
||||
public PagedDatasetProfile getPagedProfile(DatasetWizardModel dataset, eu.eudat.data.entities.Dataset datasetEntity) {
|
||||
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(datasetEntity.getProfile());
|
||||
datasetprofile.setStatus(dataset.getStatus());
|
||||
|
|
|
@ -7,6 +7,7 @@ import eu.eudat.data.dao.entities.DatasetProfileDao;
|
|||
import eu.eudat.data.entities.DatasetProfile;
|
||||
import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileAutocompleteRequest;
|
||||
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
|
||||
import eu.eudat.exceptions.datasetprofile.DatasetProfileNewVersionException;
|
||||
import eu.eudat.logic.builders.model.models.DataTableDataBuilder;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||
|
@ -49,6 +50,15 @@ public class DatasetProfileManager {
|
|||
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.admin.composite.DatasetProfile getDatasetProfile(String id) {
|
||||
eu.eudat.data.entities.DatasetProfile profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||
eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile);
|
||||
datasetprofile.setLabel(profile.getLabel());
|
||||
datasetprofile.setStatus(profile.getStatus());
|
||||
|
||||
return datasetprofile;
|
||||
}
|
||||
|
||||
public List<DatasetProfileAutocompleteItem> getWithCriteria(DatasetProfileAutocompleteRequest datasetProfileAutocompleteRequest) throws IllegalAccessException, InstantiationException {
|
||||
QueryableList<DatasetProfile> items = databaseRepository.getDatasetProfileDao().getWithCriteria(datasetProfileAutocompleteRequest.getCriteria());
|
||||
List<DatasetProfileAutocompleteItem> datasetProfiles = items.select(item -> new DatasetProfileAutocompleteItem().fromDataModel(item));
|
||||
|
@ -104,10 +114,7 @@ public class DatasetProfileManager {
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
public ResponseEntity<byte[]> getDocument(eu.eudat.models.data.user.composite.DatasetProfile datasetProfile, String label) throws IllegalAccessException, IOException, InstantiationException {
|
||||
|
||||
|
||||
FileEnvelope envelope = getXmlDocument(datasetProfile, label);
|
||||
InputStream resource = new FileInputStream(envelope.getFile());
|
||||
System.out.println("Mime Type of " + envelope.getFilename() + " is " +
|
||||
|
@ -137,7 +144,6 @@ public class DatasetProfileManager {
|
|||
return fileEnvelope;
|
||||
}
|
||||
|
||||
|
||||
public eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.DatasetProfile createDatasetProfileFromXml(MultipartFile multiPartFile) {
|
||||
ImportXmlBuilderDatasetProfile xmlBuilder = new ImportXmlBuilderDatasetProfile();
|
||||
try {
|
||||
|
@ -156,4 +162,30 @@ public class DatasetProfileManager {
|
|||
fos.close();
|
||||
return convFile;
|
||||
}
|
||||
|
||||
public eu.eudat.data.entities.DatasetProfile createNewVersionDatasetProfile(String id, eu.eudat.models.data.admin.composite.DatasetProfile profile) throws Exception {
|
||||
// Getting the DatasetProfile which we will create its new version.
|
||||
eu.eudat.data.entities.DatasetProfile oldDatasetProfile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||
|
||||
// Getting the DatasetProfile with the latest Version.
|
||||
DatasetProfileCriteria criteria = new DatasetProfileCriteria();
|
||||
LinkedList<UUID> list = new LinkedList<>();
|
||||
list.push(oldDatasetProfile.getGroupId());
|
||||
criteria.setGroupIds(list);
|
||||
criteria.setAllVersions(false);
|
||||
QueryableList<DatasetProfile> datasetProfileQueryableList = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria);
|
||||
eu.eudat.data.entities.DatasetProfile latestVersionDatasetProfile = datasetProfileQueryableList.getSingle();
|
||||
|
||||
if (latestVersionDatasetProfile.getVersion().equals(oldDatasetProfile.getVersion())){
|
||||
eu.eudat.models.data.admin.composite.DatasetProfile sortedProfile = profile.toShort();
|
||||
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(sortedProfile, apiContext);
|
||||
modelDefinition.setLabel(oldDatasetProfile.getLabel());
|
||||
modelDefinition.setVersion((short) (oldDatasetProfile.getVersion() + 1));
|
||||
modelDefinition.setGroupId(oldDatasetProfile.getGroupId());
|
||||
apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
|
||||
return modelDefinition;
|
||||
} else {
|
||||
throw new DatasetProfileNewVersionException("Version to update not the latest.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,19 +13,16 @@ public class DatasetProfile {
|
|||
private List<Section> sections;
|
||||
private List<Page> pages;
|
||||
private Short status;
|
||||
private Short version;
|
||||
|
||||
public List<Section> getSections() {
|
||||
return sections;
|
||||
}
|
||||
|
||||
public void setSections(List<Section> sections) {
|
||||
this.sections = sections;
|
||||
}
|
||||
public void setSections(List<Section> sections) { this.sections = sections; }
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
@ -33,7 +30,6 @@ public class DatasetProfile {
|
|||
public List<Page> getPages() {
|
||||
return pages;
|
||||
}
|
||||
|
||||
public void setPages(List<Page> pages) {
|
||||
this.pages = pages;
|
||||
}
|
||||
|
@ -41,11 +37,13 @@ public class DatasetProfile {
|
|||
public Short getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Short status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Short getVersion() { return version; }
|
||||
public void setVersion(Short version) { this.version = version; }
|
||||
|
||||
public void buildProfile(eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewStyle) {
|
||||
this.sections = new ModelBuilder().fromViewStyleDefinition(viewStyle.getSections(), Section.class);
|
||||
this.pages = new ModelBuilder().fromViewStyleDefinition(viewStyle.getPages(), Page.class);
|
||||
|
@ -62,6 +60,7 @@ public class DatasetProfile {
|
|||
shortProfile.setSections(shortSection);
|
||||
shortProfile.setPages(this.pages);
|
||||
shortProfile.setStatus(this.status);
|
||||
shortProfile.setVersion(this.version);
|
||||
return shortProfile;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,12 +10,11 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
|||
private String url;
|
||||
private Option autoCompleteOptions;
|
||||
private String optionsRoot;
|
||||
|
||||
private Boolean multiAutoComplete;
|
||||
|
||||
public String getOptionsRoot() {
|
||||
return optionsRoot;
|
||||
}
|
||||
|
||||
public void setOptionsRoot(String optionsRoot) {
|
||||
this.optionsRoot = optionsRoot;
|
||||
}
|
||||
|
@ -23,7 +22,6 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
|||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
@ -31,17 +29,20 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
|||
public Option getAutoCompleteOptions() {
|
||||
return autoCompleteOptions;
|
||||
}
|
||||
|
||||
public void setAutoCompleteOptions(Option autoCompleteOptions) {
|
||||
this.autoCompleteOptions = autoCompleteOptions;
|
||||
}
|
||||
|
||||
public Boolean getMultiAutoComplete() { return multiAutoComplete; }
|
||||
public void setMultiAutoComplete(Boolean multiAutoComplete) { this.multiAutoComplete = multiAutoComplete; }
|
||||
|
||||
@Override
|
||||
public Element toXml(Document doc) {
|
||||
Element root = super.toXml(doc);
|
||||
|
||||
root.setAttribute("url", this.url);
|
||||
root.setAttribute("optionsRoot", this.optionsRoot);
|
||||
root.setAttribute("multiAutoComplete", this.multiAutoComplete.toString());
|
||||
Element element = doc.createElement("option");
|
||||
element.setAttribute("label", this.autoCompleteOptions.getLabel());
|
||||
element.setAttribute("value", autoCompleteOptions.getValue());
|
||||
|
@ -54,6 +55,7 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
|||
super.fromXml(item);
|
||||
this.url = item.getAttribute("url");
|
||||
this.optionsRoot = item.getAttribute("optionsRoot");
|
||||
this.multiAutoComplete = Boolean.parseBoolean(item.getAttribute("multiAutoComplete"));
|
||||
Element optionElement = (Element) item.getElementsByTagName("option").item(0);
|
||||
if (optionElement != null) {
|
||||
this.autoCompleteOptions = new Option();
|
||||
|
@ -70,6 +72,7 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
|||
if (data != null) {
|
||||
this.url = (String) ((Map<String, Object>) data).get("url");
|
||||
this.optionsRoot = (String) ((Map<String, Object>) data).get("optionsRoot");
|
||||
this.multiAutoComplete = (Boolean) ((Map<Boolean, Object>) data).get("multiAutoComplete");
|
||||
Map<String, String> options = ((Map<String, Map<String, String>>) data).get("autoCompleteOptions");
|
||||
if (options != null) {
|
||||
this.autoCompleteOptions.setLabel(options.get("label"));
|
||||
|
|
|
@ -10,21 +10,17 @@ import java.util.UUID;
|
|||
public class DatasetProfileListingModel implements DataModel<DatasetProfile, DatasetProfileListingModel> {
|
||||
|
||||
private UUID id;
|
||||
|
||||
private String label;
|
||||
|
||||
private Short status;
|
||||
|
||||
private Date created;
|
||||
|
||||
private Date modified = new Date();
|
||||
|
||||
private String description;
|
||||
private Short version;
|
||||
private UUID groupId;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
@ -32,7 +28,6 @@ public class DatasetProfileListingModel implements DataModel<DatasetProfile, Dat
|
|||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
@ -40,7 +35,6 @@ public class DatasetProfileListingModel implements DataModel<DatasetProfile, Dat
|
|||
public Short getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Short status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
@ -48,7 +42,6 @@ public class DatasetProfileListingModel implements DataModel<DatasetProfile, Dat
|
|||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
@ -56,7 +49,6 @@ public class DatasetProfileListingModel implements DataModel<DatasetProfile, Dat
|
|||
public Date getModified() {
|
||||
return modified;
|
||||
}
|
||||
|
||||
public void setModified(Date modified) {
|
||||
this.modified = modified;
|
||||
}
|
||||
|
@ -64,11 +56,16 @@ public class DatasetProfileListingModel implements DataModel<DatasetProfile, Dat
|
|||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Short getVersion() { return version; }
|
||||
public void setVersion(Short version) { this.version = version; }
|
||||
|
||||
public UUID getGroupId() { return groupId; }
|
||||
public void setGroupId(UUID groupId) { this.groupId = groupId; }
|
||||
|
||||
@Override
|
||||
public DatasetProfileListingModel fromDataModel(DatasetProfile entity) {
|
||||
this.id = entity.getId();
|
||||
|
@ -77,6 +74,8 @@ public class DatasetProfileListingModel implements DataModel<DatasetProfile, Dat
|
|||
this.created = entity.getCreated();
|
||||
this.modified = entity.getModified();
|
||||
this.description = entity.getDescription();
|
||||
this.version = entity.getVersion();
|
||||
this.groupId = entity.getGroupId();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ public class DmpProfileImportModel {
|
|||
|
||||
private String dmpProfileName;
|
||||
private UUID dmpProfileId;
|
||||
private String values;
|
||||
|
||||
@XmlElement(name = "dmpProfileName")
|
||||
public String getDmpProfileName() { return dmpProfileName; }
|
||||
|
@ -18,4 +19,7 @@ public class DmpProfileImportModel {
|
|||
public UUID getDmpProfileId() { return dmpProfileId; }
|
||||
public void setDmpProfileId(UUID dmpProfileId) { this.dmpProfileId = dmpProfileId; }
|
||||
|
||||
@XmlElement(name = "values")
|
||||
public String getValues() { return values; }
|
||||
public void setValues(String values) { this.values = values; }
|
||||
}
|
||||
|
|
|
@ -4,15 +4,13 @@ package eu.eudat.models.data.quickwizard;
|
|||
public class QuickWizardModel {
|
||||
|
||||
private ProjectQuickWizardModel project;
|
||||
|
||||
private DmpQuickWizardModel dmp;
|
||||
|
||||
private DatasetQuickWizardModel datasets;
|
||||
private int status;
|
||||
|
||||
public ProjectQuickWizardModel getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
public void setProject(ProjectQuickWizardModel project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
@ -20,7 +18,6 @@ public class QuickWizardModel {
|
|||
public DmpQuickWizardModel getDmp() {
|
||||
return dmp;
|
||||
}
|
||||
|
||||
public void setDmp(DmpQuickWizardModel dmp) {
|
||||
this.dmp = dmp;
|
||||
}
|
||||
|
@ -28,8 +25,14 @@ public class QuickWizardModel {
|
|||
public DatasetQuickWizardModel getDatasets() {
|
||||
return datasets;
|
||||
}
|
||||
|
||||
public void setDatasets(DatasetQuickWizardModel datasets) {
|
||||
this.datasets = datasets;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import { DateTimeFormatPipe } from './pipes/date-time-format.pipe';
|
|||
import { NgForLimitPipe } from './pipes/ng-for-limit.pipe';
|
||||
import { TimezoneInfoDisplayPipe } from './pipes/timezone-info-display.pipe';
|
||||
import { EnumUtils } from './services/utilities/enum-utils.service';
|
||||
import { JsonParserPipe } from './pipes/json-parser.pipe';
|
||||
|
||||
//
|
||||
//
|
||||
|
@ -17,13 +18,15 @@ import { EnumUtils } from './services/utilities/enum-utils.service';
|
|||
NgForLimitPipe,
|
||||
TimezoneInfoDisplayPipe,
|
||||
DateFormatPipe,
|
||||
DateTimeFormatPipe
|
||||
DateTimeFormatPipe,
|
||||
JsonParserPipe
|
||||
],
|
||||
exports: [
|
||||
NgForLimitPipe,
|
||||
TimezoneInfoDisplayPipe,
|
||||
DateFormatPipe,
|
||||
DateTimeFormatPipe
|
||||
DateTimeFormatPipe,
|
||||
JsonParserPipe
|
||||
],
|
||||
providers: [
|
||||
EnumUtils,
|
||||
|
@ -31,7 +34,8 @@ import { EnumUtils } from './services/utilities/enum-utils.service';
|
|||
NgForLimitPipe,
|
||||
TimezoneInfoDisplayPipe,
|
||||
DateFormatPipe,
|
||||
DateTimeFormatPipe
|
||||
DateTimeFormatPipe,
|
||||
JsonParserPipe
|
||||
]
|
||||
})
|
||||
export class FormattingModule { }
|
||||
|
|
|
@ -5,6 +5,7 @@ export interface DatasetProfile {
|
|||
sections: Section[];
|
||||
pages: Page[];
|
||||
status: number;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface Page {
|
||||
|
|
|
@ -9,6 +9,7 @@ export interface AutoCompleteFieldData extends FieldData {
|
|||
url: string;
|
||||
optionsRoot: string;
|
||||
autoCompleteOptions: FieldDataOption;
|
||||
multiAutoComplete: boolean;
|
||||
}
|
||||
|
||||
export interface CheckBoxFieldData extends FieldData {
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
import { Pipe, PipeTransform } from "@angular/core";
|
||||
|
||||
@Pipe({
|
||||
name: 'jsonParser'
|
||||
})
|
||||
export class JsonParserPipe implements PipeTransform {
|
||||
|
||||
transform(val) {
|
||||
if (typeof val === 'string') {
|
||||
return JSON.parse(val)
|
||||
}
|
||||
else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,4 +2,6 @@ import { BaseCriteria } from "../base-criteria";
|
|||
|
||||
export class DatasetProfileCriteria extends BaseCriteria {
|
||||
public id: String;
|
||||
public groupIds: string[];
|
||||
public allVersions: boolean;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ export class DatasetProfileService {
|
|||
constructor(private http: BaseHttpService, private httpClient: HttpClient) {
|
||||
this.actionUrl = environment.Server + 'admin/';
|
||||
}
|
||||
|
||||
createForm(data) {
|
||||
return this.http.post<DatasetProfileEditorModel>(this.actionUrl + 'addDmp', data);
|
||||
}
|
||||
|
@ -46,18 +47,20 @@ export class DatasetProfileService {
|
|||
return this.http.post<DatasetProfile>(this.actionUrl + 'datasetprofile/clone/' + id, {});
|
||||
}
|
||||
|
||||
newVersion(id, data) {
|
||||
return this.http.post<DatasetProfileEditorModel>(this.actionUrl + 'newVersion/' + id, data);
|
||||
}
|
||||
|
||||
delete(id: string, data): Observable<DatasetProfile> {
|
||||
//return this.http.post<DatasetProfile>(this.actionUrl + 'addDmp/' + id, data);
|
||||
return this.http.delete<DatasetProfile>(this.actionUrl + id, {});
|
||||
}
|
||||
|
||||
|
||||
public downloadXML(id: string): Observable<HttpResponse<Blob>> {
|
||||
downloadXML(id: string): Observable<HttpResponse<Blob>> {
|
||||
let headerXml: HttpHeaders = this.headers.set('Content-Type', 'application/xml')
|
||||
return this.httpClient.get(this.actionUrl + 'getXml/' + id, { responseType: 'blob', observe: 'response', headers: headerXml });
|
||||
}
|
||||
|
||||
|
||||
uploadFile(file: FileList, labelSent: string): Observable<DataTableData<DatasetListingModel>> {
|
||||
const params = new BaseHttpParams();
|
||||
params.interceptorContext = {
|
||||
|
|
|
@ -33,6 +33,10 @@ export class DatasetWizardService {
|
|||
return this.http.get<DatasetWizardModel>(this.actionUrl + id, { headers: this.headers }); // + 'getSingle/'
|
||||
}
|
||||
|
||||
public getSinglePublic(id: String): Observable<DatasetWizardModel> {
|
||||
return this.http.get<DatasetWizardModel>(this.actionUrl + 'public/' + id, { headers: this.headers }); // + 'getSingle/'
|
||||
}
|
||||
|
||||
public delete(id: string): Observable<DatasetWizardModel> {
|
||||
return this.http.delete<DatasetWizardModel>(this.actionUrl + id, { headers: this.headers });
|
||||
}
|
||||
|
@ -45,6 +49,11 @@ export class DatasetWizardService {
|
|||
return this.httpClient.get(this.actionUrl + 'getPDF/' + id, { responseType: 'blob', observe: 'response', headers: this.headers });
|
||||
}
|
||||
|
||||
public downloadDOCX(id: string): Observable<HttpResponse<Blob>> {
|
||||
let headerDocx: HttpHeaders = this.headers.set('Content-Type', 'application/msword')
|
||||
return this.httpClient.get(this.actionUrl + id, { responseType: 'blob', observe: 'response', headers: headerDocx });
|
||||
}
|
||||
|
||||
public downloadXML(id: string): Observable<HttpResponse<Blob>> {
|
||||
let headerXml: HttpHeaders = this.headers.set('Content-Type', 'application/xml')
|
||||
return this.httpClient.get(this.actionUrl + id, { responseType: 'blob', observe: 'response', headers: headerXml }); // + 'getXml/'
|
||||
|
|
|
@ -3,12 +3,14 @@ import { CommonFormsModule } from '../../common/forms/common-forms.module';
|
|||
import { CommonUiModule } from '../../common/ui/common-ui.module';
|
||||
import { MultipleAutoCompleteComponent } from './multiple/multiple-auto-complete.component';
|
||||
import { SingleAutoCompleteComponent } from './single/single-auto-complete.component';
|
||||
import { FormattingModule } from '../../core/formatting.module';
|
||||
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonUiModule,
|
||||
CommonFormsModule
|
||||
CommonFormsModule,
|
||||
FormattingModule
|
||||
],
|
||||
declarations: [
|
||||
SingleAutoCompleteComponent,
|
||||
|
|
|
@ -20,4 +20,6 @@ export interface MultipleAutoCompleteConfiguration {
|
|||
titleFn?: (item: any) => string;
|
||||
// Display function for the drop down subtitle
|
||||
subtitleFn?: (item: any) => string;
|
||||
// Callback to intercept value assignment based on item selection
|
||||
valueAssign?: (selectedItem: any) => any;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div class="row multiple-auto-complete">
|
||||
<mat-chip-list #chipList ngDefaultControl class="col multi-chip-list" [disabled]="disabled">
|
||||
<mat-chip *ngFor="let selectedItem of _chipItems()" [disabled]="disabled" [selectable]="selectable" [removable]="removable" (removed)="_removeSelectedItem(selectedItem)">
|
||||
<mat-chip *ngFor="let selectedItem of (_chipItems() | jsonParser)" [disabled]="disabled" [selectable]="selectable" [removable]="removable" (removed)="_removeSelectedItem(selectedItem)">
|
||||
{{this._displayFn(selectedItem)}}
|
||||
<mat-icon matChipRemove *ngIf="!disabled && removable">cancel</mat-icon>
|
||||
</mat-chip>
|
||||
|
|
|
@ -87,16 +87,9 @@ export class MultipleAutoCompleteComponent implements OnInit, MatFormFieldContro
|
|||
}
|
||||
private _selectedValue;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ViewChild('textInput') textInput: ElementRef;
|
||||
@ViewChild(MatAutocompleteTrigger) autocomplete: MatAutocompleteTrigger;
|
||||
|
||||
|
||||
|
||||
|
||||
constructor(
|
||||
private fm: FocusMonitor,
|
||||
private elRef: ElementRef,
|
||||
|
@ -115,7 +108,6 @@ export class MultipleAutoCompleteComponent implements OnInit, MatFormFieldContro
|
|||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
}
|
||||
|
||||
filter(query: string): Observable<any[]> {
|
||||
|
@ -168,7 +160,24 @@ export class MultipleAutoCompleteComponent implements OnInit, MatFormFieldContro
|
|||
return this.value || [];
|
||||
}
|
||||
|
||||
_arraysEqual(arr1, arr2) {
|
||||
if (arr1.length !== arr2.length)
|
||||
return false;
|
||||
for (var i = arr1.length; i--;) {
|
||||
if (arr1[i].id !== arr2[i].id)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
_optionSelected(event: MatAutocompleteSelectedEvent) {
|
||||
if (this.configuration.valueAssign) {
|
||||
const newValue = this.configuration.valueAssign(this.value) || [];
|
||||
newValue.push(event.option.value);
|
||||
this._setValue(this.configuration.valueAssign(newValue));
|
||||
}
|
||||
else {
|
||||
const newValue = this.value || [];
|
||||
newValue.push(event.option.value);
|
||||
this._setValue(newValue);
|
||||
|
@ -176,6 +185,7 @@ export class MultipleAutoCompleteComponent implements OnInit, MatFormFieldContro
|
|||
this.optionSelected.emit(newValue);
|
||||
this.textInput.nativeElement.value = '';
|
||||
}
|
||||
}
|
||||
|
||||
private _setValue(value: any) {
|
||||
this.value = value;
|
||||
|
@ -221,6 +231,11 @@ export class MultipleAutoCompleteComponent implements OnInit, MatFormFieldContro
|
|||
}
|
||||
|
||||
_removeSelectedItem(item: any): void {
|
||||
if (this.configuration.valueAssign) {
|
||||
this.optionRemoved.emit(item);
|
||||
this.textInput.nativeElement.focus();
|
||||
}
|
||||
else {
|
||||
const index = this.value.indexOf(item);
|
||||
if (index >= 0) {
|
||||
this.value.splice(index, 1);
|
||||
|
@ -229,6 +244,7 @@ export class MultipleAutoCompleteComponent implements OnInit, MatFormFieldContro
|
|||
this.textInput.nativeElement.focus();
|
||||
this.pushChanges(this.value);
|
||||
}
|
||||
}
|
||||
|
||||
_onInputClick(item: any) {
|
||||
if (!this.autocomplete.panelOpen) {
|
||||
|
|
|
@ -9,16 +9,20 @@ export class AutoCompleteFieldDataEditorModel extends FieldDataEditorModel<AutoC
|
|||
public type: DatasetProfileComboBoxType = DatasetProfileComboBoxType.Autocomplete;
|
||||
public url: string;
|
||||
public optionsRoot: string;
|
||||
public multiAutoComplete: boolean;
|
||||
public autoCompleteOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel();
|
||||
//public multiAutoCompleteOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel();
|
||||
|
||||
buildForm(): FormGroup {
|
||||
const formGroup = this.formBuilder.group({
|
||||
label: [this.label],
|
||||
type: [this.type],
|
||||
url: [this.url],
|
||||
optionsRoot: [this.optionsRoot]
|
||||
optionsRoot: [this.optionsRoot],
|
||||
multiAutoComplete: [this.multiAutoComplete]
|
||||
});
|
||||
formGroup.addControl('autoCompleteOptions', this.autoCompleteOptions.buildForm());
|
||||
|
||||
return formGroup;
|
||||
}
|
||||
|
||||
|
@ -27,6 +31,7 @@ export class AutoCompleteFieldDataEditorModel extends FieldDataEditorModel<AutoC
|
|||
this.url = item.url;
|
||||
this.label = item.label;
|
||||
this.optionsRoot = item.optionsRoot;
|
||||
this.multiAutoComplete = item.multiAutoComplete;
|
||||
this.autoCompleteOptions = new FieldDataOptionEditorModel().fromModel(item.autoCompleteOptions);
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,14 @@ const routes: Routes = [
|
|||
path: 'clone/:cloneid',
|
||||
component: DatasetProfileEditorComponent
|
||||
},
|
||||
{
|
||||
path: 'newversion/:newversionid',
|
||||
component: DatasetProfileEditorComponent
|
||||
},
|
||||
{
|
||||
path: 'versions/:groupId',
|
||||
component: DatasetProfileListingComponent,
|
||||
},
|
||||
{
|
||||
path: '',
|
||||
component: DatasetProfileListingComponent,
|
||||
|
|
|
@ -1,15 +1,20 @@
|
|||
<div class="row" *ngIf="form.get('data')">
|
||||
|
||||
<h5 style="font-weight: bold" class="col-12">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-TITLE' | translate}}</h5>
|
||||
<h5 style="font-weight: bold" class="col-auto">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-TITLE' | translate}}</h5>
|
||||
<mat-checkbox class="col-auto" [formControl]="this.form.get('data').get('multiAutoComplete')">
|
||||
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}}
|
||||
</mat-checkbox>
|
||||
|
||||
<mat-form-field class="col-12">
|
||||
<input matInput type="string" placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-PLACEHOLDER' | translate}}" [formControl]="form.get('data').get('label')">
|
||||
<input matInput type="string" placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-PLACEHOLDER' | translate}}"
|
||||
[formControl]="form.get('data').get('label')">
|
||||
</mat-form-field>
|
||||
<mat-form-field class="col-md-12">
|
||||
<input matInput placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-URL' | translate}}" [formControl]="this.form.get('data').get('url')">
|
||||
</mat-form-field>
|
||||
<mat-form-field class="col-md-4">
|
||||
<input matInput placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-OPTIONS-ROOT' | translate}}" [formControl]="this.form.get('data').get('optionsRoot')">
|
||||
<input matInput placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-OPTIONS-ROOT' | translate}}"
|
||||
[formControl]="this.form.get('data').get('optionsRoot')">
|
||||
</mat-form-field>
|
||||
<mat-form-field class="col-md-4">
|
||||
<input matInput placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-LABEL' | translate}}" [formControl]="this.form.get('data').get('autoCompleteOptions').get('label')">
|
||||
|
|
|
@ -11,12 +11,14 @@ export class DatasetProfileEditorModel extends BaseFormModel {
|
|||
public pages: Array<PageEditorModel> = new Array<PageEditorModel>();
|
||||
public label: string;
|
||||
public status: number;
|
||||
public version: number;
|
||||
|
||||
fromModel(item: DatasetProfile): DatasetProfileEditorModel {
|
||||
if (item.sections) { this.sections = item.sections.map(x => new SectionEditorModel().fromModel(x)); }
|
||||
if (item.pages) { this.pages = item.pages.map(x => new PageEditorModel().fromModel(x)); }
|
||||
this.label = item.label;
|
||||
this.status = item.status;
|
||||
this.version = item.version;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -38,6 +40,7 @@ export class DatasetProfileEditorModel extends BaseFormModel {
|
|||
formGroup.addControl('pages', this.formBuilder.array(pagesFormArray));
|
||||
formGroup.addControl('label', new FormControl(this.label, Validators.required));
|
||||
formGroup.addControl('status', new FormControl(this.status));
|
||||
formGroup.addControl('version', new FormControl(this.version));
|
||||
return formGroup;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div class="container" *ngIf="form" [formGroup]='form' class="dataset-profile-editor">
|
||||
<mat-form-field class="full-width">
|
||||
<input matInput formControlName="label"
|
||||
<input matInput formControlName="label" [disabled]="newVersionId"
|
||||
placeholder="{{'DATASET-PROFILE-EDITOR.FIELDS.DATASET-TITLE' | translate}}" required>
|
||||
<mat-error *ngIf="form.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}
|
||||
</mat-error>
|
||||
|
|
|
@ -31,6 +31,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
|
|||
form: FormGroup;
|
||||
previewerFormGroup: FormGroup;
|
||||
private datasetProfileId: string;
|
||||
newVersionId: string;
|
||||
dataWizardModel: DatasetWizardModel;
|
||||
@ViewChild('stepper') stepper: MatHorizontalStepper;
|
||||
viewOnly = false;
|
||||
|
@ -53,6 +54,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
|
|||
this.route.paramMap.pipe(takeUntil(this._destroyed)).subscribe((paramMap: ParamMap) => {
|
||||
this.datasetProfileId = paramMap.get('id');
|
||||
const cloneId = paramMap.get('cloneid');
|
||||
this.newVersionId = paramMap.get('newversionid');
|
||||
|
||||
if (this.datasetProfileId != null) {
|
||||
this.isNew = false;
|
||||
|
@ -94,6 +96,25 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
|
|||
},
|
||||
error => this.onCallbackError(error)
|
||||
);
|
||||
} else if (this.newVersionId != null) {
|
||||
this.datasetProfileService.getDatasetProfileById(this.newVersionId)
|
||||
.pipe(map(data => data as DatasetProfile), takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
data => {
|
||||
try {
|
||||
this.dataModel = new DatasetProfileEditorModel().fromModel(data);
|
||||
// this.isDeleted = this.masterItem.isActive === IsActive.Inactive;
|
||||
this.form = this.dataModel.buildForm();
|
||||
this.form.get('version').setValue(this.form.get('version').value + 1);
|
||||
this.form.controls['label'].disable();
|
||||
this.prepareForm();
|
||||
} catch {
|
||||
this.logger.error('Could not parse MasterItem: ' + data);
|
||||
this.uiNotificationService.snackBarNotification(this.language.instant('NOTIFICATIONS.DEFAULT.ERROR'), SnackBarNotificationLevel.Error);
|
||||
}
|
||||
},
|
||||
error => this.onCallbackError(error)
|
||||
);
|
||||
} else {
|
||||
this.dataModel = new DatasetProfileEditorModel();
|
||||
this.form = this.dataModel.buildForm();
|
||||
|
@ -155,6 +176,14 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
|
|||
.subscribe(() => {
|
||||
this.router.navigate(['/dataset-profiles']);
|
||||
});
|
||||
} else if (this.newVersionId) {
|
||||
this.datasetProfileService.newVersion(this.newVersionId, data)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(() => {
|
||||
this.router.navigate(['/dataset-profiles']);
|
||||
},
|
||||
error => this.onCallbackErrorNewVersion(error)
|
||||
);
|
||||
} else {
|
||||
this.form.get('status').setValue(0);
|
||||
data = this.form.value;
|
||||
|
@ -182,6 +211,10 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
|
|||
this.router.navigate(['/master-items']);
|
||||
}
|
||||
|
||||
onCallbackErrorNewVersion(errorResponse: HttpErrorResponse) {
|
||||
this.uiNotificationService.snackBarNotification(errorResponse.error.message, SnackBarNotificationLevel.Error);
|
||||
}
|
||||
|
||||
onCallbackError(errorResponse: HttpErrorResponse) {
|
||||
// const error: HttpError = this.httpErrorHandlingService.getError(errorResponse);
|
||||
// if (error.statusCode === 400) {
|
||||
|
|
|
@ -29,9 +29,15 @@
|
|||
<mat-header-cell *matHeaderCellDef>{{'DATASET-PROFILE-LISTING.COLUMNS.ACTIONS' | translate}}</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row" (click)="$event.stopPropagation()">
|
||||
<mat-menu #actionsMenu="matMenu">
|
||||
<button mat-menu-item (click)="newVersion(row.id, row.label)">
|
||||
<mat-icon>queue</mat-icon>{{'DATASET-PROFILE-LISTING.ACTIONS.NEW-VERSION' | translate}}
|
||||
</button>
|
||||
<button mat-menu-item (click)="clone(row.id)">
|
||||
<mat-icon>filter_none</mat-icon>{{'DATASET-PROFILE-LISTING.ACTIONS.CLONE' | translate}}
|
||||
</button>
|
||||
<button mat-menu-item (click)="viewVersions(row.groupId, row.label)">
|
||||
<mat-icon>library_books</mat-icon>{{'DATASET-PROFILE-LISTING.ACTIONS.VIEW-VERSIONS' | translate}}
|
||||
</button>
|
||||
<!--<button *ngIf="row.status==1" mat-menu-item (click)="makeItPublic(row.id)"><mat-icon>people_outline</mat-icon>{{'DATASET-LISTING.ACTIONS.MAKE-IT-PUBLIC' | translate}}</button> -->
|
||||
</mat-menu>
|
||||
<button mat-icon-button [matMenuTriggerFor]="actionsMenu">
|
||||
|
|
|
@ -12,6 +12,9 @@ import { DatasetProfileCriteria } from '../../../../core/query/dataset-profile/d
|
|||
import { DatasetProfileService } from '../../../../core/services/dataset-profile/dataset-profile.service';
|
||||
import { DmpService } from '../../../../core/services/dmp/dmp.service';
|
||||
import { DatasetProfileCriteriaComponent } from './criteria/dataset-profile.component';
|
||||
import { error } from 'selenium-webdriver';
|
||||
import { UiNotificationService, SnackBarNotificationLevel } from '../../../../core/services/notification/ui-notification-service';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dataset-profile-listing-component',
|
||||
|
@ -24,32 +27,45 @@ export class DatasetProfileListingComponent extends BaseComponent implements OnI
|
|||
@ViewChild(MatSort) sort: MatSort;
|
||||
@ViewChild(DatasetProfileCriteriaComponent) criteria: DatasetProfileCriteriaComponent;
|
||||
|
||||
|
||||
dataSource: DatasetDataSource | null;
|
||||
displayedColumns: String[] = ['label', 'description', 'created', 'actions'];
|
||||
pageEvent: PageEvent;
|
||||
titlePrefix: String;
|
||||
dmpId: String;
|
||||
itemId: string;
|
||||
|
||||
constructor(
|
||||
private datasetService: DatasetProfileService,
|
||||
private router: Router,
|
||||
private route: ActivatedRoute,
|
||||
private dmpService: DmpService
|
||||
private dmpService: DmpService,
|
||||
private language: TranslateService,
|
||||
private uiNotificationService: UiNotificationService
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
this.route.params
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe((params: Params) => {
|
||||
if (params['dmpId']) {
|
||||
this.dmpId = params['dmpId'];
|
||||
if (this.dmpId != null) { this.setDmpTitle(this.dmpId); }
|
||||
this.criteria.setCriteria(this.getDefaultCriteria(this.dmpId));
|
||||
this.criteria.setCriteria(this.getDefaultCriteria());
|
||||
this.refresh();
|
||||
this.criteria.setRefreshCallback(() => this.refresh());
|
||||
} else {
|
||||
this.itemId = params['groupId'];
|
||||
|
||||
if (this.itemId) {
|
||||
const datasetProfileLabel = this.route.snapshot.queryParams.groupLabel;
|
||||
}
|
||||
|
||||
this.criteria.setCriteria(this.getDefaultCriteria());
|
||||
this.refresh();
|
||||
this.criteria.setRefreshCallback(() => this.refresh());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -58,18 +74,19 @@ export class DatasetProfileListingComponent extends BaseComponent implements OnI
|
|||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(data => {
|
||||
this.titlePrefix = data.label;
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
refresh() {
|
||||
this.dataSource = new DatasetDataSource(this.datasetService, this._paginator, this.sort, this.criteria);
|
||||
this.dataSource = new DatasetDataSource(this.datasetService, this._paginator, this.sort, this.criteria, this.itemId);
|
||||
}
|
||||
|
||||
rowClick(rowId: String) {
|
||||
this.router.navigate(['dataset-profiles/' + rowId]);
|
||||
}
|
||||
|
||||
getDefaultCriteria(dmpId: String): DatasetProfileCriteria {
|
||||
getDefaultCriteria(): DatasetProfileCriteria {
|
||||
const defaultCriteria = new DatasetProfileCriteria();
|
||||
return defaultCriteria;
|
||||
}
|
||||
|
@ -78,6 +95,14 @@ export class DatasetProfileListingComponent extends BaseComponent implements OnI
|
|||
this.router.navigate(['dataset-profiles/clone/' + id]);
|
||||
}
|
||||
|
||||
newVersion(id: string, label: string) {
|
||||
this.router.navigate(['dataset-profiles/newversion/' + id]);
|
||||
}
|
||||
|
||||
viewVersions(rowId, rowLabel) {
|
||||
this.router.navigate(['/dataset-profiles/versions/' + rowId], { queryParams: { groupLabel: rowLabel } });
|
||||
}
|
||||
|
||||
// makeItPublic(id: String) {
|
||||
// debugger;
|
||||
// this.datasetService.makeDatasetPublic(id).pipe(takeUntil(this._destroyed)).subscribe();
|
||||
|
@ -92,7 +117,8 @@ export class DatasetDataSource extends DataSource<DatasetListingModel> {
|
|||
private _service: DatasetProfileService,
|
||||
private _paginator: MatPaginator,
|
||||
private _sort: MatSort,
|
||||
private _criteria: DatasetProfileCriteriaComponent
|
||||
private _criteria: DatasetProfileCriteriaComponent,
|
||||
private itemId
|
||||
) {
|
||||
super();
|
||||
|
||||
|
@ -112,6 +138,10 @@ export class DatasetDataSource extends DataSource<DatasetListingModel> {
|
|||
if (this._sort.active) { fields = this._sort.direction === 'asc' ? ['+' + this._sort.active] : ['-' + this._sort.active]; }
|
||||
const request = new DataTableRequest<DatasetProfileCriteria>(startIndex, this._paginator.pageSize, { fields: fields });
|
||||
request.criteria = this._criteria.criteria;
|
||||
if (this.itemId) {
|
||||
request.criteria.groupIds = [this.itemId];
|
||||
request.criteria.allVersions = true;
|
||||
}
|
||||
return this._service.getPaged(request);
|
||||
})
|
||||
/*.catch((error: any) => {
|
||||
|
|
|
@ -29,9 +29,9 @@
|
|||
<div class="navigation-buttons-container">
|
||||
<button matStepperPrevious mat-raised-button
|
||||
color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.BACK' | translate}}</button>
|
||||
<button class="saveAndFinalizeButton" matStepperNext mat-raised-button (click)='saveFinalize()' [disabled]="!formGroup.valid"
|
||||
<button class="saveAndFinalizeButton" matStepperNext mat-raised-button (click)='saveFinalize()' [disabled]="!isFormValid() || !hasDatasets()"
|
||||
color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.SAVE-AND-FINALIZE' | translate}}</button>
|
||||
<button class="saveButton" matStepperNext mat-raised-button (click)='save()'
|
||||
<button class="saveButton" matStepperNext mat-raised-button (click)='save()' [disabled]="!hasDatasets()"
|
||||
color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.SAVE' | translate}}</button>
|
||||
</div>
|
||||
</mat-step>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, FormArray } from '@angular/forms';
|
||||
import { MatStepper } from '@angular/material';
|
||||
import { MatStepper, MatDialog } from '@angular/material';
|
||||
import { Router } from '@angular/router';
|
||||
import { BaseComponent } from '../../core/common/base/base.component';
|
||||
import { QuickWizardService } from '../../core/services/quick-wizard/quick-wizard.service';
|
||||
|
@ -11,6 +11,8 @@ import { takeUntil } from 'rxjs/operators';
|
|||
import { BreadcrumbItem } from '../misc/breadcrumb/definition/breadcrumb-item';
|
||||
import { SnackBarNotificationLevel, UiNotificationService } from '../../core/services/notification/ui-notification-service';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { ConfirmationDialogComponent } from '../../library/confirmation-dialog/confirmation-dialog.component';
|
||||
import { DatasetEditorWizardComponent } from '../quick-wizard/dataset-editor/dataset-editor-wizard.component';
|
||||
|
||||
@Component({
|
||||
selector: 'dataset-create-wizard.component',
|
||||
|
@ -19,10 +21,12 @@ import { TranslateService } from '@ngx-translate/core';
|
|||
})
|
||||
export class DatasetCreateWizard extends BaseComponent implements OnInit, IBreadCrumbComponent {
|
||||
breadCrumbs: Observable<BreadcrumbItem[]>;
|
||||
@ViewChild(DatasetEditorWizardComponent) datasetEditorWizardComponent: DatasetEditorWizardComponent;
|
||||
isLinear = false;
|
||||
isNew = true;
|
||||
formGroup: FormGroup;
|
||||
|
||||
|
||||
datasetCreateWizardModel: DatasetCreateWizardModel;
|
||||
@ViewChild('stepper') stepper: MatStepper;
|
||||
|
||||
|
@ -31,7 +35,8 @@ export class DatasetCreateWizard extends BaseComponent implements OnInit, IBread
|
|||
private formBuilder: FormBuilder,
|
||||
public quickWizardService: QuickWizardService,
|
||||
public language: TranslateService,
|
||||
private uiNotificationService: UiNotificationService
|
||||
private uiNotificationService: UiNotificationService,
|
||||
private dialog: MatDialog
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
@ -49,27 +54,64 @@ export class DatasetCreateWizard extends BaseComponent implements OnInit, IBread
|
|||
}
|
||||
|
||||
save() {
|
||||
for(let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls){
|
||||
if (this.formGroup.get('datasets') && this.formGroup.get('datasets').get('datasetsList') && (this.formGroup.get('datasets').get('datasetsList') as FormArray).length > 0) {
|
||||
for (let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls) {
|
||||
control.get('status').setValue('0');
|
||||
}
|
||||
this.submit();
|
||||
this.onSubmitSave();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
saveFinalize() {
|
||||
if (!this.isFormValid()) { return; }
|
||||
for(let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls){
|
||||
if (this.formGroup.get('datasets') && this.formGroup.get('datasets').get('datasetsList') && (this.formGroup.get('datasets').get('datasetsList') as FormArray).length > 0) {
|
||||
for (let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls) {
|
||||
control.get('status').setValue('1');
|
||||
}
|
||||
this.submit();
|
||||
this.onSubmitSaveAndFinalize();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
submit() {
|
||||
onSubmitSave() {
|
||||
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
||||
data: {
|
||||
message: this.language.instant('QUICKWIZARD.SAVE-DIALOG.TITLE'),
|
||||
confirmButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.AFFIRMATIVE'),
|
||||
cancelButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.NEGATIVE')
|
||||
}
|
||||
});
|
||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||
if (result) {
|
||||
this.datasetEditorWizardComponent.addDataset();
|
||||
} else if (result === false) {
|
||||
this.quickWizardService.createQuickDatasetWizard(this.formGroup.value)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
complete => this.onCallbackSuccess()
|
||||
)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onSubmitSaveAndFinalize() {
|
||||
this.quickWizardService.createQuickDatasetWizard(this.formGroup.value)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
complete => this.onCallbackSuccess()
|
||||
)
|
||||
}
|
||||
|
||||
hasDatasets() {
|
||||
if ((this.formGroup.get('datasets').get('datasetsList') as FormArray).length > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public isFormValid() {
|
||||
return this.formGroup.valid;
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
<div class="dataset-copy-dialog">
|
||||
<div class="confirmation-message">
|
||||
<mat-form-field class="col-12">
|
||||
<app-single-auto-complete [formControl]="data.formControl" placeholder="{{'DATASET-WIZARD.DIALOGUE.DMP-SEARCH.PLACEHOLDER' | translate}}"
|
||||
[configuration]="dmpAutoCompleteConfiguration">
|
||||
</app-single-auto-complete>
|
||||
</mat-form-field>
|
||||
<mat-error *ngIf="data.formControl.hasError('incorrect')">
|
||||
{{getErrorMessage()}}
|
||||
</mat-error>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col"></div>
|
||||
<div class="col-auto">
|
||||
<button mat-raised-button color="primary" type="button" (click)="cancel()">{{ data.cancelButton }}</button>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button mat-raised-button color="primary" type="button" (click)="confirm()">{{ data.confirmButton }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,6 @@
|
|||
.confirmation-message {
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
.dataset-copy-dialog {
|
||||
width: 350px;
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
import { Component } from "@angular/core";
|
||||
import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material";
|
||||
import { SingleAutoCompleteConfiguration } from "../../../../library/auto-complete/single/single-auto-complete-configuration";
|
||||
import { Observable } from "rxjs";
|
||||
import { DataTableRequest } from "../../../../core/model/data-table/data-table-request";
|
||||
import { DmpCriteria } from "../../../../core/query/dmp/dmp-criteria";
|
||||
import { DmpListingModel } from "../../../../core/model/dmp/dmp-listing";
|
||||
import { DmpService } from "../../../../core/services/dmp/dmp.service";
|
||||
import { Inject } from "@angular/core";
|
||||
import { DmpModel } from "../../../../core/model/dmp/dmp";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
|
||||
@Component({
|
||||
selector: 'dataset-copy-dialogue-component',
|
||||
templateUrl: 'dataset-copy-dialogue.component.html',
|
||||
styleUrls: ['./dataset-copy-dialogue.component.scss'],
|
||||
})
|
||||
export class DatasetCopyDialogueComponent {
|
||||
|
||||
dmpAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
|
||||
dmpModel: DmpModel;
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<DatasetCopyDialogueComponent>,
|
||||
public dmpService: DmpService,
|
||||
public language: TranslateService,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.dmpAutoCompleteConfiguration = {
|
||||
filterFn: this.searchDmp.bind(this),
|
||||
initialItems: (extraData) => this.searchDmp(''),
|
||||
displayFn: (item) => item['label'],
|
||||
titleFn: (item) => item['label']
|
||||
};
|
||||
}
|
||||
|
||||
cancel() {
|
||||
this.dialogRef.close(this.data);
|
||||
}
|
||||
|
||||
confirm() {
|
||||
this.datasetProfileValidate().subscribe(x => {
|
||||
if (this.data.datasetProfileExist) {
|
||||
this.dialogRef.close(this.data);
|
||||
}
|
||||
else if (!this.data.datasetProfileExist) {
|
||||
this.data.formControl.setErrors({'incorrect': true});
|
||||
console.log(this.data.formControl.invalid);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
searchDmp(query: string): Observable<DmpListingModel[]> {
|
||||
const fields: Array<string> = new Array<string>();
|
||||
fields.push('asc');
|
||||
const dmpDataTableRequest: DataTableRequest<DmpCriteria> = new DataTableRequest(0, null, { fields: fields });
|
||||
dmpDataTableRequest.criteria = new DmpCriteria();
|
||||
dmpDataTableRequest.criteria.like = query;
|
||||
return this.dmpService.getPaged(dmpDataTableRequest, "autocomplete").map(x => x.data);
|
||||
}
|
||||
|
||||
datasetProfileValidate() {
|
||||
return this.dmpService.getSingle(this.data.formControl.value.id).map(result => result as DmpModel)
|
||||
.map(result => {
|
||||
this.dmpModel = result
|
||||
this.dmpModel.profiles.forEach((element) => {
|
||||
if (element.id == this.data.datasetProfileId) {
|
||||
this.data.datasetProfileExist = true;
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
getErrorMessage() {
|
||||
return this.language.instant('DATASET-WIZARD.DIALOGUE.ERROR-MESSAGE');
|
||||
}
|
||||
|
||||
hasValidDatasetProfile() {
|
||||
if (this.data.datasetProfileExist) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,11 +2,22 @@
|
|||
<h3 *ngIf="isNew">{{ 'DATASET-WIZARD.TITLE.NEW' | translate }}</h3>
|
||||
<div class="row">
|
||||
<div class="col-auto">
|
||||
<h3 *ngIf="!isNew">{{datasetWizardModel?.label}} {{ 'GENERAL.NAMES.DATASET' | translate }}<span *ngIf="this.formGroup && this.formGroup.dirty">
|
||||
- {{ 'GENERAL.STATUSES.EDIT' | translate }}</span></h3>
|
||||
<h3 *ngIf="this.formGroup && this.formGroup.get('status').value == DatasetStatus.Finalized && viewOnly">{{'GENERAL.STATUSES.FINALISED'
|
||||
| translate }}</h3>
|
||||
<h3 *ngIf="!isNew">{{datasetWizardModel?.label}} {{ 'GENERAL.NAMES.DATASET' | translate }}
|
||||
<span *ngIf="this.formGroup && this.formGroup.dirty">
|
||||
- {{ 'GENERAL.STATUSES.EDIT' | translate }}</span>
|
||||
</h3>
|
||||
<h3 *ngIf="this.formGroup && this.formGroup.get('status').value == DatasetStatus.Finalized && viewOnly">{{'GENERAL.STATUSES.FINALISED' | translate }}</h3>
|
||||
</div>
|
||||
<div class="col"></div>
|
||||
<mat-menu #actionsMenu="matMenu">
|
||||
<button mat-menu-item (click)="openDmpSearchDialogue()">
|
||||
<mat-icon>file_copy</mat-icon>{{'DATASET-WIZARD.ACTIONS.COPY-DATASET' | translate}}
|
||||
</button>
|
||||
</mat-menu>
|
||||
<button mat-icon-button [matMenuTriggerFor]="actionsMenu" *ngIf="!publicMode">
|
||||
<mat-icon>more_vert</mat-icon>
|
||||
</button>
|
||||
|
||||
<!-- <div class="col"></div>
|
||||
<div class="col-auto" *ngIf=" !viewOnly">
|
||||
<button *ngIf="!editMode" class="col-auto" mat-icon-button (click)="enableForm()">
|
||||
|
@ -18,17 +29,16 @@
|
|||
</div> -->
|
||||
</div>
|
||||
<div *ngIf="this.datasetProfileDefinitionModel || this.datasetWizardModel?.datasetProfileDefinition">
|
||||
<button mat-raised-button color="primary" *ngIf="!isNew && !viewOnly" class="deleteButton"
|
||||
(click)="openConfirm(formGroup.get('label').value, formGroup.get('id').value)" type="button">{{
|
||||
'DATASET-WIZARD.ACTIONS.DELETE' | translate }}</button>
|
||||
<button mat-raised-button color="primary" *ngIf="datasetWizardModel&&datasetWizardModel?.status != 1 && !viewOnly"
|
||||
class="saveButton" (click)="save();" type="button">{{
|
||||
'DATASET-WIZARD.ACTIONS.SAVE' | translate }}</button>
|
||||
<button mat-raised-button color="primary" *ngIf="!isNew && !viewOnly && !isCopy" class="deleteButton" (click)="openConfirm(formGroup.get('label').value, formGroup.get('id').value)"
|
||||
type="button">{{ 'DATASET-WIZARD.ACTIONS.DELETE' | translate }}</button>
|
||||
<button mat-raised-button color="primary" *ngIf="datasetWizardModel&&datasetWizardModel?.status != 1 && !viewOnly" class="saveButton"
|
||||
(click)="save();" type="button">{{ 'DATASET-WIZARD.ACTIONS.SAVE' | translate }}</button>
|
||||
<button mat-raised-button color="primary" *ngIf="datasetWizardModel&&datasetWizardModel?.status != 1 && !viewOnly" [disabled]="!formGroup.valid"
|
||||
class="saveAndFinalizeButton" (click)="saveFinalize();" type="button">{{
|
||||
'DATASET-WIZARD.ACTIONS.SAVE-AND-FINALISE' | translate }}</button>
|
||||
class="saveAndFinalizeButton" (click)="saveFinalize();" type="button">{{ 'DATASET-WIZARD.ACTIONS.SAVE-AND-FINALISE' | translate }}</button>
|
||||
<button mat-raised-button color="primary" *ngIf="datasetWizardModel&&datasetWizardModel?.status == 1" class="downloadPDF"
|
||||
(click)="downloadPDF();" type="button">{{ 'DATASET-WIZARD.ACTIONS.DOWNLOAD-PDF' | translate }}</button>
|
||||
<button mat-raised-button color="primary" *ngIf="datasetWizardModel&&datasetWizardModel?.status == 1" class="downloadDOCX"
|
||||
(click)="downloadDOCX();" type="button">{{ 'DATASET-WIZARD.ACTIONS.DOWNLOAD-DOCX' | translate }}</button>
|
||||
<button mat-raised-button color="primary" *ngIf="datasetWizardModel&&datasetWizardModel?.status == 1" class="downloadXML"
|
||||
(click)="downloadXML();" type="button">{{ 'DATASET-WIZARD.ACTIONS.DOWNLOAD-XML' | translate }}</button>
|
||||
<div class="fill-space"></div>
|
||||
|
@ -56,8 +66,9 @@
|
|||
<div class="col-12">
|
||||
<div class="row">
|
||||
<div class="col"></div>
|
||||
<div class="col-auto"><button matStepperNext mat-raised-button color="primary" (click)="getDefinition()">{{'DATASET-WIZARD.ACTIONS.NEXT'
|
||||
| translate}}</button></div>
|
||||
<div class="col-auto">
|
||||
<button matStepperNext mat-raised-button color="primary" (click)="getDefinition()">{{'DATASET-WIZARD.ACTIONS.NEXT' | translate}}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -71,8 +82,9 @@
|
|||
<div class="col-12">
|
||||
<div class="row">
|
||||
<div class="col"></div>
|
||||
<div class="col-auto"><button matStepperNext mat-raised-button color="primary">{{'DATASET-WIZARD.ACTIONS.NEXT'
|
||||
| translate}}</button></div>
|
||||
<div class="col-auto">
|
||||
<button matStepperNext mat-raised-button color="primary">{{'DATASET-WIZARD.ACTIONS.NEXT' | translate}}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -86,8 +98,9 @@
|
|||
[datasetProfileId]="formGroup.get('profile').value"></app-dataset-description-form>
|
||||
<div class="col-12 description-action-row">
|
||||
<div class="row">
|
||||
<div class="col-auto"><button matStepperPrevious mat-raised-button color="primary">{{'DATASET-WIZARD.ACTIONS.BACK'
|
||||
| translate}}</button></div>
|
||||
<div class="col-auto">
|
||||
<button matStepperPrevious mat-raised-button color="primary">{{'DATASET-WIZARD.ACTIONS.BACK' | translate}}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -2,11 +2,9 @@
|
|||
.step-container {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
.external-item-card {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
.external-item-action-row,
|
||||
.description-action-row {
|
||||
margin-top: 1em;
|
||||
|
@ -36,4 +34,9 @@
|
|||
margin-bottom: 15px;
|
||||
margin-right: 15px;
|
||||
}
|
||||
.downloadDOCX {
|
||||
margin-top: 15px;
|
||||
margin-bottom: 15px;
|
||||
margin-right: 15px;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,9 +24,12 @@ import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item
|
|||
import { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCrumbComponent';
|
||||
import { DatasetDescriptionFormEditorModel } from '../../misc/dataset-description-form/dataset-description-form.model';
|
||||
import { DatasetWizardEditorModel } from './dataset-wizard-editor.model';
|
||||
import { SnackBarNotificationLevel, UiNotificationService } from '../../../core/services/notification/ui-notification-service';
|
||||
import { SnackBarNotificationLevel, UiNotificationService, SnackBarNotification } from '../../../core/services/notification/ui-notification-service';
|
||||
import { ConfirmationDialogComponent } from '../../../library/confirmation-dialog/confirmation-dialog.component';
|
||||
import { DataTableRequest } from '../../../core/model/data-table/data-table-request';
|
||||
import { DatasetCopyDialogueComponent } from './dataset-copy-dialogue/dataset-copy-dialogue.component';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { error } from 'selenium-webdriver';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dataset-wizard-component',
|
||||
|
@ -39,22 +42,20 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
|||
viewOnly = false;
|
||||
@ViewChild('stepper') stepper: MatStepper;
|
||||
editMode = false;
|
||||
publicMode = false;
|
||||
|
||||
DatasetStatus = DatasetStatus;
|
||||
dmpAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
|
||||
|
||||
datasetWizardModel: DatasetWizardEditorModel;
|
||||
isNew = true;
|
||||
isCopy = false;
|
||||
formGroup: FormGroup;
|
||||
datasetProfileDefinitionModel: DatasetDescriptionFormEditorModel;
|
||||
|
||||
availableProfiles: DatasetProfileModel[] = [];
|
||||
itemId: string;
|
||||
isLinear = false;
|
||||
firstStepFormGroup: FormGroup;
|
||||
secondFormGroup: FormGroup;
|
||||
|
||||
|
||||
|
||||
constructor(
|
||||
private datasetWizardService: DatasetWizardService,
|
||||
|
@ -71,7 +72,6 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
|||
super();
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
this.route
|
||||
.data
|
||||
|
@ -114,9 +114,12 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
|||
};
|
||||
|
||||
const params = this.route.snapshot.params;
|
||||
const queryParams = this.route.snapshot.queryParams;
|
||||
this.itemId = params['id'];
|
||||
const dmpId = params['dmpId'];
|
||||
if (this.itemId != null) {
|
||||
const newDmpId = queryParams['newDmpId'];
|
||||
const publicId = params['publicId'];
|
||||
if (this.itemId != null && newDmpId == null) {
|
||||
this.isNew = false;
|
||||
this.datasetWizardService.getSingle(this.itemId)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
|
@ -183,7 +186,91 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
|||
}]);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
} else if (newDmpId != null) {
|
||||
this.isNew = false;
|
||||
this.isCopy = true;
|
||||
this.datasetWizardService.getSingle(this.itemId)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(data => {
|
||||
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data);
|
||||
this.formGroup = this.datasetWizardModel.buildForm();
|
||||
this.formGroup.get('id').setValue(null);
|
||||
this.dmpService.getSingle(newDmpId).map(data => data as DmpModel)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(data => {
|
||||
setTimeout(() => {
|
||||
this.datasetWizardModel.dmp = data;
|
||||
this.formGroup.get('dmp').setValue(this.datasetWizardModel.dmp);
|
||||
|
||||
this.loadDatasetProfiles();
|
||||
this.breadCrumbs = Observable.of([
|
||||
{
|
||||
parentComponentName: null,
|
||||
label: 'Datasets',
|
||||
url: '/datasets',
|
||||
notFoundResolver: [
|
||||
{
|
||||
parentComponentName: null,
|
||||
label: this.datasetWizardModel.dmp.project.label,
|
||||
url: '/projects/edit/' + this.datasetWizardModel.dmp.project.id
|
||||
},
|
||||
{
|
||||
parentComponentName: null,
|
||||
label: this.datasetWizardModel.dmp.label,
|
||||
url: '/plans/edit/' + this.datasetWizardModel.dmp.id,
|
||||
}]
|
||||
}]);
|
||||
});
|
||||
});
|
||||
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
|
||||
if (this.datasetWizardModel.status === 1) {
|
||||
this.formGroup.disable();
|
||||
this.viewOnly = true;
|
||||
}
|
||||
// if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Dataset edit like DMP.
|
||||
this.loadDatasetProfiles();
|
||||
});
|
||||
} else if (publicId != null) {
|
||||
this.datasetWizardService.getSinglePublic(publicId)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.catch((error: any) => {
|
||||
this.uiNotificationService.snackBarNotification(error.error.message, SnackBarNotificationLevel.Error);
|
||||
this.router.navigate(['/explore']);
|
||||
return Observable.of(null);
|
||||
})
|
||||
.subscribe(data => {
|
||||
if (data) {
|
||||
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data);
|
||||
this.formGroup = this.datasetWizardModel.buildForm();
|
||||
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
|
||||
if (this.datasetWizardModel.status === 1) {
|
||||
this.formGroup.disable();
|
||||
this.viewOnly = true;
|
||||
}
|
||||
this.formGroup.get('dmp').setValue(this.datasetWizardModel.dmp);
|
||||
this.loadDatasetProfiles();
|
||||
this.breadCrumbs = Observable.of([
|
||||
{
|
||||
parentComponentName: null,
|
||||
label: 'Datasets',
|
||||
url: '/datasets',
|
||||
notFoundResolver: [
|
||||
{
|
||||
parentComponentName: null,
|
||||
label: this.datasetWizardModel.dmp.project.label,
|
||||
url: '/projects/edit/' + this.datasetWizardModel.dmp.project.id
|
||||
},
|
||||
{
|
||||
parentComponentName: null,
|
||||
label: this.datasetWizardModel.dmp.label,
|
||||
url: '/plans/edit/' + this.datasetWizardModel.dmp.id,
|
||||
}]
|
||||
}]);
|
||||
}
|
||||
});
|
||||
this.publicMode = true;
|
||||
}
|
||||
else {
|
||||
this.datasetWizardModel = new DatasetWizardEditorModel();
|
||||
this.formGroup = this.datasetWizardModel.buildForm();
|
||||
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
|
||||
|
@ -200,10 +287,8 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
|||
this.availableProfiles = [];
|
||||
this.formGroup.get('profile').reset();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
this.route.params
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe((params: Params) => {
|
||||
|
@ -251,7 +336,6 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
formSubmit(): void {
|
||||
if (!this.isFormValid()) { return; }
|
||||
this.onSubmit();
|
||||
|
@ -325,6 +409,18 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
|||
});
|
||||
}
|
||||
|
||||
downloadDOCX(): void {
|
||||
this.datasetWizardService.downloadDOCX(this.itemId)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(response => {
|
||||
const blob = new Blob([response.body], { type: 'application/msword' });
|
||||
const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
|
||||
|
||||
FileSaver.saveAs(blob, filename);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
downloadXML(): void {
|
||||
this.datasetWizardService.downloadXML(this.itemId)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
|
@ -404,10 +500,34 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
|||
this.datasetWizardService.delete(id)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
complete => { this.onCallbackSuccess(); this.router.navigateByUrl('/datasets')},
|
||||
complete => { this.onCallbackSuccess(); this.router.navigateByUrl('/datasets') },
|
||||
error => this.onCallbackError(error)
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
openDmpSearchDialogue() {
|
||||
const formControl = new FormControl();
|
||||
const dialogRef = this.dialog.open(DatasetCopyDialogueComponent, {
|
||||
data: {
|
||||
formControl: formControl,
|
||||
datasetId: this.formGroup.value.id,
|
||||
datasetProfileId: this.formGroup.value.profile,
|
||||
datasetProfileExist: false,
|
||||
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'),
|
||||
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL')
|
||||
}
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed))
|
||||
.subscribe(result => {
|
||||
if (result && result.datasetProfileExist) {
|
||||
console.log("I came out of the dialogue with result");
|
||||
console.log(result.formControl);
|
||||
const newDmpId = result.formControl.value.id
|
||||
this.router.navigate(['/datasets/copy/' + result.datasetId], { queryParams: { newDmpId: newDmpId } });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import { DatasetExternalServiceDialogEditorComponent } from './dataset-wizard/ex
|
|||
import { DatasetRoutingModule } from './dataset.routing';
|
||||
import { DatasetCriteriaComponent } from './listing/criteria/dataset-criteria.component';
|
||||
import { DatasetListingComponent } from './listing/dataset-listing.component';
|
||||
import { DatasetCopyDialogueComponent } from './dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
@ -37,13 +38,15 @@ import { DatasetListingComponent } from './listing/dataset-listing.component';
|
|||
DatasetExternalDataRepositoryDialogEditorComponent,
|
||||
DatasetExternalDatasetDialogEditorComponent,
|
||||
DatasetExternalRegistryDialogEditorComponent,
|
||||
DatasetExternalServiceDialogEditorComponent
|
||||
DatasetExternalServiceDialogEditorComponent,
|
||||
DatasetCopyDialogueComponent
|
||||
],
|
||||
entryComponents: [
|
||||
DatasetExternalDataRepositoryDialogEditorComponent,
|
||||
DatasetExternalDatasetDialogEditorComponent,
|
||||
DatasetExternalRegistryDialogEditorComponent,
|
||||
DatasetExternalServiceDialogEditorComponent
|
||||
DatasetExternalServiceDialogEditorComponent,
|
||||
DatasetCopyDialogueComponent
|
||||
]
|
||||
})
|
||||
export class DatasetModule { }
|
||||
|
|
|
@ -23,9 +23,9 @@ const routes: Routes = [
|
|||
},
|
||||
},
|
||||
{
|
||||
path: 'publicEdit/:id',
|
||||
path: 'publicEdit/:publicId',
|
||||
component: DatasetWizardComponent,
|
||||
canActivate: [AuthGuard],
|
||||
//canActivate: [AuthGuard],
|
||||
data: {
|
||||
public: true
|
||||
}
|
||||
|
@ -53,6 +53,15 @@ const routes: Routes = [
|
|||
data: {
|
||||
breadcrumb: true
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
path: 'copy/:id',
|
||||
component: DatasetWizardComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
breadcrumb: true
|
||||
},
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
@ -98,7 +98,6 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
|
|||
});
|
||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||
if (result && result.success) {
|
||||
console.log(result.fileList[0]);
|
||||
this.dmpService.uploadXml(result.fileList, result.dmpTitle)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe();
|
||||
|
|
|
@ -13,6 +13,7 @@ import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item
|
|||
import { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCrumbComponent';
|
||||
import { DmpWizardEditorModel } from './dmp-wizard-editor.model';
|
||||
import { SnackBarNotificationLevel, UiNotificationService } from '../../../core/services/notification/ui-notification-service';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dmp-wizard-component',
|
||||
|
@ -75,7 +76,7 @@ export class DmpWizardComponent extends BaseComponent implements OnInit, IBreadC
|
|||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
complete => this.onCallbackSuccess(),
|
||||
error => this.onCallbackError(error)
|
||||
error => this.onCallbackErrorNewVersion(error)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -96,5 +97,9 @@ export class DmpWizardComponent extends BaseComponent implements OnInit, IBreadC
|
|||
});
|
||||
}
|
||||
|
||||
onCallbackErrorNewVersion(errorResponse: HttpErrorResponse) {
|
||||
this.uiNotificationService.snackBarNotification(errorResponse.error.message, SnackBarNotificationLevel.Error);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<div *ngIf="form && this.visibilityRulesService.checkElementVisibility(this.form.get('id').value)" [id]="this.form.get('id').value" [formGroup]="form" [ngSwitch]="this.form.get('viewStyle').value.renderStyle" class="dynamic-form-field row">
|
||||
<div *ngIf="form && this.visibilityRulesService.checkElementVisibility(this.form.get('id').value)" [id]="this.form.get('id').value"
|
||||
[formGroup]="form" [ngSwitch]="this.form.get('viewStyle').value.renderStyle" class="dynamic-form-field row">
|
||||
|
||||
<h5 *ngIf="this.form.get('title').value && !isChild">{{this.form.get('title').value}}</h5>
|
||||
<mat-icon *ngIf="this.form.get('additionalInformation').value && !isChild" matTooltip="{{this.form.get('additionalInformation').value}}">info</mat-icon>
|
||||
|
@ -6,20 +7,28 @@
|
|||
<h5 *ngIf="this.form.get('description').value && !isChild" class="col-12">{{this.form.get('description').value}}
|
||||
</h5>
|
||||
<h5 *ngIf="this.form.get('extendedDescription').value && !isChild" class="col-12">
|
||||
<i>{{this.form.get('extendedDescription').value}}</i></h5>
|
||||
<i>{{this.form.get('extendedDescription').value}}</i>
|
||||
</h5>
|
||||
<mat-form-field *ngSwitchCase="datasetProfileFieldViewStyleEnum.FreeText" class="col-12">
|
||||
<input matInput [formControl]="form.get('value')" placeholder="{{form.get('data').value.label}}" [required]="form.get('validationRequired').value">
|
||||
<mat-error *ngIf="form.get('value')['errors'] && form.get('value')['errors']['required']">{{'GENERAL.VALIDATION.REQUIRED'
|
||||
| translate}}</mat-error>
|
||||
<mat-error *ngIf="form.get('value')['errors'] && form.get('value')['errors']['required']">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<div *ngSwitchCase="datasetProfileFieldViewStyleEnum.ComboBox" class="col-12">
|
||||
<div class="row">
|
||||
<mat-form-field class="col-md-12" *ngIf="form.get('data').value.type === datasetProfileComboBoxTypeEnum.Autocomplete">
|
||||
<app-single-auto-complete placeholder="{{ form.get('data').value.label | translate }}" [formControl]="form.get('value')" [configuration]="singleAutoCompleteConfiguration" [required]="form.get('validationRequired').value">
|
||||
<div *ngIf="form.get('data').value.multiAutoComplete">
|
||||
<app-multiple-auto-complete placeholder="{{ form.get('data').value.label | translate }}" [formControl]="form.get('value')"
|
||||
[configuration]="multipleAutoCompleteConfiguration" (optionRemoved)="_optionRemove($event)">
|
||||
</app-multiple-auto-complete>
|
||||
</div>
|
||||
<div *ngIf="!(form.get('data').value.multiAutoComplete)">
|
||||
<app-single-auto-complete placeholder="{{ form.get('data').value.label | translate }}" [formControl]="form.get('value')"
|
||||
[configuration]="singleAutoCompleteConfiguration" [required]="form.get('validationRequired').value">
|
||||
</app-single-auto-complete>
|
||||
<mat-error *ngIf="form.get('value').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}
|
||||
</mat-error>
|
||||
</div>
|
||||
</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">
|
||||
|
@ -38,12 +47,12 @@
|
|||
</div>
|
||||
|
||||
<mat-form-field *ngSwitchCase="datasetProfileFieldViewStyleEnum.TextArea" class="col-12">
|
||||
<textarea matInput [formControl]="form.get('value')" matTextareaAutosize matAutosizeMinRows="2" matAutosizeMaxRows="10" [required]="form.get('validationRequired').value" placeholder="{{ form.get('data').value.label | translate }}"></textarea>
|
||||
<textarea matInput [formControl]="form.get('value')" matTextareaAutosize matAutosizeMinRows="2" matAutosizeMaxRows="10" [required]="form.get('validationRequired').value"
|
||||
placeholder="{{ form.get('data').value.label | translate }}"></textarea>
|
||||
<button mat-icon-button *ngIf="!form.get('value').disabled && form.get('value').value" matSuffix aria-label="Clear" (click)="this.form.patchValue({'value': ''})">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
<mat-error *ngIf="form.get('value')['errors'] && form.get('value')['errors']['required']">{{'GENERAL.VALIDATION.REQUIRED'
|
||||
| translate}}</mat-error>
|
||||
<mat-error *ngIf="form.get('value')['errors'] && form.get('value')['errors']['required']">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<div *ngSwitchCase="datasetProfileFieldViewStyleEnum.BooleanDecision" class="col-12">
|
||||
|
@ -66,7 +75,8 @@
|
|||
</div>
|
||||
|
||||
<mat-form-field *ngSwitchCase="datasetProfileFieldViewStyleEnum.DatePicker" class="col-12">
|
||||
<input matInput placeholder="{{ form.get('data').value.label | translate }}" class="table-input" [matDatepicker]="date" [required]="form.get('validationRequired').value" [formControl]="form.get('value')">
|
||||
<input matInput placeholder="{{ form.get('data').value.label | translate }}" class="table-input" [matDatepicker]="date" [required]="form.get('validationRequired').value"
|
||||
[formControl]="form.get('value')">
|
||||
<mat-datepicker-toggle matSuffix [for]="date"></mat-datepicker-toggle>
|
||||
<mat-datepicker #date></mat-datepicker>
|
||||
<mat-error *ngIf="form.get('value').hasError('required')">
|
||||
|
|
|
@ -9,6 +9,7 @@ import { RequestItem } from '../../../../../core/query/request-item';
|
|||
import { DatasetExternalAutocompleteService } from '../../../../../core/services/dataset/dataset-external-autocomplete.service';
|
||||
import { SingleAutoCompleteConfiguration } from '../../../../../library/auto-complete/single/single-auto-complete-configuration';
|
||||
import { VisibilityRulesService } from '../../visibility-rules/visibility-rules.service';
|
||||
import { MultipleAutoCompleteConfiguration } from '../../../../../library/auto-complete/multiple/multiple-auto-complete-configuration';
|
||||
|
||||
@Component({
|
||||
selector: 'app-form-field',
|
||||
|
@ -26,6 +27,7 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
|
|||
// trackByFn = (index, item) => item ? item['id'] : null;
|
||||
|
||||
public singleAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
|
||||
public multipleAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
|
||||
datasetProfileFieldViewStyleEnum = DatasetProfileFieldViewStyle;
|
||||
datasetProfileComboBoxTypeEnum = DatasetProfileComboBoxType;
|
||||
|
||||
|
@ -41,6 +43,7 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
|
|||
|
||||
// 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)) {
|
||||
this.singleAutoCompleteConfiguration = {
|
||||
filterFn: this.searchFromAutocomplete.bind(this),
|
||||
initialItems: (extraData) => this.searchFromAutocomplete(''),
|
||||
|
@ -49,6 +52,16 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
|
|||
valueAssign: (item) => JSON.stringify(item)
|
||||
};
|
||||
}
|
||||
else {
|
||||
this.multipleAutoCompleteConfiguration = {
|
||||
filterFn: this.searchFromAutocomplete.bind(this),
|
||||
initialItems: (extraData) => this.searchFromAutocomplete(''),
|
||||
displayFn: (item) => item['label'],
|
||||
titleFn: (item) => item['label'],
|
||||
valueAssign: this._transformValue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// this.form = this.visibilityRulesService.getFormGroup(this.field.id);
|
||||
this.form.get('value').valueChanges
|
||||
|
@ -57,7 +70,22 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
|
|||
this.visibilityRulesService.updateValueAndVisibility(this.form.get('id').value, item);
|
||||
});
|
||||
}
|
||||
// }
|
||||
|
||||
_optionRemove(event) {
|
||||
const array = JSON.parse(this.form.get('value').value);
|
||||
if (array) {
|
||||
const index = array.map(x => x.id).indexOf(event.id);
|
||||
if (index >= 0) {
|
||||
array.splice(index, 1);
|
||||
}
|
||||
this.form.get('value').patchValue(JSON.stringify(array));
|
||||
}
|
||||
}
|
||||
|
||||
_transformValue(item: any) {
|
||||
if (!item) return [];
|
||||
return item && typeof item === 'string' ? JSON.parse(item) : JSON.stringify(item);
|
||||
}
|
||||
|
||||
searchFromAutocomplete(query: string) {
|
||||
const autocompleteRequestItem: RequestItem<DatasetExternalAutocompleteCriteria> = new RequestItem();
|
||||
|
@ -68,5 +96,4 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
|
|||
autocompleteRequestItem.criteria.like = query;
|
||||
return this.datasetExternalAutocompleteService.queryAutocomplete(autocompleteRequestItem);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
</div>
|
||||
<div class="col-auto">
|
||||
<mat-button-toggle-group [ngModel]="_inputValue">
|
||||
<mat-button-toggle value="list" (change)="onValChange($event.value)" matTooltip="Dataset List">
|
||||
<mat-icon>format_align_left</mat-icon>
|
||||
</mat-button-toggle>
|
||||
<mat-button-toggle value="add" (change)="onValChange($event.value)" matTooltip="Add Dataset">
|
||||
<mat-button-toggle value="add" *ngIf="listingMode()" (change)="onValChange($event.value)" matTooltip="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.ADD-BUTTON-TOOLTIP' | translate}}">
|
||||
<mat-icon>add</mat-icon>
|
||||
</mat-button-toggle>
|
||||
<mat-button-toggle value="list" (change)="onValChange($event.value)" matTooltip="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.LIST-BUTTON-TOOLTIP' | translate}}">
|
||||
<mat-icon>format_align_left</mat-icon>
|
||||
</mat-button-toggle>
|
||||
</mat-button-toggle-group>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
|
@ -43,9 +43,12 @@
|
|||
<div *ngIf="toggleButton === 2 && editedDataset" class="col-12">
|
||||
<div class="row">
|
||||
<mat-form-field class="col-md-12">
|
||||
<input matInput placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.DATASET-LABEL' | translate}}" type="string" name="datasetLabel" [formControl]="this.formGroup.get('datasets').get('datasetsList')['controls'][lastIndexOfDataset].get('datasetLabel')" required>
|
||||
<input matInput placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.DATASET-LABEL' | translate}}"
|
||||
type="string" name="datasetLabel" [formControl]="this.formGroup.get('datasets').get('datasetsList')['controls'][lastIndexOfDataset].get('datasetLabel')"
|
||||
required>
|
||||
</mat-form-field>
|
||||
<app-dataset-description-form class="col-12" [form]="this.formGroup.get('datasets').get('datasetsList')['controls'][lastIndexOfDataset]" [visibilityRules]="this.datasetProfileDefinition.rules" [datasetProfileId]="datasetProfile.value.id">
|
||||
<app-dataset-description-form class="col-12" [form]="this.formGroup.get('datasets').get('datasetsList')['controls'][lastIndexOfDataset]"
|
||||
[visibilityRules]="this.datasetProfileDefinition.rules" [datasetProfileId]="datasetProfile.value.id">
|
||||
</app-dataset-description-form>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -9,6 +9,8 @@ import { BreadcrumbItem } from "../../misc/breadcrumb/definition/breadcrumb-item
|
|||
import { IBreadCrumbComponent } from "../../misc/breadcrumb/definition/IBreadCrumbComponent";
|
||||
import { DatasetDescriptionFormEditorModel } from "../../misc/dataset-description-form/dataset-description-form.model";
|
||||
import { QuickWizardDatasetDescriptionModel } from "./quick-wizard-dataset-description-model";
|
||||
import { IfStmt } from "@angular/compiler";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
|
||||
@Component({
|
||||
selector: 'app-dataset-editor-wizard-component',
|
||||
|
@ -35,7 +37,6 @@ export class DatasetEditorWizardComponent extends BaseComponent implements OnIni
|
|||
super();
|
||||
}
|
||||
|
||||
|
||||
ngOnInit(): void {
|
||||
this.datasetWizardService.getDefinition(this.datasetProfile.value["id"])
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
|
@ -64,8 +65,8 @@ export class DatasetEditorWizardComponent extends BaseComponent implements OnIni
|
|||
this.toggleButton = 2;
|
||||
this._inputValue = "dataset";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
editDataset(index: number) {
|
||||
this.lastIndexOfDataset = index;
|
||||
this.toggleButton = 2;
|
||||
|
@ -96,5 +97,7 @@ export class DatasetEditorWizardComponent extends BaseComponent implements OnIni
|
|||
this.editedDataset = true;
|
||||
}
|
||||
|
||||
|
||||
listingMode() {
|
||||
if (this.toggleButton === 0) return true;
|
||||
}
|
||||
}
|
|
@ -43,7 +43,7 @@ export class DmpEditorWizardModel {
|
|||
baseContext.validation.push({ key: 'id', validators: [BackendErrorValidator(this.validationErrorModel, 'id')] });
|
||||
baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] });
|
||||
baseContext.validation.push({ key: 'status', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'status')] });
|
||||
baseContext.validation.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'description')] });
|
||||
baseContext.validation.push({ key: 'description', validators: [BackendErrorValidator(this.validationErrorModel, 'description')] });
|
||||
baseContext.validation.push({ key: 'datasetProfile', validators: [Validators.required, ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'datasetProfile')] });
|
||||
return baseContext;
|
||||
}
|
||||
|
|
|
@ -10,25 +10,19 @@
|
|||
<mat-card-content>
|
||||
<div class="row">
|
||||
<mat-form-field class="col-md-12">
|
||||
<input matInput placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.FIELDS.NAME' | translate}}" type="text" name="label"
|
||||
formControlName="label" required>
|
||||
<input matInput placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.FIELDS.NAME' | translate}}"
|
||||
type="text" name="label" formControlName="label" required>
|
||||
<mat-error *ngIf="formGroup.get('label').hasError('backendError')">
|
||||
{{formGroup.get('label').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('label').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field class="col-md-12">
|
||||
<textarea matInput class="description-area"
|
||||
placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.FIELDS.DESCRIPTION' | translate}}" formControlName="description"
|
||||
required></textarea>
|
||||
<mat-error *ngIf="formGroup.get('description').hasError('backendError')">
|
||||
{{formGroup.get('description').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('description').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' |
|
||||
translate}}</mat-error>
|
||||
<textarea matInput class="description-area" placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.FIELDS.DESCRIPTION' | translate}}"
|
||||
formControlName="description"></textarea>
|
||||
</mat-form-field>
|
||||
<mat-form-field class="col-12">
|
||||
<app-single-auto-complete [required]='true' [formControl]="formGroup.get('datasetProfile')"
|
||||
placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.FIELDS.PROFILE' | translate}}"
|
||||
<app-single-auto-complete [required]='true' [formControl]="formGroup.get('datasetProfile')" placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.FIELDS.PROFILE' | translate}}"
|
||||
[configuration]="profilesAutoCompleteConfiguration" [disabled]="datasetIsEmpty()">
|
||||
</app-single-auto-complete>
|
||||
<mat-error *ngIf="formGroup.get('datasetProfile').hasError('backendError')">
|
||||
|
|
|
@ -59,9 +59,9 @@
|
|||
<div class="navigation-buttons-container">
|
||||
<button matStepperPrevious mat-raised-button
|
||||
color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.BACK' | translate}}</button>
|
||||
<button class="saveAndFinalizeButton" matStepperNext mat-raised-button (click)='saveFinalize()' [disabled]="!formGroup.valid"
|
||||
<button class="saveAndFinalizeButton" matStepperNext mat-raised-button (click)='saveFinalize()' [disabled]="!isFormValid() || !hasDatasets()"
|
||||
color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.SAVE-AND-FINALIZE' | translate}}</button>
|
||||
<button class="saveButton" matStepperNext mat-raised-button (click)='formSubmit()'
|
||||
<button class="saveButton" matStepperNext mat-raised-button (click)='formSubmit()' [disabled]="!hasDatasets()"
|
||||
color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.SAVE' | translate}}</button>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { AbstractControl, FormArray, FormControl, FormGroup } from '@angular/forms';
|
||||
import { MatSnackBar, MatStepper } from '@angular/material';
|
||||
import { MatSnackBar, MatStepper, MatDialog } from '@angular/material';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
@ -13,6 +13,8 @@ import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item
|
|||
import { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCrumbComponent';
|
||||
import { ProjectEditorWizardModel } from '../project-editor/project-editor-wizard-model';
|
||||
import { QuickWizardEditorWizardModel } from './quick-wizard-editor.model';
|
||||
import { DatasetEditorWizardComponent } from '../dataset-editor/dataset-editor-wizard.component';
|
||||
import { ConfirmationDialogComponent } from '../../../library/confirmation-dialog/confirmation-dialog.component';
|
||||
|
||||
|
||||
@Component({
|
||||
|
@ -24,6 +26,7 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
|
|||
|
||||
breadCrumbs: Observable<BreadcrumbItem[]> = Observable.of([]);
|
||||
@ViewChild('stepper') stepper: MatStepper;
|
||||
@ViewChild(DatasetEditorWizardComponent) datasetEditorWizardComponent: DatasetEditorWizardComponent;
|
||||
isNew = true;
|
||||
quickWizard: QuickWizardEditorWizardModel
|
||||
formGroup: FormGroup = null;
|
||||
|
@ -34,7 +37,8 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
|
|||
public router: Router,
|
||||
public language: TranslateService,
|
||||
public quickWizardService: QuickWizardService,
|
||||
private uiNotificationService: UiNotificationService
|
||||
private uiNotificationService: UiNotificationService,
|
||||
private dialog: MatDialog
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
@ -67,10 +71,10 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
|
|||
formSubmit(): void {
|
||||
this.touchAllFormFields(this.formGroup);
|
||||
if (this.formGroup.get('datasets') && this.formGroup.get('datasets').get('datasetsList') && (this.formGroup.get('datasets').get('datasetsList') as FormArray).length > 0) {
|
||||
for(let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls){
|
||||
for (let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls) {
|
||||
control.get('status').setValue('0');
|
||||
}
|
||||
this.onSubmit();
|
||||
this.onSubmitSave();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
@ -78,10 +82,22 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
|
|||
|
||||
saveFinalize() {
|
||||
if (!this.isFormValid()) { return; }
|
||||
for(let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls){
|
||||
if (this.formGroup.get('datasets') && this.formGroup.get('datasets').get('datasetsList') && (this.formGroup.get('datasets').get('datasetsList') as FormArray).length > 0) {
|
||||
for (let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls) {
|
||||
control.get('status').setValue('1');
|
||||
}
|
||||
this.onSubmit();
|
||||
this.onSubminSaveAndFinalize();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
hasDatasets() {
|
||||
if ((this.formGroup.get('datasets').get('datasetsList') as FormArray).length > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public isFormValid() {
|
||||
|
@ -103,7 +119,7 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
|
|||
}
|
||||
}
|
||||
|
||||
onSubmit(): void {
|
||||
onSubminSaveAndFinalize() {
|
||||
this.quickWizardService.createQuickWizard(this.formGroup.getRawValue())
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
|
@ -112,6 +128,27 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
|
|||
);
|
||||
}
|
||||
|
||||
onSubmitSave(): void {
|
||||
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
||||
data: {
|
||||
message: this.language.instant('QUICKWIZARD.SAVE-DIALOG.TITLE'),
|
||||
confirmButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.AFFIRMATIVE'),
|
||||
cancelButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.NEGATIVE')
|
||||
}
|
||||
});
|
||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||
if (result) {
|
||||
this.datasetEditorWizardComponent.addDataset();
|
||||
} else if (result === false) {
|
||||
this.quickWizardService.createQuickDatasetWizard(this.formGroup.value)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
complete => this.onCallbackSuccess()
|
||||
)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onCallbackSuccess(): void {
|
||||
this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
|
||||
this.router.navigate(['/home']);
|
||||
|
|
|
@ -95,7 +95,7 @@
|
|||
"FIELD-TITLE": "Field Name",
|
||||
"DESCRIPTION": "Description",
|
||||
"EXTENDED-DESCRIPTION": "Extended Description",
|
||||
"ADDITIONAL-INFORMATION":"Additional Information",
|
||||
"ADDITIONAL-INFORMATION": "Additional Information",
|
||||
"MULTIPLICITY-MIN": "Multiplicity Min",
|
||||
"MULTIPLICITY-MAX": "Multiplicity Max",
|
||||
"MULTIPLICITY-ADD-ONE-FIELD": "Add one more fieldset",
|
||||
|
@ -143,7 +143,8 @@
|
|||
"FIELD-DATE-PICKER-TITLE": "Date Picker",
|
||||
"FIELD-DATE-PICKER-PLACEHOLDER": "Input Placeholder",
|
||||
"FIELD-DATE-PICKER-LABEL": "Label",
|
||||
"FIELD-DATE-PICKER-VALUE": "Value"
|
||||
"FIELD-DATE-PICKER-VALUE": "Value",
|
||||
"FIELD-MULTIPLE-AUTOCOMPLETE": "Multiple Autocomplete"
|
||||
},
|
||||
"DEFAULT-VALUES": {
|
||||
"NONE": "None",
|
||||
|
@ -254,7 +255,9 @@
|
|||
"SAVE": "Save",
|
||||
"SAVE-AND-FINALISE": "Save and Finalise",
|
||||
"DOWNLOAD-PDF": "Download PDF",
|
||||
"DOWNLOAD-XML": "Download XML"
|
||||
"DOWNLOAD-XML": "Download XML",
|
||||
"DOWNLOAD-DOCX": "Download DOCX",
|
||||
"COPY-DATASET": "Copy Dataset"
|
||||
},
|
||||
"UPLOAD": {
|
||||
"UPLOAD-XML": "Import",
|
||||
|
@ -262,6 +265,12 @@
|
|||
"UPLOAD-XML-NAME": "Name Of Dataset Profile",
|
||||
"UPLOAD-XML-IMPORT": "File",
|
||||
"UPLOAD-XML-FILE-CANCEL": "Cancel"
|
||||
},
|
||||
"DIALOGUE": {
|
||||
"DMP-SEARCH": {
|
||||
"PLACEHOLDER": "Search DMP"
|
||||
},
|
||||
"ERROR-MESSAGE": "This DMP does not contain this Dataset Profile"
|
||||
}
|
||||
},
|
||||
"DATASET-LISTING": {
|
||||
|
@ -311,7 +320,9 @@
|
|||
"EDIT": "Edit",
|
||||
"MAKE-IT-PUBLIC": "Make it public",
|
||||
"VIEW": "View",
|
||||
"CLONE": "Clone"
|
||||
"CLONE": "Clone",
|
||||
"NEW-VERSION": "New Version",
|
||||
"VIEW-VERSIONS": "All Dataset Versions"
|
||||
}
|
||||
},
|
||||
"DMP-PROFILE-EDITOR": {
|
||||
|
@ -425,7 +436,7 @@
|
|||
"PERIOD-FROM": "Start",
|
||||
"PERIOD-TO": "End",
|
||||
"STATUS": "Status",
|
||||
"NONE":"-",
|
||||
"NONE": "-",
|
||||
"TAGS": "Tags"
|
||||
},
|
||||
"DMP": {
|
||||
|
@ -680,17 +691,17 @@
|
|||
"ACTIONS": {
|
||||
"DELETE": "Delete",
|
||||
"SAVE": "Save",
|
||||
"SAVE-AND-FINALIZE":"Save and Finalize",
|
||||
"SAVE-AND-FINALIZE": "Save and Finalize",
|
||||
"NEXT": "Next",
|
||||
"BACK": "Back",
|
||||
"CREATE-NEW":"Create new project",
|
||||
"EXIST":"Existing Project"
|
||||
"CREATE-NEW": "Create new project",
|
||||
"EXIST": "Existing Project"
|
||||
},
|
||||
"FIRST-STEP": {
|
||||
"TITLE": "Project",
|
||||
"OR": "or",
|
||||
"FIELDS": {
|
||||
"SELECT-PROJECT":"Pick the project the DMP is associate with",
|
||||
"SELECT-PROJECT": "Pick the project the DMP is associate with",
|
||||
"LABEL": "Label",
|
||||
"DESCRIPTION": "Description"
|
||||
}
|
||||
|
@ -698,25 +709,34 @@
|
|||
"SECOND-STEP": {
|
||||
"TITLE": "DMP Description",
|
||||
"NEW-TITLE": "",
|
||||
"DMP-NAME":"Dmp For Project : ",
|
||||
"DMP-NAME": "Dmp For Project : ",
|
||||
"FIELDS": {
|
||||
"NAME": "Title of the Dmp",
|
||||
"DESCRIPTION": "Description",
|
||||
"DESCRIPTION": "Provide an optional description for the DMP context and purpose",
|
||||
"PROFILE": "Dataset Description Template"
|
||||
}
|
||||
},
|
||||
"THIRD-STEP": {
|
||||
"TITLE": "Dataset Description",
|
||||
"NEW-TITLE":"",
|
||||
"DATASET-LABEL":"Dataset Title",
|
||||
"DATASET-NAME":"Dataset : ",
|
||||
"DATASET-NAME-FOR":" For Dmp : "
|
||||
"NEW-TITLE": "",
|
||||
"DATASET-LABEL": "Dataset Title",
|
||||
"DATASET-NAME": "Dataset : ",
|
||||
"DATASET-NAME-FOR": " For Dmp : ",
|
||||
"LIST-BUTTON-TOOLTIP": "Dataset List",
|
||||
"ADD-BUTTON-TOOLTIP": "Add Dataset"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ADD": {
|
||||
"TITLE": "Describe Dataset"
|
||||
}
|
||||
},
|
||||
"SAVE-DIALOG": {
|
||||
"TITLE": "Would you like to add another Dataset?",
|
||||
"ACTIONS": {
|
||||
"AFFIRMATIVE": "Yes",
|
||||
"NEGATIVE": "No"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue