Skip to content

Commit 525da41

Browse files
committed
Fixed initial index, schedule lines, and related things.
1 parent 55a6e66 commit 525da41

File tree

6 files changed

+18
-14
lines changed

6 files changed

+18
-14
lines changed

assets/src/modules/sm/App/controllers/AppController.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ angular.module('sm').controller("AppController", function($scope, localStorage,
7676
if(!$scope.state.displayOptions.hasOwnProperty('creditWarning') || !$scope.state.displayOptions.creditWarning) {
7777
$scope.state.displayOptions.creditWarning = 18;
7878
}
79+
if($scope.state.schedules.length > 0 && $scope.state.schedules[0].length > 0 && !$scope.state.schedules[0][0].hasOwnProperty('initialIndex')){
80+
for (var count = 0; count < $scope.state.schedules.length; count++) {
81+
$scope.state.schedules[count][0].initialIndex = count;
82+
}
83+
}
7984
} else {
8085

8186
// Before state meta

assets/src/modules/sm/App/directives/paginationControlsDirective.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ angular.module('sm').directive('paginationControls', function() {
1212
link: {
1313
pre: function(scope) {
1414
scope.numberOfPages = function() {
15-
return Math.ceil(scope.totalLength / scope.displayOptions.pageSize);
15+
var numPages = Math.ceil(scope.totalLength / scope.displayOptions.pageSize);
16+
if(scope.displayOptions.currentPage == numPages) {
17+
scope.displayOptions.currentPage = numPages - 1;
18+
}
19+
return numPages;
1620
};
1721
},
1822
post: function(scope, elm, attrs) {

assets/src/modules/sm/Generate/controllers/GenerateController.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ angular.module('sm').controller("GenerateController", function($scope, globalKbd
186186
$scope.state.displayOptions.currentPage = 0;
187187
$scope.scrollToSchedules();
188188

189-
for (var count = 0; count < schedules.length; count++) {
190-
schedules[count].initialIndex = count;
189+
for (var count = 0; count < data.schedules.length; count++) {
190+
data.schedules[count][0].initialIndex = count;
191191
}
192192

193193
$scope.state.schedules = data.schedules;

assets/src/modules/sm/Schedule/directives/scheduleActionsDirective.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ angular.module('sm').directive('scheduleActions', function($http, $q, shareServi
155155
hide: function() {
156156
ga('send', 'event', 'schedule', 'hide');
157157
scope.$parent.$parent.state.schedules.splice(scope.$index, 1);
158-
$timeout(scope.redraw, 10);
159158
}
160159
}
161160
};

assets/src/modules/sm/Schedule/directives/scheduleDirective.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ angular.module('sm').directive('schedule', function($timeout, $filter) {
189189
templateUrl: '/<%=modulePath%>Schedule/templates/scheduleitem.min.html',
190190
link: {
191191
pre: function(scope, elm, attrs) {
192+
if (scope.schedule.length > 0) {
193+
scope.initialIndex = scope.schedule[0].initialIndex;
194+
}
195+
192196
scope.scheduleController = new Schedule(scope);
193197
scope.itemEnter = function($event) {
194198
var $target = $($event.target),
@@ -225,7 +229,6 @@ angular.module('sm').directive('schedule', function($timeout, $filter) {
225229
if(scope.scheduleController.init(options)) {
226230
// Only redraw if valid options
227231
scope.scheduleController.draw();
228-
console.log("poop");
229232

230233
// Fix pixel alignment issues
231234
$timeout(function() {
@@ -243,13 +246,6 @@ angular.module('sm').directive('schedule', function($timeout, $filter) {
243246
},10,true);
244247
}
245248
};
246-
scope.redraw = function() {
247-
if(!scope.overrideDrawOptions) {
248-
update(scope.state.drawOptions);
249-
} else {
250-
update(scope.overrideDrawOptions);
251-
}
252-
};
253249

254250
if(!scope.overrideDrawOptions) {
255251
scope.$watchCollection('state.drawOptions', update);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div ng-show="!print" class="panel-heading">
33
<div class="row form-horizontal">
44
<div class="col-xs-12">
5-
<h2 class="panel-title control-label pull-left smaller-sm">{{saveAction == "create"?("Schedule " + (state.schedules.indexOf(schedule) + 1)):"My Schedule"}}</h2>
5+
<h2 class="panel-title control-label pull-left smaller-sm">{{saveAction == "create"?("Schedule " + (initialIndex + 1)):"My Schedule"}}</h2>
66
<div class="btn-group pull-right hidden-xs hidden-sm">
77
<div class="btn-group">
88
<button ng-click="scheduleActions.save(saveAction)" type="button" class="btn btn-primary"><i class="fa" ng-class="{'fa-save': saveAction == 'create', 'fa-copy': saveAction == 'fork'}"></i> {{saveAction == "create"?"Save":"Copy and Edit"}} </button>
@@ -69,7 +69,7 @@ <h2 class="panel-title control-label pull-left smaller-sm">{{saveAction == "crea
6969
</div>
7070
<div class="schedule-cont">
7171
<div class="schedule-track" ng-class="mobileTrackClass">
72-
<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" ng-attr-id="day{{$index}}" 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}}" ng-attr-fill="url(#day{{$index}})" /></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><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><g svg-text-content="item.content"></g></g></g></svg>
72+
<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><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><g svg-text-content="item.content"></g></g></g></svg>
7373
</div>
7474
</div>
7575
<div ng-if="!print && totalCredits > state.displayOptions.creditWarning" class="row">

0 commit comments

Comments
 (0)