### Description - This is the first PR on Phones field; - We are introducing new field type(Phones) - We are Forbidding creation of Phone field - We Added support for filtering and sorting on Phones field - We are using the same display mode as used on the Links field type (chips), check the Domain field of the Company object - We are also using the same logic of the link when editing the field **How to Test** 1. Checkout to TWNTY-6260 branch 2. Reset database using "npx nx database:reset twenty-server" command 3. Add custom field of type Phones in settings/data-model **Loom Video:**\ <https://www.loom.com/share/3c981260be254dcf851256d020a20ab0?sid=58507361-3a3b-452c-9de8-b5b1abda70ac> ### Refs #6260 Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
60 lines
1.5 KiB
TypeScript
60 lines
1.5 KiB
TypeScript
import { FieldMetadataDefaultValue } from 'src/engine/metadata-modules/field-metadata/interfaces/field-metadata-default-value.interface';
|
|
|
|
import { FieldMetadataType } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
|
|
|
export function generateDefaultValue(
|
|
type: FieldMetadataType,
|
|
): FieldMetadataDefaultValue {
|
|
switch (type) {
|
|
case FieldMetadataType.TEXT:
|
|
case FieldMetadataType.PHONE:
|
|
case FieldMetadataType.EMAIL:
|
|
return "''";
|
|
case FieldMetadataType.EMAILS:
|
|
return {
|
|
primaryEmail: "''",
|
|
additionalEmails: null,
|
|
};
|
|
case FieldMetadataType.FULL_NAME:
|
|
return {
|
|
firstName: "''",
|
|
lastName: "''",
|
|
};
|
|
case FieldMetadataType.ADDRESS:
|
|
return {
|
|
addressStreet1: "''",
|
|
addressStreet2: "''",
|
|
addressCity: "''",
|
|
addressState: "''",
|
|
addressCountry: "''",
|
|
addressPostcode: "''",
|
|
addressLat: null,
|
|
addressLng: null,
|
|
};
|
|
case FieldMetadataType.LINK:
|
|
return {
|
|
url: "''",
|
|
label: "''",
|
|
};
|
|
case FieldMetadataType.CURRENCY:
|
|
return {
|
|
amountMicros: null,
|
|
currencyCode: "''",
|
|
};
|
|
case FieldMetadataType.LINKS:
|
|
return {
|
|
primaryLinkLabel: "''",
|
|
primaryLinkUrl: "''",
|
|
secondaryLinks: null,
|
|
};
|
|
case FieldMetadataType.PHONES:
|
|
return {
|
|
primaryPhoneNumber: "''",
|
|
primaryPhoneCountryCode: "''",
|
|
additionalPhones: null,
|
|
};
|
|
default:
|
|
return null;
|
|
}
|
|
}
|