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
Eugene Shen
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 @@
"todomvc-common"
:
"~0.1.4"
,
"jquery"
:
"~2.1.0"
,
"handlebars"
:
"~1.3.0"
,
"ember"
:
"~1.
5
.0"
,
"ember"
:
"~1.
6
.0"
,
"ember-data"
:
"1.0.0-beta.7"
,
"ember-localstorage-adapter"
:
"latest"
}
...
...
architecture-examples/emberjs/bower_components/ember-localstorage-adapter/localstorage_adapter.js
View file @
d6c38b45
/*global Ember*/
/*global DS*/
'
use strict
'
;
(
function
()
{
'
use strict
'
;
DS
.
LSSerializer
=
DS
.
JSONSerializer
.
extend
({
DS
.
LSSerializer
=
DS
.
JSONSerializer
.
extend
({
serializeHasMany
:
function
(
record
,
json
,
relationship
)
{
var
key
=
relationship
.
key
,
...
...
@@ -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
)
{
if
(
payload
&&
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
];
if
(
embeddedPayload
)
{
...
...
@@ -35,11 +72,29 @@ DS.LSSerializer = DS.JSONSerializer.extend({
}
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 method is the model's name as a string.
...
...
@@ -68,20 +123,20 @@ DS.LSAdapter = DS.Adapter.extend(Ember.Evented, {
return
new
Ember
.
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
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
)
{
resolve
(
finalRecord
);
});
}
else
{
if
(
!
record
)
{
reject
();
}
else
{
resolve
(
record
);
}
}
});
resolve
(
record
);
},
findMany
:
function
(
store
,
type
,
ids
)
{
...
...
@@ -96,6 +151,12 @@ DS.LSAdapter = DS.Adapter.extend(Ember.Evented, {
}
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, {
var
namespace
=
this
.
_namespaceForType
(
type
),
results
=
this
.
query
(
namespace
.
records
,
query
);
if
(
results
.
get
(
'
length
'
))
{
results
=
this
.
loadRelationshipsForMany
(
type
,
results
);
return
Ember
.
RSVP
.
resolve
(
results
);
}
else
{
return
Ember
.
RSVP
.
reject
();
}
},
query
:
function
(
records
,
query
)
{
...
...
@@ -188,7 +254,7 @@ DS.LSAdapter = DS.Adapter.extend(Ember.Evented, {
// private
adapterNamespace
:
function
()
{
return
this
.
namespace
||
'
DS.LSAdapter
'
;
return
this
.
get
(
'
namespace
'
)
||
'
DS.LSAdapter
'
;
},
loadData
:
function
()
{
...
...
@@ -213,7 +279,7 @@ DS.LSAdapter = DS.Adapter.extend(Ember.Evented, {
},
modelNamespace
:
function
(
type
)
{
return
type
.
url
||
type
.
toString
()
;
return
type
.
url
||
type
.
typeKey
;
},
...
...
@@ -392,6 +458,58 @@ DS.LSAdapter = DS.Adapter.extend(Ember.Evented, {
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, {
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