Skip to content

Commit

Permalink
Update filter on dashboard (#7843)
Browse files Browse the repository at this point in the history
* update filter

* update filter

* wiki adjusted

* changed viewport
  • Loading branch information
keshavsethi authored Jun 3, 2020
1 parent 4b1ede8 commit 8817870
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 16 deletions.
52 changes: 44 additions & 8 deletions app/assets/javascripts/dashboard.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,46 @@
$(document).ready(function () {
$('#selectall').click(function () {
$('.node-type').prop('checked', this.checked);
});

$('.node-type').change(function () {
var check = ($('.node-type').filter(":checked").length == $('.node-type').length);
$('#selectall').prop("checked", check);
});
});
var viewport = function() {
var e = window, a = 'inner';
if (!('innerWidth' in window )) {
a = 'client';
e = document.documentElement || document.body;
}
return { width : e[ a+'Width' ] , height : e[ a+'Height' ] };
}
function listselect(){
var types = [
'note',
'question',
'event',
'comment',
'wiki'
];


var selected = [];
$('#checkboxes input:checked').each(function() {
selected.push($(this).attr('data-type'));
});
let intersection = types.filter(x => selected.includes(x));
let difference = types.filter(x => !selected.includes(x));
for(var i=0;i<intersection.length;i++){
if (!(intersection[i] == 'wiki' && viewport().width > 992)){
$('.note-container-' + intersection[i]).show();
}
}
for(var j=0;j<difference.length;j++){
$('.note-container-' + difference[j]).hide();
}
}

(function() {

Expand All @@ -9,15 +51,9 @@
'comment': true,
'wiki': true
};



var viewport = function() {
var e = window, a = 'inner';
if (!('innerWidth' in window )) {
a = 'client';
e = document.documentElement || document.body;
}
return { width : e[ a+'Width' ] , height : e[ a+'Height' ] };
}

var setTypeVisibility = function(type, checked) {

Expand Down
16 changes: 8 additions & 8 deletions app/views/dashboard/_activity.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,42 +23,42 @@
<span class="caret"></span>
</button>

<div class="dropdown-menu">
<a class="form-check dropdown-item" href="#">
<div class="dropdown-menu" id="checkboxes">
<a class="form-check dropdown-item" href="#" onclick="listselect()">
<label class="form-check-label">
<input data-type="all" class="node-type-all" type="checkbox" checked="checked" />
<input data-type="all" class="node-type-all" type="checkbox" checked="checked" id="selectall" />
<%= translation('dashboard._activity.dropdown.all') %>
</label>
</a>

<div class="dropdown-divider"></div>

<a class="form-check dropdown-item" href="#">
<a class="form-check dropdown-item" href="#" onclick="listselect()">
<label class="form-check-label">
<input data-type="note" class="node-type node-type-note" type="checkbox" checked="checked" />
<%= translation('dashboard._activity.dropdown.research_notes') %>
</label>
</a>
<a class="form-check dropdown-item" href="#">
<a class="form-check dropdown-item" href="#" onclick="listselect()">
<label class="form-check-label">
<input data-type="question" class="node-type node-type-question" type="checkbox" checked="checked" />
<%= translation('dashboard._activity.dropdown.question') %>
</label>
</a>
<a class="form-check dropdown-item" href="#">
<a class="form-check dropdown-item" href="#" onclick="listselect()">
<label class="form-check-label">
<input data-type="event" class="node-type node-type-event" type="checkbox" checked="checked" />
<%= translation('dashboard._activity.dropdown.events') %>
</label>
</a>
<a class="form-check dropdown-item" href="#">
<a class="form-check dropdown-item" href="#" onclick="listselect()">
<label class="form-check-label">
<input data-type="comment" class="node-type node-type-comment" type="checkbox" checked="checked" />
<%= translation('dashboard._activity.dropdown.comments') %>
</label>
</a>

<a class="d-lg-none dropdown-item" href="#">
<a class="d-lg-none dropdown-item" href="#" onclick="listselect()">
<label>
<input data-type="wiki" class="node-type node-type-wiki" type="checkbox" checked="checked" />
<%= translation('dashboard._activity.dropdown.wiki') %>
Expand Down

0 comments on commit 8817870

Please sign in to comment.