Skip to content

Commit

Permalink
was testing out various solutions for action items
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleqhua committed May 8, 2020
1 parent 2a08f92 commit 6ef68e4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
6 changes: 6 additions & 0 deletions app/controllers/api/assignments_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'json'
class Api::AssignmentsController < ApplicationController
before_action :set_assignment, only: [:show, :update, :destroy]
before_action :set_template, only: [:show_template, :update_template, :destroy_template]
Expand Down Expand Up @@ -198,8 +199,13 @@ def action_item_params
end

def bulk_assignment_params
puts params
# puts JSON.parse(params['assignments'])
# params['assignments'] = JSON.parse(params['assignments']).to_s.delete_suffix(']')
all_assignment_params = params.permit(assignments: [:title, :description, :due_date, :category, :file], participant_ids: [])
end



def assignment_params
puts "i am in assignments params"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def sentry_helper(professional_questionnaire)

# may not work
def questionnaire_params
puts params
questionnaire_params = params.require(:professional_questionnaire).permit(:participant_id, :course_completion,
:work_history, :job_search_materials, :professional_goals,
:barriers, :education_history, :begin_skills_assessment_date, :end_skills_assessment_date,
Expand Down
8 changes: 7 additions & 1 deletion app/javascript/components/ActionItemCreationPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class ActionItemCreationPage extends React.Component {
description: actionItem.description,
due_date: actionItem.dueDate,
category: actionItem.category,
file: actionItem.file
}));

// let assignments = [];
Expand All @@ -114,12 +115,17 @@ class ActionItemCreationPage extends React.Component {
participant_ids: participantIds,
};
const formData = new FormData();
formData.append('assignments', assignments);
formData.append('assignments', JSON.stringify(assignments));
formData.append('participant_ids', participantIds);
console.log("this is the body")
console.log(body);
console.log("this is form data");
console.log(formData);
for (var pair of formData.entries()) {
console.log(pair[0] + ', ' + pair[1]);
}
console.log(assignments);
console.log(assignments[0]);
apiPost('/api/assignments', formData)
.then((res) => console.log(res))
.catch(error => {
Expand Down
6 changes: 3 additions & 3 deletions app/javascript/components/QuestionnaireForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ class QuestionnaireForm extends React.Component {
formData.append(`${qType}[resume]`, this.state.file);
formData.append(`${qType}[participant_id]`, this.props.participantId);

for (var pair of formData.entries()) {
console.log(pair[0] + ', ' + pair[1]);
}
// for (var pair of formData.entries()) {
// console.log(pair[0] + ', ' + pair[1]);
// }

const { id } = this.props.questionnaire;
const request = `/api/${qType}s/${id}`;
Expand Down

0 comments on commit 6ef68e4

Please sign in to comment.