update Ember to 1.12.1/ember-data to 1.0.0-beta.18

No issue
- fixed "{{#each}}" helper in templates to use block syntax
- fixed deprecated ember.controller getter/setter function to use new syntax
- removed unnecessary pass-protect route view
This commit is contained in:
Austin Burdine 2015-06-02 20:56:42 -06:00
parent 73d3bf53c7
commit c5535e0a1b
29 changed files with 118 additions and 112 deletions

View File

@ -13,7 +13,7 @@ var BaseAdapter = DS.RESTAdapter.extend({
delete query.id;
}
return this.ajax(this.buildURL(type.typeKey, id), 'GET', {data: query});
return this.ajax(this.buildURL(type.modelName, id), 'GET', {data: query});
},
buildURL: function (type, id) {

View File

@ -53,7 +53,7 @@ var EmbeddedRelationAdapter = BaseAdapter.extend({
},
preparePayload: function (store, type, record) {
var serializer = store.serializerFor(type.typeKey),
var serializer = store.serializerFor(type.modelName),
payload = {};
serializer.serializeIntoHash(payload, type, record);
@ -62,7 +62,7 @@ var EmbeddedRelationAdapter = BaseAdapter.extend({
},
buildIncludeURL: function (store, type, id) {
var url = this.buildURL(type.typeKey, id),
var url = this.buildURL(type.modelName, id),
includes = this.getEmbeddedRelations(store, type);
if (includes.length) {

View File

@ -3,7 +3,7 @@ import ApplicationAdapter from 'ghost/adapters/application';
var SettingAdapter = ApplicationAdapter.extend({
updateRecord: function (store, type, record) {
var data = {},
serializer = store.serializerFor(type.typeKey);
serializer = store.serializerFor(type.modelName);
// remove the fake id that we added onto the model.
delete record.id;
@ -14,7 +14,7 @@ var SettingAdapter = ApplicationAdapter.extend({
// use the ApplicationAdapter's buildURL method but do not
// pass in an id.
return this.ajax(this.buildURL(type.typeKey), 'PUT', {data: data});
return this.ajax(this.buildURL(type.modelName), 'PUT', {data: data});
}
});

View File

@ -70,20 +70,21 @@ export default Ember.Controller.extend(SettingsMenuMixin, {
}),
/*jshint unused:false */
publishedAtValue: Ember.computed('model.published_at', function (key, value) {
var pubDate = this.get('model.published_at');
publishedAtValue: Ember.computed('model.published_at', {
get: function () {
var pubDate = this.get('model.published_at');
// We're using a fake setter to reset
// the cache for this property
if (arguments.length > 1) {
if (pubDate) {
return formatDate(pubDate);
}
return formatDate(moment());
},
set: function (key, value) {
// We're using a fake setter to reset
// the cache for this property
return formatDate(moment());
}
if (pubDate) {
return formatDate(pubDate);
}
return formatDate(moment());
}),
/*jshint unused:true */

View File

@ -14,16 +14,18 @@ export default Ember.Controller.extend({
return this.get('model.cover') || '';
}),
isDatedPermalinks: Ember.computed('model.permalinks', function (key, value) {
// setter
if (arguments.length > 1) {
isDatedPermalinks: Ember.computed('model.permalinks', {
set: function (key, value) {
this.set('model.permalinks', value ? '/:year/:month/:day/:slug/' : '/:slug/');
var slugForm = this.get('model.permalinks');
return slugForm !== '/:slug/';
},
get: function () {
var slugForm = this.get('model.permalinks');
return slugForm !== '/:slug/';
}
// getter
var slugForm = this.get('model.permalinks');
return slugForm !== '/:slug/';
}),
themes: Ember.computed(function () {

View File

@ -120,55 +120,56 @@ export default Ember.Mixin.create({
// an ugly hack, but necessary to watch all the model's properties
// and more, without having to be explicit and do it manually
isDirty: Ember.computed.apply(Ember, watchedProps.concat(function (key, value) {
if (arguments.length > 1) {
return value;
}
isDirty: Ember.computed.apply(Ember, watchedProps.concat({
get: function () {
var model = this.get('model'),
markdown = model.get('markdown'),
title = model.get('title'),
titleScratch = model.get('titleScratch'),
scratch = this.get('editor').getValue(),
changedAttributes;
var model = this.get('model'),
markdown = model.get('markdown'),
title = model.get('title'),
titleScratch = model.get('titleScratch'),
scratch = this.get('editor').getValue(),
changedAttributes;
if (!this.tagNamesEqual()) {
return true;
}
if (titleScratch !== title) {
return true;
}
// since `scratch` is not model property, we need to check
// it explicitly against the model's markdown attribute
if (markdown !== scratch) {
return true;
}
// if the Adapter failed to save the model isError will be true
// and we should consider the model still dirty.
if (model.get('isError')) {
return true;
}
// models created on the client always return `isDirty: true`,
// so we need to see which properties have actually changed.
if (model.get('isNew')) {
changedAttributes = Ember.keys(model.changedAttributes());
if (changedAttributes.length) {
if (!this.tagNamesEqual()) {
return true;
}
return false;
}
if (titleScratch !== title) {
return true;
}
// even though we use the `scratch` prop to show edits,
// which does *not* change the model's `isDirty` property,
// `isDirty` will tell us if the other props have changed,
// as long as the model is not new (model.isNew === false).
return model.get('isDirty');
// since `scratch` is not model property, we need to check
// it explicitly against the model's markdown attribute
if (markdown !== scratch) {
return true;
}
// if the Adapter failed to save the model isError will be true
// and we should consider the model still dirty.
if (model.get('isError')) {
return true;
}
// models created on the client always return `isDirty: true`,
// so we need to see which properties have actually changed.
if (model.get('isNew')) {
changedAttributes = Ember.keys(model.changedAttributes());
if (changedAttributes.length) {
return true;
}
return false;
}
// even though we use the `scratch` prop to show edits,
// which does *not* change the model's `isDirty` property,
// `isDirty` will tell us if the other props have changed,
// as long as the model is not new (model.isNew === false).
return model.get('isDirty');
},
set: function (key, value) {
return value;
}
})),
// used on window.onbeforeunload

View File

@ -3,16 +3,17 @@ import Ember from 'ember';
export default Ember.Mixin.create({
application: Ember.inject.controller(),
isViewingSubview: Ember.computed('application.showSettingsMenu', function (key, value) {
// Not viewing a subview if we can't even see the PSM
if (!this.get('application.showSettingsMenu')) {
isViewingSubview: Ember.computed('application.showSettingsMenu', {
get: function () {
return false;
}
if (arguments.length > 1) {
},
set: function (key, value) {
// Not viewing a subview if we can't even see the PSM
if (!this.get('application.showSettingsMenu')) {
return false;
}
return value;
}
return false;
}),
actions: {

View File

@ -29,16 +29,17 @@ export default DS.Model.extend(ValidationEngine, {
ghostPaths: Ember.inject.service('ghost-paths'),
role: Ember.computed('roles', function (name, value) {
if (arguments.length > 1) {
role: Ember.computed('roles', {
get: function () {
return this.get('roles.firstObject');
},
set: function (key, value) {
// Only one role per user, so remove any old data.
this.get('roles').clear();
this.get('roles').pushObject(value);
return value;
}
return this.get('roles.firstObject');
}),
// TODO: Once client-side permissions are in place,

View File

@ -7,7 +7,7 @@ var ApplicationSerializer = DS.RESTSerializer.extend({
options.includeId = true;
// We have a plural root in the API
var root = Ember.String.pluralize(type.typeKey),
var root = Ember.String.pluralize(type.modelName),
data = this.serialize(record, options);
// Don't ever pass uuid's

View File

@ -18,8 +18,8 @@ var PostSerializer = ApplicationSerializer.extend(DS.EmbeddedRecordsMixin, {
},
extractSingle: function (store, primaryType, payload) {
var root = this.keyForAttribute(primaryType.typeKey),
pluralizedRoot = Ember.String.pluralize(primaryType.typeKey);
var root = this.keyForAttribute(primaryType.modelName),
pluralizedRoot = Ember.String.pluralize(primaryType.modelName);
// make payload { post: { title: '', tags: [obj, obj], etc. } }.
// this allows ember-data to pull the embedded tags out again,
@ -37,7 +37,7 @@ var PostSerializer = ApplicationSerializer.extend(DS.EmbeddedRecordsMixin, {
options.includeId = true;
// We have a plural root in the API
var root = Ember.String.pluralize(type.typeKey),
var root = Ember.String.pluralize(type.modelName),
data = this.serialize(record, options);
// Properties that exist on the model but we don't want sent in the payload

View File

@ -7,7 +7,7 @@ var SettingSerializer = ApplicationSerializer.extend({
options = options || {};
options.includeId = false;
var root = Ember.String.pluralize(type.typeKey),
var root = Ember.String.pluralize(type.modelName),
data = this.serialize(record, options),
payload = [];

View File

@ -6,7 +6,7 @@ var TagSerializer = ApplicationSerializer.extend({
options = options || {};
options.includeId = true;
var root = Ember.String.pluralize(type.typeKey),
var root = Ember.String.pluralize(type.modelName),
data = this.serialize(record, options);
// Properties that exist on the model but we don't want sent in the payload

View File

@ -8,8 +8,8 @@ var UserSerializer = ApplicationSerializer.extend(DS.EmbeddedRecordsMixin, {
},
extractSingle: function (store, primaryType, payload) {
var root = this.keyForAttribute(primaryType.typeKey),
pluralizedRoot = Ember.String.pluralize(primaryType.typeKey);
var root = this.keyForAttribute(primaryType.modelName),
pluralizedRoot = Ember.String.pluralize(primaryType.modelName);
payload[root] = payload[pluralizedRoot][0];
delete payload[pluralizedRoot];

View File

@ -1,6 +1,6 @@
{{#if importErrors}}
<table class="table">
{{#each error in importErrors}}
{{#each importErrors as |error|}}
<tr><td>{{error.message}}</td></tr>
{{/each}}
</table>

View File

@ -1,4 +1,4 @@
<div class="gh-alert-content">
{{message.message}}
</div>
<button class="gh-alert-close icon-x" {{action "closeNotification"}}><span class="hidden">Close</span></button>
<button class="gh-alert-close icon-x" {{action "closeNotification"}}><span class="hidden">Close</span></button>

View File

@ -1,3 +1,3 @@
{{#each message in messages}}
{{#each messages as |message|}}
{{gh-alert message=message}}
{{/each}}

View File

@ -1,3 +1,3 @@
{{#each message in messages}}
{{#each messages as |message|}}
{{gh-notification message=message}}
{{/each}}

View File

@ -1,5 +1,5 @@
<select id="{{selectId}}" name="{{selectName}}">
{{#each role in roles}}
{{#each roles as |role|}}
<option value={{role.id}}>{{role.name}}</option>
{{/each}}
</select>

View File

@ -16,7 +16,7 @@
<h3>Stack Trace</h3>
<p><strong>{{message}}</strong></p>
<ul class="error-stack-list">
{{#each item in stack}}
{{#each stack as |item|}}
<li>
at
{{#if item.function}}<em class="error-stack-function">{{item.function}}</em>{{/if}}

View File

@ -5,7 +5,7 @@
</div>
<div class="publish-bar-tags">
<div class="tags-wrapper tags">
{{#each tag in controller.tags}}
{{#each controller.tags as |tag|}}
<span class="tag" {{action "deleteTag" tag target=view}}>{{tag.name}} <i class="icon-x"></i></span>
{{/each}}
</div>
@ -14,7 +14,7 @@
<input type="hidden" class="tags-holder" id="tags-holder">
{{view view.tagInputView class="tag-input js-tag-input" id="tags" value=newTagText}}
<ul class="suggestions dropdown-menu dropdown-triangle-bottom" style={{view.overlayStyles}}>
{{#each suggestion in suggestions}}
{{#each suggestions as |suggestion|}}
{{#view view.suggestionView suggestion=suggestion}}
<a href="javascript:void(0);">{{view.suggestion.highlightedName}}</a>
{{/view}}

View File

@ -2,7 +2,7 @@
<section class="content-list js-content-list {{if postListFocused 'keyboard-focused'}}">
{{#view "paginated-scroll-box" tagName="section" classNames="content-list-content js-content-scrollbox"}}
<ol class="posts-list">
{{#each post in controller itemController="posts/post" itemView="post-item-view" itemTagName="li"}}
{{#each controller itemController="posts/post" itemView="post-item-view" itemTagName="li" as |post|}}
{{#link-to "posts.post" post.model class="permalink" alternateActive=view.active title="Edit this post"}}
<h3 class="entry-title">{{post.model.title}}</h3>
<section class="entry-meta">

View File

@ -9,7 +9,7 @@
<th>Status</th>
</thead>
<tbody>
{{#each appController in model itemController="settings/app"}}
{{#each model itemController="settings/app" as |appController|}}
<tr>
<td>
{{#if appController.model.package}}{{appController.model.package.name}} - {{appController.model.package.version}}{{else}}{{appController.model.name}} - package.json missing :({{/if}}

View File

@ -7,7 +7,7 @@
<section class="view-container">
<form id="settings-navigation" class="gh-blognav js-gh-blognav" novalidate="novalidate">
{{#each navItem in navigationItems}}
{{#each navigationItems as |navItem|}}
{{gh-navitem navItem=navItem baseUrl=blogUrl addItem="addItem" deleteItem="deleteItem" updateUrl="updateUrl"}}
{{/each}}
</form>

View File

@ -6,7 +6,7 @@
</header>
<section class="view-container settings-tags">
{{#each tag in tags}}
{{#each tags as |tag|}}
<div class="settings-tag">
<button class="tag-edit-button" {{action "editTag" tag}}>
<span class="tag-title">{{tag.name}}</span>

View File

@ -11,7 +11,7 @@
<h4 class="user-list-title">Invited users</h4>
{{#each user in invitedUsers itemController="settings/users/user"}}
{{#each invitedUsers itemController="settings/users/user" as |user|}}
<div class="user-list-item">
<span class="user-list-item-icon icon-mail">ic</span>
@ -37,7 +37,7 @@
<h4 class="user-list-title">Active users</h4>
{{#each user in activeUsers itemController="settings/users/user"}}
{{#each activeUsers itemController="settings/users/user" as |user|}}
{{#link-to 'settings.users.user' user.model class="user-list-item" }}
<span class="user-list-item-figure" style={{user.userImageBackground}}>
<span class="hidden">Photo of {{user.model.name}}</span>
@ -52,7 +52,7 @@
</div>
<aside class="user-list-item-aside">
{{#unless user.model.isAuthor}}
{{#each role in user.model.roles}}
{{#each user.model.roles as |role|}}
<span class="role-label {{role.lowerCaseName}}">{{role.name}}</span>
{{/each}}
{{/unless}}

View File

@ -15,8 +15,13 @@ var BoundOneWay = function (upstream, transform) {
transform = function (value) { return value; };
}
return Ember.computed(upstream, function (key, value) {
return arguments.length > 1 ? value : transform(this.get(upstream));
return Ember.computed(upstream, {
get: function () {
return transform(this.get(upstream));
},
set: function (key, value) {
return value;
}
});
};

View File

@ -1,5 +0,0 @@
import BaseView from 'ghost/views/settings/content-base';
var SettingsGeneralView = BaseView.extend();
export default SettingsGeneralView;

View File

@ -4,8 +4,8 @@
"blueimp-md5": "1.1.0",
"codemirror": "5.2.0",
"devicejs": "0.2.7",
"ember": "1.11.3",
"ember-data": "1.0.0-beta.16.1",
"ember": "1.12.1",
"ember-data": "1.0.0-beta.18",
"ember-load-initializers": "ember-cli/ember-load-initializers#0.0.2",
"ember-resolver": "0.1.15",
"ember-simple-auth": "0.8.0-beta.2",

View File

@ -32,7 +32,7 @@
"ember-cli-simple-auth": "0.8.0-beta.2",
"ember-cli-simple-auth-oauth2": "0.8.0-beta.2",
"ember-cli-uglify": "1.0.1",
"ember-data": "1.0.0-beta.16.1",
"ember-data": "1.0.0-beta.18",
"ember-export-application-global": "^1.0.2",
"ember-myth": "0.0.2",
"fs-extra": "0.16.3",