Skip to content

Commit

Permalink
Bumping to v0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim-Intellipharm committed May 5, 2015
1 parent 0ed0e60 commit fed61ca
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 68 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "angular-cakephp",
"description": "An AngularJS data modelling framework that ties in with a CakePHP REST API",
"version": "0.3.4",
"version": "0.4.0",
"homepage": "https://github.com/intellipharm/angular-cakephp",
"repository": {
"type": "git",
Expand Down
76 changes: 14 additions & 62 deletions dist/angular-cakephp.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*!
* angular-cakephp v0.3.4
* angular-cakephp v0.4.0
* http://intellipharm.com/
*
* Copyright 2015 Intellipharm
*
* 2015-04-15 08:31:47
* 2015-05-06 09:37:54
*
*/
(function() {
Expand Down Expand Up @@ -91,16 +91,19 @@
// create new active record instance
var instance = new model.active_record_class(data);


// set the standard cakephp created and modified timestamps if wanted
if (model.config.timestamps) {
instance.created = data.created;
instance.modified = data.modified;
}


// set instance properties
instance.model = model;
Object.defineProperty(instance, 'model', {
configurable: false,
enumerable: false,
value: model,
writable: false
});

// return active record instance
return instance;
Expand Down Expand Up @@ -201,8 +204,7 @@
* @returns {construct}
*/
BaseActiveRecord.prototype.virtualField = function(name, valueFn) {
var self = this,
virtualValue;
var virtualValue;

if (!name) {
throw new Error(ERROR_VIRTUAL_FIELD_NAME);
Expand All @@ -226,7 +228,7 @@
get: function() {
return virtualValue;
},
set: function(value) {
set: function() {
virtualValue = valueFn.apply(this);
return virtualValue;
}
Expand Down Expand Up @@ -281,18 +283,7 @@
// these properties and methods will be available to all model services
//---------------------------------------------------

var ERROR_INVALID_CONFIG = 'Invalid Config';
var ERROR_MISSING_PARAMS = 'Missing Required Params';
var ERROR_MODEL_DOES_NOT_EXIST = 'Model does not exist';

// virtual field
var ERROR_VIRTUAL_FIELD_NAME = 'Name argument is required';
var ERROR_VIRTUAL_FIELD_NAME_NOT_STRING = 'Name argument needs to be a string';
var ERROR_VIRTUAL_FIELD_NAME_NOT_FIELD = 'Name argument is not in the object';
var ERROR_VIRTUAL_FIELD_NAME_NOT_VIRTUAL_FIELD = 'Name argument is not a virtual field';
var ERROR_VIRTUAL_FIELD_VALUE = 'Value argument is required';
var ERROR_VIRTUAL_FIELD_VALUE_NOT_FUNCTION = 'Value argument needs to be a function';

var ERROR_MISSING_PARAMS = 'Missing Required Params';

// angular services
var $http;
Expand All @@ -310,7 +301,6 @@
// settings
var api_url;
var apiEndpointTransformer = null;
var timestamps;

/**
* BaseModel
Expand Down Expand Up @@ -435,7 +425,6 @@
return instance;
};


//-----------------------------------------------
// C.R.U.D
//-----------------------------------------------
Expand Down Expand Up @@ -705,28 +694,11 @@
// HttpRequest Service
//---------------------------------------------------

var HttpRequestService = function($q) {
var HttpRequestService = function() {

/**
* prepareRequest
*/
this.prepareRequest = function(data) {

var result = [];
_(response.data).forEach(function(item) {

// format response data
_.merge(item, item[model.active_record_class.name]);
delete item[model.active_record_class.name];

// create active record instance
result.push(model.new(item));
});
resolve(result);
};
};

HttpRequestService.$inject = ['$q'];
HttpRequestService.$inject = [];

angular.module('AngularCakePHP').service('HttpRequestService', HttpRequestService);

Expand All @@ -745,7 +717,6 @@
$injector
) {


/**
* handleIndexResponse
*
Expand Down Expand Up @@ -936,8 +907,6 @@

var TransformerService = function($injector) {

var self = this;

var urlParamTransformer = null;

// optional services
Expand Down Expand Up @@ -997,24 +966,7 @@
* @returns {*}
*/
this.transformRequestData = function(data) {
var d = _.clone(data, true);

if (_.has(d, 'model')) {
delete d.model;
}

// remove model for all sub items too
_.forEach(d, function(item, key) {
if (_.isArray(item)) {
_.forEach(item, function(i) {
i = this.transformRequestData(i);
}, this);
} else if (_.isObject(item)) {
item = this.transformRequestData(item);
}
}, this);

return d;
return data;
};

/**
Expand Down
Loading

0 comments on commit fed61ca

Please sign in to comment.