diff --git a/app/assets/javascripts/admin/views/permalinks-list.js.es6 b/app/assets/javascripts/admin/components/permalinks-list.js.es6 similarity index 100% rename from app/assets/javascripts/admin/views/permalinks-list.js.es6 rename to app/assets/javascripts/admin/components/permalinks-list.js.es6 diff --git a/app/assets/javascripts/admin/views/screened-emails-list.js.es6 b/app/assets/javascripts/admin/components/screened-emails-list.js.es6 similarity index 100% rename from app/assets/javascripts/admin/views/screened-emails-list.js.es6 rename to app/assets/javascripts/admin/components/screened-emails-list.js.es6 diff --git a/app/assets/javascripts/admin/views/screened-ip-addresses-list.js.es6 b/app/assets/javascripts/admin/components/screened-ip-addresses-list.js.es6 similarity index 100% rename from app/assets/javascripts/admin/views/screened-ip-addresses-list.js.es6 rename to app/assets/javascripts/admin/components/screened-ip-addresses-list.js.es6 diff --git a/app/assets/javascripts/admin/views/screened-urls-list.js.es6 b/app/assets/javascripts/admin/components/screened-urls-list.js.es6 similarity index 100% rename from app/assets/javascripts/admin/views/screened-urls-list.js.es6 rename to app/assets/javascripts/admin/components/screened-urls-list.js.es6 diff --git a/app/assets/javascripts/admin/views/staff-action-logs-list.js.es6 b/app/assets/javascripts/admin/components/staff-action-logs-list.js.es6 similarity index 100% rename from app/assets/javascripts/admin/views/staff-action-logs-list.js.es6 rename to app/assets/javascripts/admin/components/staff-action-logs-list.js.es6 diff --git a/app/assets/javascripts/admin/templates/badges-show.hbs b/app/assets/javascripts/admin/templates/badges-show.hbs index 7d32344c31f..23dc5f5d319 100644 --- a/app/assets/javascripts/admin/templates/badges-show.hbs +++ b/app/assets/javascripts/admin/templates/badges-show.hbs @@ -23,21 +23,21 @@
- {{view "select" name="badge_type_id" - value=buffered.badge_type_id - content=badgeTypes - optionValuePath="content.id" - optionLabelPath="content.name" - disabled=readOnly}} + {{combo-box name="badge_type_id" + value=buffered.badge_type_id + content=badgeTypes + optionValuePath="content.id" + optionLabelPath="content.name" + disabled=readOnly}}
- {{view "select" name="badge_grouping_id" - value=buffered.badge_grouping_id - content=badgeGroupings - optionValuePath="content.id" - optionLabelPath="content.displayName"}} + {{combo-box name="badge_grouping_id" + value=buffered.badge_grouping_id + content=badgeGroupings + optionValuePath="content.id" + optionLabelPath="content.displayName"}}  
@@ -89,12 +89,12 @@
- {{view "select" name="trigger" - value=buffered.trigger - content=badgeTriggers - optionValuePath="content.id" - optionLabelPath="content.name" - disabled=readOnly}} + {{combo-box name="trigger" + value=buffered.trigger + content=badgeTriggers + optionValuePath="content.id" + optionLabelPath="content.name" + disabled=readOnly}}
{{/if}} diff --git a/app/assets/javascripts/admin/templates/logs/screened_emails.hbs b/app/assets/javascripts/admin/templates/logs/screened_emails.hbs index fba64d367d8..8817c49a2be 100644 --- a/app/assets/javascripts/admin/templates/logs/screened_emails.hbs +++ b/app/assets/javascripts/admin/templates/logs/screened_emails.hbs @@ -19,7 +19,7 @@
- {{view 'screened-emails-list' content=controller}} + {{screened-emails-list content=controller}} {{else}} diff --git a/app/assets/javascripts/admin/templates/logs/screened_ip_addresses.hbs b/app/assets/javascripts/admin/templates/logs/screened_ip_addresses.hbs index 5aaada9ea2f..5fb4217e348 100644 --- a/app/assets/javascripts/admin/templates/logs/screened_ip_addresses.hbs +++ b/app/assets/javascripts/admin/templates/logs/screened_ip_addresses.hbs @@ -24,7 +24,7 @@
- {{view 'screened-ip-addresses-list' content=controller}} + {{screened-ip-addresses-list content=controller}} {{else}} diff --git a/app/assets/javascripts/admin/templates/logs/screened_urls.hbs b/app/assets/javascripts/admin/templates/logs/screened_urls.hbs index 4fa38f11705..493205f275b 100644 --- a/app/assets/javascripts/admin/templates/logs/screened_urls.hbs +++ b/app/assets/javascripts/admin/templates/logs/screened_urls.hbs @@ -16,7 +16,7 @@
- {{view 'screened-urls-list' content=controller}} + {{screened-urls-list content=controller}} {{else}} {{i18n 'search.no_results'}} diff --git a/app/assets/javascripts/admin/templates/logs/staff_action_logs.hbs b/app/assets/javascripts/admin/templates/logs/staff_action_logs.hbs index acabdbb9d77..3b3b601df36 100644 --- a/app/assets/javascripts/admin/templates/logs/staff_action_logs.hbs +++ b/app/assets/javascripts/admin/templates/logs/staff_action_logs.hbs @@ -50,7 +50,7 @@ {{#conditional-loading-spinner condition=loading}} {{#if model.length}} - {{view "staff-action-logs-list" content=controller}} + {{staff-action-logs-list content=controller}} {{else}} {{i18n 'search.no_results'}} {{/if}} diff --git a/app/assets/javascripts/admin/templates/permalinks.hbs b/app/assets/javascripts/admin/templates/permalinks.hbs index 7d6e1ff8fc0..1d6151b95ea 100644 --- a/app/assets/javascripts/admin/templates/permalinks.hbs +++ b/app/assets/javascripts/admin/templates/permalinks.hbs @@ -17,7 +17,7 @@
- {{view 'permalinks-list' content=controller}} + {{permalinks-list content=controller}} {{else}} {{i18n 'search.no_results'}} diff --git a/app/assets/javascripts/discourse/views/choose-topic.js.es6 b/app/assets/javascripts/discourse/components/choose-topic.js.es6 similarity index 95% rename from app/assets/javascripts/discourse/views/choose-topic.js.es6 rename to app/assets/javascripts/discourse/components/choose-topic.js.es6 index cb2a346614b..85b46c5abc5 100644 --- a/app/assets/javascripts/discourse/views/choose-topic.js.es6 +++ b/app/assets/javascripts/discourse/components/choose-topic.js.es6 @@ -1,9 +1,7 @@ import debounce from 'discourse/lib/debounce'; import { searchForTerm } from 'discourse/lib/search'; -export default Ember.View.extend({ - templateName: 'choose_topic', - +export default Ember.Component.extend({ topicTitleChanged: function() { this.setProperties({ loading: true, diff --git a/app/assets/javascripts/discourse/components/edit-category-security.js.es6 b/app/assets/javascripts/discourse/components/edit-category-security.js.es6 index 502ed2325de..05b1f025155 100644 --- a/app/assets/javascripts/discourse/components/edit-category-security.js.es6 +++ b/app/assets/javascripts/discourse/components/edit-category-security.js.es6 @@ -17,7 +17,7 @@ export default buildCategoryPanel('security', { if (!this.get('category.is_special')) { this.get('category').addPermission({ group_name: group + "", - permission: PermissionType.create({id}) + permission: PermissionType.create({ id: parseInt(id) }) }); } }, diff --git a/app/assets/javascripts/discourse/views/topic-closing.js.es6 b/app/assets/javascripts/discourse/components/topic-closing.js.es6 similarity index 93% rename from app/assets/javascripts/discourse/views/topic-closing.js.es6 rename to app/assets/javascripts/discourse/components/topic-closing.js.es6 index 52c97c9dbb6..b92f7740358 100644 --- a/app/assets/javascripts/discourse/views/topic-closing.js.es6 +++ b/app/assets/javascripts/discourse/components/topic-closing.js.es6 @@ -1,6 +1,6 @@ import StringBuffer from 'discourse/mixins/string-buffer'; -export default Ember.View.extend(StringBuffer, { +export default Ember.Component.extend(StringBuffer, { elementId: 'topic-closing-info', delayedRerender: null, @@ -9,7 +9,7 @@ export default Ember.View.extend(StringBuffer, { 'topic.details.auto_close_based_on_last_post', 'topic.details.auto_close_hours'], - renderString: function(buffer) { + renderString(buffer) { if (!!Ember.isEmpty(this.get('topic.details.auto_close_at'))) return; if (this.get("topic.closed")) return; @@ -43,7 +43,7 @@ export default Ember.View.extend(StringBuffer, { this.set('delayedRerender', Em.run.later(this, this.rerender, rerenderDelay)); }, - willDestroyElement: function() { + willDestroyElement() { if( this.delayedRerender ) { Em.run.cancel(this.get('delayedRerender')); } diff --git a/app/assets/javascripts/discourse/views/topic-footer-buttons.js.es6 b/app/assets/javascripts/discourse/components/topic-footer-buttons.js.es6 similarity index 100% rename from app/assets/javascripts/discourse/views/topic-footer-buttons.js.es6 rename to app/assets/javascripts/discourse/components/topic-footer-buttons.js.es6 diff --git a/app/assets/javascripts/discourse/controllers/share.js.es6 b/app/assets/javascripts/discourse/controllers/share.js.es6 index fa1c3ff390a..b5a2eaa3c3f 100644 --- a/app/assets/javascripts/discourse/controllers/share.js.es6 +++ b/app/assets/javascripts/discourse/controllers/share.js.es6 @@ -1,22 +1,33 @@ import Sharing from 'discourse/lib/sharing'; import { longDateNoYear } from 'discourse/lib/formatter'; +import computed from 'ember-addons/ember-computed-decorators'; export default Ember.Controller.extend({ needs: ['topic'], - title: Ember.computed.alias('controllers.topic.model.title'), - displayDate: function() { - return longDateNoYear(new Date(this.get('date'))); - }.property('date'), + @computed('type', 'postNumber') + title(type, postNumber) { + if (type === 'topic') { return I18n.t('share.topic'); } + if (postNumber) { + return I18n.t('share.post', { postNumber }); + } else { + return I18n.t('share.topic'); + } + }, + + @computed('date') + displayDate(date) { + return longDateNoYear(new Date(date)); + }, // Close the share controller actions: { - close: function() { + close() { this.setProperties({ link: '', postNumber: '' }); return false; }, - share: function(source) { + share(source) { var url = source.generateUrl(this.get('link'), this.get('title')); if (source.shouldOpenInPopup) { window.open(url, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width=600,height=' + (source.popupHeight || 315)); @@ -26,7 +37,8 @@ export default Ember.Controller.extend({ } }, - sources: function() { + @computed + sources() { return Sharing.activeSources(this.siteSettings.share_links); - }.property() + } }); diff --git a/app/assets/javascripts/discourse/controllers/topic.js.es6 b/app/assets/javascripts/discourse/controllers/topic.js.es6 index 1071f6d7f7a..7c7c332666d 100644 --- a/app/assets/javascripts/discourse/controllers/topic.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic.js.es6 @@ -7,6 +7,7 @@ import { popupAjaxError } from 'discourse/lib/ajax-error'; import computed from 'ember-addons/ember-computed-decorators'; import Composer from 'discourse/models/composer'; import DiscourseURL from 'discourse/lib/url'; +import { categoryBadgeHTML } from 'discourse/helpers/category-link'; export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, { needs: ['modal', 'composer', 'quote-button', 'topic-progress', 'application'], @@ -76,6 +77,58 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, { } }, + @computed('model', 'topicTrackingState.messageCount') + browseMoreMessage(model) { + + // TODO decide what to show for pms + if (model.get('isPrivateMessage')) { return; } + + const opts = { latestLink: `${I18n.t("topic.view_latest_topics")}` }; + let category = model.get('category'); + + if (category && Em.get(category, 'id') === Discourse.Site.currentProp("uncategorized_category_id")) { + category = null; + } + + if (category) { + opts.catLink = categoryBadgeHTML(category); + } else { + opts.catLink = "" + I18n.t("topic.browse_all_categories") + ""; + } + + const unreadTopics = this.topicTrackingState.countUnread(); + const newTopics = this.topicTrackingState.countNew(); + + if (newTopics + unreadTopics > 0) { + const hasBoth = unreadTopics > 0 && newTopics > 0; + + return I18n.messageFormat("topic.read_more_MF", { + "BOTH": hasBoth, + "UNREAD": unreadTopics, + "NEW": newTopics, + "CATEGORY": category ? true : false, + latestLink: opts.latestLink, + catLink: opts.catLink + }); + } else if (category) { + return I18n.t("topic.read_more_in_category", opts); + } else { + return I18n.t("topic.read_more", opts); + } + }, + + @computed('model') + pmPath(model) { + return this.currentUser && this.currentUser.pmPath(model); + }, + + @computed('model') + suggestedTitle(model) { + return model.get('isPrivateMessage') ? + ` ${I18n.t("suggested_topics.pm_title")}` : + I18n.t("suggested_topics.title"); + }, + @computed('model.postStream.streamFilters.username_filters') username_filters: { set(value) { diff --git a/app/assets/javascripts/discourse/pre-initializers/inject-discourse-objects.js.es6 b/app/assets/javascripts/discourse/pre-initializers/inject-discourse-objects.js.es6 index 96c4cea3292..04729de959f 100644 --- a/app/assets/javascripts/discourse/pre-initializers/inject-discourse-objects.js.es6 +++ b/app/assets/javascripts/discourse/pre-initializers/inject-discourse-objects.js.es6 @@ -7,6 +7,7 @@ import DiscourseLocation from 'discourse/lib/discourse-location'; import SearchService from 'discourse/services/search'; import { startTracking, default as TopicTrackingState } from 'discourse/models/topic-tracking-state'; import ScreenTrack from 'discourse/lib/screen-track'; +import TopicFooterButtons from 'discourse/components/topic-footer-buttons'; function inject() { const app = arguments[0], @@ -70,6 +71,13 @@ export default { app.register('key-value-store:main', keyValueStore, { instantiate: false }); injectAll(app, 'keyValueStore'); + Discourse.TopicFooterButtonsView = { + reopen(obj) { + Ember.warn('`Discourse.TopicFooterButtonsView` is deprecated. Use the `topic-footer-buttons` component instead'); + TopicFooterButtons.reopen(obj); + } + }; + startTracking(topicTrackingState); } }; diff --git a/app/assets/javascripts/discourse/templates/components/avatar-uploader.hbs b/app/assets/javascripts/discourse/templates/components/avatar-uploader.hbs index 21761c67bd7..f75af099535 100644 --- a/app/assets/javascripts/discourse/templates/components/avatar-uploader.hbs +++ b/app/assets/javascripts/discourse/templates/components/avatar-uploader.hbs @@ -3,7 +3,7 @@ {{#if uploading}} - {{i18n 'upload_selector.uploading'}} {{view.uploadProgress}}% + {{i18n 'upload_selector.uploading'}} {{uploadProgress}}% {{/if}} {{#if imageIsNotASquare}}
{{i18n 'user.change_avatar.image_is_not_a_square'}}
diff --git a/app/assets/javascripts/discourse/templates/choose_topic.hbs b/app/assets/javascripts/discourse/templates/components/choose-topic.hbs similarity index 100% rename from app/assets/javascripts/discourse/templates/choose_topic.hbs rename to app/assets/javascripts/discourse/templates/components/choose-topic.hbs diff --git a/app/assets/javascripts/discourse/templates/components/edit-category-security.hbs b/app/assets/javascripts/discourse/templates/components/edit-category-security.hbs index 1b323792a9e..760863befee 100644 --- a/app/assets/javascripts/discourse/templates/components/edit-category-security.hbs +++ b/app/assets/javascripts/discourse/templates/components/edit-category-security.hbs @@ -15,8 +15,11 @@ {{/each}} {{#if editingPermissions}} - {{view 'select' content=category.availableGroups value=selectedGroup}} - {{view 'select' class="permission-selector" optionValuePath="content.id" optionLabelPath="content.description" content=category.availablePermissions value=selectedPermission}} + {{combo-box content=category.availableGroups value=selectedGroup}} + {{combo-box class="permission-selector" + nameProperty="description" + content=category.availablePermissions + value=selectedPermission}} {{else}} {{#unless category.is_special}} diff --git a/app/assets/javascripts/discourse/templates/modal/merge-topic.hbs b/app/assets/javascripts/discourse/templates/modal/merge-topic.hbs index 19160f99c07..e8e3be1432b 100644 --- a/app/assets/javascripts/discourse/templates/modal/merge-topic.hbs +++ b/app/assets/javascripts/discourse/templates/modal/merge-topic.hbs @@ -2,7 +2,7 @@

{{{i18n 'topic.merge_topic.instructions' count=selectedPostsCount}}}

- {{view "choose-topic" currentTopicId=model.id selectedTopicId=selectedTopicId}} + {{choose-topic currentTopicId=model.id selectedTopicId=selectedTopicId}}
diff --git a/app/assets/javascripts/discourse/templates/share.hbs b/app/assets/javascripts/discourse/templates/share.hbs index 85a5a8e4b14..12344222245 100644 --- a/app/assets/javascripts/discourse/templates/share.hbs +++ b/app/assets/javascripts/discourse/templates/share.hbs @@ -1,7 +1,7 @@ -{{#if controller.link}} -

{{view.title}}

+{{#if link}} +

{{title}}

- {{#if date}} + {{#if controller.date}} {{displayDate}} {{/if}} diff --git a/app/assets/javascripts/discourse/templates/topic.hbs b/app/assets/javascripts/discourse/templates/topic.hbs index d8fc7fd7080..f785b0bce69 100644 --- a/app/assets/javascripts/discourse/templates/topic.hbs +++ b/app/assets/javascripts/discourse/templates/topic.hbs @@ -34,7 +34,7 @@ {{else}}

{{#unless model.is_warning}} - + {{fa-icon "envelope"}} {{/unless}} @@ -62,7 +62,9 @@ {{/if}}
- {{view "selected-posts"}} +
+ {{partial "selected-posts"}} +
@@ -115,12 +117,12 @@ {{#conditional-loading-spinner condition=model.postStream.loadingFilter}} {{#if loadedAllPosts}} - {{view "topic-closing" topic=model}} + {{topic-closing topic=model}} {{#if session.showSignupCta}} {{! replace "Log In to Reply" with the infobox }} {{signup-cta}} {{else}} - {{view "topic-footer-buttons" topic=model}} + {{topic-footer-buttons topic=model}} {{/if}} {{#if model.pending_posts_count}} @@ -137,14 +139,16 @@ {{/if}} {{#if showSelectedPostsAtBottom}} - {{view "selected-posts"}} +
+ {{partial "selected-posts"}} +
{{/if}} {{plugin-outlet "topic-above-suggested"}} {{#if model.details.suggested_topics.length}}
-

{{{view.suggestedTitle}}}

+

{{{suggestedTitle}}}

{{#if model.isPrivateMessage}} {{basic-topic-list hideCategory="true" @@ -155,7 +159,7 @@ {{basic-topic-list topics=model.details.suggested_topics postsAction="showTopicEntrance"}} {{/if}}
-

{{{view.browseMoreMessage}}}

+

{{{browseMoreMessage}}}

{{/if}} diff --git a/app/assets/javascripts/discourse/views/selected-posts.js.es6 b/app/assets/javascripts/discourse/views/selected-posts.js.es6 deleted file mode 100644 index 28f4375f3b6..00000000000 --- a/app/assets/javascripts/discourse/views/selected-posts.js.es6 +++ /dev/null @@ -1,4 +0,0 @@ -export default Ember.View.extend({ - classNameBindings: ['controller.multiSelect::hidden', ':selected-posts'], - templateName: "selected-posts", -}); diff --git a/app/assets/javascripts/discourse/views/share.js.es6 b/app/assets/javascripts/discourse/views/share.js.es6 index 29ce3f95c69..96029481224 100644 --- a/app/assets/javascripts/discourse/views/share.js.es6 +++ b/app/assets/javascripts/discourse/views/share.js.es6 @@ -5,16 +5,6 @@ export default Ember.View.extend({ elementId: 'share-link', classNameBindings: ['hasLink'], - title: function() { - if (this.get('controller.type') === 'topic') return I18n.t('share.topic'); - var postNumber = this.get('controller.postNumber'); - if (postNumber) { - return I18n.t('share.post', {postNumber: this.get('controller.postNumber')}); - } else { - return I18n.t('share.topic'); - } - }.property('controller.type', 'controller.postNumber'), - hasLink: function() { if (!Ember.isEmpty(this.get('controller.link'))) return 'visible'; return null; diff --git a/app/assets/javascripts/discourse/views/topic.js.es6 b/app/assets/javascripts/discourse/views/topic.js.es6 index 6ef0621a528..08175db3006 100644 --- a/app/assets/javascripts/discourse/views/topic.js.es6 +++ b/app/assets/javascripts/discourse/views/topic.js.es6 @@ -1,7 +1,6 @@ import AddCategoryClass from 'discourse/mixins/add-category-class'; import AddArchetypeClass from 'discourse/mixins/add-archetype-class'; import ClickTrack from 'discourse/lib/click-track'; -import { categoryBadgeHTML } from 'discourse/helpers/category-link'; import Scrolling from 'discourse/mixins/scrolling'; const TopicView = Ember.View.extend(AddCategoryClass, AddArchetypeClass, Scrolling, { @@ -134,60 +133,7 @@ const TopicView = Ember.View.extend(AddCategoryClass, AddArchetypeClass, Scrolli // Trigger a scrolled event this.appEvents.trigger('topic:scrolled', offset); - }, - - pmPath: function() { - var currentUser = this.get('controller.currentUser'); - return currentUser && currentUser.pmPath(this.get('topic')); - }.property(), - - browseMoreMessage: function() { - - // TODO decide what to show for pms - if (this.get('topic.isPrivateMessage')) { - return; - } - - var opts = { latestLink: "" + I18n.t("topic.view_latest_topics") + "" }, - category = this.get('topic.category'); - - if(category && Em.get(category, 'id') === Discourse.Site.currentProp("uncategorized_category_id")) { - category = null; - } - - if (category) { - opts.catLink = categoryBadgeHTML(category); - } else { - opts.catLink = "" + I18n.t("topic.browse_all_categories") + ""; - } - - const tracking = this.get('topicTrackingState'), - unreadTopics = tracking.countUnread(), - newTopics = tracking.countNew(); - - if (newTopics + unreadTopics > 0) { - const hasBoth = unreadTopics > 0 && newTopics > 0; - - return I18n.messageFormat("topic.read_more_MF", { - "BOTH": hasBoth, - "UNREAD": unreadTopics, - "NEW": newTopics, - "CATEGORY": category ? true : false, - latestLink: opts.latestLink, - catLink: opts.catLink - }); - } else if (category) { - return I18n.t("topic.read_more_in_category", opts); - } else { - return I18n.t("topic.read_more", opts); - } - }.property('topicTrackingState.messageCount', 'topic'), - - suggestedTitle: function(){ - return this.get('controller.model.isPrivateMessage') ? - " " + I18n.t("suggested_topics.pm_title") : - I18n.t("suggested_topics.title"); - }.property('topic') + } }); function highlight(postNumber) {