mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-23 08:48:06 +01:00
Improve min poll options, expose value in API
This commit is contained in:
parent
22427cd43c
commit
9c8fb2d475
8 changed files with 14 additions and 5 deletions
|
@ -81,7 +81,7 @@ class Option extends React.PureComponent {
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<div className='poll__cancel'>
|
<div className='poll__cancel'>
|
||||||
<IconButton disabled={index < 1} title={intl.formatMessage(messages.remove_option)} icon='times' onClick={this.handleOptionRemove} />
|
<IconButton disabled={index < pollLimits.min_options} title={intl.formatMessage(messages.remove_option)} icon='times' onClick={this.handleOptionRemove} />
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
|
|
|
@ -60,6 +60,7 @@ import { me, defaultContentType } from 'flavours/glitch/initial_state';
|
||||||
import { overwrite } from 'flavours/glitch/utils/js_helpers';
|
import { overwrite } from 'flavours/glitch/utils/js_helpers';
|
||||||
import { unescapeHTML } from 'flavours/glitch/utils/html';
|
import { unescapeHTML } from 'flavours/glitch/utils/html';
|
||||||
import { recoverHashtags } from 'flavours/glitch/utils/hashtag';
|
import { recoverHashtags } from 'flavours/glitch/utils/hashtag';
|
||||||
|
import { pollLimits } from 'flavours/glitch/initial_state';
|
||||||
|
|
||||||
const totalElefriends = 3;
|
const totalElefriends = 3;
|
||||||
|
|
||||||
|
@ -127,7 +128,7 @@ const initialState = ImmutableMap({
|
||||||
});
|
});
|
||||||
|
|
||||||
const initialPoll = ImmutableMap({
|
const initialPoll = ImmutableMap({
|
||||||
options: ImmutableList(['']),
|
options: ImmutableList(new Array(pollLimits.min_options).fill('')),
|
||||||
expires_in: 24 * 3600,
|
expires_in: 24 * 3600,
|
||||||
multiple: false,
|
multiple: false,
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,6 +7,7 @@ import IconButton from 'mastodon/components/icon_button';
|
||||||
import Icon from 'mastodon/components/icon';
|
import Icon from 'mastodon/components/icon';
|
||||||
import AutosuggestInput from 'mastodon/components/autosuggest_input';
|
import AutosuggestInput from 'mastodon/components/autosuggest_input';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import { pollLimits } from 'mastodon/initial_state';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
option_placeholder: { id: 'compose_form.poll.option_placeholder', defaultMessage: 'Choice {number}' },
|
option_placeholder: { id: 'compose_form.poll.option_placeholder', defaultMessage: 'Choice {number}' },
|
||||||
|
@ -102,7 +103,7 @@ class Option extends React.PureComponent {
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<div className='poll__cancel'>
|
<div className='poll__cancel'>
|
||||||
<IconButton disabled={index < 1} title={intl.formatMessage(messages.remove_option)} icon='times' onClick={this.handleOptionRemove} />
|
<IconButton disabled={index < pollLimits.min_options} title={intl.formatMessage(messages.remove_option)} icon='times' onClick={this.handleOptionRemove} />
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
|
|
|
@ -129,4 +129,7 @@ export const version = getMeta('version');
|
||||||
export const translationEnabled = getMeta('translation_enabled');
|
export const translationEnabled = getMeta('translation_enabled');
|
||||||
export const languages = initialState?.languages;
|
export const languages = initialState?.languages;
|
||||||
|
|
||||||
|
// CatCatNya~ specific setting for vanilla flavor
|
||||||
|
export const pollLimits = (initialState && initialState.poll_limits);
|
||||||
|
|
||||||
export default initialState;
|
export default initialState;
|
||||||
|
|
|
@ -52,7 +52,7 @@ import { STORE_HYDRATE } from '../actions/store';
|
||||||
import { REDRAFT } from '../actions/statuses';
|
import { REDRAFT } from '../actions/statuses';
|
||||||
import { Map as ImmutableMap, List as ImmutableList, OrderedSet as ImmutableOrderedSet, fromJS } from 'immutable';
|
import { Map as ImmutableMap, List as ImmutableList, OrderedSet as ImmutableOrderedSet, fromJS } from 'immutable';
|
||||||
import uuid from '../uuid';
|
import uuid from '../uuid';
|
||||||
import { me } from '../initial_state';
|
import { me, pollLimits } from '../initial_state';
|
||||||
import { unescapeHTML } from '../utils/html';
|
import { unescapeHTML } from '../utils/html';
|
||||||
|
|
||||||
const initialState = ImmutableMap({
|
const initialState = ImmutableMap({
|
||||||
|
@ -95,7 +95,7 @@ const initialState = ImmutableMap({
|
||||||
});
|
});
|
||||||
|
|
||||||
const initialPoll = ImmutableMap({
|
const initialPoll = ImmutableMap({
|
||||||
options: ImmutableList(['']),
|
options: ImmutableList(new Array(pollLimits.min_options).fill('')),
|
||||||
expires_in: 24 * 3600,
|
expires_in: 24 * 3600,
|
||||||
multiple: false,
|
multiple: false,
|
||||||
});
|
});
|
||||||
|
|
|
@ -17,6 +17,7 @@ class InitialStateSerializer < ActiveModel::Serializer
|
||||||
|
|
||||||
def poll_limits
|
def poll_limits
|
||||||
{
|
{
|
||||||
|
min_options: PollValidator::MIN_OPTIONS,
|
||||||
max_options: PollValidator::MAX_OPTIONS,
|
max_options: PollValidator::MAX_OPTIONS,
|
||||||
max_option_chars: PollValidator::MAX_OPTION_CHARS,
|
max_option_chars: PollValidator::MAX_OPTION_CHARS,
|
||||||
min_expiration: PollValidator::MIN_EXPIRATION,
|
min_expiration: PollValidator::MIN_EXPIRATION,
|
||||||
|
|
|
@ -67,6 +67,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
||||||
},
|
},
|
||||||
|
|
||||||
polls: {
|
polls: {
|
||||||
|
min_options: PollValidator::MIN_OPTIONS,
|
||||||
max_options: PollValidator::MAX_OPTIONS,
|
max_options: PollValidator::MAX_OPTIONS,
|
||||||
max_characters_per_option: PollValidator::MAX_OPTION_CHARS,
|
max_characters_per_option: PollValidator::MAX_OPTION_CHARS,
|
||||||
min_expiration: PollValidator::MIN_EXPIRATION,
|
min_expiration: PollValidator::MIN_EXPIRATION,
|
||||||
|
|
|
@ -42,6 +42,7 @@ class REST::V1::InstanceSerializer < ActiveModel::Serializer
|
||||||
|
|
||||||
def poll_limits
|
def poll_limits
|
||||||
{
|
{
|
||||||
|
min_options: PollValidator::MIN_OPTIONS,
|
||||||
max_options: PollValidator::MAX_OPTIONS,
|
max_options: PollValidator::MAX_OPTIONS,
|
||||||
max_option_chars: PollValidator::MAX_OPTION_CHARS,
|
max_option_chars: PollValidator::MAX_OPTION_CHARS,
|
||||||
min_expiration: PollValidator::MIN_EXPIRATION,
|
min_expiration: PollValidator::MIN_EXPIRATION,
|
||||||
|
@ -91,6 +92,7 @@ class REST::V1::InstanceSerializer < ActiveModel::Serializer
|
||||||
},
|
},
|
||||||
|
|
||||||
polls: {
|
polls: {
|
||||||
|
min_options: PollValidator::MIN_OPTIONS,
|
||||||
max_options: PollValidator::MAX_OPTIONS,
|
max_options: PollValidator::MAX_OPTIONS,
|
||||||
max_characters_per_option: PollValidator::MAX_OPTION_CHARS,
|
max_characters_per_option: PollValidator::MAX_OPTION_CHARS,
|
||||||
min_expiration: PollValidator::MIN_EXPIRATION,
|
min_expiration: PollValidator::MIN_EXPIRATION,
|
||||||
|
|
Loading…
Reference in a new issue