Skip to content

Commit 366114f

Browse files
committed
fixed datatable
1 parent 6784150 commit 366114f

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

app/assets/stylesheets/project4.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ form button:hover, form button:active {
6262
background-color: #7b9095;
6363
}
6464

65+
.dataTables_scrollHeadInner{
66+
padding: 0 !important;
67+
}
68+
6569
.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default, .ui-button, html .ui-button.ui-state-disabled:hover, html .ui-button.ui-state-disabled:active{
6670
background-color: #b4bfba;
6771
}

app/controllers/plans_controller.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ def index
1515
# GET /plans/1
1616
# GET /plans/1.json
1717
def show
18+
if @plan.user_id != current_user.id
19+
redirect_to plans_path
20+
end
1821
end
1922

2023
# GET /plans/new

app/javascript/packs/myjs.js

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ window.getAllPlans = function(){
4545
{ "data": "open" }
4646
],
4747
"paging": false,
48-
"scrollCollapse": false
4948
});
5049
$('.dataTables_scrollHeadInner').css('padding', '0');
5150
planTableLoaded = true;
@@ -101,7 +100,7 @@ window.getPlan = function(){
101100
],
102101
"scrollY": "95px",
103102
"paging": false,
104-
"scrollCollapse": false
103+
"scrollCollapse": false
105104
});
106105
$('.dataTables_scrollHeadInner').css('padding', '0');
107106
catalogLoaded = true;
@@ -223,6 +222,7 @@ window.dropOnPlan = function(event){
223222
else{
224223
// From catalog table
225224
currPlan.hrsTotal += draggedCourse.credits;
225+
removeFromRequirements(draggedCourse.designator);
226226
}
227227
// add to javascript plan object
228228
let destTerm = event.target.children[0].children[0].innerText.split(" ")[0];
@@ -281,10 +281,42 @@ window.dropInTrash = function(event){
281281
$("#hrsCurrent").html("Current Hours: " + currPlan.hrsCurrent);
282282
$("#hrsFuture").html("Remaining Hours: " + currPlan.hrsFuture);
283283
$("#hrsTotal").html("Total Hours Planned: " + currPlan.hrsTotal);
284+
285+
addToRequirements(draggedCourse.designator);
284286
}
285287
draggedCourse = null;
286288
}
287289

290+
// Unhide requirement if removed from plan
291+
window.addToRequirements = function(designator){
292+
let acc = $('#accordion').get()[0];
293+
for (let i=1; i<acc.children.length; i+=2){
294+
let accChild = acc.children[i];
295+
for (let j = 0; j<accChild.children.length; j++){
296+
let req = accChild.children[j];
297+
if (req.innerText.includes(designator)){
298+
req.removeAttribute('hidden');
299+
return;
300+
}
301+
}
302+
}
303+
}
304+
305+
// Hide requirement if added from catalog table
306+
window.removeFromRequirements = function(designator){
307+
let acc = $('#accordion').get()[0];
308+
for (let i=1; i<acc.children.length; i+=2){
309+
let accChild = acc.children[i];
310+
for (let j = 0; j<accChild.children.length; j++){
311+
let req = accChild.children[j];
312+
if (req.innerText.includes(designator)){
313+
req.setAttribute('hidden', true);
314+
return;
315+
}
316+
}
317+
}
318+
}
319+
288320
class Course {
289321
constructor(desig, year, term){
290322
this.term = term;

0 commit comments

Comments
 (0)