Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3a02d3d

Browse files
committed
Stable Version 1.4.2.
1 parent2487771 commit3a02d3d

File tree

9 files changed

+110
-52
lines changed

9 files changed

+110
-52
lines changed

‎CHANGELOG.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
#####1.4.2 - 18 November 2014
2+
3+
######Backwards compatible API changes
4+
-#238 - Filter by substring ("in", "notIn', "|in" and "|notIn" operators now work on strings)
5+
6+
######Backwards compatible bug fixes
7+
- Fixed "allowSimpleWhere" default not being set
8+
19
#####1.4.1 - 11 November 2014
210

311
######Backwards compatible bug fixes

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ Unlike Backbone and Ember Models, angular-data does not require the use of gette
88

99
Supporting relations, computed properties, model lifecycle control and a slew of other features, angular-data is the tool for giving your data the respect it deserves.
1010

11-
__Latest Release:__[1.4.1](https://github.com/jmdobry/angular-data/releases/tag/1.4.1)
11+
__Latest Release:__[1.4.2](https://github.com/jmdobry/angular-data/releases/tag/1.4.2)
1212

1313
Angular-data is finally 1.0.!
1414

15-
Angular-data 1.x will continue to see bug fixes, butall new development will be on[js-data](https://github.com/js-data/js-data) and[js-data-angular](https://github.com/jmdobry/angular-data/pull/198) (Angular-data 2.0).
15+
Angular-data 1.x will continue to see bug fixes, butmost new development will be on[js-data](https://github.com/js-data/js-data) and[js-data-angular](https://github.com/jmdobry/angular-data/pull/198) (Angular-data 2.0).
1616

1717
####A note about Angular-data 2.0 (in development)
1818
See[angular-data/pull/198](https://github.com/jmdobry/angular-data/pull/198).

‎bower.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"author":"Jason Dobry",
33
"name":"angular-data",
44
"description":"Data store for Angular.js.",
5-
"version":"1.4.1",
5+
"version":"1.4.2",
66
"homepage":"http://angular-data.pseudobry.com/",
77
"repository": {
88
"type":"git",

‎dist/angular-data.js‎

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
*@author Jason Dobry <jason.dobry@gmail.com>
33
*@file angular-data.js
4-
*@version 1.4.1 - Homepage <http://angular-data.pseudobry.com/>
4+
*@version 1.4.2 - Homepage <http://angular-data.pseudobry.com/>
55
*@copyright (c) 2014 Jason Dobry <https://github.com/jmdobry/>
66
*@license MIT <https://github.com/jmdobry/angular-data/blob/master/LICENSE>
77
*
@@ -4139,6 +4139,7 @@ Defaults.prototype.idAttribute = 'id';
41394139
Defaults.prototype.defaultAdapter='DSHttpAdapter';
41404140
Defaults.prototype.defaultFilter=function(collection,resourceName,params,options){
41414141
var_this=this;
4142+
varDSUtils=_this.utils;
41424143
varfiltered=collection;
41434144
varwhere=null;
41444145
varreserved={
@@ -4152,14 +4153,14 @@ Defaults.prototype.defaultFilter = function (collection, resourceName, params, o
41524153

41534154
params=params||{};
41544155

4155-
if(_this.utils.isObject(params.where)){
4156+
if(DSUtils.isObject(params.where)){
41564157
where=params.where;
41574158
}else{
41584159
where={};
41594160
}
41604161

41614162
if(options.allowSimpleWhere){
4162-
_this.utils.forEach(params,function(value,key){
4163+
DSUtils.forEach(params,function(value,key){
41634164
if(!(keyinreserved)&&!(keyinwhere)){
41644165
where[key]={
41654166
'==':value
@@ -4168,26 +4169,26 @@ Defaults.prototype.defaultFilter = function (collection, resourceName, params, o
41684169
});
41694170
}
41704171

4171-
if(_this.utils.isEmpty(where)){
4172+
if(DSUtils.isEmpty(where)){
41724173
where=null;
41734174
}
41744175

41754176
if(where){
4176-
filtered=_this.utils.filter(filtered,function(attrs){
4177+
filtered=DSUtils.filter(filtered,function(attrs){
41774178
varfirst=true;
41784179
varkeep=true;
4179-
_this.utils.forEach(where,function(clause,field){
4180-
if(_this.utils.isString(clause)){
4180+
DSUtils.forEach(where,function(clause,field){
4181+
if(DSUtils.isString(clause)){
41814182
clause={
41824183
'===':clause
41834184
};
4184-
}elseif(_this.utils.isNumber(clause)||_this.utils.isBoolean(clause)){
4185+
}elseif(DSUtils.isNumber(clause)||DSUtils.isBoolean(clause)){
41854186
clause={
41864187
'==':clause
41874188
};
41884189
}
4189-
if(_this.utils.isObject(clause)){
4190-
_this.utils.forEach(clause,function(val,op){
4190+
if(DSUtils.isObject(clause)){
4191+
DSUtils.forEach(clause,function(val,op){
41914192
if(op==='=='){
41924193
keep=first ?(attrs[field]==val) :keep&&(attrs[field]==val);
41934194
}elseif(op==='==='){
@@ -4205,9 +4206,17 @@ Defaults.prototype.defaultFilter = function (collection, resourceName, params, o
42054206
}elseif(op==='<='){
42064207
keep=first ?(attrs[field]<=val) :keep&&(attrs[field]<=val);
42074208
}elseif(op==='in'){
4208-
keep=first ?_this.utils.contains(val,attrs[field]) :keep&&_this.utils.contains(val,attrs[field]);
4209+
if(DSUtils.isString(val)){
4210+
keep=first ?val.indexOf(attrs[field])!==-1 :keep&&val.indexOf(attrs[field])!==-1;
4211+
}else{
4212+
keep=first ?DSUtils.contains(val,attrs[field]) :keep&&DSUtils.contains(val,attrs[field]);
4213+
}
42094214
}elseif(op==='notIn'){
4210-
keep=first ?!_this.utils.contains(val,attrs[field]) :keep&&!_this.utils.contains(val,attrs[field]);
4215+
if(DSUtils.isString(val)){
4216+
keep=first ?val.indexOf(attrs[field])===-1 :keep&&val.indexOf(attrs[field])===-1;
4217+
}else{
4218+
keep=first ?!DSUtils.contains(val,attrs[field]) :keep&&!DSUtils.contains(val,attrs[field]);
4219+
}
42114220
}elseif(op==='|=='){
42124221
keep=first ?(attrs[field]==val) :keep||(attrs[field]==val);
42134222
}elseif(op==='|==='){
@@ -4225,9 +4234,17 @@ Defaults.prototype.defaultFilter = function (collection, resourceName, params, o
42254234
}elseif(op==='|<='){
42264235
keep=first ?(attrs[field]<=val) :keep||(attrs[field]<=val);
42274236
}elseif(op==='|in'){
4228-
keep=first ?_this.utils.contains(val,attrs[field]) :keep||_this.utils.contains(val,attrs[field]);
4237+
if(DSUtils.isString(val)){
4238+
keep=first ?val.indexOf(attrs[field])!==-1 :keep||val.indexOf(attrs[field])!==-1;
4239+
}else{
4240+
keep=first ?DSUtils.contains(val,attrs[field]) :keep||DSUtils.contains(val,attrs[field]);
4241+
}
42294242
}elseif(op==='|notIn'){
4230-
keep=first ?!_this.utils.contains(val,attrs[field]) :keep||!_this.utils.contains(val,attrs[field]);
4243+
if(DSUtils.isString(val)){
4244+
keep=first ?val.indexOf(attrs[field])===-1 :keep||val.indexOf(attrs[field])===-1;
4245+
}else{
4246+
keep=first ?!DSUtils.contains(val,attrs[field]) :keep||!DSUtils.contains(val,attrs[field]);
4247+
}
42314248
}
42324249
first=false;
42334250
});
@@ -4239,29 +4256,29 @@ Defaults.prototype.defaultFilter = function (collection, resourceName, params, o
42394256

42404257
varorderBy=null;
42414258

4242-
if(_this.utils.isString(params.orderBy)){
4259+
if(DSUtils.isString(params.orderBy)){
42434260
orderBy=[
42444261
[params.orderBy,'ASC']
42454262
];
4246-
}elseif(_this.utils.isArray(params.orderBy)){
4263+
}elseif(DSUtils.isArray(params.orderBy)){
42474264
orderBy=params.orderBy;
42484265
}
42494266

4250-
if(!orderBy&&_this.utils.isString(params.sort)){
4267+
if(!orderBy&&DSUtils.isString(params.sort)){
42514268
orderBy=[
42524269
[params.sort,'ASC']
42534270
];
4254-
}elseif(!orderBy&&_this.utils.isArray(params.sort)){
4271+
}elseif(!orderBy&&DSUtils.isArray(params.sort)){
42554272
orderBy=params.sort;
42564273
}
42574274

42584275
// Apply 'orderBy'
42594276
if(orderBy){
42604277
varindex=0;
42614278
angular.forEach(orderBy,function(def,i){
4262-
if(_this.utils.isString(def)){
4279+
if(DSUtils.isString(def)){
42634280
orderBy[i]=[def,'ASC'];
4264-
}elseif(!_this.utils.isArray(def)){
4281+
}elseif(!DSUtils.isArray(def)){
42654282
thrownew_this.errors.IllegalArgumentError('DS.filter(resourceName[, params][, options]): '+JSON.stringify(def)+': Must be a string or an array!',{
42664283
params:{
42674284
'orderBy[i]':{
@@ -4271,8 +4288,8 @@ Defaults.prototype.defaultFilter = function (collection, resourceName, params, o
42714288
}
42724289
});
42734290
}
4274-
filtered=_this.utils.sort(filtered,function(a,b){
4275-
returncompare(_this.utils,orderBy,index,a,b);
4291+
filtered=DSUtils.sort(filtered,function(a,b){
4292+
returncompare(DSUtils,orderBy,index,a,b);
42764293
});
42774294
});
42784295
}

‎dist/angular-data.min.js‎

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎guide/nav.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
<iclass="icon-wrench icon-white"></i> API<bclass="caret"></b>
8383
</a>
8484
<ulclass="dropdown-menu">
85-
<liclass="nav-header">Angular-data - 1.3.0</li>
85+
<liclass="nav-header">Angular-data - 1.4.2</li>
8686
<li>
8787
<ahref="/documentation/api/angular-data/angular-data">Overview</a>
8888
</li>
@@ -107,7 +107,7 @@
107107
<ahref="/documentation/api/angular-data-mocks/DSHttpAdapter">DSHttpAdapter</a>
108108
</li>
109109
<liclass="divider"></li>
110-
<liclass="nav-header">Angular-cache - 3.2.0</li>
110+
<liclass="nav-header">Angular-cache - 3.2.1</li>
111111
<li>
112112
<ahref="/documentation/api/angular-cache/angular-cache">Overview</a>
113113
</li>

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name":"angular-data",
33
"description":"Data store for Angular.js.",
4-
"version":"1.4.1",
4+
"version":"1.4.2",
55
"homepage":"http://angular-data.pseudobry.com",
66
"repository": {
77
"type":"git",

‎src/datastore/index.js‎

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Defaults.prototype.idAttribute = 'id';
4747
Defaults.prototype.defaultAdapter='DSHttpAdapter';
4848
Defaults.prototype.defaultFilter=function(collection,resourceName,params,options){
4949
var_this=this;
50+
varDSUtils=_this.utils;
5051
varfiltered=collection;
5152
varwhere=null;
5253
varreserved={
@@ -60,14 +61,14 @@ Defaults.prototype.defaultFilter = function (collection, resourceName, params, o
6061

6162
params=params||{};
6263

63-
if(_this.utils.isObject(params.where)){
64+
if(DSUtils.isObject(params.where)){
6465
where=params.where;
6566
}else{
6667
where={};
6768
}
6869

6970
if(options.allowSimpleWhere){
70-
_this.utils.forEach(params,function(value,key){
71+
DSUtils.forEach(params,function(value,key){
7172
if(!(keyinreserved)&&!(keyinwhere)){
7273
where[key]={
7374
'==':value
@@ -76,26 +77,26 @@ Defaults.prototype.defaultFilter = function (collection, resourceName, params, o
7677
});
7778
}
7879

79-
if(_this.utils.isEmpty(where)){
80+
if(DSUtils.isEmpty(where)){
8081
where=null;
8182
}
8283

8384
if(where){
84-
filtered=_this.utils.filter(filtered,function(attrs){
85+
filtered=DSUtils.filter(filtered,function(attrs){
8586
varfirst=true;
8687
varkeep=true;
87-
_this.utils.forEach(where,function(clause,field){
88-
if(_this.utils.isString(clause)){
88+
DSUtils.forEach(where,function(clause,field){
89+
if(DSUtils.isString(clause)){
8990
clause={
9091
'===':clause
9192
};
92-
}elseif(_this.utils.isNumber(clause)||_this.utils.isBoolean(clause)){
93+
}elseif(DSUtils.isNumber(clause)||DSUtils.isBoolean(clause)){
9394
clause={
9495
'==':clause
9596
};
9697
}
97-
if(_this.utils.isObject(clause)){
98-
_this.utils.forEach(clause,function(val,op){
98+
if(DSUtils.isObject(clause)){
99+
DSUtils.forEach(clause,function(val,op){
99100
if(op==='=='){
100101
keep=first ?(attrs[field]==val) :keep&&(attrs[field]==val);
101102
}elseif(op==='==='){
@@ -113,9 +114,17 @@ Defaults.prototype.defaultFilter = function (collection, resourceName, params, o
113114
}elseif(op==='<='){
114115
keep=first ?(attrs[field]<=val) :keep&&(attrs[field]<=val);
115116
}elseif(op==='in'){
116-
keep=first ?_this.utils.contains(val,attrs[field]) :keep&&_this.utils.contains(val,attrs[field]);
117+
if(DSUtils.isString(val)){
118+
keep=first ?val.indexOf(attrs[field])!==-1 :keep&&val.indexOf(attrs[field])!==-1;
119+
}else{
120+
keep=first ?DSUtils.contains(val,attrs[field]) :keep&&DSUtils.contains(val,attrs[field]);
121+
}
117122
}elseif(op==='notIn'){
118-
keep=first ?!_this.utils.contains(val,attrs[field]) :keep&&!_this.utils.contains(val,attrs[field]);
123+
if(DSUtils.isString(val)){
124+
keep=first ?val.indexOf(attrs[field])===-1 :keep&&val.indexOf(attrs[field])===-1;
125+
}else{
126+
keep=first ?!DSUtils.contains(val,attrs[field]) :keep&&!DSUtils.contains(val,attrs[field]);
127+
}
119128
}elseif(op==='|=='){
120129
keep=first ?(attrs[field]==val) :keep||(attrs[field]==val);
121130
}elseif(op==='|==='){
@@ -133,9 +142,17 @@ Defaults.prototype.defaultFilter = function (collection, resourceName, params, o
133142
}elseif(op==='|<='){
134143
keep=first ?(attrs[field]<=val) :keep||(attrs[field]<=val);
135144
}elseif(op==='|in'){
136-
keep=first ?_this.utils.contains(val,attrs[field]) :keep||_this.utils.contains(val,attrs[field]);
145+
if(DSUtils.isString(val)){
146+
keep=first ?val.indexOf(attrs[field])!==-1 :keep||val.indexOf(attrs[field])!==-1;
147+
}else{
148+
keep=first ?DSUtils.contains(val,attrs[field]) :keep||DSUtils.contains(val,attrs[field]);
149+
}
137150
}elseif(op==='|notIn'){
138-
keep=first ?!_this.utils.contains(val,attrs[field]) :keep||!_this.utils.contains(val,attrs[field]);
151+
if(DSUtils.isString(val)){
152+
keep=first ?val.indexOf(attrs[field])===-1 :keep||val.indexOf(attrs[field])===-1;
153+
}else{
154+
keep=first ?!DSUtils.contains(val,attrs[field]) :keep||!DSUtils.contains(val,attrs[field]);
155+
}
139156
}
140157
first=false;
141158
});
@@ -147,29 +164,29 @@ Defaults.prototype.defaultFilter = function (collection, resourceName, params, o
147164

148165
varorderBy=null;
149166

150-
if(_this.utils.isString(params.orderBy)){
167+
if(DSUtils.isString(params.orderBy)){
151168
orderBy=[
152169
[params.orderBy,'ASC']
153170
];
154-
}elseif(_this.utils.isArray(params.orderBy)){
171+
}elseif(DSUtils.isArray(params.orderBy)){
155172
orderBy=params.orderBy;
156173
}
157174

158-
if(!orderBy&&_this.utils.isString(params.sort)){
175+
if(!orderBy&&DSUtils.isString(params.sort)){
159176
orderBy=[
160177
[params.sort,'ASC']
161178
];
162-
}elseif(!orderBy&&_this.utils.isArray(params.sort)){
179+
}elseif(!orderBy&&DSUtils.isArray(params.sort)){
163180
orderBy=params.sort;
164181
}
165182

166183
// Apply 'orderBy'
167184
if(orderBy){
168185
varindex=0;
169186
angular.forEach(orderBy,function(def,i){
170-
if(_this.utils.isString(def)){
187+
if(DSUtils.isString(def)){
171188
orderBy[i]=[def,'ASC'];
172-
}elseif(!_this.utils.isArray(def)){
189+
}elseif(!DSUtils.isArray(def)){
173190
thrownew_this.errors.IllegalArgumentError('DS.filter(resourceName[, params][, options]): '+JSON.stringify(def)+': Must be a string or an array!',{
174191
params:{
175192
'orderBy[i]':{
@@ -179,8 +196,8 @@ Defaults.prototype.defaultFilter = function (collection, resourceName, params, o
179196
}
180197
});
181198
}
182-
filtered=_this.utils.sort(filtered,function(a,b){
183-
returncompare(_this.utils,orderBy,index,a,b);
199+
filtered=DSUtils.sort(filtered,function(a,b){
200+
returncompare(DSUtils,orderBy,index,a,b);
184201
});
185202
});
186203
}

‎test/integration/datastore/sync_methods/filter.test.js‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,22 @@ describe('DS.filter(resourceName[, params][, options])', function () {
184184

185185
assert.deepEqual(angular.toJson(DS.filter('post',params)),angular.toJson([p1,p4,p5]),'should accept normal "in" clause');
186186

187+
params.where={
188+
author:{
189+
'in':'John'
190+
}
191+
};
192+
193+
assert.deepEqual(JSON.stringify(DS.filter('post',params)),JSON.stringify([p1]),'should accept normal "in" clause with a string');
194+
195+
params.where={
196+
author:{
197+
'notIn':'John'
198+
}
199+
};
200+
201+
assert.deepEqual(JSON.stringify(DS.filter('post',params)),JSON.stringify([p2,p3,p4,p5]),'should accept normal "notIn" clause with a string');
202+
187203
params.where={
188204
age:{
189205
'|in':[31]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp