Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
todomvc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sven Franck
todomvc
Commits
d6c38b45
Commit
d6c38b45
authored
Jul 10, 2014
by
Pascal Hartig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ember: Upgrade to 1.6.0
parent
5a53ef13
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36481 additions
and
33794 deletions
+36481
-33794
architecture-examples/emberjs/bower.json
architecture-examples/emberjs/bower.json
+1
-1
architecture-examples/emberjs/bower_components/ember-localstorage-adapter/localstorage_adapter.js
...onents/ember-localstorage-adapter/localstorage_adapter.js
+483
-364
architecture-examples/emberjs/bower_components/ember/ember.js
...itecture-examples/emberjs/bower_components/ember/ember.js
+35758
-33269
architecture-examples/emberjs/bower_components/jquery/dist/jquery.js
...e-examples/emberjs/bower_components/jquery/dist/jquery.js
+239
-160
No files found.
architecture-examples/emberjs/bower.json
View file @
d6c38b45
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
"todomvc-common"
:
"~0.1.4"
,
"todomvc-common"
:
"~0.1.4"
,
"jquery"
:
"~2.1.0"
,
"jquery"
:
"~2.1.0"
,
"handlebars"
:
"~1.3.0"
,
"handlebars"
:
"~1.3.0"
,
"ember"
:
"~1.
5
.0"
,
"ember"
:
"~1.
6
.0"
,
"ember-data"
:
"1.0.0-beta.7"
,
"ember-data"
:
"1.0.0-beta.7"
,
"ember-localstorage-adapter"
:
"latest"
"ember-localstorage-adapter"
:
"latest"
}
}
...
...
architecture-examples/emberjs/bower_components/ember-localstorage-adapter/localstorage_adapter.js
View file @
d6c38b45
/*global Ember*/
/*global Ember*/
/*global DS*/
/*global DS*/
'
use strict
'
;
(
function
()
{
'
use strict
'
;
DS
.
LSSerializer
=
DS
.
JSONSerializer
.
extend
({
DS
.
LSSerializer
=
DS
.
JSONSerializer
.
extend
({
serializeHasMany
:
function
(
record
,
json
,
relationship
)
{
serializeHasMany
:
function
(
record
,
json
,
relationship
)
{
var
key
=
relationship
.
key
,
var
key
=
relationship
.
key
,
...
@@ -16,10 +17,46 @@ DS.LSSerializer = DS.JSONSerializer.extend({
...
@@ -16,10 +17,46 @@ DS.LSSerializer = DS.JSONSerializer.extend({
}
}
},
},
/**
* Extracts whatever was returned from the adapter.
*
* If the adapter returns relationships in an embedded way, such as follows:
*
* ```js
* {
* "id": 1,
* "title": "Rails Rambo",
*
* "_embedded": {
* "comment": [{
* "id": 1,
* "comment_title": "FIRST"
* }, {
* "id": 2,
* "comment_title": "Rails is unagi"
* }]
* }
* }
*
* this method will create separated JSON for each resource and then push
* them individually to the Store.
*
* In the end, only the main resource will remain, containing the ids of its
* relationships. Given the relations are already in the Store, we will
* return a JSON with the main resource alone. The Store will sort out the
* associations by itself.
*
* @method extractSingle
* @private
* @param {DS.Store} store the returned store
* @param {DS.Model} type the type/model
* @param {Object} payload returned JSON
*/
extractSingle
:
function
(
store
,
type
,
payload
)
{
extractSingle
:
function
(
store
,
type
,
payload
)
{
if
(
payload
&&
payload
.
_embedded
)
{
if
(
payload
&&
payload
.
_embedded
)
{
for
(
var
relation
in
payload
.
_embedded
)
{
for
(
var
relation
in
payload
.
_embedded
)
{
var
typeName
=
Ember
.
String
.
singularize
(
relation
),
var
relType
=
type
.
typeForRelationship
(
relation
);
var
typeName
=
relType
.
typeKey
,
embeddedPayload
=
payload
.
_embedded
[
relation
];
embeddedPayload
=
payload
.
_embedded
[
relation
];
if
(
embeddedPayload
)
{
if
(
embeddedPayload
)
{
...
@@ -35,11 +72,29 @@ DS.LSSerializer = DS.JSONSerializer.extend({
...
@@ -35,11 +72,29 @@ DS.LSSerializer = DS.JSONSerializer.extend({
}
}
return
this
.
normalize
(
type
,
payload
);
return
this
.
normalize
(
type
,
payload
);
},
/**
* This is exactly the same as extractSingle, but used in an array.
*
* @method extractSingle
* @private
* @param {DS.Store} store the returned store
* @param {DS.Model} type the type/model
* @param {Array} payload returned JSONs
*/
extractArray
:
function
(
store
,
type
,
payload
)
{
var
serializer
=
this
;
return
payload
.
map
(
function
(
record
)
{
var
extracted
=
serializer
.
extractSingle
(
store
,
type
,
record
);
return
serializer
.
normalize
(
type
,
record
);
});
}
}
});
});
DS
.
LSAdapter
=
DS
.
Adapter
.
extend
(
Ember
.
Evented
,
{
DS
.
LSAdapter
=
DS
.
Adapter
.
extend
(
Ember
.
Evented
,
{
/**
/**
This is the main entry point into finding records. The first parameter to
This is the main entry point into finding records. The first parameter to
this method is the model's name as a string.
this method is the model's name as a string.
...
@@ -68,20 +123,20 @@ DS.LSAdapter = DS.Adapter.extend(Ember.Evented, {
...
@@ -68,20 +123,20 @@ DS.LSAdapter = DS.Adapter.extend(Ember.Evented, {
return
new
Ember
.
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
return
new
Ember
.
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
var
record
=
Ember
.
A
(
namespace
.
records
[
id
]);
var
record
=
Ember
.
A
(
namespace
.
records
[
id
]);
if
(
allowRecursive
&&
record
)
{
if
(
!
record
||
!
record
.
hasOwnProperty
(
'
id
'
))
{
store
.
dematerializeRecord
(
store
.
typeMapFor
(
type
).
idToRecord
[
id
]);
reject
();
return
;
}
if
(
allowRecursive
)
{
adapter
.
loadRelationships
(
type
,
record
).
then
(
function
(
finalRecord
)
{
adapter
.
loadRelationships
(
type
,
record
).
then
(
function
(
finalRecord
)
{
resolve
(
finalRecord
);
resolve
(
finalRecord
);
});
});
}
else
{
if
(
!
record
)
{
reject
();
}
else
{
}
else
{
resolve
(
record
);
resolve
(
record
);
}
}
}
});
});
resolve
(
record
);
},
},
findMany
:
function
(
store
,
type
,
ids
)
{
findMany
:
function
(
store
,
type
,
ids
)
{
...
@@ -96,6 +151,12 @@ DS.LSAdapter = DS.Adapter.extend(Ember.Evented, {
...
@@ -96,6 +151,12 @@ DS.LSAdapter = DS.Adapter.extend(Ember.Evented, {
}
}
resolve
(
results
);
resolve
(
results
);
}).
then
(
function
(
records
)
{
if
(
records
.
get
(
'
length
'
))
{
return
adapter
.
loadRelationshipsForMany
(
type
,
records
);
}
else
{
return
records
;
}
});
});
},
},
...
@@ -117,7 +178,12 @@ DS.LSAdapter = DS.Adapter.extend(Ember.Evented, {
...
@@ -117,7 +178,12 @@ DS.LSAdapter = DS.Adapter.extend(Ember.Evented, {
var
namespace
=
this
.
_namespaceForType
(
type
),
var
namespace
=
this
.
_namespaceForType
(
type
),
results
=
this
.
query
(
namespace
.
records
,
query
);
results
=
this
.
query
(
namespace
.
records
,
query
);
if
(
results
.
get
(
'
length
'
))
{
results
=
this
.
loadRelationshipsForMany
(
type
,
results
);
return
Ember
.
RSVP
.
resolve
(
results
);
return
Ember
.
RSVP
.
resolve
(
results
);
}
else
{
return
Ember
.
RSVP
.
reject
();
}
},
},
query
:
function
(
records
,
query
)
{
query
:
function
(
records
,
query
)
{
...
@@ -188,7 +254,7 @@ DS.LSAdapter = DS.Adapter.extend(Ember.Evented, {
...
@@ -188,7 +254,7 @@ DS.LSAdapter = DS.Adapter.extend(Ember.Evented, {
// private
// private
adapterNamespace
:
function
()
{
adapterNamespace
:
function
()
{
return
this
.
namespace
||
'
DS.LSAdapter
'
;
return
this
.
get
(
'
namespace
'
)
||
'
DS.LSAdapter
'
;
},
},
loadData
:
function
()
{
loadData
:
function
()
{
...
@@ -213,7 +279,7 @@ DS.LSAdapter = DS.Adapter.extend(Ember.Evented, {
...
@@ -213,7 +279,7 @@ DS.LSAdapter = DS.Adapter.extend(Ember.Evented, {
},
},
modelNamespace
:
function
(
type
)
{
modelNamespace
:
function
(
type
)
{
return
type
.
url
||
type
.
toString
()
;
return
type
.
url
||
type
.
typeKey
;
},
},
...
@@ -392,6 +458,58 @@ DS.LSAdapter = DS.Adapter.extend(Ember.Evented, {
...
@@ -392,6 +458,58 @@ DS.LSAdapter = DS.Adapter.extend(Ember.Evented, {
return
Object
.
prototype
.
toString
.
call
(
value
)
===
'
[object Array]
'
;
return
Object
.
prototype
.
toString
.
call
(
value
)
===
'
[object Array]
'
;
},
},
/**
* Same as `loadRelationships`, but for an array of records.
*
* @method loadRelationshipsForMany
* @private
* @param {DS.Model} type
* @param {Object} recordsArray
*/
loadRelationshipsForMany
:
function
(
type
,
recordsArray
)
{
var
adapter
=
this
;
return
new
Ember
.
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
var
recordsWithRelationships
=
[],
recordsToBeLoaded
=
[],
promises
=
[];
/**
* Some times Ember puts some stuff in arrays. We want to clean it so
* we know exactly what to iterate over.
*/
for
(
var
i
in
recordsArray
)
{
if
(
recordsArray
.
hasOwnProperty
(
i
))
{
recordsToBeLoaded
.
push
(
recordsArray
[
i
]);
}
}
var
loadNextRecord
=
function
(
record
)
{
/**
* Removes the first item from recordsToBeLoaded
*/
recordsToBeLoaded
=
recordsToBeLoaded
.
slice
(
1
);
var
promise
=
adapter
.
loadRelationships
(
type
,
record
);
promise
.
then
(
function
(
recordWithRelationships
)
{
recordsWithRelationships
.
push
(
recordWithRelationships
);
if
(
recordsToBeLoaded
[
0
])
{
loadNextRecord
(
recordsToBeLoaded
[
0
]);
}
else
{
resolve
(
recordsWithRelationships
);
}
});
}
/**
* We start by the first record
*/
loadNextRecord
(
recordsToBeLoaded
[
0
]);
});
},
/**
/**
*
*
...
@@ -408,4 +526,5 @@ DS.LSAdapter = DS.Adapter.extend(Ember.Evented, {
...
@@ -408,4 +526,5 @@ DS.LSAdapter = DS.Adapter.extend(Ember.Evented, {
return
relationships
;
return
relationships
;
}
}
}
}
});
});
}());
architecture-examples/emberjs/bower_components/ember/ember.js
View file @
d6c38b45
This diff is collapsed.
Click to expand it.
architecture-examples/emberjs/bower_components/jquery/dist/jquery.js
View file @
d6c38b45
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment