mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
Merged PR 1056: #2696 Upgrade of p4mUser is now possible
#2696 Upgrade of p4mUser is now possible
This commit is contained in:
committed by
Lorenz Hilpert
parent
f46ef394d9
commit
1d2df695d3
@@ -43,6 +43,7 @@ export abstract class CustomerCreateComponentBase {
|
||||
|
||||
cusotmers$: Observable<InputOptionsDTO>;
|
||||
private _p4mUser: KeyValueDTOOfStringAndString;
|
||||
private _p4mUserFeature: 'webshop' | 'store';
|
||||
|
||||
get p4mUser() {
|
||||
return this._p4mUser;
|
||||
@@ -52,6 +53,14 @@ export abstract class CustomerCreateComponentBase {
|
||||
this._p4mUser = data;
|
||||
}
|
||||
|
||||
get p4mUserFeature() {
|
||||
return this._p4mUserFeature;
|
||||
}
|
||||
|
||||
set p4mUserFeature(data: 'webshop' | 'store') {
|
||||
this._p4mUserFeature = data;
|
||||
}
|
||||
|
||||
get organisationGroup(): AbstractControl {
|
||||
return this.control?.get('organisation');
|
||||
}
|
||||
@@ -83,6 +92,17 @@ export abstract class CustomerCreateComponentBase {
|
||||
f.selected = f.value === this.type;
|
||||
f.enabled = isBoolean(f.enabled) ? f.enabled : true;
|
||||
});
|
||||
|
||||
// Upgrade p4mUser if necessary - Only show available option and select it
|
||||
if (!!this.p4mUser && !!r?.filter?.customertype) {
|
||||
if (!r.filter.customertype.includes(this.p4mUserFeature)) {
|
||||
result.options.values = result.options.values.filter(
|
||||
(option) => option.value === (this.p4mUserFeature === 'store' ? 'webshop' : 'store')
|
||||
);
|
||||
result.options.values[0].selected = true;
|
||||
result.options.values[0].enabled = true;
|
||||
}
|
||||
}
|
||||
return result.options;
|
||||
})
|
||||
);
|
||||
@@ -139,8 +159,9 @@ export abstract class CustomerCreateComponentBase {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (query.card) {
|
||||
if (query.card && query.cardFeature) {
|
||||
this.p4mUser = JSON.parse(decodeURIComponent(query.card));
|
||||
this.p4mUserFeature = decodeURIComponent(query.cardFeature) as 'webshop' | 'store';
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -317,7 +317,7 @@ export abstract class CustomerSearch implements OnInit, OnDestroy {
|
||||
|
||||
if (this.searchState === 'result' && !r.dialog) {
|
||||
if (Number(r?.result[0]?.id) < 0) {
|
||||
this.navgateToCreateCustomer(r.result[0]);
|
||||
this.navgateToCreateCustomerWithCard(r.result[0]);
|
||||
} else if (hits === 1) {
|
||||
this.navigateToDetails(r.result[0].id);
|
||||
} else {
|
||||
@@ -424,7 +424,8 @@ export abstract class CustomerSearch implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
navgateToCreateCustomer(customer: CustomerInfoDTO) {
|
||||
navgateToCreateCustomerWithCard(customer: CustomerInfoDTO) {
|
||||
const feature = customer?.features?.find((feature) => feature.key === 'webshop') ? 'webshop' : 'store';
|
||||
const customerCreateQueryParams = {
|
||||
gender: customer?.gender,
|
||||
title: customer?.title,
|
||||
@@ -444,8 +445,9 @@ export abstract class CustomerSearch implements OnInit, OnDestroy {
|
||||
vatId: customer?.organisation?.vatId,
|
||||
dateOfBirth: customer?.dateOfBirth,
|
||||
card: encodeURIComponent(JSON.stringify(customer?.features[0])),
|
||||
cardFeature: feature,
|
||||
};
|
||||
this.router.navigate(['customer', 'create', customer?.features?.find((feature) => feature.key === 'webshop') ? 'webshop' : 'store'], {
|
||||
this.router.navigate(['customer', 'create', feature], {
|
||||
queryParams: customerCreateQueryParams,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -24,6 +24,23 @@ export class CustomerCreateGuard implements CanActivateChild {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If Upgrade for p4mUser is necessary - select the correct route
|
||||
// cardFeature is either 'webshop' or 'store' for p4mUsers
|
||||
if (!!route?.queryParams?.card && !!route?.queryParams?.cardFeature) {
|
||||
this.router.navigate(
|
||||
[
|
||||
'/customer/create',
|
||||
selectables[route?.queryParams?.cardFeature] === true
|
||||
? route?.queryParams?.cardFeature
|
||||
: route?.queryParams?.cardFeature === 'webshop'
|
||||
? 'store'
|
||||
: 'webshop',
|
||||
],
|
||||
{ queryParams: route.queryParams }
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const key in selectables) {
|
||||
if (Object.prototype.hasOwnProperty.call(selectables, key)) {
|
||||
if (selectables[key]) {
|
||||
|
||||
Reference in New Issue
Block a user