Sha256: 6d524e2424d6ebdbeb01b6b8aa920b339fb980c557d874c412a76cb7c4994176

Contents?: true

Size: 762 Bytes

Versions: 38

Compression:

Stored size: 762 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Elections
    class RemainingTimeCalloutCell < Decidim::ViewModel
      helper_method :needs_to_show_remaining_time?, :remaining_time

      private

      def needs_to_show_remaining_time?
        model.ongoing? && model.end_time < 12.hours.from_now
      end

      def remaining_time
        minutes_to_end = ((model.end_time - Time.current) / 60).floor
        t("remaining_time", count: remaining_hours(minutes_to_end), minutes: remaining_minutes(minutes_to_end), scope: "decidim.elections.election_m.footer")
      end

      def remaining_hours(minutes_to_end)
        minutes_to_end / 60
      end

      def remaining_minutes(minutes_to_end)
        minutes_to_end % 60
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
decidim-elections-0.28.4 app/cells/decidim/elections/remaining_time_callout_cell.rb
decidim-elections-0.27.9 app/cells/decidim/elections/remaining_time_callout_cell.rb
decidim-elections-0.28.3 app/cells/decidim/elections/remaining_time_callout_cell.rb
decidim-elections-0.27.8 app/cells/decidim/elections/remaining_time_callout_cell.rb
decidim-elections-0.28.2 app/cells/decidim/elections/remaining_time_callout_cell.rb
decidim-elections-0.27.7 app/cells/decidim/elections/remaining_time_callout_cell.rb
decidim-elections-0.28.1 app/cells/decidim/elections/remaining_time_callout_cell.rb
decidim-elections-0.27.6 app/cells/decidim/elections/remaining_time_callout_cell.rb
decidim-elections-0.26.10 app/cells/decidim/elections/remaining_time_callout_cell.rb
decidim-elections-0.26.9 app/cells/decidim/elections/remaining_time_callout_cell.rb
decidim-elections-0.28.0 app/cells/decidim/elections/remaining_time_callout_cell.rb
decidim-elections-0.27.5 app/cells/decidim/elections/remaining_time_callout_cell.rb
decidim-elections-0.28.0.rc5 app/cells/decidim/elections/remaining_time_callout_cell.rb
decidim-elections-0.28.0.rc4 app/cells/decidim/elections/remaining_time_callout_cell.rb
decidim-elections-0.26.8 app/cells/decidim/elections/remaining_time_callout_cell.rb
decidim-elections-0.27.4 app/cells/decidim/elections/remaining_time_callout_cell.rb
decidim-elections-0.27.3 app/cells/decidim/elections/remaining_time_callout_cell.rb
decidim-elections-0.26.7 app/cells/decidim/elections/remaining_time_callout_cell.rb
decidim-elections-0.26.5 app/cells/decidim/elections/remaining_time_callout_cell.rb
decidim-elections-0.27.2 app/cells/decidim/elections/remaining_time_callout_cell.rb