1/** 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import DataColumns from './DataColumns'; 17import DataType from './DataType'; 18import {DataItemType} from './DataType'; 19 20/** 21 * Address Data Type 22 */ 23export class StructuredPostal extends DataType { 24 static readonly CONTENT_ITEM_TYPE: string = 'postal_address'; 25 static readonly CONTENT_ITEM_TYPE_ID: number = DataItemType.STRUCTURED_POSTAL; 26 static readonly FORMATTED_ADDRESS: string = DataType.DATA; 27 static readonly STREET: string = DataColumns.STREET; 28 static readonly POBOX: string = DataColumns.POBOX; 29 static readonly NEIGHBORHOOD: string = DataColumns.NEIGHBORHOOD; 30 static readonly CITY: string = DataColumns.CITY; 31 static readonly REGION: string = DataColumns.REGION; 32 static readonly POSTCODE: string = DataColumns.POSTCODE; 33 static readonly COUNTRY: string = DataColumns.COUNTRY; 34 static readonly TYPE_HOME: number = 1; 35 static readonly TYPE_WORK: number = 2; 36 static readonly TYPE_OTHER: number = 3; 37 38 static getTypeLabelResource(type: number) { 39 switch (type) { 40 case StructuredPostal.TYPE_HOME: 41 return $r('app.string.email_type_home'); 42 case StructuredPostal.TYPE_WORK: 43 return $r('app.string.email_type_work'); 44 case StructuredPostal.TYPE_OTHER: 45 return $r('app.string.email_type_other'); 46 default: 47 return $r('app.string.email_type_custom'); 48 } 49 } 50 51 constructor() { 52 super(); 53 } 54}