Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track Progress on Strategies #1719

Closed
wants to merge 52 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
36cf917
Display contributors as a table
GayathriVenkatesh Mar 25, 2020
e1430fb
Use grids.scss to display contributors as table
GayathriVenkatesh Mar 30, 2020
06a14fd
Update grids.scss
GayathriVenkatesh Mar 30, 2020
7b1e9f3
Update contribute.html.erb
GayathriVenkatesh Apr 1, 2020
fd45438
Update gridThreeItemAlways()
GayathriVenkatesh Apr 1, 2020
671c57c
Add New Moment Button to home page
GayathriVenkatesh Apr 2, 2020
b2fbf3f
Merge remote-tracking branch 'upstream/master' into moments
GayathriVenkatesh Apr 2, 2020
130080c
Add 'Mark as Finished' option for strategies
GayathriVenkatesh Apr 2, 2020
201cf50
Add Tasks page
GayathriVenkatesh Apr 14, 2020
074fa4f
Merge branch 'master' into strategies
GayathriVenkatesh Apr 14, 2020
05ea003
Add Task to all languages
GayathriVenkatesh Apr 14, 2020
b700bdd
Merge branch 'strategies' of github.com:GayathriVenkatesh/ifme into s…
GayathriVenkatesh Apr 14, 2020
e7ce1e1
Codeclimate issues
GayathriVenkatesh Apr 17, 2020
a40700f
Fix rspec errors
GayathriVenkatesh Apr 17, 2020
343d750
Update tasks_controller.rb
Manasa2850 Apr 21, 2020
f793949
Update strategies_controller.rb
Manasa2850 Apr 21, 2020
69fef40
Update strategies_controller.rb
Manasa2850 Apr 21, 2020
1b625c5
Remove rake from Gemfile
Apr 26, 2020
4839cdd
Remove unwanted commits
Apr 26, 2020
06aa0fd
Delete .rake_tasks~
GayathriVenkatesh Apr 26, 2020
a986ce4
Add add_visible_to_strategies file
Apr 26, 2020
d2f9030
Merge branch 'strategies' of https://github.com/GayathriVenkatesh/ifm…
Apr 26, 2020
6c2a1b4
Use translation key
Apr 26, 2020
3d56560
Check if task exists
GayathriVenkatesh Apr 26, 2020
fd883c3
Delete todo_items_helper.rb
GayathriVenkatesh Apr 26, 2020
6ee81d5
Remove show function from tasks controller
GayathriVenkatesh Apr 26, 2020
2ca7062
Merge branch 'strategies' of https://github.com/GayathriVenkatesh/ifm…
GayathriVenkatesh Apr 26, 2020
3cf1569
Add show function
GayathriVenkatesh Apr 26, 2020
06bcd2f
Delete using destroy_all
GayathriVenkatesh Apr 30, 2020
1e088d4
Delete scaffolds.scss
GayathriVenkatesh Apr 30, 2020
719c25e
Codeclimate
GayathriVenkatesh May 13, 2020
61c4502
Update 20200224201131_create_moment_categories_join_table.rb
GayathriVenkatesh May 13, 2020
15700e5
Merge branch 'master' into strategies
GayathriVenkatesh May 13, 2020
96a5301
Update strategies_controller.rb
GayathriVenkatesh May 13, 2020
0ec0bad
Remove trailing spaces
GayathriVenkatesh May 13, 2020
4b365c9
codeclimate
Manasa2850 May 13, 2020
1089f6d
Update strategies_controller.rb
Manasa2850 May 13, 2020
a8adbef
Create tasks_controller_spec.rb
GayathriVenkatesh May 19, 2020
b360190
Remove show route
GayathriVenkatesh May 24, 2020
957f671
Remove development flag
GayathriVenkatesh May 24, 2020
d001eb8
Remove gem whenever
GayathriVenkatesh May 24, 2020
6d40000
Remove search tests
GayathriVenkatesh May 24, 2020
dfa599d
Remove todolists
Manasa2850 May 25, 2020
f41b5b8
codeclimate
Manasa2850 May 25, 2020
1656963
remove create_task from strategies_controller.rb
Manasa2850 May 25, 2020
9d5c6d5
add create_task to strategies_concern.rb
Manasa2850 May 25, 2020
3b5f6a3
codeclimate
Manasa2850 May 25, 2020
69b38aa
codeclimate
Manasa2850 May 25, 2020
895707e
Create todo_items_controller_spec.rb
Manasa2850 May 25, 2020
349021d
Removing since we have a task scheduler
Manasa2850 May 25, 2020
b2e87d3
Update todo_items_controller_spec.rb
Manasa2850 May 25, 2020
2db2e2d
Update todo_items_controller_spec.rb
Manasa2850 May 25, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,8 @@ GEM
websocket-driver (0.7.1)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.4)
whenever (1.0.0)
chronic (>= 0.6.3)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.3.0)
Expand Down Expand Up @@ -558,6 +560,7 @@ DEPENDENCIES
rails-erd (~> 1.6)
rails-i18n (~> 6.0.0)
rails_12factor (= 0.0.3)
rake (= 12.3.3)
react_on_rails (= 11.3.0)
resque (= 2.0.0)
resque-scheduler (= 4.4.0)
Expand All @@ -582,6 +585,7 @@ DEPENDENCIES
uglifier (~> 4.1.20)
webdrivers
webpacker (= 3.5.5)
whenever

RUBY VERSION
ruby 2.6.0p0
Expand Down
15 changes: 12 additions & 3 deletions app/controllers/concerns/strategies_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,20 @@ def premade_strategy
)
end

def create_task(strategy)
task = Task.find(strategy.id)
return unless task

task.finished = strategy.finished
task.title = strategy.name
task.save
end

def strategy_params
params.require(:strategy).permit(
:name, :description, :published_at, :draft, :comment,
{ category: [] }, { viewers: [] }, :visible, :bookmarked,
perform_strategy_reminder_attributes: %i[active id]
:name, :description, :published_at, :draft,
:comment, { category: [] }, { viewers: [] }, :visible, :bookmarked,
:finished, perform_strategy_reminder_attributes: %i[active id]
)
end
end
5 changes: 3 additions & 2 deletions app/controllers/strategies_controller.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# frozen_string_literal: true

class StrategiesController < ApplicationController
include CollectionPageSetupConcern
include ReminderHelper
include StrategiesConcern
include Shared
include StrategiesConcern
include MomentsHelper
include TagsHelper

Expand Down Expand Up @@ -94,12 +93,14 @@ def update
end
empty_array_for :viewers, :category
shared_update(@strategy, strategy_params)
create_task(@strategy)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be testing for this new task functionality in the test for update.

end

# DELETE /strategies/1
# DELETE /strategies/1.json
def destroy
shared_destroy(@strategy)
Task.where(id: @strategy.id).destroy_all
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be testing for this new task functionality in the test for destroy.

PerformStrategyReminder.where(strategy_id: @strategy.id).destroy_all
end

Expand Down
19 changes: 19 additions & 0 deletions app/controllers/tasks_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

class TasksController < ApplicationController
Manasa2850 marked this conversation as resolved.
Show resolved Hide resolved
before_action :set_task

def index
@tasks = Task.all
end

private

def set_task
@task = Task.find(params[:id])
end

def task_params
params.require(:task).permit(:title, :description)
end
end
19 changes: 19 additions & 0 deletions app/controllers/todo_items_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true
#
class TodoItemsController < ApplicationController
Manasa2850 marked this conversation as resolved.
Show resolved Hide resolved
before_action :set_task

def create
@todo_item = @task.todo_items.create(todo_item_params)
end

private

def set_task
@task = TodoList.find(params[:task_id])
end

def todo_item_params
params[:todo_item].permit(:content)
end
end
15 changes: 11 additions & 4 deletions app/helpers/strategies_form_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ def build_strategy_comment(strategy)
)
end

def build_strategy_finished(strategy)
build_switch_input(true, strategy.finished, false)
.merge(
id: 'strategy_finished',
name: 'strategy[finished]',
label: t('strategies.form.mark_as_finished')
)
end

def build_strategy_publishing(strategy)
build_switch_input('0', !strategy.published?, '1').merge(
id: 'strategy_publishing', name: 'publishing',
Expand Down Expand Up @@ -90,17 +99,15 @@ def build_switch_input(value, checked, unchecked_value)
{
type: 'switch', value: value,
uncheckedValue: unchecked_value,
checked: checked,
dark: true
checked: checked, dark: true
}
end

def category_checkboxes
checkboxes = []
@categories.each do |item|
checkboxes.push(
id: item.slug,
label: item.name,
id: item.slug, label: item.name,
value: item.id,
checked: @strategy.categories.include?(item)
)
Expand Down
3 changes: 2 additions & 1 deletion app/helpers/strategies_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def strategy_form_inputs(strategy, viewers)
get_viewers_input(viewers, 'strategy', 'strategies', strategy),
build_strategy_comment(strategy), build_strategy_publishing(strategy),
build_strategy_visible(strategy),
Rails.env.development? ? build_strategy_bookmarked(strategy) : {},
build_strategy_finished(strategy),
build_strategy_bookmarked(strategy),
build_strategy_reminder(strategy).merge(type: 'checkbox'),
build_strategy_reminder_attributes(strategy)]
end
Expand Down
23 changes: 23 additions & 0 deletions app/helpers/tasks_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

module TasksHelper
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be unit testing this helper.

def present_task(element)
{
name: element.title,
link: 'strategies/' + element.title.downcase.strip.tr(' ', '-') + '/edit',
date: TimeAgo.created_or_edited(element),
categories: slugs_hash('Followed ': element.no_of_days_followed.to_s +
'/' + element.total_no_of_days.to_s + ' days')
}
end

def task_props(elements)
elements.map { |element| present_task(element) }
end

private

def slugs_hash(data)
data.map { |total_no_of_days| { name: total_no_of_days } }
end
end
16 changes: 15 additions & 1 deletion app/models/strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# visible :boolean default(TRUE)
# bookmarked :boolean default(FALSE)
#

class Strategy < ApplicationRecord
include Viewer
include CommonMethods
Expand Down Expand Up @@ -70,4 +69,19 @@ def published?
def comments
Comment.comments_from(self)
end

after_save :update_tasks_table

private

def update_tasks_table
@task = Task.exists?(id) ? Task.find(id) : Task.new(id: id)
@task.title = name
@task.description = description
@task.finished = finished
@task.date = updated_at
@task.no_of_days_followed = finished ? 1 : 0
@task.total_no_of_days = (created_at.to_date - Time.zone.today).to_i + 1
@task.save
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should handle errors in the event that save does not work.

end
end
5 changes: 5 additions & 0 deletions app/models/task.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true
#
class Task < ApplicationRecord
has_many :todo_items
end
5 changes: 5 additions & 0 deletions app/models/todo_item.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true
#
class TodoItem < ApplicationRecord
belongs_to :task
end
4 changes: 2 additions & 2 deletions app/views/pages/home.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% if user_signed_in? && @stories.any? %>
<% title t('pages.home.stories') %>
<% @page_new = "New Moment" %>
<% title t('pages.home.stories') %>
<% @page_new = t('moments.new') %>
<% page_new new_moment_path %>
<% elsif user_signed_in? %>
<% title t('pages.home.signed_in_empty.main_message_one', { name: current_user.name }) %>
Expand Down
1 change: 1 addition & 0 deletions app/views/shared/_dashboard_nav_links.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<%= dashboard_nav_link_to(t('categories.plural'), categories_path) %>
<%= dashboard_nav_link_to(t('moods.plural'), moods_path) %>
<%= dashboard_nav_link_to(t('strategies.plural'), strategies_path) %>
<%= dashboard_nav_link_to(t('tasks.plural'), tasks_path) %>
<%= dashboard_nav_link_to(t('medications.index.title'), medications_path) %>
<%= dashboard_nav_link_to(t('groups.plural'), groups_path) %>
<%= dashboard_nav_link_to(t('allies.index.title'), allies_path) %>
Expand Down
7 changes: 7 additions & 0 deletions app/views/tasks/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<% title t('tasks.plural') %>
<%= react_component('BaseContainer', props: {
container: 'StoryContainer',
data: task_props(@tasks),
fetchUrl: tasks_path,
lastPage: true
})%>
4 changes: 4 additions & 0 deletions app/views/todo_items/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<%= form_for([@task, @task.todo_items.build]) do |f| %>
<%= f.text_field :content, placeholder: "New Todo" %>
<%= f.submit %>
<% end %>
2 changes: 2 additions & 0 deletions app/views/todo_items/_todo_item.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<p><%= todo_item.content %></p>
<%= link_to task_todo_item_path(@task, todo_item.id), method: :delete, data: { confirm: t('common.actions.confirm') } %>
31 changes: 31 additions & 0 deletions client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@
lodash "^4.17.13"
source-map "^0.5.0"

"@babel/generator@^7.9.0":
version "7.9.4"
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.9.4.tgz#12441e90c3b3c4159cdecf312075bf1a8ce2dbce"
integrity sha512-rjP8ahaDy/ouhrvCoU1E5mqaitWrxwuNGU+dy1EpaoK48jZay4MdkskKGIMHLZNewg8sAsqpGSREJwP0zH3YQA==
dependencies:
"@babel/types" "^7.9.0"
jsesc "^2.5.1"
lodash "^4.17.13"
source-map "^0.5.0"

"@babel/helper-annotate-as-pure@^7.8.3":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.8.3.tgz#60bc0bc657f63a0924ff9a4b4a0b24a13cf4deee"
Expand Down Expand Up @@ -281,6 +291,11 @@
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.9.4.tgz#68a35e6b0319bbc014465be43828300113f2f2e8"
integrity sha512-bC49otXX6N0/VYhgOMh4gnP26E9xnDZK3TmbNpxYzzz9BQLBosQwfyOe9/cXUU3txYhTzLCbcqd5c8y/OmCjHA==

"@babel/parser@^7.7.5", "@babel/parser@^7.9.0":
version "7.9.4"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.9.4.tgz#68a35e6b0319bbc014465be43828300113f2f2e8"
integrity sha512-bC49otXX6N0/VYhgOMh4gnP26E9xnDZK3TmbNpxYzzz9BQLBosQwfyOe9/cXUU3txYhTzLCbcqd5c8y/OmCjHA==

"@babel/plugin-proposal-async-generator-functions@^7.8.3":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.8.3.tgz#bad329c670b382589721b27540c7d288601c6e6f"
Expand Down Expand Up @@ -938,6 +953,15 @@
lodash "^4.17.13"
to-fast-properties "^2.0.0"

"@babel/types@^7.9.0":
version "7.9.0"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.9.0.tgz#00b064c3df83ad32b2dbf5ff07312b15c7f1efb5"
integrity sha512-BS9JKfXkzzJl8RluW4JGknzpiUV7ZrvTayM6yfqLTVBEnFtyowVIOu6rqxRd5cVO6yGoWf4T8u8dgK9oB+GCng==
dependencies:
"@babel/helper-validator-identifier" "^7.9.0"
lodash "^4.17.13"
to-fast-properties "^2.0.0"

"@base2/[email protected]":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@base2/pretty-print-object/-/pretty-print-object-1.0.0.tgz#860ce718b0b73f4009e153541faff2cb6b85d047"
Expand Down Expand Up @@ -8401,6 +8425,13 @@ json5@^2.1.1, json5@^2.1.2:
dependencies:
minimist "^1.2.5"

json5@^2.1.2:
version "2.1.3"
resolved "https://registry.yarnpkg.com/json5/-/json5-2.1.3.tgz#c9b0f7fa9233bfe5807fe66fcf3a5617ed597d43"
integrity sha512-KXPvOm8K9IJKFM0bmdn8QXh7udDh1g/giieX0NLCaMnb4hEiVFqnop2ImTXCc5e0/oHz3LTqmHGtExn5hfMkOA==
dependencies:
minimist "^1.2.5"

jsonfile@^2.1.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8"
Expand Down
3 changes: 3 additions & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ de:
not_found:
header_message: 'Diese Seite existiert nicht'
empty_params: 'Kann nicht leer sein'
tasks:
plural: 'Aufgaben'
groups:
singular: Gruppe
plural: Gruppen
Expand Down Expand Up @@ -985,6 +987,7 @@ de:
describe: 'Beschreibe deine Strategie.'
strategies_label: >-
Welche Strategien helfen dir, auf diese Gedanken zu kommen?
mark_as_finished: 'Als fertig markieren'
name_hint: >-
Jegliche Aktivität, Gedankengang oder Form von Selbsthilfe, die
dich weiterbringt
Expand Down
5 changes: 4 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ en:
not_found:
header_message: 'This page does not exist'
empty_params: 'Can''t be blank'
tasks:
plural: Tasks
groups:
singular: Group
plural: Groups
Expand Down Expand Up @@ -521,7 +523,7 @@ en:
We're always looking for ideas from everyone,
including <strong>mental health advocates</strong>,
<strong>health professionals</strong>, <strong>software
developers</strong>, <strong>translators</strong>, and
developers</strong>,<strong>translators</strong>, and
<strong>user experience designers</strong>!
<p class="noMarginBottom">Please %{email_link} and
we'll connect with you! You will be invited to
Expand Down Expand Up @@ -917,6 +919,7 @@ en:
form:
describe: 'Describe the strategy.'
strategies_label: 'What strategies would help achieve these thoughts?'
mark_as_finished: 'Mark as Finished'
name_hint: >-
Any activity, train of thought, or form or self-care that
helps you
Expand Down
3 changes: 3 additions & 0 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ es:
not_found:
header_message: 'Esta página no existe'
empty_params: 'No puede estar en blanco'
tasks:
plural: Tareas
groups:
singular: Grupo
plural: Grupos
Expand Down Expand Up @@ -820,6 +822,7 @@ es:
describe: 'Describir estrategia'
strategies_label: '¿Qué estrategias ayudarían a conseguir estos
pensamientos?'
mark_as_finished: 'Marcar como terminada'
name_hint: 'Cualquier actividad, tren de pensamiento, o forma de auto
cuidado que te ayude'
viewers_hint: 'Los aliados que pueden ver tu estrategia y etiquetar con
Expand Down
3 changes: 3 additions & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ fr:
not_found:
header_message: "Cette page n'existe pas"
empty_params: 'Ne peut pas être vide'
tasks:
plural: Tâches
groups:
singular: Groupe
plural: Groupes
Expand Down Expand Up @@ -962,6 +964,7 @@ fr:
strategies_label: >-
Quelles stratégies aideraient à atteindre cet état
d''esprit ?
mark_as_finished: 'Marquer comme terminé'
name_hint: >-
Une activité, fil de pensées ou pratique de bien-être qui vous
aide.
Expand Down
Loading