Contacts JS models: improve documentation
This commit is contained in:
parent
2f17e94fef
commit
0ee725b945
|
@ -6,7 +6,7 @@
|
||||||
/**
|
/**
|
||||||
* @name AddressBook
|
* @name AddressBook
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param {object} futureAddressBookData
|
* @param {object} futureAddressBookData - either an object literal or a promise
|
||||||
*/
|
*/
|
||||||
function AddressBook(futureAddressBookData) {
|
function AddressBook(futureAddressBookData) {
|
||||||
// Data is immediately available
|
// Data is immediately available
|
||||||
|
@ -106,8 +106,8 @@
|
||||||
/**
|
/**
|
||||||
* @memberOf AddressBook
|
* @memberOf AddressBook
|
||||||
* @desc Subscribe to another user's addressbook and add it to the list of addressbooks.
|
* @desc Subscribe to another user's addressbook and add it to the list of addressbooks.
|
||||||
* @param {String} uid - user id
|
* @param {string} uid - user id
|
||||||
* @param {String} path - path of folder for specified user
|
* @param {string} path - path of folder for specified user
|
||||||
* @returns a promise of the HTTP query result
|
* @returns a promise of the HTTP query result
|
||||||
*/
|
*/
|
||||||
AddressBook.$subscribe = function(uid, path) {
|
AddressBook.$subscribe = function(uid, path) {
|
||||||
|
@ -193,6 +193,12 @@
|
||||||
return this.$save();
|
return this.$save();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function $delete
|
||||||
|
* @memberof AddressBook.prototype
|
||||||
|
* @desc Delete the addressbook from the server and the static list of addressbooks.
|
||||||
|
* @returns a promise of the HTTP operation
|
||||||
|
*/
|
||||||
AddressBook.prototype.$delete = function() {
|
AddressBook.prototype.$delete = function() {
|
||||||
var _this = this,
|
var _this = this,
|
||||||
d = AddressBook.$q.defer(),
|
d = AddressBook.$q.defer(),
|
||||||
|
@ -213,19 +219,36 @@
|
||||||
return d.promise;
|
return d.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function $save
|
||||||
|
* @memberof AddressBook.prototype
|
||||||
|
* @desc Save the addressbook to the server. This currently can only affect the name of the addressbook.
|
||||||
|
* @returns a promise of the HTTP operation
|
||||||
|
*/
|
||||||
AddressBook.prototype.$save = function() {
|
AddressBook.prototype.$save = function() {
|
||||||
return AddressBook.$$resource.save(this.id, this.$omit()).then(function(data) {
|
return AddressBook.$$resource.save(this.id, this.$omit()).then(function(data) {
|
||||||
return data;
|
return data;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function $getCard
|
||||||
|
* @memberof AddressBook.prototype
|
||||||
|
* @desc Fetch the card attributes from the server.
|
||||||
|
* @returns a promise of the HTTP operation
|
||||||
|
*/
|
||||||
AddressBook.prototype.$getCard = function(cardId) {
|
AddressBook.prototype.$getCard = function(cardId) {
|
||||||
return this.$id().then(function(addressbookId) {
|
return this.$id().then(function(addressbookId) {
|
||||||
return AddressBook.$Card.$find(addressbookId, cardId);
|
return AddressBook.$Card.$find(addressbookId, cardId);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Unwrap a promise
|
/**
|
||||||
|
* @function $unwrap
|
||||||
|
* @memberof AddressBook.prototype
|
||||||
|
* @desc Unwrap a promise and instanciate new Card objects using received data.
|
||||||
|
* @param {promise} futureAddressBookData - a promise of the AddressBook's data
|
||||||
|
*/
|
||||||
AddressBook.prototype.$unwrap = function(futureAddressBookData) {
|
AddressBook.prototype.$unwrap = function(futureAddressBookData) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
|
||||||
|
@ -257,7 +280,12 @@
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// $omit returns a sanitized object used to send to the server
|
/**
|
||||||
|
* @function $omit
|
||||||
|
* @memberof AddressBook.prototype
|
||||||
|
* @desc Return a sanitized object used to send to the server.
|
||||||
|
* @return an object literal copy of the Addressbook instance
|
||||||
|
*/
|
||||||
AddressBook.prototype.$omit = function() {
|
AddressBook.prototype.$omit = function() {
|
||||||
var addressbook = {};
|
var addressbook = {};
|
||||||
angular.forEach(this, function(value, key) {
|
angular.forEach(this, function(value, key) {
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
*/
|
*/
|
||||||
Card.$factory = ['$timeout', 'sgSettings', 'sgResource', function($timeout, Settings, Resource) {
|
Card.$factory = ['$timeout', 'sgSettings', 'sgResource', function($timeout, Settings, Resource) {
|
||||||
angular.extend(Card, {
|
angular.extend(Card, {
|
||||||
$$resource: new Resource(Settings.baseURL),
|
$$resource: new Resource(Settings.baseURL, Settings.activeUser),
|
||||||
$timeout: $timeout
|
$timeout: $timeout
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -411,10 +411,10 @@
|
||||||
*/
|
*/
|
||||||
Card.prototype.$unwrap = function(futureCardData) {
|
Card.prototype.$unwrap = function(futureCardData) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
if (futureCardData) {
|
|
||||||
// Expose the promise
|
// Expose the promise
|
||||||
this.$futureCardData = futureCardData;
|
this.$futureCardData = futureCardData;
|
||||||
}
|
|
||||||
// Resolve the promise
|
// Resolve the promise
|
||||||
this.$futureCardData.then(function(data) {
|
this.$futureCardData.then(function(data) {
|
||||||
// Calling $timeout will force Angular to refresh the view
|
// Calling $timeout will force Angular to refresh the view
|
||||||
|
@ -435,7 +435,7 @@
|
||||||
* @function $omit
|
* @function $omit
|
||||||
* @memberof Card.prototype
|
* @memberof Card.prototype
|
||||||
* @desc Return a sanitized object used to send to the server.
|
* @desc Return a sanitized object used to send to the server.
|
||||||
* @param {boolean} deep - make a deep copy if true
|
* @param {Boolean} [deep] - make a deep copy if true
|
||||||
* @return an object literal copy of the Card instance
|
* @return an object literal copy of the Card instance
|
||||||
*/
|
*/
|
||||||
Card.prototype.$omit = function(deep) {
|
Card.prototype.$omit = function(deep) {
|
||||||
|
|
Loading…
Reference in a new issue