mirror of
https://github.com/discourse/discourse.git
synced 2025-03-21 21:05:58 +08:00
UX: Automatically generate poll name for poll builder.
This commit is contained in:
parent
949be591da
commit
3cb8bbb851
@ -487,6 +487,7 @@ export default Ember.Component.extend({
|
|||||||
applySurround: (head, tail, exampleKey) => this._applySurround(selected, head, tail, exampleKey),
|
applySurround: (head, tail, exampleKey) => this._applySurround(selected, head, tail, exampleKey),
|
||||||
applyList: (head, exampleKey) => this._applyList(selected, head, exampleKey),
|
applyList: (head, exampleKey) => this._applyList(selected, head, exampleKey),
|
||||||
addText: text => this._addText(selected, text),
|
addText: text => this._addText(selected, text),
|
||||||
|
getText: () => this.get('value'),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (button.sendAction) {
|
if (button.sendAction) {
|
||||||
|
@ -91,12 +91,17 @@ export default Ember.Controller.extend({
|
|||||||
return this._comboboxOptions(1, (parseInt(pollMax) || 1) + 1);
|
return this._comboboxOptions(1, (parseInt(pollMax) || 1) + 1);
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("isNumber", "showMinMax", "pollName", "pollType", "publicPoll", "pollOptions", "pollMin", "pollMax", "pollStep")
|
@computed("isNumber", "showMinMax", "pollType", "publicPoll", "pollOptions", "pollMin", "pollMax", "pollStep")
|
||||||
pollOutput(isNumber, showMinMax, pollName, pollType, publicPoll, pollOptions, pollMin, pollMax, pollStep) {
|
pollOutput(isNumber, showMinMax, pollType, publicPoll, pollOptions, pollMin, pollMax, pollStep) {
|
||||||
let pollHeader = '[poll';
|
let pollHeader = '[poll';
|
||||||
let output = '';
|
let output = '';
|
||||||
|
|
||||||
if (pollName) pollHeader += ` name=${pollName.trim().replace(/\s/g, '-')}`;
|
const match = this.get("toolbarEvent").getText().match(/\[poll(\s+name=[^\s\]]+)*.*\]/igm);
|
||||||
|
|
||||||
|
if (match) {
|
||||||
|
pollHeader += ` name=poll${match.length + 1}`;
|
||||||
|
};
|
||||||
|
|
||||||
if (pollType) pollHeader += ` type=${pollType}`;
|
if (pollType) pollHeader += ` type=${pollType}`;
|
||||||
if (pollMin && showMinMax) pollHeader += ` min=${pollMin}`;
|
if (pollMin && showMinMax) pollHeader += ` min=${pollMin}`;
|
||||||
if (pollMax) pollHeader += ` max=${pollMax}`;
|
if (pollMax) pollHeader += ` max=${pollMax}`;
|
||||||
@ -137,8 +142,6 @@ export default Ember.Controller.extend({
|
|||||||
|
|
||||||
_setupPoll() {
|
_setupPoll() {
|
||||||
this.setProperties({
|
this.setProperties({
|
||||||
pollName: '',
|
|
||||||
pollNamePlaceholder: I18n.t("poll.ui_builder.poll_name.placeholder"),
|
|
||||||
pollType: null,
|
pollType: null,
|
||||||
publicPoll: false,
|
publicPoll: false,
|
||||||
pollOptions: '',
|
pollOptions: '',
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
<div class="modal-body poll-ui-builder">
|
<div class="modal-body poll-ui-builder">
|
||||||
<form class="poll-ui-builder-form form-horizontal">
|
<form class="poll-ui-builder-form form-horizontal">
|
||||||
<div class="input-group">
|
|
||||||
<label class="input-group-label">{{i18n 'poll.ui_builder.poll_name.label'}}</label>
|
|
||||||
{{input name="poll-name" value=pollName placeholder=pollNamePlaceholder}}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<label class="input-group-label">{{i18n 'poll.ui_builder.poll_type.label'}}</label>
|
<label class="input-group-label">{{i18n 'poll.ui_builder.poll_type.label'}}</label>
|
||||||
{{combo-box content=pollTypes
|
{{combo-box content=pollTypes
|
||||||
|
@ -74,9 +74,6 @@ en:
|
|||||||
insert: Insert Poll
|
insert: Insert Poll
|
||||||
help:
|
help:
|
||||||
options_count: Enter at least 2 options
|
options_count: Enter at least 2 options
|
||||||
poll_name:
|
|
||||||
label: Name
|
|
||||||
placeholder: Enter Name
|
|
||||||
poll_type:
|
poll_type:
|
||||||
label: Type
|
label: Type
|
||||||
regular: Single Choice
|
regular: Single Choice
|
||||||
|
Loading…
x
Reference in New Issue
Block a user