Skip to content

Commit

Permalink
Merge pull request #31 from FAC-Sixteen/fix/remove-opinion-ids
Browse files Browse the repository at this point in the history
remove opinion ids from index, getData and script
  • Loading branch information
dubhcait authored Apr 12, 2019
2 parents 924c2d1 + cf0f740 commit 0721a11
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 34 deletions.
1 change: 0 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ <h1>Hello Onions</h1>
<section class="opinion-section">
<table class="opinion-table">
<tr>
<th>ID</th>
<th>Name</th>
<th>Opinion</th>
<th>Date</th>
Expand Down
64 changes: 32 additions & 32 deletions public/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,44 @@ const opinionTable = document.querySelector('.opinion-table');
const formActionId = document.querySelector('#form-id-to-send');

const buildEachRow = (data, tableToFill) => {
console.log('This is the data:', data);
while(tableToFill.childNodes[2]) {
tableToFill.removeChild(tableToFill.childNodes[2])
};

const inputs = data;

while(tableToFill.childNodes[2]) {
tableToFill.removeChild(tableToFill.childNodes[2])
};

const inputs = data;
inputs.forEach((input) => {
const inputRow = document.createElement('tr');

inputRow.value = input.id;
inputs.forEach((input) => {
const inputRow = document.createElement('tr');
inputRow.value = input.id;

if (tableToFill === actionTable) {
const inputId = document.createElement('td');
inputId.textContent = input.id;
inputRow.appendChild(inputId);

if (tableToFill === actionTable) {
const inputAction = document.createElement('td');
inputAction.textContent = input.action_point;
inputRow.appendChild(inputAction);
} else {
const inputName = document.createElement('td');
inputName.textContent = input.name;
const inputOpinion = document.createElement('td');
inputOpinion.textContent = input.opinion;
inputRow.appendChild(inputName);
inputRow.appendChild(inputOpinion);
}

const inputDate = document.createElement('td');
inputDate.textContent = input.date;
inputRow.appendChild(inputDate);

if (tableToFill === actionTable) {
inputRow.addEventListener('click', getOpinionTable );
}
tableToFill.appendChild(inputRow);
});
const inputAction = document.createElement('td');
inputAction.textContent = input.action_point;
inputRow.appendChild(inputAction);

} else if (tableToFill === opinionTable) {
const inputName = document.createElement('td');
inputName.textContent = input.name;
inputRow.appendChild(inputName);

const inputOpinion = document.createElement('td');
inputOpinion.textContent = input.opinion;
inputRow.appendChild(inputOpinion);
}

const inputDate = document.createElement('td');
inputDate.textContent = input.date;
inputRow.appendChild(inputDate);

if (tableToFill === actionTable) {
inputRow.addEventListener('click', getOpinionTable );
}
tableToFill.appendChild(inputRow);
});
};

//on load function to get current actions table
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/queries/getData.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const actionQuery = cb => {
//FINISH THIS
const opinionQuery = (cb, url) => {
let id = url.split('=')[1];
dbConnection.query(`SELECT id, name, opinion, date FROM opinions WHERE action_id = $1`,[id],
dbConnection.query(`SELECT name, opinion, date FROM opinions WHERE action_id = $1`,[id],
(err, res) => {
if (err) return cb(err);
cb(null, res.rows);
Expand Down

0 comments on commit 0721a11

Please sign in to comment.