mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 00:41:16 +08:00
UX: Automatically generate poll name for poll builder.
This commit is contained in:
@ -91,12 +91,17 @@ export default Ember.Controller.extend({
|
||||
return this._comboboxOptions(1, (parseInt(pollMax) || 1) + 1);
|
||||
},
|
||||
|
||||
@computed("isNumber", "showMinMax", "pollName", "pollType", "publicPoll", "pollOptions", "pollMin", "pollMax", "pollStep")
|
||||
pollOutput(isNumber, showMinMax, pollName, pollType, publicPoll, pollOptions, pollMin, pollMax, pollStep) {
|
||||
@computed("isNumber", "showMinMax", "pollType", "publicPoll", "pollOptions", "pollMin", "pollMax", "pollStep")
|
||||
pollOutput(isNumber, showMinMax, pollType, publicPoll, pollOptions, pollMin, pollMax, pollStep) {
|
||||
let pollHeader = '[poll';
|
||||
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 (pollMin && showMinMax) pollHeader += ` min=${pollMin}`;
|
||||
if (pollMax) pollHeader += ` max=${pollMax}`;
|
||||
@ -137,8 +142,6 @@ export default Ember.Controller.extend({
|
||||
|
||||
_setupPoll() {
|
||||
this.setProperties({
|
||||
pollName: '',
|
||||
pollNamePlaceholder: I18n.t("poll.ui_builder.poll_name.placeholder"),
|
||||
pollType: null,
|
||||
publicPoll: false,
|
||||
pollOptions: '',
|
||||
|
Reference in New Issue
Block a user