using a proper displayLabel for the parent SepaMandate->Customer (HOWTO)
Unfortunately without a test for the HTML template changes of the Angular components because these seem to come only with Protractor, which we had not configured in JHipster.
This commit is contained in:
@ -11,6 +11,7 @@ import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
@ -22,11 +23,14 @@ public class SepaMandateService implements IdToDtoResolver<SepaMandateDTO> {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(SepaMandateService.class);
|
||||
|
||||
private final EntityManager em;
|
||||
|
||||
private final SepaMandateRepository sepaMandateRepository;
|
||||
|
||||
private final SepaMandateMapper sepaMandateMapper;
|
||||
|
||||
public SepaMandateService(SepaMandateRepository sepaMandateRepository, SepaMandateMapper sepaMandateMapper) {
|
||||
public SepaMandateService(final EntityManager em, final SepaMandateRepository sepaMandateRepository, final SepaMandateMapper sepaMandateMapper) {
|
||||
this.em = em;
|
||||
this.sepaMandateRepository = sepaMandateRepository;
|
||||
this.sepaMandateMapper = sepaMandateMapper;
|
||||
}
|
||||
@ -41,6 +45,8 @@ public class SepaMandateService implements IdToDtoResolver<SepaMandateDTO> {
|
||||
log.debug("Request to save SepaMandate : {}", sepaMandateDTO);
|
||||
SepaMandate sepaMandate = sepaMandateMapper.toEntity(sepaMandateDTO);
|
||||
sepaMandate = sepaMandateRepository.save(sepaMandate);
|
||||
em.flush();
|
||||
em.refresh(sepaMandate);
|
||||
return sepaMandateMapper.toDto(sepaMandate);
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ public class SepaMandateDTO implements AccessMappings, FluentBuilder<SepaMandate
|
||||
private Long customerId;
|
||||
|
||||
@AccessFor(update = Role.IGNORED, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
||||
private String customerPrefix;
|
||||
private String customerDisplayLabel;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
@ -149,12 +149,12 @@ public class SepaMandateDTO implements AccessMappings, FluentBuilder<SepaMandate
|
||||
this.customerId = customerId;
|
||||
}
|
||||
|
||||
public String getCustomerPrefix() {
|
||||
return customerPrefix;
|
||||
public String getCustomerDisplayLabel() {
|
||||
return customerDisplayLabel;
|
||||
}
|
||||
|
||||
public void setCustomerPrefix(String customerPrefix) {
|
||||
this.customerPrefix = customerPrefix;
|
||||
public void setCustomerDisplayLabel(String customerDisplayLabel) {
|
||||
this.customerDisplayLabel = customerDisplayLabel;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -192,7 +192,7 @@ public class SepaMandateDTO implements AccessMappings, FluentBuilder<SepaMandate
|
||||
", lastUsedDate='" + getLastUsedDate() + "'" +
|
||||
", remark='" + getRemark() + "'" +
|
||||
", customer=" + getCustomerId() +
|
||||
", customerPrefix='" + getCustomerPrefix() + "'" +
|
||||
", customerDisplayLabel='" + getCustomerDisplayLabel() + "'" +
|
||||
"}";
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
package org.hostsharing.hsadminng.service.mapper;
|
||||
|
||||
import org.hostsharing.hsadminng.domain.*;
|
||||
import org.hostsharing.hsadminng.domain.SepaMandate;
|
||||
import org.hostsharing.hsadminng.service.dto.SepaMandateDTO;
|
||||
|
||||
import org.mapstruct.*;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
|
||||
/**
|
||||
* Mapper for the entity SepaMandate and its DTO SepaMandateDTO.
|
||||
@ -12,9 +14,14 @@ import org.mapstruct.*;
|
||||
public interface SepaMandateMapper extends EntityMapper<SepaMandateDTO, SepaMandate> {
|
||||
|
||||
@Mapping(source = "customer.id", target = "customerId")
|
||||
@Mapping(source = "customer.prefix", target = "customerPrefix")
|
||||
@Mapping(target = "customerDisplayLabel", ignore = true)
|
||||
SepaMandateDTO toDto(SepaMandate sepaMandate);
|
||||
|
||||
@AfterMapping
|
||||
default void setDisplayLabels(final @MappingTarget SepaMandateDTO dto, final SepaMandate entity) {
|
||||
dto.setCustomerDisplayLabel(CustomerMapper.displayLabel(entity.getCustomer()));
|
||||
}
|
||||
|
||||
@Mapping(source = "customerId", target = "customer")
|
||||
SepaMandate toEntity(SepaMandateDTO sepaMandateDTO);
|
||||
|
||||
|
@ -37,6 +37,7 @@
|
||||
<dd>
|
||||
<span>{{sepaMandate.lastUsedDate}}</span>
|
||||
</dd>
|
||||
</dd>
|
||||
<dt><span jhiTranslate="hsadminNgApp.sepaMandate.remark">Remark</span></dt>
|
||||
<dd>
|
||||
<span>{{sepaMandate.remark}}</span>
|
||||
@ -44,7 +45,7 @@
|
||||
<dt><span jhiTranslate="hsadminNgApp.sepaMandate.customer">Customer</span></dt>
|
||||
<dd>
|
||||
<div *ngIf="sepaMandate.customerId">
|
||||
<a [routerLink]="['/customer', sepaMandate.customerId, 'view']">{{sepaMandate.customerPrefix}}</a>
|
||||
<a [routerLink]="['/customer', sepaMandate.customerId, 'view']">{{sepaMandate.customerDisplayLabel}}</a>
|
||||
</div>
|
||||
</dd>
|
||||
</dl>
|
||||
|
@ -124,7 +124,7 @@
|
||||
<label class="form-control-label" jhiTranslate="hsadminNgApp.sepaMandate.customer" for="field_customer">Customer</label>
|
||||
<select class="form-control" id="field_customer" name="customer" [(ngModel)]="sepaMandate.customerId" required>
|
||||
<option *ngIf="!editForm.value.customer" [ngValue]="null" selected></option>
|
||||
<option [ngValue]="customerOption.id" *ngFor="let customerOption of customers; trackBy: trackCustomerById">{{customerOption.prefix}}</option>
|
||||
<option [ngValue]="customerOption.id" *ngFor="let customerOption of customers; trackBy: trackCustomerById">{{customerOption.displayLabel}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div [hidden]="!(editForm.controls.customer?.dirty && editForm.controls.customer?.invalid)">
|
||||
|
@ -24,7 +24,7 @@
|
||||
<th jhiSortBy="validUntilDate"><span jhiTranslate="hsadminNgApp.sepaMandate.validUntilDate">Valid Until Date</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="lastUsedDate"><span jhiTranslate="hsadminNgApp.sepaMandate.lastUsedDate">Last Used Date</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="remark"><span jhiTranslate="hsadminNgApp.sepaMandate.remark">Remark</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="customerPrefix"><span jhiTranslate="hsadminNgApp.sepaMandate.customer">Customer</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="customerDisplayLabel"><span jhiTranslate="hsadminNgApp.sepaMandate.customer">Customer</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -42,7 +42,7 @@
|
||||
<td>{{sepaMandate.remark}}</td>
|
||||
<td>
|
||||
<div *ngIf="sepaMandate.customerId">
|
||||
<a [routerLink]="['../customer', sepaMandate.customerId , 'view' ]" >{{sepaMandate.customerPrefix}}</a>
|
||||
<a [routerLink]="['../customer', sepaMandate.customerId , 'view' ]" >{{sepaMandate.customerDisplayLabel}}</a>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
|
@ -11,7 +11,7 @@ export interface ISepaMandate {
|
||||
validUntilDate?: Moment;
|
||||
lastUsedDate?: Moment;
|
||||
remark?: string;
|
||||
customerPrefix?: string;
|
||||
customerDisplayLabel?: string;
|
||||
customerId?: number;
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ export class SepaMandate implements ISepaMandate {
|
||||
public validUntilDate?: Moment,
|
||||
public lastUsedDate?: Moment,
|
||||
public remark?: string,
|
||||
public customerPrefix?: string,
|
||||
public customerDisplayLabel?: string,
|
||||
public customerId?: number
|
||||
) {}
|
||||
}
|
||||
|
Reference in New Issue
Block a user