diff --git a/app/javascript/styles/mastodon/admin.scss b/app/javascript/styles/mastodon/admin.scss index e9b584f396..2f3b96411d 100644 --- a/app/javascript/styles/mastodon/admin.scss +++ b/app/javascript/styles/mastodon/admin.scss @@ -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; diff --git a/app/javascript/styles/mastodon/polls.scss b/app/javascript/styles/mastodon/polls.scss index 4402e51b9b..b13c9d6132 100644 --- a/app/javascript/styles/mastodon/polls.scss +++ b/app/javascript/styles/mastodon/polls.scss @@ -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 { diff --git a/app/models/status_edit.rb b/app/models/status_edit.rb index 2c2306bb75..a3da107853 100644 --- a/app/models/status_edit.rb +++ b/app/models/status_edit.rb @@ -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 diff --git a/app/views/admin/shared/_status_attachments.html.haml b/app/views/admin/shared/_status_attachments.html.haml index 92cc696453..24af2b5f7d 100644 --- a/app/views/admin/shared/_status_attachments.html.haml +++ b/app/views/admin/shared/_status_attachments.html.haml @@ -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) diff --git a/config/locales/en.yml b/config/locales/en.yml index b657932d80..ebbb72fb07 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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: