Skip to content

Commit

Permalink
Merge pull request #7765 from fjordllc/chore/convert-daily-reports-to…
Browse files Browse the repository at this point in the history
…-slim

日報一覧(全て、未読)を非JS化
  • Loading branch information
komagata authored May 28, 2024
2 parents 1292055 + d45da03 commit 1b738bb
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 13 deletions.
6 changes: 5 additions & 1 deletion app/controllers/reports/unchecked_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# frozen_string_literal: true

class Reports::UncheckedController < ApplicationController
PAGER_NUMBER = 25

before_action :require_staff_login
def index; end
def index
@reports = Report.unchecked.not_wip.list.page(params[:page]).per(PAGER_NUMBER)
end
end
7 changes: 6 additions & 1 deletion app/controllers/reports_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

class ReportsController < ApplicationController
PAGER_NUMBER = 25

include Rails.application.routes.url_helpers
before_action :set_report, only: %i[show]
before_action :set_my_report, only: %i[destroy]
Expand All @@ -11,7 +13,10 @@ class ReportsController < ApplicationController
before_action :set_categories, only: %i[create update]
before_action :set_watch, only: %i[show]

def index; end
def index
@reports = Report.list.page(params[:page]).per(PAGER_NUMBER)
@reports = @reports.joins(:practices).where(practices: { id: params[:practice_id] }) if params[:practice_id].present?
end

def show
@products = @report.user.products.not_wip.order(published_at: :desc)
Expand Down
4 changes: 2 additions & 2 deletions app/views/application/_unconfirmed_links_open.html.slim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
hr.a-border
hr.a-border-tint
.card-footer
.card-main-actions
ul.card-main-actions__items
li.card-main-actions__item
button#js-shortcut-unconfirmed-links-open.thread-unconfirmed-links-form__action(class="a-button is-sm is-secondary")
button#js-shortcut-unconfirmed-links-open.thread-unconfirmed-links-form__action(class="a-button is-sm is-block is-secondary")
| #{label}
66 changes: 66 additions & 0 deletions app/views/reports/_report.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
.card-list-item(class="#{report.wip? ? 'is-wip' : ''}")
.card-list-item__inner
.card-list-item__user
= render 'users/icon', user: report.user, link_class: 'card-list-item__user-link', image_class: 'card-list-item__user-icon'
.card-list-item__rows
.card-list-item__row
.card-list-item-title
.card-list-item-title__start
- if report.wip?
.a-list-item-badge.is-wip
span
| WIP
h2.card-list-item-title__title(itemprop='name')
= link_to report, itemprop: 'url', class: 'card-list-item-title__link a-text-link js-unconfirmed-link' do
= image_tag("emotion/#{report.emotion}.svg", alt: report.emotion, class: 'card-list-item-title__emotion-image')
= report.title
- if current_user == report.user
.card-list-item-title__end
label.card-list-item-actions__trigger(for="#{report.id}")
i.fa-solid.fa-ellipsis-h
.card-list-item-actions
input.a-toggle-checkbox(type="checkbox" id=="#{report.id}")
.card-list-item-actions__inner
ul.card-list-item-actions__items
li.card-list-item-actions__item
= link_to edit_report_path(report), class: 'card-list-item-actions__action' do
i.fa-solid.fa-pen
| 内容変更
li.card-list-item-actions__item
= link_to new_report_path(id: report), class: 'card-list-item-actions__action' do
i.fa-solid.fa-copy
| コピー
label.a-overlay(for="#{report.id}")
.card-list-item__row
.card-list-item-meta
.card-list-item-meta__items
.card-list-item-meta__item
= link_to report.user, class: 'a-user-name' do
= report.user.long_name
.card-list-item-meta__item
time.a-meta(datetime="#{report.reported_on.to_datetime}")
= l report.reported_on
| の日報
- if report.comments.any?
hr.card-list-item__row-separator
.card-list-item__row
.card-list-item-meta
.card-list-item-meta__items
.card-list-item-meta__item
.a-meta
| コメント(#{report.comments.size}
.card-list-item-meta__item
.card-list-item__user-icons
= render partial: 'comments/user_icons', collection: report.comments.commented_users, as: :user
.card-list-item-meta__item
time.a-meta(datetime="#{report.comments.last.updated_at.to_datetime}" pubdate='pubdate')
| 〜 #{l report.comments.last.updated_at, format: :date_and_time}

- if report.checks.any?
.stamp.stamp-approve
h2.stamp__content.is-title 確認済
time.stamp__content.is-created-at
= l report.checks.last.created_at.to_date, format: :short
.stamp__content.is-user-name
.stamp__content-inner
= report.checks.last.user.login_name
37 changes: 29 additions & 8 deletions app/views/reports/index.html.slim
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
- title @search_words.present? ? "'#{@search_words.join(' ')}'の検索結果" : '日報'

- if @search_words.present?
- set_meta_tags description: "日報'#{@search_words.join(' ')}'の検索結果の一覧ページです。"
- else
- set_meta_tags description: '日報の一覧ページです。'
- title '日報'
- set_meta_tags description: '日報の一覧ページです。'

header.page-header
.container
Expand All @@ -16,5 +12,30 @@ header.page-header

= render 'reports/tabs'

- practices = current_user.practices.as_json(only: %i[id title])
= react_component('Reports', all: true, practices: practices)
.page-main
nav.page-filter.form
.container.is-md
= form_with url: reports_path, local: true, method: 'get'
.form-item.is-inline-md-up
= label_tag :practice_id, 'プラクティスで絞り込む', class: 'a-form-label'
= select_tag :practice_id, options_from_collection_for_select(current_user.practices, :id, :title, selected: params[:practice_id]), include_blank: '全ての日報を表示', onchange: 'this.form.submit()', id: 'js-choices-single-select'
hr.a-border
- if @reports.empty?
.o-empty-message
.o-empty-message__icon
.card-list.a-card
.card__description
.o-empty-message
.o-empty-message__icon
i.fa-regular.fa-sad-tear
.o-empty-message__text
| 日報はまだありません。
- else
.page-body
.container.is-md
.page-content.reports
= paginate @reports
.card-list.a-card
.card-list__items
= render partial: 'reports/report', collection: @reports, as: :report
= paginate @reports
19 changes: 18 additions & 1 deletion app/views/reports/unchecked/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,21 @@ header.page-header

= render 'reports/tabs'

= react_component('Reports', unchecked: true)
.page-main
- if @reports.empty?
.o-empty-message
.o-empty-message__icon
i.fa-regular.fa-smile
p.o-empty-message__text
| 未チェックの日報はありません
- else
.page-body
.container.is-md
.page-content.reports
= paginate @reports
.card-list.a-card
.card-list__items
= render partial: 'reports/report', collection: @reports, as: :report
- if mentor_login?
= render partial: 'unconfirmed_links_open', locals: { label: '未チェックの日報を一括で開く' }
= paginate @reports

0 comments on commit 1b738bb

Please sign in to comment.