From f9c38bcc6654b23939c202b4cc9cd72b1c74c3a5 Mon Sep 17 00:00:00 2001 From: Gustavo Valenzuela Date: Wed, 8 Nov 2023 16:16:00 -0800 Subject: [PATCH] Standup rich text (#404) * Add yesterdays_description, todays_description, and blockers to standup_meeting_params * Add rich text associations for yesterdays_description, todays_description, and blockers to StandupMeeting model * adds rich_text_are fields to form * pass new content_type that maps to new rich text associations * Add trix-context class to rich_text_areas * restore has_rich_text previous naming * remove added params * Add task to migrate standup meeting data to action text --- app/models/standup_meeting.rb | 4 ++++ app/views/standup_meetings/_form.html.erb | 14 ++++++------ lib/tasks/migrate_fields_to_rich_text.rake | 25 ++++++++++++++++++++++ 3 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 lib/tasks/migrate_fields_to_rich_text.rake diff --git a/app/models/standup_meeting.rb b/app/models/standup_meeting.rb index 66dd12a7..e2770f0e 100644 --- a/app/models/standup_meeting.rb +++ b/app/models/standup_meeting.rb @@ -29,6 +29,10 @@ class StandupMeeting < ApplicationRecord belongs_to :standup_meeting_group, inverse_of: :standup_meetings belongs_to :user + has_rich_text :yesterday_work_description + has_rich_text :today_work_description + has_rich_text :blockers_description + alias_method :group, :standup_meeting_group validates :meeting_date, presence: true diff --git a/app/views/standup_meetings/_form.html.erb b/app/views/standup_meetings/_form.html.erb index 6715648b..1d1fa0c6 100644 --- a/app/views/standup_meetings/_form.html.erb +++ b/app/views/standup_meetings/_form.html.erb @@ -10,22 +10,24 @@ <%= standup_meeting.meeting_date %> +
<%= form.label :yesterday_work_description, '1. What did you work on yesterday? (or last working day)', class: 'mb-4 md:mb-0' %> - <%= form.text_area :yesterday_work_description, required: true, class: 'textarea-lg textarea-primary textarea', placeholder: 'e.g., Got the first version of feature X up in a draft PR' %> + <%= form.rich_text_area :yesterday_work_description, required: true, class: 'textarea-lg textarea-primary textarea trix-content', placeholder: 'e.g., Got the first version of feature X up in a draft PR' %>
- <%= form.label :today_work_description, '2. What do you plan on working on today?', class: 'mb-4 md:mb-0' %> - <%= form.text_area :today_work_description, required: true, class: 'textarea-lg textarea-primary textarea', placeholder: "e.g., 1. Review some outstanding PRs\n2. Push forward on second feature" %> + <%= form.label :today_work_description, '2. What do you plan on working on today?', class: 'mb-4 md:mb-0' %> + <%= form.rich_text_area :today_work_description, required: true, class: 'textarea-lg textarea-primary textarea trix-content', placeholder: "e.g., 1. Review some outstanding PRs\n2. Push forward on second feature" %>
- <%= form.label :blockers_description, '3. Do you have any blockers? (Leave empty if none)', class: 'mb-4 md:mb-0'%> - <%= form.text_area :blockers_description, class: 'textarea-lg textarea-primary textarea', placeholder: 'e.g., Wireframes for third feature are still not complete' %> + <%= form.label :blockers_description, '3. Do you have any blockers? (Leave empty if none)', class: 'mb-4 md:mb-0' %> + <%= form.rich_text_area :blockers_description, required: true, class: 'textarea-lg textarea-primary textarea trix-content' %>
+
<%= form.hidden_field :status, value: :completed %> <%= form.submit "Check-in", class: 'btn btn-primary' %> - + <% end %> <%= render StandupMeeting::SkipButtonComponent.new(standup_meeting_group:, standup_meeting:, current_user:) %> diff --git a/lib/tasks/migrate_fields_to_rich_text.rake b/lib/tasks/migrate_fields_to_rich_text.rake new file mode 100644 index 00000000..a055883e --- /dev/null +++ b/lib/tasks/migrate_fields_to_rich_text.rake @@ -0,0 +1,25 @@ +namespace :standup_meeting do + desc 'Migrate standup meeting data to action text' + + task migrate_data_to_action_text: :environment do + failed_updates = [] + + StandupMeeting.where(status: 'completed').find_each do |meeting| + meeting.update!( + today_work_description: meeting.read_attribute_before_type_cast(:today_work_description), + yesterday_work_description: meeting.read_attribute_before_type_cast(:yesterday_work_description), + blockers_description: meeting.read_attribute_before_type_cast(:blockers_description) + ) + rescue StandardError => e + failed_updates << { id: meeting.id, error: e.message } + Rails.logger.error "Migration failed for StandupMeeting id: #{meeting.id}, error: #{e.message}" + end + + if failed_updates.any? + puts "Migration completed with some failures: #{failed_updates.size} failed updates." + Rails.logger.error "Failed updates: #{failed_updates.inspect}" + else + puts 'StandupMeeting data migration to action text is complete.' + end + end +end