mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 09:42:46 +08:00
Changed combo-box to number inputs for min, max and step values.
This commit is contained in:

committed by
Guo Xiang Tan

parent
911d6abfad
commit
c423544208
@ -120,9 +120,20 @@ export default Ember.Controller.extend({
|
|||||||
return output;
|
return output;
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("pollOptionsCount", "isNumber")
|
@computed("pollOptionsCount", "isNumber", "pollMin", "pollMax")
|
||||||
disableInsert(count, isNumber) {
|
disableInsert(count, isNumber, pollMin, pollMax) {
|
||||||
return isNumber ? false : (count < 2);
|
return (pollMin >= pollMax) || (isNumber ? false : (count < 2));
|
||||||
|
},
|
||||||
|
|
||||||
|
@computed("pollMin", "pollMax")
|
||||||
|
minMaxValueValidation(pollMin, pollMax) {
|
||||||
|
let options = { ok: true };
|
||||||
|
|
||||||
|
if (pollMin >= pollMax) {
|
||||||
|
options = { failed: true, reason: I18n.t("poll.ui_builder.help.invalid_values") };
|
||||||
|
}
|
||||||
|
|
||||||
|
return InputValidation.create(options);
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("disableInsert")
|
@computed("disableInsert")
|
||||||
|
@ -11,16 +11,17 @@
|
|||||||
{{#if showMinMax}}
|
{{#if showMinMax}}
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<label class="input-group-label">{{i18n 'poll.ui_builder.poll_config.min'}}</label>
|
<label class="input-group-label">{{i18n 'poll.ui_builder.poll_config.min'}}</label>
|
||||||
{{combo-box content=pollMinOptions
|
{{input type='number'
|
||||||
value=pollMin
|
value=pollMin
|
||||||
valueAttribute="value"
|
valueAttribute="value"
|
||||||
class="poll-options-min"}}
|
class="poll-options-min"}}
|
||||||
|
{{input-tip validation=minMaxValueValidation}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<label class="input-group-label">{{i18n 'poll.ui_builder.poll_config.max'}}</label>
|
<label class="input-group-label">{{i18n 'poll.ui_builder.poll_config.max'}}</label>
|
||||||
{{combo-box content=pollMaxOptions
|
{{input type='number'
|
||||||
value=pollMax
|
value=pollMax
|
||||||
valueAttribute="value"
|
valueAttribute="value"
|
||||||
class="poll-options-max"}}
|
class="poll-options-max"}}
|
||||||
@ -29,7 +30,7 @@
|
|||||||
{{#if isNumber}}
|
{{#if isNumber}}
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<label class="input-group-label">{{i18n 'poll.ui_builder.poll_config.step'}}</label>
|
<label class="input-group-label">{{i18n 'poll.ui_builder.poll_config.step'}}</label>
|
||||||
{{combo-box content=pollStepOptions
|
{{input type='number'
|
||||||
value=pollStep
|
value=pollStep
|
||||||
valueAttribute="value"
|
valueAttribute="value"
|
||||||
class="poll-options-step"}}
|
class="poll-options-step"}}
|
||||||
|
@ -74,6 +74,7 @@ en:
|
|||||||
insert: Insert Poll
|
insert: Insert Poll
|
||||||
help:
|
help:
|
||||||
options_count: Enter at least 2 options
|
options_count: Enter at least 2 options
|
||||||
|
invalid_values: Minimum value must be smaller than the maximum value.
|
||||||
poll_type:
|
poll_type:
|
||||||
label: Type
|
label: Type
|
||||||
regular: Single Choice
|
regular: Single Choice
|
||||||
|
Reference in New Issue
Block a user