ResourceBase
Expression Extends:
class ResourceBase extends mix(null, Injectable)
Direct Subclass:
Indirect Subclass:
Resource base
Static Member Summary
Static Public Members | ||
public static get |
Returns if the resource is readonly |
|
public static get abstract |
Resource name |
|
public static get |
Resource path template |
|
public static get |
Returns the url key of the resource |
Static Protected Members | ||
protected static get |
protectedFields: Array<string>: string[] Protected read-only fields |
Constructor Summary
Public Constructor | ||
public |
constructor(api: Mapcreator, data: Object<String, *>) |
Member Summary
Public Members | ||
public get |
api: Mapcreator: * Get api instance |
|
public set |
api(value: Mapcreator) Set the api instance |
|
public get |
Auto generated Resource base url |
|
public get |
fieldNames: Array<String>: * List fields that contain object data |
|
public get |
If the resource can be owned by an organisation |
|
public get |
Auto generated resource url |
Method Summary
Public Methods | ||
public |
Clone the object |
|
public |
refresh(updateSelf: Boolean): CancelablePromise<ResourceBase> Refresh the resource by requesting it from the server again |
|
public |
Resets model instance to it's original state |
|
public |
sanitize() Clean up instance and commit all changes locally. |
|
public |
static(Target: string | Class, Constructor: Class?, seedData: Object<string, *>): SimpleResourceProxy Static proxy generation |
|
public |
Transform instance to object |
|
public |
String representation of the resource, similar to Python's repr |
Protected Methods | ||
protected |
_guessType(name: string, value: *): * Guess type based on property name |
|
protected |
_proxyResourceList(Target: string | Class<ResourceBase>, url: String, seedData: object): SimpleResourceProxy Macro for resource listing |
|
protected |
Moves new fields to this._properties and turns them into a getter/setter |
Static Public Members
Static Protected Members
Public Constructors
public constructor(api: Mapcreator, data: Object<String, *>) source
Params:
Name | Type | Attribute | Description |
api | Mapcreator | Api instance |
|
data | Object<String, *> | Item data |
Public Members
Public Methods
public refresh(updateSelf: Boolean): CancelablePromise<ResourceBase> source
Refresh the resource by requesting it from the server again
Params:
Name | Type | Attribute | Description |
updateSelf | Boolean | Update the current instance |
Throw:
If the api returns errors |
public reset(fields: Array<string> | string | null) source
Resets model instance to it's original state
public sanitize() source
Clean up instance and commit all changes locally. This means that any changed fields will be marked as unchanged whilst keeping their new values. The changes will not be saved.
public static(Target: string | Class, Constructor: Class?, seedData: Object<string, *>): SimpleResourceProxy source
Static proxy generation
Example:
user.static('jobs').lister();
class FooBar extends ResourceBase {
static get resourceName() {
return 'custom';
}
}
api.static(FooBar)
.get(1)
.then(console.log);
public toObject(camelCaseKeys: boolean): {} source
Transform instance to object
Params:
Name | Type | Attribute | Description |
camelCaseKeys | boolean |
|
camelCase object keys |
Return:
{} | Object |
Protected Methods
protected _guessType(name: string, value: *): * source
Guess type based on property name
Params:
Name | Type | Attribute | Description |
name | string | Field name |
|
value | * | Field Value |
Return:
* | Original or converted value |
protected _proxyResourceList(Target: string | Class<ResourceBase>, url: String, seedData: object): SimpleResourceProxy source
Macro for resource listing
Params:
Name | Type | Attribute | Description |
Target | string | Class<ResourceBase> | Target object |
|
url | String |
|
Target url, if null it will guess |
seedData | object | Internal use, used for seeding SimpleResourceProxy::new |
protected _updateProperties() source
Moves new fields to this._properties and turns them into a getter/setter