From f8224918863fc93e7feb7abfa64586229c45f9b1 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Wed, 11 Jun 2014 10:57:30 -0400 Subject: [PATCH] ES6: Convert a couple view helpers. They should probably be components evnetually! --- .../javascripts/admin/templates/group.js.handlebars | 2 +- .../templates/site_settings/setting_enum.js.handlebars | 2 +- .../javascripts/admin/templates/user_badges.js.handlebars | 2 +- .../javascripts/admin/templates/user_index.js.handlebars | 4 ++-- .../discourse/initializers/deprecations.js.es6 | 4 +++- .../discourse/initializers/view-helpers.js.es6 | 7 ++++++- .../components/screened-ip-address-form.handlebars | 2 +- .../discourse/templates/composer.js.handlebars | 2 +- .../templates/modal/bulk_change_category.js.handlebars | 2 +- .../discourse/templates/modal/edit_category.js.handlebars | 2 +- .../discourse/templates/modal/split_topic.js.handlebars | 2 +- .../javascripts/discourse/templates/topic.js.handlebars | 2 +- .../discourse/templates/user/badge-title.js.handlebars | 2 +- .../discourse/templates/user/preferences.js.handlebars | 8 ++++---- .../{category_chooser_view.js => category-chooser.js.es6} | 6 +++--- .../views/{combobox_view.js => combo-box.js.es6} | 4 +--- app/assets/javascripts/main_include.js | 2 +- 17 files changed, 30 insertions(+), 25 deletions(-) rename app/assets/javascripts/discourse/views/{category_chooser_view.js => category-chooser.js.es6} (92%) rename app/assets/javascripts/discourse/views/{combobox_view.js => combo-box.js.es6} (94%) diff --git a/app/assets/javascripts/admin/templates/group.js.handlebars b/app/assets/javascripts/admin/templates/group.js.handlebars index fccefe35b1c..7b844db1183 100644 --- a/app/assets/javascripts/admin/templates/group.js.handlebars +++ b/app/assets/javascripts/admin/templates/group.js.handlebars @@ -18,7 +18,7 @@
- {{combobox valueAttribute="value" value=alias_level content=aliasLevelOptions}} + {{combo-box valueAttribute="value" value=alias_level content=aliasLevelOptions}}
diff --git a/app/assets/javascripts/admin/templates/site_settings/setting_enum.js.handlebars b/app/assets/javascripts/admin/templates/site_settings/setting_enum.js.handlebars index f4b4bda4fbb..6e07962828f 100644 --- a/app/assets/javascripts/admin/templates/site_settings/setting_enum.js.handlebars +++ b/app/assets/javascripts/admin/templates/site_settings/setting_enum.js.handlebars @@ -2,7 +2,7 @@

{{unbound settingName}}

- {{combobox valueAttribute="value" content=validValues value=value none=allowsNone}} + {{combo-box valueAttribute="value" content=validValues value=value none=allowsNone}}
{{unbound description}}
{{#if dirty}} diff --git a/app/assets/javascripts/admin/templates/user_badges.js.handlebars b/app/assets/javascripts/admin/templates/user_badges.js.handlebars index faa16f001f6..fa4d1bd8d6f 100644 --- a/app/assets/javascripts/admin/templates/user_badges.js.handlebars +++ b/app/assets/javascripts/admin/templates/user_badges.js.handlebars @@ -15,7 +15,7 @@

{{i18n admin.badges.no_badges}}

{{else}}
- {{combobox valueAttribute="id" value=controller.selectedBadgeId content=controller.grantableBadges}} + {{combo-box valueAttribute="id" value=controller.selectedBadgeId content=controller.grantableBadges}} {{/if}} diff --git a/app/assets/javascripts/admin/templates/user_index.js.handlebars b/app/assets/javascripts/admin/templates/user_index.js.handlebars index c195ad16fb4..867fa38226c 100644 --- a/app/assets/javascripts/admin/templates/user_index.js.handlebars +++ b/app/assets/javascripts/admin/templates/user_index.js.handlebars @@ -56,7 +56,7 @@
{{i18n admin.groups.primary}}
{{#if custom_groups}} - {{combobox content=custom_groups value=primary_group_id nameProperty="name" none="admin.groups.no_primary"}} + {{combo-box content=custom_groups value=primary_group_id nameProperty="name" none="admin.groups.no_primary"}} {{else}} — {{/if}} @@ -229,7 +229,7 @@
{{i18n trust_level}}
- {{combobox content=trustLevels value=trust_level nameProperty="detailedName"}} + {{combo-box content=trustLevels value=trust_level nameProperty="detailedName"}}
{{#if leaderRequirements}} diff --git a/app/assets/javascripts/discourse/initializers/deprecations.js.es6 b/app/assets/javascripts/discourse/initializers/deprecations.js.es6 index 2bb5733132f..d3883854b57 100644 --- a/app/assets/javascripts/discourse/initializers/deprecations.js.es6 +++ b/app/assets/javascripts/discourse/initializers/deprecations.js.es6 @@ -2,7 +2,9 @@ var deprecatedViewHelpers = { inputTip: 'input-tip', pagedown: 'pagedown-editor', textField: 'text-field', - userSelector: 'user-selector' + userSelector: 'user-selector', + combobox: 'combo-box', + categoryChooser: 'category-chooser' }; export default { diff --git a/app/assets/javascripts/discourse/initializers/view-helpers.js.es6 b/app/assets/javascripts/discourse/initializers/view-helpers.js.es6 index 2c5d144af6a..b3483a0e707 100644 --- a/app/assets/javascripts/discourse/initializers/view-helpers.js.es6 +++ b/app/assets/javascripts/discourse/initializers/view-helpers.js.es6 @@ -1,4 +1,9 @@ -var helpers = ['input-tip', 'pagedown-editor', 'text-field', 'user-selector']; +var helpers = ['input-tip', + 'pagedown-editor', + 'text-field', + 'user-selector', + 'category-chooser', + 'combo-box']; /** Creates view helpers for some views. Many of these should probably be converted diff --git a/app/assets/javascripts/discourse/templates/components/screened-ip-address-form.handlebars b/app/assets/javascripts/discourse/templates/components/screened-ip-address-form.handlebars index 9635dd3e5cd..234bb506fd1 100644 --- a/app/assets/javascripts/discourse/templates/components/screened-ip-address-form.handlebars +++ b/app/assets/javascripts/discourse/templates/components/screened-ip-address-form.handlebars @@ -1,4 +1,4 @@ {{i18n admin.logs.screened_ips.form.label}} {{text-field value=ip_address disabled=formSubmitted class="ip-address-input" placeholderKey="admin.logs.screened_ips.form.ip_address" autocorrect="off" autocapitalize="off"}} -{{combobox content=actionNames value=actionName}} +{{combo-box content=actionNames value=actionName}} diff --git a/app/assets/javascripts/discourse/templates/composer.js.handlebars b/app/assets/javascripts/discourse/templates/composer.js.handlebars index 12b3cc8cfa0..1911dddaedb 100644 --- a/app/assets/javascripts/discourse/templates/composer.js.handlebars +++ b/app/assets/javascripts/discourse/templates/composer.js.handlebars @@ -44,7 +44,7 @@ {{#unless model.privateMessage}}
- {{categoryChooser valueAttribute="id" value=model.categoryId}} + {{category-chooser valueAttribute="id" value=model.categoryId}} {{popupInputTip validation=view.categoryValidation shownAt=view.showCategoryTip}}
{{#if model.archetype.hasOptions}} diff --git a/app/assets/javascripts/discourse/templates/modal/bulk_change_category.js.handlebars b/app/assets/javascripts/discourse/templates/modal/bulk_change_category.js.handlebars index 6a5fe566a58..074dc8ffad2 100644 --- a/app/assets/javascripts/discourse/templates/modal/bulk_change_category.js.handlebars +++ b/app/assets/javascripts/discourse/templates/modal/bulk_change_category.js.handlebars @@ -1,6 +1,6 @@

Choose the new category for the topics:

-

{{categoryChooser value=newCategoryId}}

+

{{category-chooser value=newCategoryId}}

{{#if loading}}
{{i18n loading}}
diff --git a/app/assets/javascripts/discourse/templates/modal/edit_category.js.handlebars b/app/assets/javascripts/discourse/templates/modal/edit_category.js.handlebars index 65497f587d8..b9a18d4d871 100644 --- a/app/assets/javascripts/discourse/templates/modal/edit_category.js.handlebars +++ b/app/assets/javascripts/discourse/templates/modal/edit_category.js.handlebars @@ -29,7 +29,7 @@ {{/each}} {{else}} - {{categoryChooser valueAttribute="id" value=parent_category_id categories=parentCategories rootNone=true}} + {{category-chooser valueAttribute="id" value=parent_category_id categories=parentCategories rootNone=true}} {{/if}} diff --git a/app/assets/javascripts/discourse/templates/modal/split_topic.js.handlebars b/app/assets/javascripts/discourse/templates/modal/split_topic.js.handlebars index 579b204a613..d87d551ecd1 100644 --- a/app/assets/javascripts/discourse/templates/modal/split_topic.js.handlebars +++ b/app/assets/javascripts/discourse/templates/modal/split_topic.js.handlebars @@ -12,7 +12,7 @@ {{text-field value=topicName placeholderKey="composer.title_placeholder" elementId='split-topic-name'}} - {{categoryChooser value=categoryId}} + {{category-chooser value=categoryId}}
diff --git a/app/assets/javascripts/discourse/templates/topic.js.handlebars b/app/assets/javascripts/discourse/templates/topic.js.handlebars index ec8add46b9a..b3d3483919c 100644 --- a/app/assets/javascripts/discourse/templates/topic.js.handlebars +++ b/app/assets/javascripts/discourse/templates/topic.js.handlebars @@ -18,7 +18,7 @@ {{#if isPrivateMessage}} {{else}} - {{categoryChooser valueAttribute="id" value=newCategoryId source=category_id}} + {{category-chooser valueAttribute="id" value=newCategoryId source=category_id}} {{/if}} {{text-field id='edit-title' value=newTitle}} diff --git a/app/assets/javascripts/discourse/templates/user/badge-title.js.handlebars b/app/assets/javascripts/discourse/templates/user/badge-title.js.handlebars index 6bf807b8de1..81ad2f65fc1 100644 --- a/app/assets/javascripts/discourse/templates/user/badge-title.js.handlebars +++ b/app/assets/javascripts/discourse/templates/user/badge-title.js.handlebars @@ -10,7 +10,7 @@
- {{combobox valueAttribute="id" value=selectedUserBadgeId nameProperty="badge.name" content=selectableUserBadges}} + {{combo-box valueAttribute="id" value=selectedUserBadgeId nameProperty="badge.name" content=selectableUserBadges}}
diff --git a/app/assets/javascripts/discourse/templates/user/preferences.js.handlebars b/app/assets/javascripts/discourse/templates/user/preferences.js.handlebars index 06673c850a9..7b35de2a1b6 100644 --- a/app/assets/javascripts/discourse/templates/user/preferences.js.handlebars +++ b/app/assets/javascripts/discourse/templates/user/preferences.js.handlebars @@ -112,7 +112,7 @@
- {{combobox valueAttribute="value" content=availableLocales value=locale none="user.locale.default"}} + {{combo-box valueAttribute="value" content=availableLocales value=locale none="user.locale.default"}}
{{i18n user.locale.instructions}} @@ -146,7 +146,7 @@ {{preference-checkbox labelKey="user.email_digests.title" checked=email_digests}} {{#if email_digests}}
- {{combobox valueAttribute="value" content=digestFrequencies value=digest_after_days}} + {{combo-box valueAttribute="value" content=digestFrequencies value=digest_after_days}}
{{/if}} {{preference-checkbox labelKey="user.email_private_messages" checked=email_private_messages}} @@ -163,12 +163,12 @@
- {{combobox valueAttribute="value" content=autoTrackDurations value=auto_track_topics_after_msecs}} + {{combo-box valueAttribute="value" content=autoTrackDurations value=auto_track_topics_after_msecs}}
- {{combobox valueAttribute="value" content=considerNewTopicOptions value=new_topic_duration_minutes}} + {{combo-box valueAttribute="value" content=considerNewTopicOptions value=new_topic_duration_minutes}}
{{preference-checkbox labelKey="user.external_links_in_new_tab" checked=external_links_in_new_tab}} diff --git a/app/assets/javascripts/discourse/views/category_chooser_view.js b/app/assets/javascripts/discourse/views/category-chooser.js.es6 similarity index 92% rename from app/assets/javascripts/discourse/views/category_chooser_view.js rename to app/assets/javascripts/discourse/views/category-chooser.js.es6 index 67154a7a019..6d224325414 100644 --- a/app/assets/javascripts/discourse/views/category_chooser_view.js +++ b/app/assets/javascripts/discourse/views/category-chooser.js.es6 @@ -6,7 +6,9 @@ @namespace Discourse @module Discourse **/ -Discourse.CategoryChooserView = Discourse.ComboboxView.extend({ +import ComboboxView from 'discourse/views/combo-box'; + +export default ComboboxView.extend({ classNames: ['combobox category-combobox'], overrideWidths: true, dataAttributes: ['id', 'description_text'], @@ -57,5 +59,3 @@ Discourse.CategoryChooserView = Discourse.ComboboxView.extend({ } }); - -Discourse.View.registerHelper('categoryChooser', Discourse.CategoryChooserView); diff --git a/app/assets/javascripts/discourse/views/combobox_view.js b/app/assets/javascripts/discourse/views/combo-box.js.es6 similarity index 94% rename from app/assets/javascripts/discourse/views/combobox_view.js rename to app/assets/javascripts/discourse/views/combo-box.js.es6 index 31f16c8c264..41a9f3deb61 100644 --- a/app/assets/javascripts/discourse/views/combobox_view.js +++ b/app/assets/javascripts/discourse/views/combo-box.js.es6 @@ -6,7 +6,7 @@ @namespace Discourse @module Discourse **/ -Discourse.ComboboxView = Discourse.View.extend({ +export default Discourse.View.extend({ tagName: 'select', classNames: ['combobox'], valueAttribute: 'id', @@ -79,5 +79,3 @@ Discourse.ComboboxView = Discourse.View.extend({ } }); - -Discourse.View.registerHelper('combobox', Discourse.ComboboxView); diff --git a/app/assets/javascripts/main_include.js b/app/assets/javascripts/main_include.js index 8455c69b0eb..5b8325915c4 100644 --- a/app/assets/javascripts/main_include.js +++ b/app/assets/javascripts/main_include.js @@ -22,7 +22,7 @@ //= require ./discourse/views/text-field //= require ./discourse/views/modal/modal_body_view //= require ./discourse/views/modal/flag_view -//= require ./discourse/views/combobox_view +//= require ./discourse/views/combo-box //= require ./discourse/views/buttons/button_view //= require ./discourse/views/buttons/dropdown_button_view //= require ./discourse/views/buttons/notifications_button