Skip to content

Commit

Permalink
Standup rich text (#404)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
GALTdea authored Nov 9, 2023
1 parent c6ba55b commit f9c38bc
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
4 changes: 4 additions & 0 deletions app/models/standup_meeting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions app/views/standup_meetings/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,24 @@
<%= standup_meeting.meeting_date %>
</span>
</div>

<div class="flex flex-col justify-between space-y-2">
<%= 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' %>
</div>
<div class="flex flex-col justify-between space-y-2">
<%= 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" %>
</div>
<div class="flex flex-col justify-between space-y-2">
<%= 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' %>
</div>

<div class="flex flex-row-reverse space-x-4">
<%= 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:) %>
Expand Down
25 changes: 25 additions & 0 deletions lib/tasks/migrate_fields_to_rich_text.rake
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f9c38bc

Please sign in to comment.