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

This commit is contained in:
apapachristou 2020-07-10 16:52:42 +03:00
commit b605a35cd4
5 changed files with 48 additions and 21 deletions

View File

@ -155,6 +155,7 @@ public class DataManagementPlanManager {
if (fieldsGroup.equals("listing")) {
if (!dataManagementPlanTableRequest.getCriteria().isOnlyPublic()) {
itemsFuture = pagedItems.withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class))
.distinct()
.selectAsync(item -> {
item.setDataset(
item.getDataset().stream()
@ -168,6 +169,7 @@ public class DataManagementPlanManager {
.whenComplete((resultList, throwable) -> dataTable.setData(resultList));
} else {
itemsFuture = pagedItems.withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class))
.distinct()
.selectAsync(item -> {
item.setDataset(
item.getDataset().stream()
@ -178,10 +180,12 @@ public class DataManagementPlanManager {
}
} else if (fieldsGroup.equals("autocomplete")) {
itemsFuture = pagedItems
.distinct()
.selectAsync(item -> new DataManagementPlanListingModel().fromDataModelAutoComplete(item))
.whenComplete((resultList, throwable) -> dataTable.setData(resultList));
} else {
itemsFuture = pagedItems
.distinct()
.selectAsync(item -> new DataManagementPlanListingModel().fromDataModelAssociatedProfiles(item))
.whenComplete((resultList, throwable) -> dataTable.setData(resultList));
}

View File

@ -82,7 +82,7 @@ public class InvitationsManager {
Unmarshaller unmarshaller = context.createUnmarshaller();
Properties properties = (Properties) unmarshaller.unmarshal(new StringReader(invitation.getProperties()));
UserInfo invitedUser = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
QueryableList<UserDMP> userDMPQueryableList = apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where(((builder, root) -> builder.and(builder.equal(root.get("dmp").get("id"), invitation.getDmp().getId()), builder.equal(root.get("user").get("id"), invitation.getUser().getId()))));
QueryableList<UserDMP> userDMPQueryableList = apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where(((builder, root) -> builder.and(builder.equal(root.get("dmp").get("id"), invitation.getDmp().getId()), builder.equal(root.get("user").get("id"), invitedUser.getId()))));
UserDMP existingUserDMP = userDMPQueryableList.getSingleOrDefault();
if (existingUserDMP != null) {
if (properties.getRole() != null && existingUserDMP.getRole() > properties.getRole()) {

View File

@ -14,7 +14,15 @@
[configuration]="usersAutoCompleteConfiguration">
</app-multiple-auto-complete>
</mat-form-field>
<div class="col-12 d-flex justify-content-end row m-0">
<div class="col-12 d-flex justify-content-end align-items-center row m-0 pr-0">
<mat-form-field class="select-role" floatLabel="never">
<mat-label>{{'DMP-LISTING.MEMBER' | translate}}</mat-label>
<mat-select [formControl]="formGroup.get('role')">
<mat-option *ngFor="let roleName of roleNames | keyvalue" selected [value]="roles[roleName.value]">
{{ roleName.value }}
</mat-option>
</mat-select>
</mat-form-field>
<button mat-raised-button (click)="send()" type="button"
class="invite-btn">{{'DMP-LISTING.ACTIONS.INVITE-SHORT' | translate}}</button>
</div>

View File

@ -28,6 +28,10 @@
border-radius: 4px;
}
::ng-deep .mat-dialog-container {
border-radius: 8px;
}
::ng-deep .mat-form-field-underline {
display: none;
}
@ -56,3 +60,12 @@
margin-bottom: 0.25em;
}
.select-role {
width: 16% !important;
font-size: 14px;
color: #848484;
height: min-content;
margin-right: 2.5rem;
border: none;
background-color: transparent;
}

View File

@ -14,6 +14,7 @@ import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/mu
import { BaseComponent } from '@common/base/base.component';
import { Observable } from 'rxjs';
import { map, takeUntil } from 'rxjs/operators';
import { Role } from '@app/core/common/enum/role';
@Component({
selector: 'app-invitation-component',
@ -26,6 +27,8 @@ export class DmpInvitationDialogComponent extends BaseComponent implements OnIni
public filteredUsersAsync = false;
public filteredUsers: DmpInvitationUser[];
public emails: string[] = [];
public roles = Role;
public roleNames: string[];
visible = true;
selectable = true;
@ -33,13 +36,29 @@ export class DmpInvitationDialogComponent extends BaseComponent implements OnIni
addOnBlur = true;
readonly separatorKeysCodes: number[] = [ENTER, COMMA];
constructor(
public invitationService: DmpInvitationService,
public route: ActivatedRoute,
public router: Router,
public dialogRef: MatDialogRef<DmpInvitationDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any
) {
super();
this.roleNames = Object.keys(this.roles).filter(key => key.length > 1);
}
ngOnInit(): void {
const invitation = new DmpInvitation();
invitation.dataManagementPlan = this.data.dmpId;
this.formGroup = invitation.buildForm();
}
usersAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = {
filterFn: this.filterUsers.bind(this),
initialItems: (excludedItems: any[]) => this.filterUsers('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))),
displayFn: (item) => typeof(item) === 'string' ? item : item.name,
titleFn: (item) => typeof(item) === 'string' ? item : item.name,
valueAssign: (item) => {
const result = typeof(item) === 'string' ? item : item.email;
console.log(result);
return result;
@ -64,30 +83,13 @@ export class DmpInvitationDialogComponent extends BaseComponent implements OnIni
}
}
constructor(
public invitationService: DmpInvitationService,
public route: ActivatedRoute,
public router: Router,
public dialogRef: MatDialogRef<DmpInvitationDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any
) { super(); }
ngOnInit(): void {
const invitation = new DmpInvitation();
invitation.dataManagementPlan = this.data.dmpId;
this.formGroup = invitation.buildForm();
}
send(value: any) {
let invitationObject: any = {};
invitationObject.dataManagementPlan = this.data.dmpId;
invitationObject.role = this.formGroup.get('role').value;
invitationObject.users = [];
console.log(this.formGroup.get('users').value);
invitationObject.users.push(...(<any[]>this.formGroup.get('users').value).filter(user => typeof(user) === 'string').map(email => ({ email: email, name: email })));
invitationObject.users.push(...(<any[]>this.formGroup.get('users').value).filter(user => typeof(user) !== 'string'));
console.log(invitationObject.users);
//invitationObject.users.push(...this.formGroup.get('users').value);
this.emails.forEach(email => {
invitationObject.users.push({ email: email, name: email });