Skip to content

Commit

Permalink
refactor: replace deprecated formly field configuration properties
Browse files Browse the repository at this point in the history
* execute formly-migrate schematic for each project
* replace deprecated leftover properties manually
* adapt inline documentation and rename some variables
* remove eslint deprecated rule exception for formly field properties

BREAKING CHANGE: replace all deprecated formly field configuration properties
  • Loading branch information
Eisie96 committed Mar 1, 2023
1 parent 932cafa commit fad6075
Show file tree
Hide file tree
Showing 128 changed files with 337 additions and 341 deletions.
9 changes: 1 addition & 8 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,7 @@
"dot-notation": "off", // disabled in favor of @typescript-eslint/dot-notation
"eqeqeq": ["error", "always"],
"etc/no-commented-out-code": "warn",
"etc/no-deprecated": [
"warn",
{
"ignored": {
"templateOptions|to|FormlyTemplateOptions|expressionProperties": "name" // deprecated formly methods are temporarily ignored
}
}
],
"etc/no-deprecated": ["warn"],
"id-blacklist": [
"error",
"any",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class CostCenterBuyerEditDialogComponent implements OnInit {
key: 'buyerName',
type: 'ish-plain-text-field',
className: 'col-8',
templateOptions: {
props: {
labelClass: 'col-4',
fieldClass: 'col-8',
label: 'account.costcenter.details.buyers.list.header.name',
Expand All @@ -59,7 +59,7 @@ export class CostCenterBuyerEditDialogComponent implements OnInit {
key: 'budgetValue',
type: 'ish-text-input-field',
className: ' col-6 col-md-8',
templateOptions: {
props: {
postWrappers: [{ wrapper: 'input-addon', index: -1 }],
labelClass: 'col-md-4',
fieldClass: 'col-md-8 pr-0',
Expand All @@ -81,7 +81,7 @@ export class CostCenterBuyerEditDialogComponent implements OnInit {
key: 'budgetPeriod',
type: 'ish-select-field',
className: 'col-6 col-md-4',
templateOptions: {
props: {
fieldClass: 'col-12 label-empty',
options: FormsService.getCostCenterBudgetPeriodOptions(),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ export class CostCenterFormComponent implements OnInit {
{
key: 'currency',
type: 'ish-text-input-field',
templateOptions: {
props: {
fieldClass: 'd-none',
required: true,
},
},
{
key: 'costCenterId',
type: 'ish-text-input-field',
templateOptions: {
props: {
label: 'account.costcenter.id.label',
required: true,
hideRequiredMarker: true,
Expand All @@ -100,7 +100,7 @@ export class CostCenterFormComponent implements OnInit {
{
key: 'name',
type: 'ish-text-input-field',
templateOptions: {
props: {
label: 'account.costcenter.name.label',
required: true,
hideRequiredMarker: true,
Expand All @@ -118,7 +118,7 @@ export class CostCenterFormComponent implements OnInit {
className: 'col-6 col-md-8',
key: 'budgetValue',
type: 'ish-text-input-field',
templateOptions: {
props: {
postWrappers: [{ wrapper: 'input-addon', index: -1 }],
labelClass: 'col-md-6',
fieldClass: 'col-md-6 pr-0',
Expand All @@ -143,7 +143,7 @@ export class CostCenterFormComponent implements OnInit {
className: 'col-6 col-md-4',
type: 'ish-select-field',
key: 'budgetPeriod',
templateOptions: {
props: {
fieldClass: 'col-12 label-empty',
options: FormsService.getCostCenterBudgetPeriodOptions(),
},
Expand All @@ -153,7 +153,7 @@ export class CostCenterFormComponent implements OnInit {
{
key: 'costCenterManager',
type: 'ish-select-field',
templateOptions: {
props: {
label: 'account.costcenter.manager.label',
required: true,
hideRequiredMarker: true,
Expand All @@ -169,15 +169,15 @@ export class CostCenterFormComponent implements OnInit {
},
{
type: 'ish-fieldset-field',
templateOptions: {
props: {
// hide active flag for new cost centers
fieldsetClass: !this.costCenter ? 'd-none' : undefined,
},
fieldGroup: [
{
key: 'active',
type: 'ish-checkbox-field',
templateOptions: {
props: {
label: 'account.costCenter.active.label',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ export class UserBudgetFormComponent implements OnInit, OnDestroy {
{
key: 'currency',
type: 'ish-text-input-field',
templateOptions: {
props: {
fieldClass: 'd-none',
required: true,
},
},
{
key: 'orderSpentLimitValue',
type: 'ish-text-input-field',
templateOptions: {
props: {
postWrappers: [{ wrapper: 'input-addon', index: -1 }],
label: 'account.user.new.order_spend_limit.label',
placeholder: 'account.budget.unlimited',
Expand All @@ -106,7 +106,7 @@ export class UserBudgetFormComponent implements OnInit, OnDestroy {
className: 'col-8',
key: 'budgetValue',
type: 'ish-text-input-field',
templateOptions: {
props: {
postWrappers: [{ wrapper: 'input-addon', index: -1 }],
labelClass: 'col-md-6',
fieldClass: 'col-md-6 pr-0',
Expand All @@ -129,7 +129,7 @@ export class UserBudgetFormComponent implements OnInit, OnDestroy {
className: 'col-4',
type: 'ish-select-field',
key: 'budgetPeriod',
templateOptions: {
props: {
fieldClass: 'col-12 label-empty',
options: this.periods.map(period => ({
value: period,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class UserProfileFormComponent implements OnInit {
? {
key: 'email',
type: 'ish-email-field',
templateOptions: {
props: {
label: 'account.user.email.label',
required: true,
},
Expand All @@ -61,7 +61,7 @@ export class UserProfileFormComponent implements OnInit {
{
key: 'active',
type: 'ish-checkbox-field',
templateOptions: {
props: {
label: 'account.user.active.label',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class CostCenterBuyersPageComponent implements OnDestroy, OnInit {
{
key: 'addBuyers',
type: 'repeatCostCenterBuyers',
templateOptions: {},
props: {},
fieldArray: {
fieldGroupClassName: 'row list-item-row',
fieldGroup: [
Expand All @@ -103,23 +103,23 @@ export class CostCenterBuyersPageComponent implements OnDestroy, OnInit {
key: 'selected',
defaultValue: false,
className: 'col-1 col-md-2 list-item pb-0',
templateOptions: {
props: {
fieldClass: 'offset-md-2 col-2 mt-1',
},
},
{
key: 'name',
type: 'ish-html-text-field',
className: 'col-11 col-sm-10 col-md-3 list-item pb-0',
templateOptions: {
props: {
inputClass: 'col-form-label pb-0',
},
},
{
key: 'budgetValue',
type: 'ish-text-input-field',
className: 'col-6 col-md-4 list-item',
templateOptions: {
props: {
fieldClass: 'col-12',
postWrappers: [{ wrapper: 'input-addon', index: -1 }],
addonLeft: {
Expand All @@ -139,7 +139,7 @@ export class CostCenterBuyersPageComponent implements OnDestroy, OnInit {
key: 'budgetPeriod',
type: 'ish-select-field',
className: 'col-6 col-md-3 list-item',
templateOptions: {
props: {
fieldClass: 'col-12',
options: FormsService.getCostCenterBudgetPeriodOptions(),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class RequisitionRejectDialogComponent implements OnInit {
{
key: 'comment',
type: 'ish-textarea-field',
templateOptions: {
props: {
label: 'approval.rejectform.add_a_comment.label',
required: true,
maxLength: 1000,
Expand Down
12 changes: 6 additions & 6 deletions src/app/core/models/payment-method/payment-method.mapper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ describe('Payment Method Mapper', () => {
expect(paymentMethod.parameters[0].type).toEqual('ish-text-input-field');
expect(paymentMethod.parameters[0].key).toEqual('holder');
expect(paymentMethod.parameters[0].hide).toBeFalse();
expect(paymentMethod.parameters[0].templateOptions.type).toEqual('text');
expect(paymentMethod.parameters[0].templateOptions.required).toBeTrue();
expect(paymentMethod.parameters[0].props.type).toEqual('text');
expect(paymentMethod.parameters[0].props.required).toBeTrue();

expect(paymentMethod.parameters[1].templateOptions.pattern).toBe(regexp);
expect(paymentMethod.parameters[1].templateOptions.minLength).toBe(15);
expect(paymentMethod.parameters[1].templateOptions.maxLength).toBe(34);
expect(paymentMethod.parameters[1].templateOptions.attributes).toBeObject();
expect(paymentMethod.parameters[1].props.pattern).toBe(regexp);
expect(paymentMethod.parameters[1].props.minLength).toBe(15);
expect(paymentMethod.parameters[1].props.maxLength).toBe(34);
expect(paymentMethod.parameters[1].props.attributes).toBeObject();

expect(paymentMethod.parameters[3].hide).toBeTrue();
});
Expand Down
10 changes: 5 additions & 5 deletions src/app/core/models/payment-method/payment-method.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class PaymentMethodMapper {
const param: FormlyFieldConfig = {
key: p.name,
type: p.options ? 'ish-select-field' : 'ish-text-input-field',
templateOptions: {
props: {
labelClass: 'col-md-4',
fieldClass: 'col-sm-6',
type: p.type === 'string' ? 'text' : (p.type as string).toLowerCase(),
Expand All @@ -192,20 +192,20 @@ export class PaymentMethodMapper {

if (p.constraints) {
if (p.constraints.required) {
param.templateOptions.required = true;
param.props.required = true;
param.validation.messages = { ...param.validation.messages, required: p.constraints.required.message };
}
if (p.constraints.size) {
param.templateOptions.minLength = p.constraints.size.min;
param.templateOptions.maxLength = p.constraints.size.max;
param.props.minLength = p.constraints.size.min;
param.props.maxLength = p.constraints.size.max;
param.validation.messages = {
...param.validation.messages,
minLength: p.constraints.size.message,
maxLength: p.constraints.size.message,
};
}
if (p.constraints.pattern) {
param.templateOptions.pattern = p.constraints.pattern.regexp;
param.props.pattern = p.constraints.pattern.regexp;
param.validation.messages = {
...param.validation.messages,
pattern: p.constraints.pattern.message,
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/utils/dev/basket-mock-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class BasketMockData {
{
key: 'IBAN',
type: 'input',
templateOptions: {
props: {
type: 'text',
required: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class ContactFormComponent implements OnInit {
{
key: 'name',
type: 'ish-text-input-field',
templateOptions: {
props: {
label: 'helpdesk.contactus.name.label',
required: true,
},
Expand All @@ -59,30 +59,30 @@ export class ContactFormComponent implements OnInit {
{
key: 'email',
type: 'ish-email-field',
templateOptions: {
props: {
label: 'helpdesk.contactus.email.label',
required: true,
},
},
{
key: 'phone',
type: 'ish-phone-field',
templateOptions: {
props: {
label: 'helpdesk.contactus.phone.label',
required: true,
},
},
{
key: 'order',
type: 'ish-text-input-field',
templateOptions: {
props: {
label: 'helpdesk.contactus.order.label',
},
},
{
key: 'subject',
type: 'ish-select-field',
templateOptions: {
props: {
label: 'helpdesk.contactus.subject.label',
required: true,
options: this.contactUsFacade.contactSubjects$().pipe(
Expand All @@ -101,7 +101,7 @@ export class ContactFormComponent implements OnInit {
{
key: 'comment',
type: 'ish-textarea-field',
templateOptions: {
props: {
label: 'helpdesk.contactus.comments.label',
required: true,
maxLength: 30000,
Expand All @@ -115,7 +115,7 @@ export class ContactFormComponent implements OnInit {
},
{
type: 'ish-captcha-field',
templateOptions: {
props: {
topic: 'contactUs',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class OrderTemplatePreferencesDialogComponent implements OnInit {
{
key: 'title',
type: 'ish-text-input-field',
templateOptions: {
props: {
required: true,
label: 'account.order_template.form.name.label',
hideRequiredMarker: true,
Expand Down
Loading

0 comments on commit fad6075

Please sign in to comment.