Skip to content

Commit 2ace9a6

Browse files
committed
WIP fix to make print view save configuration settings. (Works fine except state is lost when main page is refreshed.)
1 parent f5a42b7 commit 2ace9a6

File tree

3 files changed

+36
-32
lines changed

3 files changed

+36
-32
lines changed

assets/src/modules/sm/Schedule/controllers/SchedulePrintController.js

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,37 +24,41 @@ angular.module('sm').controller("SchedulePrintController", function($scope, $loc
2424
}
2525

2626
$scope.heading = "My " + year + "-" + (year+1) + " " + term + " Schedule";
27+
}
2728

28-
$scope.printTheme = 'woc';
29-
30-
$scope.printThemeOptions = [{
31-
value: 'woc',
32-
label: "Modern Colors"
33-
}, {
34-
value: 'bow',
35-
label: "Classic B&W"
36-
}, {
37-
value: 'gow',
38-
label: "Classic Greyscale"
39-
}, {
40-
value: 'boc',
41-
label: "Black Text & Colors"
42-
}];
43-
44-
$scope.printClassDetails = 'NPL';
45-
46-
$scope.printClassDetailsOptions = [{
47-
value: 'NPL',
48-
label: "Number, Professor, Location"
49-
}, {
50-
value: 'LPN',
51-
label: "Location, Professor, Number"
52-
}, {
53-
value: 'LNP',
54-
label: "Location, Number, Professor"
55-
}];
29+
if (!$scope.state.printTheme) {
30+
$scope.state.printTheme = 'woc';
5631
}
5732

33+
$scope.printThemeOptions = [{
34+
value: 'woc',
35+
label: "Modern Colors"
36+
}, {
37+
value: 'bow',
38+
label: "Classic B&W"
39+
}, {
40+
value: 'gow',
41+
label: "Classic Greyscale"
42+
}, {
43+
value: 'boc',
44+
label: "Black Text & Colors"
45+
}];
46+
47+
if (!$scope.state.printClassDetails) {
48+
$scope.state.printClassDetails = 'NPL';
49+
}
50+
51+
$scope.printClassDetailsOptions = [{
52+
value: 'NPL',
53+
label: "Number, Professor, Location"
54+
}, {
55+
value: 'LPN',
56+
label: "Location, Professor, Number"
57+
}, {
58+
value: 'LNP',
59+
label: "Location, Number, Professor"
60+
}];
61+
5862
localStorage.setItem("reloadSchedule", null);
5963

6064
$scope.printFn = window.print.bind(window);

assets/src/modules/sm/Schedule/templates/schedule.print.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ <h3 class="panel-title">
2020
<div class="form-group">
2121
<label for="printOptions-theme" class="col-sm-4 control-label">Theme:</label>
2222
<div class="col-sm-8">
23-
<select id="printOptions-theme" class="form-control" ng-model="printTheme" ng-options="opt.value as opt.label for opt in printThemeOptions"></select>
23+
<select id="printOptions-theme" class="form-control" ng-model="state.printTheme" ng-options="opt.value as opt.label for opt in printThemeOptions"></select>
2424
</div>
2525
</div>
2626
</div>
2727
<div class="col-sm-9">
2828
<div class="form-group">
2929
<label for="printOptions-classDetails" class="col-sm-3 control-label">Class Details:</label>
3030
<div class="col-sm-7">
31-
<select id="printOptions-classDetails" class="form-control" ng-model="printClassDetails" ng-options="opt.value as opt.label for opt in printClassDetailsOptions"></select>
31+
<select id="printOptions-classDetails" class="form-control" ng-model="state.printClassDetails" ng-options="opt.value as opt.label for opt in printClassDetailsOptions"></select>
3232
</div>
3333
</div>
3434
</div>
@@ -42,4 +42,4 @@ <h3 class="panel-title">
4242
</div>
4343
</div>
4444
<h2 id="print_header" class="center" ng-bind="heading"></h2>
45-
<div ng-class="printTheme" schedule print="true"></div>
45+
<div ng-class="state.printTheme" schedule print="true"></div>

assets/src/modules/sm/Schedule/templates/scheduleitem.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ <h2 class="panel-title control-label pull-left smaller-sm">{{saveAction == "crea
7070
<div class="schedule-cont">
7171
<div class="schedule-track" ng-class="mobileTrackClass">
7272
<svg version="1.1" ng-attr-height="{{grid.opts.height}}" width="100%" xmlns="http://www.w3.org/2000/svg"><defs><pattern vector-effect="non-scaling-stroke" id="day{{initialIndex}}" width="100%" x="0" height="40" patternUnits="userSpaceOnUse"><line vector-effect="non-scaling-stroke" x1="0" y1="19.5" x2="100%" y2="19.5" style="stroke:#bbb;stroke-width:1" /></pattern></defs><rect x="0" y="0" width="100%" height="100%" fill="#ffffff" /><g ng-attr-transform="{{grid.opts.pixelAlignment}}" font-family="Roboto" font-size="15"><g class="svg-schedule-hours"><text fill="#aaa" text-anchor="end" ng-repeat="hour in grid.hours track by $index" ng-attr-x="{{print?'41':'5%'}}" ng-attr-y="{{($index * 40) + 25}}">{{hour}}</text></g><g ng-repeat="day in grid.days"><text y="12" ng-attr-x="{{day.offset}}" ng-attr-width="{{grid.opts.daysWidth}}" fill="#aaa" ng-bind="day.name"></text><rect y="19" ng-attr-x="{{day.offset}}" ng-attr-width="{{grid.opts.daysWidth}}" ng-attr-height="{{grid.opts.daysHeight}}" fill="url(#day{{initialIndex}})" /></g><g svg-schedule-item class="item" ng-mouseenter="itemEnter($event)" ng-mouseleave="itemLeave($event)" ng-repeat="item in scheduleItems | orderBy:'-boundry.y'"><rect ng-attr-x="{{item.boundry.x}}" ng-attr-y="{{item.boundry.y}}" ng-attr-width="{{item.boundry.width}}" ng-attr-height="{{item.boundry.height}}" ng-attr-fill="{{item.color}}" fill-opacity=".8" /><rect ng-if="item.boundry.shorten != 0" ng-attr-x="{{item.boundry.x}}" ng-attr-y="{{item.boundry.shorten < 0 ?item.boundry.y : item.boundry.y + item.boundry.height - 2}}" ng-attr-width="{{item.boundry.width}}" height="2" fill="#ffff00" /><text svg-text-line="{{item.title}}" ng-attr-x="{{item.boundry.x}}" ng-attr-y="{{item.boundry.y + 16}}" transform="translate(3,0)" font-weight="bold" fill="white"></text>
73-
<g ng-switch="printClassDetails">
73+
<g ng-switch="state.printClassDetails">
7474
<g ng-switch-default>
7575
<text ng-if="item.boundry.height > 32 && item.content.courseNum" svg-text-line="{{item.content.courseNum}}" ng-attr-x="{{item.boundry.x}}" ng-attr-y="{{item.boundry.y + 32}}" transform="translate(3,0)" fill="#fff"></text><text ng-if="item.boundry.height > 48 && item.content.instructor" svg-text-line="{{item.content.instructor}}" ng-attr-x="{{item.boundry.x}}" ng-attr-y="{{item.boundry.y + 48}}" transform="translate(3,0)" fill="#fff"></text><text ng-if="item.boundry.height > 64 && item.content.location" svg-text-line="{{item.content.location}}" ng-attr-x="{{item.boundry.x}}" ng-attr-y="{{item.boundry.y + 64}}" transform="translate(3,0)" fill="#fff"></text>
7676
</g>

0 commit comments

Comments
 (0)