From 8ec8567f05743f7257bc779a7a78ad22d8eb1aea Mon Sep 17 00:00:00 2001 From: Norifumi Ogawa Date: Sat, 2 Apr 2022 23:36:40 +0900 Subject: [PATCH 01/71] =?UTF-8?q?=E3=82=AB=E3=83=AC=E3=83=B3=E3=83=80?= =?UTF-8?q?=E3=83=BC=E3=81=A7=E6=97=A5=E4=BB=98=E3=82=92=E6=8C=87=E5=AE=9A?= =?UTF-8?q?=E3=81=97=E3=81=A6=E6=96=B0=E8=A6=8F=E3=81=AEreport=E4=BD=9C?= =?UTF-8?q?=E6=88=90=E7=94=BB=E9=9D=A2=E3=82=92=E9=96=8B=E3=81=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/reports_controller.rb | 8 ++++++-- app/javascript/niconico_calendar.vue | 17 ++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 75a60f7a9fb..7ad3b9511ef 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -26,14 +26,18 @@ def show end def new - @report = Report.new(reported_on: Date.current) + year, month, day = params[:reported_on].scan(/\d+/).map(&:to_i) if params[:reported_on] + @report = if Date.valid_date?(year, month, day) + Report.new(reported_on: params[:reported_on].to_date) + else + Report.new(reported_on: Date.current) + end @report.learning_times.build return unless params[:id] report = current_user.reports.find(params[:id]) @report.title = report.title - @report.reported_on = Date.current @report.emotion = report.emotion @report.description = "\n" + report.description @report.practices = report.practices diff --git a/app/javascript/niconico_calendar.vue b/app/javascript/niconico_calendar.vue index bb3df687ee0..66f3953a363 100644 --- a/app/javascript/niconico_calendar.vue +++ b/app/javascript/niconico_calendar.vue @@ -56,7 +56,14 @@ :src='`/images/emotion/${date.emotion}.svg`', :alt='date.emotion' ) - .niconico-calendar__day-inner(v-else) + a.niconico-calendar__day-inner( + v-else-if='isPastDate(date.date)', + :href='`/reports/new?reported_on=${calendarYear}-${calendarMonth}-${date.date}`' + ) + .niconico-calendar__day-label {{ date.date }} + .niconico-calendar__day-value + i.fas.fa-minus(v-if='date.date') + a.niconico-calendar__day-inner(v-else) .niconico-calendar__day-label {{ date.date }} .niconico-calendar__day-value i.fas.fa-minus(v-if='date.date') @@ -247,6 +254,14 @@ export default { const params = new URLSearchParams(location.search) params.set('niconico_calendar', `${year}-${month}`) history.replaceState(history.state, '', `?${params}${location.hash}`) + }, + isPastDate(date) { + if (this.calendarYear > this.currentYear) return false + if (this.calendarYear < this.currentYear) return true + if (this.calendarMonth > this.currentMonth) return false + if (this.calendarMonth < this.currentMonth) return true + if (date > this.today) return false + return true } } } From 04500dc2fae4505efc10b7beb04e59c5b6cb9fa1 Mon Sep 17 00:00:00 2001 From: Norifumi Ogawa Date: Sun, 3 Apr 2022 10:21:06 +0900 Subject: [PATCH 02/71] =?UTF-8?q?=E6=97=A5=E4=BB=98=E3=81=8C=E3=81=AA?= =?UTF-8?q?=E3=81=84=E6=97=A5=E3=81=AF=E3=83=AA=E3=83=B3=E3=82=AF=E3=81=97?= =?UTF-8?q?=E3=81=AA=E3=81=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/niconico_calendar.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/javascript/niconico_calendar.vue b/app/javascript/niconico_calendar.vue index 66f3953a363..3c106418d2b 100644 --- a/app/javascript/niconico_calendar.vue +++ b/app/javascript/niconico_calendar.vue @@ -57,7 +57,7 @@ :alt='date.emotion' ) a.niconico-calendar__day-inner( - v-else-if='isPastDate(date.date)', + v-else-if='date.date && isPastDate(date.date)', :href='`/reports/new?reported_on=${calendarYear}-${calendarMonth}-${date.date}`' ) .niconico-calendar__day-label {{ date.date }} From 53eb7c81e672718b763d5383c924e2171ec86a5d Mon Sep 17 00:00:00 2001 From: Norifumi Ogawa Date: Mon, 4 Apr 2022 11:54:16 +0900 Subject: [PATCH 03/71] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/system/home_test.rb | 15 +++++++++++++++ test/system/reports_test.rb | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/test/system/home_test.rb b/test/system/home_test.rb index 0ef78419c69..d3181ce8463 100644 --- a/test/system/home_test.rb +++ b/test/system/home_test.rb @@ -144,6 +144,21 @@ class HomeTest < ApplicationSystemTestCase assert_current_path(/niconico_calendar=#{1.month.ago.strftime('%Y-%m')}/) end + test 'set a link to the new report form at today on Nico Nico calendar' do + visit_with_auth "/?niconico_calendar=#{Time.current.strftime('%Y-%m')}", 'hajime' + assert_link(href: "/reports/new?reported_on=#{Time.current.strftime('%Y-%-m-%-d')}") + end + + test 'set a link to the new report form at past date on Nico Nico calendar' do + visit_with_auth '/?niconico_calendar=2022-03', 'hajime' + assert_link(href: '/reports/new?reported_on=2022-3-1') + end + + test 'no link to the new report on future dates in the Nico Nico calendar' do + visit_with_auth "/?niconico_calendar=#{Time.current.next_month.strftime('%Y-%m')}", 'hajime' + assert_no_link(href: "/reports/new?reported_on=#{Time.current.next_month.strftime('%Y-%-m-%-d')}") + end + test 'show the grass for student' do assert users(:kimura).student? visit_with_auth '/', 'kimura' diff --git a/test/system/reports_test.rb b/test/system/reports_test.rb index f5347b10dba..5a3723201e7 100644 --- a/test/system/reports_test.rb +++ b/test/system/reports_test.rb @@ -730,4 +730,9 @@ def wait_for_watch_change assert_text '2020年06月01日 の日報' assert_text '今日は1時間学習しました。' end + + test 'open new report with a past date' do + visit_with_auth '/reports/new?reported_on=2022-1-1', 'komagata' + assert_equal '2022-01-01', find('#report_reported_on').value + end end From 799a82dd0da12ae7acf7e9d43ccf41330625e420 Mon Sep 17 00:00:00 2001 From: eatplaynap Date: Fri, 25 Mar 2022 22:31:25 +0900 Subject: [PATCH 04/71] =?UTF-8?q?=E6=A4=9C=E7=B4=A2=E7=B5=90=E6=9E=9C?= =?UTF-8?q?=E4=B8=80=E8=A6=A7=E3=81=A7WIP=E3=81=AE=E6=97=A5=E5=A0=B1?= =?UTF-8?q?=E3=82=84Docs=E3=82=92=E8=AD=98=E5=88=A5=E3=81=A7=E3=81=8D?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/search_helper.rb | 4 ++++ app/javascript/searchable.vue | 13 ++++++++++++- app/views/api/searchables/_searchable.json.jbuilder | 6 ++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index 49e5de833ae..2a233e9df0a 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -43,4 +43,8 @@ def comment_or_answer?(searchable) def talk?(searchable) searchable.instance_of?(User) && searchable.talk.present? end + + def have_no_wip?(searchable) + searchable.is_a?(Practice) || searchable.is_a?(Answer) || searchable.is_a?(User) || searchable.is_a?(Comment) + end end diff --git a/app/javascript/searchable.vue b/app/javascript/searchable.vue index a6b375b9be6..a11ea62d5f5 100644 --- a/app/javascript/searchable.vue +++ b/app/javascript/searchable.vue @@ -1,5 +1,5 @@