refactor(contacts):
This commit is contained in:
parent
b995d7bc31
commit
e52fb1cacc
@ -1,6 +1,9 @@
|
||||
import {Plugin, Cordova, InstanceProperty, CordovaInstance} from './plugin';
|
||||
import { Cordova, CordovaInstance, Plugin, InstanceProperty } from './plugin';
|
||||
|
||||
|
||||
declare var window: any,
|
||||
navigator: any;
|
||||
|
||||
export interface IContactProperties {
|
||||
/** A globally unique identifier. */
|
||||
id?: string;
|
||||
@ -32,7 +35,6 @@ export interface IContactProperties {
|
||||
urls?: IContactField[];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
@ -51,9 +53,11 @@ export class Contact {
|
||||
@InstanceProperty get photos(): IContactField[] { return; }
|
||||
@InstanceProperty get categories(): IContactField[] { return; }
|
||||
@InstanceProperty get urls(): IContactField[] { return; }
|
||||
|
||||
constructor() {
|
||||
this._objectInstance = navigator.contacts.create();
|
||||
}
|
||||
|
||||
clone(): Contact {
|
||||
let newContact = new Contact();
|
||||
for (let prop in this) {
|
||||
@ -62,17 +66,21 @@ export class Contact {
|
||||
}
|
||||
return newContact;
|
||||
}
|
||||
|
||||
@CordovaInstance()
|
||||
remove(): Promise<any> { return; }
|
||||
|
||||
@CordovaInstance()
|
||||
save(): Promise<any> { return; }
|
||||
}
|
||||
|
||||
interface IContactError {
|
||||
/** Error code */
|
||||
code: number;
|
||||
/** Error message */
|
||||
message: string;
|
||||
}
|
||||
|
||||
declare var ContactError: {
|
||||
new (code: number): IContactError;
|
||||
UNKNOWN_ERROR: number;
|
||||
@ -83,6 +91,7 @@ declare var ContactError: {
|
||||
NOT_SUPPORTED_ERROR: number;
|
||||
PERMISSION_DENIED_ERROR: number
|
||||
};
|
||||
|
||||
export interface IContactName {
|
||||
/** The complete name of the contact. */
|
||||
formatted?: string;
|
||||
@ -103,9 +112,11 @@ export interface IContactName {
|
||||
*/
|
||||
export class ContactName implements IContactName {
|
||||
private _objectInstance: any;
|
||||
|
||||
constructor(formatted?: string, familyName?: string, givenName?: string, middleName?: string, honorificPrefix?: string, honorificSuffix?: string) {
|
||||
this._objectInstance = new window.ContactName(formatted, familyName, givenName, middleName, honorificPrefix, honorificSuffix);
|
||||
}
|
||||
|
||||
@InstanceProperty get formatted(): string { return; }
|
||||
@InstanceProperty get familyName(): string { return; }
|
||||
@InstanceProperty get givenName(): string { return; }
|
||||
@ -128,9 +139,11 @@ export interface IContactField {
|
||||
*/
|
||||
export class ContactField implements IContactField {
|
||||
private _objectInstance: any;
|
||||
|
||||
constructor(type?: string, value?: string, pref?: boolean) {
|
||||
this._objectInstance = new window.ContactField(type, value, pref);
|
||||
}
|
||||
|
||||
@InstanceProperty get type(): string { return; }
|
||||
@InstanceProperty get value(): string { return; }
|
||||
@InstanceProperty get pref(): boolean { return; }
|
||||
@ -160,6 +173,7 @@ export interface IContactAddress {
|
||||
*/
|
||||
export class ContactAddress implements IContactAddress {
|
||||
private _objectInstance: any;
|
||||
|
||||
constructor(pref?: boolean,
|
||||
type?: string,
|
||||
formatted?: string,
|
||||
@ -170,6 +184,7 @@ export class ContactAddress implements IContactAddress {
|
||||
country?: string) {
|
||||
this._objectInstance = new window.ContactAddress(pref, type, formatted, streetAddress, locality, region, postalCode, country);
|
||||
}
|
||||
|
||||
@InstanceProperty get pref(): boolean { return; }
|
||||
@InstanceProperty get type(): string { return; }
|
||||
@InstanceProperty get formatted(): string { return; }
|
||||
@ -223,9 +238,11 @@ export interface IContactFindOptions {
|
||||
*/
|
||||
export class ContactFindOptions implements IContactFindOptions {
|
||||
private _objectInstance: any;
|
||||
|
||||
constructor() {
|
||||
this._objectInstance = new window.ContactFindOptions();
|
||||
}
|
||||
|
||||
@InstanceProperty get filter(): string { return; }
|
||||
@InstanceProperty get multiple(): boolean { return; }
|
||||
@InstanceProperty get desiredFields(): any { return; }
|
||||
@ -263,6 +280,7 @@ export class Contacts {
|
||||
static create(): Contact {
|
||||
return new Contact();
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for contacts in the Contacts list.
|
||||
*
|
||||
@ -285,6 +303,7 @@ export class Contacts {
|
||||
errorIndex: 2
|
||||
})
|
||||
static find(fields: string[], options?: any): Promise<any> { return; }
|
||||
|
||||
/**
|
||||
* Select a single Contact.
|
||||
* @return Returns a Promise that resolves with the selected Contact
|
||||
|
Loading…
x
Reference in New Issue
Block a user