This repository has been archived by the owner on Nov 10, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
/
pinboard.js
102 lines (84 loc) · 3.19 KB
/
pinboard.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
"use strict";
treeherder.controller('PinboardCtrl', [
'$scope', '$rootScope', 'thEvents', 'thPinboard', 'thNotify', 'ThLog',
function PinboardCtrl(
$scope, $rootScope, thEvents, thPinboard, thNotify, ThLog) {
var $log = new ThLog(this.constructor.name);
$rootScope.$on(thEvents.jobPin, function(event, job) {
$scope.pinJob(job);
if(!$scope.$$phase){
$scope.$digest();
}
});
$scope.pinJob = function(job) {
thPinboard.pinJob(job);
if (!$scope.selectedJob) {
$scope.viewJob(job);
}
};
$scope.pinSelectedJob = function() {
thPinboard.pinJob($scope.selectedJob);
};
$scope.unPinJob = function(id) {
thPinboard.unPinJob(id);
};
$scope.addBug = function(bug) {
thPinboard.addBug(bug);
};
$scope.removeBug = function(id) {
thPinboard.removeBug(id);
};
$scope.unPinAll = function() {
thPinboard.unPinAll();
};
$scope.save = function() {
if ($scope.user.loggedin) {
if ($scope.enteringBugNumber) {
// we should save this for the user, as they likely
// just forgot to hit enter.
$scope.saveEnteredBugNumber();
}
$scope.classification.who = $scope.user.email;
thPinboard.save($scope.classification);
$rootScope.selectedJob = null;
} else {
thNotify.send("must be logged in to classify jobs", "danger");
}
};
$scope.saveClassificationOnly = function() {
if ($scope.user.loggedin) {
$scope.classification.who = $scope.user.email;
thPinboard.saveClassificationOnly($scope.classification);
} else {
thNotify.send("must be logged in to classify jobs", "danger");
}
};
$scope.saveBugsOnly = function() {
if ($scope.user.loggedin) {
thPinboard.saveBugsOnly();
} else {
thNotify.send("must be logged in to classify jobs", "danger");
}
};
$scope.hasPinnedJobs = function() {
return thPinboard.hasPinnedJobs();
};
$scope.toggleEnterBugNumber = function() {
$scope.enteringBugNumber = !$scope.enteringBugNumber;
$scope.focusInput = $scope.enteringBugNumber;
};
$scope.saveEnteredBugNumber = function() {
$log.debug("new bug number to be saved: ", $scope.newEnteredBugNumber);
thPinboard.addBug({id:$scope.newEnteredBugNumber});
$scope.toggleEnterBugNumber();
};
$scope.viewJob = function(job) {
$rootScope.selectedJob = job;
$rootScope.$broadcast(thEvents.jobClick, job);
$rootScope.$broadcast(thEvents.selectJob, job);
};
$scope.classification = thPinboard.createNewClassification();
$scope.pinnedJobs = thPinboard.pinnedJobs;
$scope.relatedBugs = thPinboard.relatedBugs;
}
]);