diff --git a/app/assets/javascripts/admin/controllers/admin-email-incomings.js.es6 b/app/assets/javascripts/admin/controllers/admin-email-incomings.js.es6 index deb7f0771c6..a6acd9af78f 100644 --- a/app/assets/javascripts/admin/controllers/admin-email-incomings.js.es6 +++ b/app/assets/javascripts/admin/controllers/admin-email-incomings.js.es6 @@ -1,11 +1,21 @@ import IncomingEmail from 'admin/models/incoming-email'; export default Ember.Controller.extend({ - loadMore() { - return IncomingEmail.findAll(this.get("filter"), this.get("model.length")) - .then(incoming => { - if (incoming.length < 50) { this.get("model").set("allLoaded", true); } - this.get("model").addObjects(incoming); - }); + loading: false, + + actions: { + + loadMore() { + if (this.get("loading") || this.get("model.allLoaded")) { return; } + this.set('loading', true); + + IncomingEmail.findAll(this.get("filter"), this.get("model.length")) + .then(incoming => { + if (incoming.length < 50) { this.get("model").set("allLoaded", true); } + this.get("model").addObjects(incoming); + }).finally(() => { + this.set('loading', false); + }); + } } }); diff --git a/app/assets/javascripts/admin/controllers/admin-email-logs.js.es6 b/app/assets/javascripts/admin/controllers/admin-email-logs.js.es6 index 2506a0cd999..44a38dfa324 100644 --- a/app/assets/javascripts/admin/controllers/admin-email-logs.js.es6 +++ b/app/assets/javascripts/admin/controllers/admin-email-logs.js.es6 @@ -1,11 +1,20 @@ import EmailLog from 'admin/models/email-log'; export default Ember.Controller.extend({ - loadMore() { - return EmailLog.findAll(this.get("filter"), this.get("model.length")) - .then(logs => { - if (logs.length < 50) { this.get("model").set("allLoaded", true); } - this.get("model").addObjects(logs); - }); + loading: false, + + actions: { + loadMore() { + if (this.get("loading") || this.get("model.allLoaded")) { return; } + + this.set('loading', true); + return EmailLog.findAll(this.get("filter"), this.get("model.length")) + .then(logs => { + if (logs.length < 50) { this.get("model").set("allLoaded", true); } + this.get("model").addObjects(logs); + }).finally(() => { + this.set('loading', false); + }); + } } }); diff --git a/app/assets/javascripts/admin/templates/email-received.hbs b/app/assets/javascripts/admin/templates/email-received.hbs index 95e0cb2dc57..e6e3bcbec96 100644 --- a/app/assets/javascripts/admin/templates/email-received.hbs +++ b/app/assets/javascripts/admin/templates/email-received.hbs @@ -1,55 +1,57 @@ - - - - - - - +{{#load-more selector=".email-list tr" action="loadMore"}} +
{{i18n 'admin.email.time'}}{{i18n 'admin.email.incoming_emails.from_address'}}{{i18n 'admin.email.incoming_emails.to_addresses'}}{{i18n 'admin.email.incoming_emails.subject'}}
+ + + + + + + + + + + + + + - - - - - - - - - {{#each email in model}} - - - + + + + - - - - {{else}} - - {{/each}} + + + {{else}} + + {{/each}} -
{{i18n 'admin.email.time'}}{{i18n 'admin.email.incoming_emails.from_address'}}{{i18n 'admin.email.incoming_emails.to_addresses'}}{{i18n 'admin.email.incoming_emails.subject'}}
{{i18n 'admin.email.logs.filters.title'}}{{text-field value=filter.from placeholderKey="admin.email.incoming_emails.filters.from_placeholder"}}{{text-field value=filter.to placeholderKey="admin.email.incoming_emails.filters.to_placeholder"}}{{text-field value=filter.subject placeholderKey="admin.email.incoming_emails.filters.subject_placeholder"}}
{{i18n 'admin.email.logs.filters.title'}}{{text-field value=filter.from placeholderKey="admin.email.incoming_emails.filters.from_placeholder"}}{{text-field value=filter.to placeholderKey="admin.email.incoming_emails.filters.to_placeholder"}}{{text-field value=filter.subject placeholderKey="admin.email.incoming_emails.filters.subject_placeholder"}}
{{format-date email.created_at}} -
- {{#if email.user}} - {{#link-to 'adminUser' email.user}} - {{avatar email.user imageSize="tiny"}} - {{email.from_address}} - {{/link-to}} + {{#each email in model}} +
{{format-date email.created_at}} +
+ {{#if email.user}} + {{#link-to 'adminUser' email.user}} + {{avatar email.user imageSize="tiny"}} + {{email.from_address}} + {{/link-to}} + {{else}} + — + {{/if}} +
+
+ {{#each to in email.to_addresses}} +

{{unbound to}}

+ {{/each}} + {{#each cc in email.cc_addresses}} +

{{unbound cc}}

+ {{/each}} +
+ {{#if email.post_url}} + {{email.subject}} {{else}} - — + {{email.subject}} {{/if}} - - - {{#each to in email.to_addresses}} -

{{unbound to}}

- {{/each}} - {{#each cc in email.cc_addresses}} -

{{unbound cc}}

- {{/each}} -
- {{#if email.post_url}} - {{email.subject}} - {{else}} - {{email.subject}} - {{/if}} -
{{i18n 'admin.email.incoming_emails.none'}}
{{i18n 'admin.email.incoming_emails.none'}}
+ +{{/load-more}} -{{conditional-loading-spinner condition=view.loading}} +{{conditional-loading-spinner condition=loading}} diff --git a/app/assets/javascripts/admin/templates/email-rejected.hbs b/app/assets/javascripts/admin/templates/email-rejected.hbs index 3c5f3cba8eb..664eb728669 100644 --- a/app/assets/javascripts/admin/templates/email-rejected.hbs +++ b/app/assets/javascripts/admin/templates/email-rejected.hbs @@ -1,54 +1,56 @@ - - - - - - - - +{{#load-more selector=".email-list tr" action="loadMore"}} +
{{i18n 'admin.email.time'}}{{i18n 'admin.email.incoming_emails.from_address'}}{{i18n 'admin.email.incoming_emails.to_addresses'}}{{i18n 'admin.email.incoming_emails.subject'}}{{i18n 'admin.email.incoming_emails.error'}}
+ + + + + + + + + + + + + + + + - - - - - - - - + {{#each email in model}} + + + + + + + + {{else}} + + {{/each}} - {{#each email in model}} - - - - - - - - {{else}} - - {{/each}} +
{{i18n 'admin.email.time'}}{{i18n 'admin.email.incoming_emails.from_address'}}{{i18n 'admin.email.incoming_emails.to_addresses'}}{{i18n 'admin.email.incoming_emails.subject'}}{{i18n 'admin.email.incoming_emails.error'}}
{{i18n 'admin.email.logs.filters.title'}}{{text-field value=filter.from placeholderKey="admin.email.incoming_emails.filters.from_placeholder"}}{{text-field value=filter.to placeholderKey="admin.email.incoming_emails.filters.to_placeholder"}}{{text-field value=filter.subject placeholderKey="admin.email.incoming_emails.filters.subject_placeholder"}}{{text-field value=filter.error placeholderKey="admin.email.incoming_emails.filters.error_placeholder"}}
{{i18n 'admin.email.logs.filters.title'}}{{text-field value=filter.from placeholderKey="admin.email.incoming_emails.filters.from_placeholder"}}{{text-field value=filter.to placeholderKey="admin.email.incoming_emails.filters.to_placeholder"}}{{text-field value=filter.subject placeholderKey="admin.email.incoming_emails.filters.subject_placeholder"}}{{text-field value=filter.error placeholderKey="admin.email.incoming_emails.filters.error_placeholder"}}
{{format-date email.created_at}} +
+ {{#if email.user}} + {{#link-to 'adminUser' email.user}} + {{avatar email.user imageSize="tiny"}} + {{email.from_address}} + {{/link-to}} + {{else}} + — + {{/if}} +
+
+ {{#each to in email.to_addresses}} +

{{unbound to}}

+ {{/each}} + {{#each cc in email.cc_addresses}} +

{{unbound cc}}

+ {{/each}} +
{{email.subject}} + {{email.error}} +
{{i18n 'admin.email.incoming_emails.none'}}
{{format-date email.created_at}} -
- {{#if email.user}} - {{#link-to 'adminUser' email.user}} - {{avatar email.user imageSize="tiny"}} - {{email.from_address}} - {{/link-to}} - {{else}} - — - {{/if}} -
-
- {{#each to in email.to_addresses}} -

{{unbound to}}

- {{/each}} - {{#each cc in email.cc_addresses}} -

{{unbound cc}}

- {{/each}} -
{{email.subject}} - {{email.error}} -
{{i18n 'admin.email.incoming_emails.none'}}
+{{/load-more}} - - -{{conditional-loading-spinner condition=view.loading}} +{{conditional-loading-spinner condition=loading}} diff --git a/app/assets/javascripts/admin/templates/email-sent.hbs b/app/assets/javascripts/admin/templates/email-sent.hbs index 2f8785c6f59..ca5fb4aaa2a 100644 --- a/app/assets/javascripts/admin/templates/email-sent.hbs +++ b/app/assets/javascripts/admin/templates/email-sent.hbs @@ -1,47 +1,49 @@ - - - - - - - - +{{#load-more selector=".email-list tr" action="loadMore"}} +
{{i18n 'admin.email.sent_at'}}{{i18n 'admin.email.user'}}{{i18n 'admin.email.to_address'}}{{i18n 'admin.email.email_type'}}{{i18n 'admin.email.reply_key'}}
+ + + + + + + + + + + + + + + + - - - - - - - - + {{#each l in model}} + + + + + + + + {{else}} + + {{/each}} - {{#each l in model}} - - - - - - - - {{else}} - - {{/each}} +
{{i18n 'admin.email.sent_at'}}{{i18n 'admin.email.user'}}{{i18n 'admin.email.to_address'}}{{i18n 'admin.email.email_type'}}{{i18n 'admin.email.reply_key'}}
{{i18n 'admin.email.logs.filters.title'}}{{text-field value=filter.user placeholderKey="admin.email.logs.filters.user_placeholder"}}{{text-field value=filter.address placeholderKey="admin.email.logs.filters.address_placeholder"}}{{text-field value=filter.type placeholderKey="admin.email.logs.filters.type_placeholder"}}{{text-field value=filter.reply_key placeholderKey="admin.email.logs.filters.reply_key_placeholder"}}
{{i18n 'admin.email.logs.filters.title'}}{{text-field value=filter.user placeholderKey="admin.email.logs.filters.user_placeholder"}}{{text-field value=filter.address placeholderKey="admin.email.logs.filters.address_placeholder"}}{{text-field value=filter.type placeholderKey="admin.email.logs.filters.type_placeholder"}}{{text-field value=filter.reply_key placeholderKey="admin.email.logs.filters.reply_key_placeholder"}}
{{format-date l.created_at}} + {{#if l.user}} + {{#link-to 'adminUser' l.user}}{{avatar l.user imageSize="tiny"}}{{/link-to}} + {{#link-to 'adminUser' l.user}}{{l.user.username}}{{/link-to}} + {{else}} + — + {{/if}} + {{l.to_address}}{{l.email_type}} + {{#if l.post_url}} + {{l.reply_key}} + {{else}} + {{l.reply_key}} + {{/if}} +
{{i18n 'admin.email.logs.none'}}
{{format-date l.created_at}} - {{#if l.user}} - {{#link-to 'adminUser' l.user}}{{avatar l.user imageSize="tiny"}}{{/link-to}} - {{#link-to 'adminUser' l.user}}{{l.user.username}}{{/link-to}} - {{else}} - — - {{/if}} - {{l.to_address}}{{l.email_type}} - {{#if l.post_url}} - {{l.reply_key}} - {{else}} - {{l.reply_key}} - {{/if}} -
{{i18n 'admin.email.logs.none'}}
+{{/load-more}} - - -{{conditional-loading-spinner condition=view.loading}} +{{conditional-loading-spinner condition=loading}} diff --git a/app/assets/javascripts/admin/templates/email-skipped.hbs b/app/assets/javascripts/admin/templates/email-skipped.hbs index 6ef48725668..9c21c428cd9 100644 --- a/app/assets/javascripts/admin/templates/email-skipped.hbs +++ b/app/assets/javascripts/admin/templates/email-skipped.hbs @@ -1,47 +1,49 @@ - - - - - - - - +{{#load-more selector=".email-list tr" action="loadMore"}} +
{{i18n 'admin.email.time'}}{{i18n 'admin.email.user'}}{{i18n 'admin.email.to_address'}}{{i18n 'admin.email.email_type'}}{{i18n 'admin.email.skipped_reason'}}
+ + + + + + + + + + + + + + + + - - - - - - - - + {{#each l in model}} + + + + + + + + {{else}} + + {{/each}} - {{#each l in model}} - - - - - - - - {{else}} - - {{/each}} +
{{i18n 'admin.email.time'}}{{i18n 'admin.email.user'}}{{i18n 'admin.email.to_address'}}{{i18n 'admin.email.email_type'}}{{i18n 'admin.email.skipped_reason'}}
{{i18n 'admin.email.logs.filters.title'}}{{text-field value=filter.user placeholderKey="admin.email.logs.filters.user_placeholder"}}{{text-field value=filter.address placeholderKey="admin.email.logs.filters.address_placeholder"}}{{text-field value=filter.type placeholderKey="admin.email.logs.filters.type_placeholder"}}{{text-field value=filter.skipped_reason placeholderKey="admin.email.logs.filters.skipped_reason_placeholder"}}
{{i18n 'admin.email.logs.filters.title'}}{{text-field value=filter.user placeholderKey="admin.email.logs.filters.user_placeholder"}}{{text-field value=filter.address placeholderKey="admin.email.logs.filters.address_placeholder"}}{{text-field value=filter.type placeholderKey="admin.email.logs.filters.type_placeholder"}}{{text-field value=filter.skipped_reason placeholderKey="admin.email.logs.filters.skipped_reason_placeholder"}}
{{format-date l.created_at}} + {{#if l.user}} + {{#link-to 'adminUser' l.user}}{{avatar l.user imageSize="tiny"}}{{/link-to}} + {{#link-to 'adminUser' l.user}}{{l.user.username}}{{/link-to}} + {{else}} + — + {{/if}} + {{l.to_address}}{{l.email_type}} + {{#if l.post_url}} + {{l.skipped_reason}} + {{else}} + {{l.skipped_reason}} + {{/if}} +
{{i18n 'admin.email.logs.none'}}
{{format-date l.created_at}} - {{#if l.user}} - {{#link-to 'adminUser' l.user}}{{avatar l.user imageSize="tiny"}}{{/link-to}} - {{#link-to 'adminUser' l.user}}{{l.user.username}}{{/link-to}} - {{else}} - — - {{/if}} - {{l.to_address}}{{l.email_type}} - {{#if l.post_url}} - {{l.skipped_reason}} - {{else}} - {{l.skipped_reason}} - {{/if}} -
{{i18n 'admin.email.logs.none'}}
+{{/load-more}} - - -{{conditional-loading-spinner condition=view.loading}} +{{conditional-loading-spinner condition=loading}} diff --git a/app/assets/javascripts/admin/views/admin-email-incomings.js.es6 b/app/assets/javascripts/admin/views/admin-email-incomings.js.es6 deleted file mode 100644 index 6360f857b71..00000000000 --- a/app/assets/javascripts/admin/views/admin-email-incomings.js.es6 +++ /dev/null @@ -1,14 +0,0 @@ -import LoadMore from "discourse/mixins/load-more"; - -export default Ember.View.extend(LoadMore, { - loading: false, - eyelineSelector: ".email-list tr", - - actions: { - loadMore() { - if (this.get("loading") || this.get("model.allLoaded")) { return; } - this.set("loading", true); - return this.get("controller").loadMore().then(() => this.set("loading", false)); - } - } -}); diff --git a/app/assets/javascripts/admin/views/admin-email-logs.js.es6 b/app/assets/javascripts/admin/views/admin-email-logs.js.es6 deleted file mode 100644 index 6360f857b71..00000000000 --- a/app/assets/javascripts/admin/views/admin-email-logs.js.es6 +++ /dev/null @@ -1,14 +0,0 @@ -import LoadMore from "discourse/mixins/load-more"; - -export default Ember.View.extend(LoadMore, { - loading: false, - eyelineSelector: ".email-list tr", - - actions: { - loadMore() { - if (this.get("loading") || this.get("model.allLoaded")) { return; } - this.set("loading", true); - return this.get("controller").loadMore().then(() => this.set("loading", false)); - } - } -}); diff --git a/app/assets/javascripts/admin/views/admin-email-received.js.es6 b/app/assets/javascripts/admin/views/admin-email-received.js.es6 deleted file mode 100644 index da0d8de157c..00000000000 --- a/app/assets/javascripts/admin/views/admin-email-received.js.es6 +++ /dev/null @@ -1,5 +0,0 @@ -import AdminEmailIncomingsView from "admin/views/admin-email-incomings"; - -export default AdminEmailIncomingsView.extend({ - templateName: "admin/templates/email-received" -}); diff --git a/app/assets/javascripts/admin/views/admin-email-rejected.js.es6 b/app/assets/javascripts/admin/views/admin-email-rejected.js.es6 deleted file mode 100644 index b89fe8d46a0..00000000000 --- a/app/assets/javascripts/admin/views/admin-email-rejected.js.es6 +++ /dev/null @@ -1,5 +0,0 @@ -import AdminEmailIncomingsView from "admin/views/admin-email-incomings"; - -export default AdminEmailIncomingsView.extend({ - templateName: "admin/templates/email-rejected" -}); diff --git a/app/assets/javascripts/admin/views/admin-email-sent.js.es6 b/app/assets/javascripts/admin/views/admin-email-sent.js.es6 deleted file mode 100644 index d007a79644f..00000000000 --- a/app/assets/javascripts/admin/views/admin-email-sent.js.es6 +++ /dev/null @@ -1,5 +0,0 @@ -import AdminEmailLogsView from "admin/views/admin-email-logs"; - -export default AdminEmailLogsView.extend({ - templateName: "admin/templates/email-sent" -}); diff --git a/app/assets/javascripts/admin/views/admin-email-skipped.js.es6 b/app/assets/javascripts/admin/views/admin-email-skipped.js.es6 deleted file mode 100644 index e3c44670992..00000000000 --- a/app/assets/javascripts/admin/views/admin-email-skipped.js.es6 +++ /dev/null @@ -1,5 +0,0 @@ -import AdminEmailLogsView from "admin/views/admin-email-logs"; - -export default AdminEmailLogsView.extend({ - templateName: "admin/templates/email-skipped" -}); diff --git a/app/assets/javascripts/discourse/components/check-mark.js.es6 b/app/assets/javascripts/discourse/components/check-mark.js.es6 new file mode 100644 index 00000000000..702af6a15a4 --- /dev/null +++ b/app/assets/javascripts/discourse/components/check-mark.js.es6 @@ -0,0 +1,11 @@ +import computed from 'ember-addons/ember-computed-decorators'; + +export default Ember.Component.extend({ + tagName: 'i', + classNameBindings: [':fa', 'iconClass'], + + @computed('checked') + iconClass(checked) { + return checked ? 'fa-check' : 'fa-times'; + } +}); diff --git a/app/assets/javascripts/discourse/components/load-more.js.es6 b/app/assets/javascripts/discourse/components/load-more.js.es6 new file mode 100644 index 00000000000..4b355a5b0aa --- /dev/null +++ b/app/assets/javascripts/discourse/components/load-more.js.es6 @@ -0,0 +1,16 @@ +import LoadMore from "discourse/mixins/load-more"; + +export default Ember.Component.extend(LoadMore, { + _viaComponent: true, + + init() { + this._super(); + this.set('eyelineSelector', this.get('selector')); + }, + + actions: { + loadMore() { + this.sendAction(); + } + } +}); diff --git a/app/assets/javascripts/discourse/mixins/load-more.js.es6 b/app/assets/javascripts/discourse/mixins/load-more.js.es6 index c422e1cd633..16c8734054d 100644 --- a/app/assets/javascripts/discourse/mixins/load-more.js.es6 +++ b/app/assets/javascripts/discourse/mixins/load-more.js.es6 @@ -5,6 +5,14 @@ import { on } from 'ember-addons/ember-computed-decorators'; // Provides the ability to load more items for a view which is scrolled to the bottom. export default Ember.Mixin.create(Ember.ViewTargetActionSupport, Scrolling, { + init() { + this._super(); + if (!this._viaComponent) { + console.warn('Using `LoadMore` as a view mixin is deprecated. Use `{{load-more}}` instead'); + } + + }, + scrolled() { const eyeline = this.get('eyeline'); return eyeline && eyeline.update(); diff --git a/app/assets/javascripts/discourse/templates/badges/show.hbs b/app/assets/javascripts/discourse/templates/badges/show.hbs index 7f15cc73e13..f762e6dfe62 100644 --- a/app/assets/javascripts/discourse/templates/badges/show.hbs +++ b/app/assets/javascripts/discourse/templates/badges/show.hbs @@ -14,21 +14,25 @@
{{i18n 'badges.granted' count=grantCount}}
-
{{i18n 'badges.allow_title'}} {{{view.allowTitle}}}
{{i18n 'badges.multiple_grant'}} {{{view.multipleGrant}}} +
+ {{i18n 'badges.allow_title'}} {{check-mark checked=model.allow_title}}
+ {{i18n 'badges.multiple_grant'}} {{check-mark checked=model.multiple_grant}}
{{#if userBadges}}
- {{#each userBadges as |ub|}} - {{#user-info user=ub.user size="medium" class="badge-info" date=ub.granted_at}} -
{{i18n 'badges.granted_on' date=(inline-date ub.granted_at)}}
- {{#if ub.post_number}} - {{{ub.topic.fancyTitle}}} - {{/if}} - {{/user-info}} - {{/each}} + {{#load-more selector=".badge-info" action="loadMore"}} + {{#each userBadges as |ub|}} + {{#user-info user=ub.user size="medium" class="badge-info" date=ub.granted_at}} +
{{i18n 'badges.granted_on' date=(inline-date ub.granted_at)}}
+ {{#if ub.post_number}} + {{{ub.topic.fancyTitle}}} + {{/if}} + {{/user-info}} + {{/each}} + {{/load-more}} {{#unless canLoadMore}} {{#if user}} diff --git a/app/assets/javascripts/discourse/views/badges-show.js.es6 b/app/assets/javascripts/discourse/views/badges-show.js.es6 deleted file mode 100644 index 2aae5f7675a..00000000000 --- a/app/assets/javascripts/discourse/views/badges-show.js.es6 +++ /dev/null @@ -1,11 +0,0 @@ -import LoadMore from "discourse/mixins/load-more"; - -export default Ember.View.extend(LoadMore, { - eyelineSelector: '.badge-info', - tickOrX: function(field){ - var icon = this.get('controller.model.' + field) ? "fa-check" : "fa-times"; - return ""; - }, - allowTitle: function() { return this.tickOrX("allow_title"); }.property(), - multipleGrant: function() { return this.tickOrX("multiple_grant"); }.property() -});