diff --git a/app/assets/stylesheets/case_states.sass b/app/assets/stylesheets/case_states.sass new file mode 100644 index 000000000..bdd48dd6c --- /dev/null +++ b/app/assets/stylesheets/case_states.sass @@ -0,0 +1,2 @@ +.stat-label + font-style: italic diff --git a/app/controllers/cases/stats_controller.rb b/app/controllers/cases/stats_controller.rb new file mode 100644 index 000000000..cb3ed5992 --- /dev/null +++ b/app/controllers/cases/stats_controller.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +module Cases + # The stats for a {Case} include its slug, what library it is in, etc. + class StatsController < ApplicationController + before_action :authenticate_reader! + + layout 'admin' + + # @param [GET] /cases/case-slug/stats + def show + set_case + set_libraries + set_editorships + set_group_and_deployment + end + + private + + def set_case + @case = Case.friendly.find(params[:case_slug]).decorate + @case.licensor current_reader + authorize @case + end + + def set_libraries + @libraries = LibraryPolicy::AdminScope.new(current_reader, Library) + .resolve + end + + def set_editorships + @editorships = @case.editorships + end + + def set_group_and_deployment + @enrollment = current_user.enrollment_for_case @case + @group = @enrollment.try(:active_group) || GlobalGroup.new + @deployment = @group.deployment_for_case @case + end + + end +end diff --git a/app/helpers/cases_helper.rb b/app/helpers/cases_helper.rb index 63007dd91..14c8afdb6 100644 --- a/app/helpers/cases_helper.rb +++ b/app/helpers/cases_helper.rb @@ -11,4 +11,20 @@ def translators_string(c) def cases_as_json(cases) array = cases.map { |c| raw render partial: 'cases/case', formats: [:json], locals: { c: c } } end + + def locales_to_sentence(locales = []) + if locales.present? + locales.map{|locale| + tr = Translation.language_name(locale) + if tr + "#{tr} (#{locale})" + else + "" + end + }&.compact&.to_sentence + else + "" + end + + end end diff --git a/app/javascript/catalog/CatalogToolbar.jsx b/app/javascript/catalog/CatalogToolbar.jsx index 05d0efda3..e6c8d31e2 100644 --- a/app/javascript/catalog/CatalogToolbar.jsx +++ b/app/javascript/catalog/CatalogToolbar.jsx @@ -99,12 +99,20 @@ class SearchField extends React.Component< onSubmit={this.handleSubmit} ref={ref} > + (this.input = el)} className="pt-round" leftIcon="search" + aria-label={this.props.intl.formatMessage({ + id: 'search.searchCases', + })} rightElement={ + diff --git a/app/views/my_cases/index.html.haml b/app/views/my_cases/index.html.haml index 2db66c8c6..83b345fa8 100644 --- a/app/views/my_cases/index.html.haml +++ b/app/views/my_cases/index.html.haml @@ -15,7 +15,6 @@ aria: { label: I18n.t('helpers.help') }, target: '_blank', rel: 'noopener noreferrer' do -# Empty - :markdown #{t '.put_your_own_cases_on_gala'} .pt-callout.pt-icon-hand-right @@ -51,6 +50,7 @@ %td= t 'activerecord.attributes.case.locale' %td= t 'activerecord.attributes.case.library' %td= t 'activerecord.attributes.case.published' + %td= t 'my_cases.index.case_stats' %td %td %td @@ -90,6 +90,11 @@ - else — + %td + = link_to '', case_stats_path(kase), + aria: { label: t('.case_stats') }, + class: 'pt-button pt-minimal pt-icon-series-search' + %td = link_to '', edit_case_path(kase), aria: { label: t('.edit_case') }, @@ -104,6 +109,8 @@ = link_to '', case_confirm_deletion_path(kase), class: 'pt-button pt-minimal pt-intent-danger pt-icon-trash', aria: { label: t('.delete_case') } + + - else .pt-non-ideal-state diff --git a/config/locales/en.yml b/config/locales/en.yml index c3c28752a..b39ba22d5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -261,6 +261,20 @@ en: locations: Site locations new: create_a_case: Create a Case + stats: + show: + case_stats: Case Stats + created: Created + published: "Published:" + last_updated: "Last Updated:" + deployments: "Deployments" + visits: Unique Visits + locales: Locales + podcast_listens: Podcast Listens - %{podcast_title} + disclaimer: > + Totals count only users that were signed-in to Gala when viewing the case. + 'Unique Visits' counts readers who viewed a page beyond the overview page of your case. + Readers' browser settings may impact the accuracy of these counts. settings: edit: change_library: Change library @@ -830,7 +844,8 @@ en: Invite Someone to Manage this Library my_cases: index: - confirm_delete: > + case_stats: Case Stats + confirm_delete: Are you sure you wish to delete this case? This action cannot be undone. create_a_case: Create a Case delete_case: Delete case. @@ -1023,6 +1038,7 @@ en: results: Search results search: Search search_cases: Search Cases... + submit_search: Submit search try_again: Try searching for something else. spotlights: add_citation: > diff --git a/config/routes.rb b/config/routes.rb index 1b5bfd850..51a8bd3bc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -113,6 +113,8 @@ resource :settings, module: 'cases', only: %i[edit update] + resource :stats, module: 'cases', only: %i[show] + resources :taggings, only: %i[create destroy], param: :tag_name resources :translations, only: %i[new create show], param: :case_locale