com.phloxui
Version:
PhloxUI Ng2+ Framework
79 lines (78 loc) • 3.77 kB
TypeScript
/**
* <p style="text-indent: 2em;">
* An interface class of a component which has <code>data</code> or can bind <code>data</code> with. All classes implementing this interface must provide the
* <code>data mechanism</code> to the user. A single <code>data parent</code> may have one or more <code>data children</code>. When parent's data is changed,
* the parent will propogate the data change to all of its children. The method [[isDataDirty]] provides you the way to check that the data has been edited
* from its original state or not. This mechanism is very useful when you're developing an application which allows the user to edit data before save. When
* the user is leaving the page with unsaved data, the application may notify a warning message asking the user to save the data before leaving. Imagine that
* if your page contains a numerous of input components, by using the <code>data mechanism</code> provided by this interface, you can easily register those
* input components as page's <code>data children</code>. And, when you want to check that the user can leave this page or not, you just use the method
* [[isDataDirty]] on page component, it will automatically check the data dirty state on all of its <code>data children</code>.
* </p>
*
* @author shiorin, tee4cute
* @see [[AbstractHasData]]
*/
export interface IHasData {
/**
* Get the <code>data</code> object bound to <code>this</code> component.
*/
getData(): any;
/**
* Set and bind <code><b>data</b></code> into <code>this</code> component.
*
* @param data The data object to set.
*/
setData(data: any): void;
/**
* Add a <code>data <b>child</b></code> into <code>this</code> component.
*
* @param child A <code>data child</code> component to be added.
*/
addDataChild(child: IHasData): void;
/**
* Remove the given <code>data <b>child</b></code> from <code>this</code> component.
*
* @param child A <code>data child</code> component to be removed.
*/
removeDataChild(child: IHasData): void;
/**
* Set a <code>data parent</code> into <code>this</code> component.
*
* @param parent A <code>data parent</code> component to be set.
*/
setDataParent(parent: IHasData): void;
/**
* Get the <code>data parent</code> of <code>this</code> component. This method can return <code>null</code> if <code>this</code>
* component has no <code>data parent</code>.
*/
getDataParent(): IHasData;
/**
* Get the array of <code>data children</code> of <code>this</code> component. This method will return <code>empty array</code> if
* there is no any <code>data child</code> of <code>this</code> component.
*/
getDataChildren(): IHasData[];
/**
* To check that the <code>data</code> bound to <code>this</code> component is dirty or not. The <code>data</code> will be marked
* as dirty if it is changed from its original state.
*/
isDataDirty(): boolean;
/**
* To check that <code>this</code> component will ignore data propagated from <code>data parent</code> or not.
*/
isIgnoreParentData(): boolean;
/**
* Set a flag indicating that <code>this</code> component will ignore data propagated from <code>data parent</code> or not.
*
* @param ignore A flag indicating that <code>this</code> component will ignore data propagated from <code>data parent</code> or not.
*/
setIgnoreParentData(ignore: boolean): void;
/**
* To save <code>data</code> that bound to <code>this</code> component.
*/
saveData(data?: any): void;
/**
* To reset <code>data</code> that bound to <code>this</code> component.
*/
resetData(): void;
}