ES6: Convert a couple view helpers. They should probably be components

evnetually!
This commit is contained in:
Robin Ward 2014-06-11 10:57:30 -04:00
parent 18489ba83a
commit f822491886
17 changed files with 30 additions and 25 deletions

View file

@ -18,7 +18,7 @@
<div class="control-group">
<label class="control-label">{{i18n groups.alias_levels.title}}</label>
<div class="controls">
{{combobox valueAttribute="value" value=alias_level content=aliasLevelOptions}}
{{combo-box valueAttribute="value" value=alias_level content=aliasLevelOptions}}
</div>
</div>
<div class='controls'>

View file

@ -2,7 +2,7 @@
<h3>{{unbound settingName}}</h3>
</div>
<div class="setting-value">
{{combobox valueAttribute="value" content=validValues value=value none=allowsNone}}
{{combo-box valueAttribute="value" content=validValues value=value none=allowsNone}}
<div class='desc'>{{unbound description}}</div>
</div>
{{#if dirty}}

View file

@ -15,7 +15,7 @@
<p>{{i18n admin.badges.no_badges}}</p>
{{else}}
<br>
{{combobox valueAttribute="id" value=controller.selectedBadgeId content=controller.grantableBadges}}
{{combo-box valueAttribute="id" value=controller.selectedBadgeId content=controller.grantableBadges}}
<button class='btn btn-primary' {{action grantBadge controller.selectedBadgeId}}>{{i18n admin.badges.grant}}</button>
{{/if}}

View file

@ -56,7 +56,7 @@
<div class='field'>{{i18n admin.groups.primary}}</div>
<div class='value'>
{{#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}}
&mdash;
{{/if}}
@ -229,7 +229,7 @@
<div class='display-row'>
<div class='field'>{{i18n trust_level}}</div>
<div class="value">
{{combobox content=trustLevels value=trust_level nameProperty="detailedName"}}
{{combo-box content=trustLevels value=trust_level nameProperty="detailedName"}}
</div>
<div class="controls">
{{#if leaderRequirements}}

View file

@ -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 {

View file

@ -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

View file

@ -1,4 +1,4 @@
<b>{{i18n admin.logs.screened_ips.form.label}}</b>
{{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}}
<button class="btn btn-small" {{action submit target="view"}} {{bind-attr disabled="formSubmitted"}}>{{i18n admin.logs.screened_ips.form.add}}</button>

View file

@ -44,7 +44,7 @@
{{#unless model.privateMessage}}
<div class="category-input">
{{categoryChooser valueAttribute="id" value=model.categoryId}}
{{category-chooser valueAttribute="id" value=model.categoryId}}
{{popupInputTip validation=view.categoryValidation shownAt=view.showCategoryTip}}
</div>
{{#if model.archetype.hasOptions}}

View file

@ -1,6 +1,6 @@
<p>Choose the new category for the topics:</p>
<p>{{categoryChooser value=newCategoryId}}</p>
<p>{{category-chooser value=newCategoryId}}</p>
{{#if loading}}
<div class='loading'>{{i18n loading}}</div>

View file

@ -29,7 +29,7 @@
{{/each}}
{{else}}
<label>{{i18n category.parent}}</label>
{{categoryChooser valueAttribute="id" value=parent_category_id categories=parentCategories rootNone=true}}
{{category-chooser valueAttribute="id" value=parent_category_id categories=parentCategories rootNone=true}}
{{/if}}
</section>

View file

@ -12,7 +12,7 @@
{{text-field value=topicName placeholderKey="composer.title_placeholder" elementId='split-topic-name'}}
<label>{{i18n categories.category}}</label>
{{categoryChooser value=categoryId}}
{{category-chooser value=categoryId}}
</form>
</div>

View file

@ -18,7 +18,7 @@
{{#if isPrivateMessage}}
<span class="private-message-glyph"><i class='fa fa-envelope'></i></span>
{{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}}

View file

@ -10,7 +10,7 @@
<div class="control-group">
<label class="control-label">{{i18n badges.title}}</label>
<div class="controls">
{{combobox valueAttribute="id" value=selectedUserBadgeId nameProperty="badge.name" content=selectableUserBadges}}
{{combo-box valueAttribute="id" value=selectedUserBadgeId nameProperty="badge.name" content=selectableUserBadges}}
</div>
</div>

View file

@ -112,7 +112,7 @@
<div class="control-group">
<label class="control-label">{{i18n user.locale.title}}</label>
<div class="controls">
{{combobox valueAttribute="value" content=availableLocales value=locale none="user.locale.default"}}
{{combo-box valueAttribute="value" content=availableLocales value=locale none="user.locale.default"}}
</div>
<div class='instructions'>
{{i18n user.locale.instructions}}
@ -146,7 +146,7 @@
{{preference-checkbox labelKey="user.email_digests.title" checked=email_digests}}
{{#if email_digests}}
<div class='controls controls-dropdown'>
{{combobox valueAttribute="value" content=digestFrequencies value=digest_after_days}}
{{combo-box valueAttribute="value" content=digestFrequencies value=digest_after_days}}
</div>
{{/if}}
{{preference-checkbox labelKey="user.email_private_messages" checked=email_private_messages}}
@ -163,12 +163,12 @@
<label class="control-label">{{i18n user.other_settings}}</label>
<div class="controls controls-dropdown">
<label>{{i18n user.auto_track_topics}}</label>
{{combobox valueAttribute="value" content=autoTrackDurations value=auto_track_topics_after_msecs}}
{{combo-box valueAttribute="value" content=autoTrackDurations value=auto_track_topics_after_msecs}}
</div>
<div class="controls controls-dropdown">
<label>{{i18n user.new_topic_duration.label}}</label>
{{combobox valueAttribute="value" content=considerNewTopicOptions value=new_topic_duration_minutes}}
{{combo-box valueAttribute="value" content=considerNewTopicOptions value=new_topic_duration_minutes}}
</div>
{{preference-checkbox labelKey="user.external_links_in_new_tab" checked=external_links_in_new_tab}}

View file

@ -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);

View file

@ -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);

View file

@ -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