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