mirror of
https://github.com/mastodon/mastodon.git
synced 2025-10-05 00:22:42 +00:00
Support displaying polls in Admin UI (#35933)
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
6f8187e595
commit
15401e6988
|
@ -1873,7 +1873,7 @@ a.sparkline {
|
|||
font-size: 15px;
|
||||
line-height: 22px;
|
||||
|
||||
li {
|
||||
> li {
|
||||
counter-increment: step 1;
|
||||
padding-inline-start: 2.5rem;
|
||||
padding-bottom: 8px;
|
||||
|
|
|
@ -102,7 +102,8 @@
|
|||
cursor: pointer;
|
||||
}
|
||||
|
||||
&.editable {
|
||||
&.editable,
|
||||
&.disabled {
|
||||
align-items: center;
|
||||
overflow: visible;
|
||||
}
|
||||
|
@ -160,7 +161,8 @@
|
|||
}
|
||||
}
|
||||
|
||||
&__option.editable &__input {
|
||||
&__option.editable &__input,
|
||||
&__option.disabled &__input {
|
||||
&:active,
|
||||
&:focus,
|
||||
&:hover {
|
||||
|
|
|
@ -43,16 +43,36 @@ class StatusEdit < ApplicationRecord
|
|||
scope :ordered, -> { order(id: :asc) }
|
||||
|
||||
delegate :local?, :application, :edited?, :edited_at,
|
||||
:discarded?, :visibility, :language, to: :status
|
||||
:discarded?, :reply?, :visibility, :language, to: :status
|
||||
|
||||
def with_media?
|
||||
ordered_media_attachments.any?
|
||||
end
|
||||
|
||||
def with_poll?
|
||||
poll_options.present?
|
||||
end
|
||||
|
||||
def poll
|
||||
return @poll if defined?(@poll)
|
||||
return @poll = nil if poll_options.blank?
|
||||
|
||||
@poll = Poll.new({
|
||||
options: poll_options,
|
||||
account_id: account_id,
|
||||
status_id: status_id,
|
||||
})
|
||||
end
|
||||
|
||||
alias preloadable_poll poll
|
||||
|
||||
def emojis
|
||||
return @emojis if defined?(@emojis)
|
||||
|
||||
@emojis = CustomEmoji.from_text([spoiler_text, text].join(' '), status.account.domain)
|
||||
fields = [spoiler_text, text]
|
||||
fields += preloadable_poll.options unless preloadable_poll.nil?
|
||||
|
||||
@emojis = CustomEmoji.from_text(fields.join(' '), status.account.domain)
|
||||
end
|
||||
|
||||
def ordered_media_attachments
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
- if status.with_poll?
|
||||
.poll
|
||||
%ul
|
||||
- status.preloadable_poll.options.each_with_index do |option, _index|
|
||||
%li
|
||||
%label.poll__option.disabled<>
|
||||
- if status.preloadable_poll.multiple?
|
||||
%span.poll__input.checkbox{ role: 'checkbox', 'aria-label': option }
|
||||
- else
|
||||
%span.poll__input{ role: 'radio', 'aria-label': option }
|
||||
%span.poll__option__text
|
||||
= prerender_custom_emojis(html_aware_format(option, status.local?, multiline: false), status.emojis)
|
||||
%button.button.button-secondary{ disabled: true }
|
||||
= t('polls.vote')
|
||||
|
||||
- if status.with_media?
|
||||
- if status.ordered_media_attachments.first.video?
|
||||
= render_video_component(status, visible: false)
|
||||
|
|
|
@ -1740,6 +1740,7 @@ en:
|
|||
self_vote: You cannot vote in your own polls
|
||||
too_few_options: must have more than one item
|
||||
too_many_options: can't contain more than %{max} items
|
||||
vote: Vote
|
||||
posting_defaults:
|
||||
explanation: These settings will be used as defaults when you create new posts, but you can edit them per post within the composer.
|
||||
preferences:
|
||||
|
|
Loading…
Reference in New Issue
Block a user