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

Fix Required Fields #241

Merged
merged 2 commits into from
Jan 25, 2016
Merged
Changes from 1 commit
Commits
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
20 changes: 20 additions & 0 deletions app/src/main/assets/chart.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
<script src="jquery-1.5.1.min.js"></script>
<script src="freezeheader.js"></script>
<script src="chart.js"></script>
<script>
function isRowEmpty(parentNode) {
Copy link
Member

Choose a reason for hiding this comment

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

This should probably go in chart.js

Copy link
Member

Choose a reason for hiding this comment

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

Actually, can we do this in pebble instead of in JS? It would fit better with our current programming model that way, and I think it would be more performant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@capnfabs I tried but pebble worn me out. There is a bug regarding variable scope in pebble and that's why I choose this solution. We really need to revome pebble as soon as possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@capnfabs Trust me, that wasn't my first option.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

var rowEmpty = true;
$(parentNode).find('td').each(function(index, element) {
var innerHtml = element.innerHTML.trim();
if ( innerHtml != "" ) {
rowEmpty = false;
}
});
return rowEmpty;
}
</script>

<!-- Use double-quotes for HTML attributes; single-quotes for JS/Pebble strings. -->
<body>
Expand Down Expand Up @@ -99,6 +111,14 @@
{% endif %}
</td>
{% endfor %}
<script>
// Hides the row if not required and no observation is recorded.
if (!{{row.item.required}}) {
if (isRowEmpty(document.currentScript.parentNode)) {
document.currentScript.parentNode.style.display = 'none';
}
}
</script>
</tr>
{% endfor %}
</tbody>
Expand Down