Upgrade to Ember 1.7.1 + group patch

This commit is contained in:
Robin Ward 2014-10-31 17:35:27 -04:00
parent c32df362d4
commit a6b1be81b1
15 changed files with 47411 additions and 46233 deletions

View file

@ -1,14 +1,5 @@
/**
This controller supports the interface for listing screened email addresses in the admin section.
@class AdminLogsScreenedEmailsController
@extends Ember.ArrayController
@namespace Discourse
@module Discourse
**/
export default Ember.ArrayController.extend(Discourse.Presence, { export default Ember.ArrayController.extend(Discourse.Presence, {
loading: false, loading: false,
content: [],
actions: { actions: {
clearBlock: function(row){ clearBlock: function(row){
@ -23,7 +14,7 @@ export default Ember.ArrayController.extend(Discourse.Presence, {
var self = this; var self = this;
this.set('loading', true); this.set('loading', true);
Discourse.ScreenedEmail.findAll().then(function(result) { Discourse.ScreenedEmail.findAll().then(function(result) {
self.set('content', result); self.set('model', result);
self.set('loading', false); self.set('loading', false);
}); });
} }

View file

@ -1,28 +1,19 @@
/**
This controller supports the interface for listing screened IP addresses in the admin section.
@class AdminLogsScreenedIpAddressesController
@extends Ember.ArrayController
@namespace Discourse
@module Discourse
**/
export default Ember.ArrayController.extend(Discourse.Presence, { export default Ember.ArrayController.extend(Discourse.Presence, {
loading: false, loading: false,
content: [],
itemController: 'admin-log-screened-ip-address', itemController: 'admin-log-screened-ip-address',
show: function() { show: function() {
var self = this; var self = this;
this.set('loading', true); this.set('loading', true);
Discourse.ScreenedIpAddress.findAll().then(function(result) { Discourse.ScreenedIpAddress.findAll().then(function(result) {
self.set('content', result); self.set('model', result);
self.set('loading', false); self.set('loading', false);
}); });
}, },
actions: { actions: {
recordAdded: function(arg) { recordAdded: function(arg) {
this.get("content").unshiftObject(arg); this.get("model").unshiftObject(arg);
} }
} }
}); });

View file

@ -1,20 +1,11 @@
/**
This controller supports the interface for listing screened URLs in the admin section.
@class AdminLogsScreenedUrlsController
@extends Ember.ArrayController
@namespace Discourse
@module Discourse
**/
export default Ember.ArrayController.extend(Discourse.Presence, { export default Ember.ArrayController.extend(Discourse.Presence, {
loading: false, loading: false,
content: [],
show: function() { show: function() {
var self = this; var self = this;
this.set('loading', true); this.set('loading', true);
Discourse.ScreenedUrl.findAll().then(function(result) { Discourse.ScreenedUrl.findAll().then(function(result) {
self.set('content', result); self.set('model', result);
self.set('loading', false); self.set('loading', false);
}); });
} }

View file

@ -15,7 +15,7 @@ export default Ember.ArrayController.extend(Discourse.Presence, {
this.set('loading', true); this.set('loading', true);
Discourse.URL.set('queryParams', this.get('filters')); // TODO: doesn't work Discourse.URL.set('queryParams', this.get('filters')); // TODO: doesn't work
Discourse.StaffActionLog.findAll(this.get('filters')).then(function(result) { Discourse.StaffActionLog.findAll(this.get('filters')).then(function(result) {
self.set('content', result); self.set('model', result);
self.set('loading', false); self.set('loading', false);
}); });
}.observes('filters.action_name', 'filters.acting_user', 'filters.target_user', 'filters.subject'), }.observes('filters.action_name', 'filters.acting_user', 'filters.target_user', 'filters.subject'),

View file

@ -10,7 +10,6 @@ export default Ember.ArrayController.extend(Discourse.Presence, {
username: null, username: null,
query: null, query: null,
selectAll: false, selectAll: false,
content: null,
loading: false, loading: false,
mustApproveUsers: Discourse.computed.setting('must_approve_users'), mustApproveUsers: Discourse.computed.setting('must_approve_users'),
@ -27,7 +26,7 @@ export default Ember.ArrayController.extend(Discourse.Presence, {
**/ **/
selectAllChanged: function() { selectAllChanged: function() {
var _this = this; var _this = this;
_.each(this.get('content'),function(user) { _.each(this.get('model'),function(user) {
user.set('selected', _this.get('selectAll')); user.set('selected', _this.get('selectAll'));
}); });
}.observes('selectAll'), }.observes('selectAll'),
@ -74,9 +73,9 @@ export default Ember.ArrayController.extend(Discourse.Presence, {
@property selectedCount @property selectedCount
**/ **/
selectedCount: function() { selectedCount: function() {
if (this.blank('content')) return 0; if (this.blank('model')) return 0;
return this.get('content').filterProperty('selected').length; return this.get('model').filterProperty('selected').length;
}.property('content.@each.selected'), }.property('model.@each.selected'),
/** /**
Do we have any selected users? Do we have any selected users?
@ -95,7 +94,7 @@ export default Ember.ArrayController.extend(Discourse.Presence, {
adminUsersListController.set('loading', true); adminUsersListController.set('loading', true);
Discourse.AdminUser.findAll(this.get('query'), { filter: this.get('username'), show_emails: showEmails }).then(function (result) { Discourse.AdminUser.findAll(this.get('query'), { filter: this.get('username'), show_emails: showEmails }).then(function (result) {
adminUsersListController.set('content', result); adminUsersListController.set('model', result);
adminUsersListController.set('loading', false); adminUsersListController.set('loading', false);
}); });
}, },
@ -114,24 +113,15 @@ export default Ember.ArrayController.extend(Discourse.Presence, {
this.set('query', term); this.set('query', term);
}, },
/** actions: {
Approve all the currently selected users.
@method approveUsers
**/
approveUsers: function() { approveUsers: function() {
Discourse.AdminUser.bulkApprove(this.get('content').filterProperty('selected')); Discourse.AdminUser.bulkApprove(this.get('model').filterProperty('selected'));
this.refreshUsers(); this.refreshUsers();
}, },
/**
Reject all the currently selected users.
@method rejectUsers
**/
rejectUsers: function() { rejectUsers: function() {
var controller = this; var controller = this;
Discourse.AdminUser.bulkReject(this.get('content').filterProperty('selected')).then(function(result){ Discourse.AdminUser.bulkReject(this.get('model').filterProperty('selected')).then(function(result){
var message = I18n.t("admin.users.reject_successful", {count: result.success}); var message = I18n.t("admin.users.reject_successful", {count: result.success});
if (result.failed > 0) { if (result.failed > 0) {
message += ' ' + I18n.t("admin.users.reject_failures", {count: result.failed}); message += ' ' + I18n.t("admin.users.reject_failures", {count: result.failed});
@ -145,5 +135,6 @@ export default Ember.ArrayController.extend(Discourse.Presence, {
showEmails: function() { showEmails: function() {
this.refreshUsers(true); this.refreshUsers(true);
} }
}
}); });

View file

@ -48,7 +48,7 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, {
if (arguments.length > 1) { if (arguments.length > 1) {
postStream.set('show_deleted', value); postStream.set('show_deleted', value);
} }
return postStream.get('show_deleted') ? true : null; return postStream.get('show_deleted') ? true : undefined;
}.property('postStream.summary'), }.property('postStream.summary'),
filter: function(key, value) { filter: function(key, value) {
@ -58,10 +58,18 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, {
if (arguments.length > 1) { if (arguments.length > 1) {
postStream.set('summary', value === "summary"); postStream.set('summary', value === "summary");
} }
return postStream.get('summary') ? "summary" : null; return postStream.get('summary') ? "summary" : undefined;
}.property('postStream.summary'), }.property('postStream.summary'),
username_filters: Discourse.computed.queryAlias('postStream.streamFilters.username_filters'), username_filters: function(key, value) {
var postStream = this.get('postStream');
if (!postStream) { return; }
if (arguments.length > 1) {
postStream.set('streamFilters.username_filters', value);
}
return postStream.get('streamFilters.username_filters');
}.property('postStream.streamFilters.username_filters'),
init: function() { init: function() {
this._super(); this._super();

View file

@ -81,9 +81,13 @@ DiscourseGroupedEach.prototype = {
data.insideEach = true; data.insideEach = true;
for (var i = 0; i < contentLength; i++) { for (var i = 0; i < contentLength; i++) {
var row = content.objectAt(i); var row = content.objectAt(i);
var keywords = Em.get(data, 'keywords');
if (!keywords) {
keywords = {};
Em.set(data, 'keywords', keywords);
}
if (keyword) { if (keyword) {
data.keywords = data.keywords || {}; Em.set(keywords, keyword, row);
data.keywords[keyword] = row;
} }
template(row, { data: data }); template(row, { data: data });
} }

View file

@ -3,7 +3,10 @@ export function renderAvatar(user, options) {
if (user) { if (user) {
var username = Em.get(user, 'username'); var username = Em.get(user, 'username');
if (!username) username = Em.get(user, options.usernamePath); if (!username) {
if (!options.usernamePath) { return ''; }
username = Em.get(user, options.usernamePath);
}
var title; var title;
if (!options.ignoreTitle) { if (!options.ignoreTitle) {

View file

@ -112,24 +112,6 @@ Discourse.computed = {
return computed.property.apply(computed, args); return computed.property.apply(computed, args);
}, },
/**
Creates a one way alias to a computed property, suitable for query params.
@method queryAlias
@param {String} path to the alias
@param {String} defaultValue for the variable (omitted if equal)
**/
queryAlias: function(path, defaultValue) {
return Em.computed(function(key, value) {
if (value) {
// Annoying but this ensures the parameter is present
}
var result = this.get(path);
if (typeof result !== "undefined" && result.toString() === defaultValue) { return; }
return result;
}).property(path);
},
/** /**
Creates a property from a SiteSetting. In the future the plan is for them to Creates a property from a SiteSetting. In the future the plan is for them to
be able to update when changed. be able to update when changed.

View file

@ -1,11 +1,11 @@
<h3><i class='fa fa-envelope'></i> {{i18n private_message_info.title}}</h3> <h3><i class='fa fa-envelope'></i> {{i18n private_message_info.title}}</h3>
<div class='participants clearfix'> <div class='participants clearfix'>
{{#grouped-each details.allowed_groups}} {{#each details.allowed_groups}}
<div class='user group'> <div class='user group'>
#{{unbound name}} #{{unbound name}}
</div> </div>
{{/grouped-each}} {{/each}}
{{#grouped-each details.allowed_users}} {{#each details.allowed_users}}
<div class='user'> <div class='user'>
{{#link-to 'user' this}} {{#link-to 'user' this}}
{{avatar this imageSize="small"}} {{avatar this imageSize="small"}}
@ -17,7 +17,7 @@
<a class='remove-invited' {{action "removeAllowedUser" this}}><i class="fa fa-times"></i></a> <a class='remove-invited' {{action "removeAllowedUser" this}}><i class="fa fa-times"></i></a>
{{/if}} {{/if}}
</div> </div>
{{/grouped-each}} {{/each}}
</div> </div>
{{#if details.can_invite_to}} {{#if details.can_invite_to}}
<div class='controls'> <div class='controls'>

View file

@ -46,7 +46,9 @@
{{/if}} {{/if}}
{{#if showPosterAvatar}} {{#if showPosterAvatar}}
<li {{bind-attr class=":avatars mapCollapsed::hidden"}}> <li {{bind-attr class=":avatars mapCollapsed::hidden"}}>
{{#grouped-each participant in details.fewParticipants}}{{topic-participant participant=participant}}{{/grouped-each}} {{#each details.fewParticipants}}
{{topic-participant participant=this}}
{{/each}}
</li> </li>
{{/if}} {{/if}}
</ul> </ul>
@ -54,14 +56,16 @@
{{#unless mapCollapsed}} {{#unless mapCollapsed}}
<section class='avatars clearfix'> <section class='avatars clearfix'>
{{#grouped-each participant in details.participants}}{{topic-participant participant=participant}}{{/grouped-each}} {{#each details.participants}}
{{topic-participant participant=this}}
{{/each}}
</section> </section>
{{#if infoLinks}} {{#if infoLinks}}
<section class='links'> <section class='links'>
<table class='topic-links'> <table class='topic-links'>
{{#grouped-each infoLinks}} {{#each infoLinks}}
<tr> <tr>
<td> <td>
<span class='badge badge-notification clicks' title='{{i18n topic_map.clicks count=clicks}}'>{{clicks}}</span> <span class='badge badge-notification clicks' title='{{i18n topic_map.clicks count=clicks}}'>{{clicks}}</span>
@ -73,7 +77,7 @@
{{link-domain this}} {{link-domain this}}
</td> </td>
</tr> </tr>
{{/grouped-each}} {{/each}}
</table> </table>
{{#if showAllLinksControls}} {{#if showAllLinksControls}}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long