-
Notifications
You must be signed in to change notification settings - Fork 5
/
ISLabel.j
81 lines (65 loc) · 1.59 KB
/
ISLabel.j
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
/*
* ISLabel.j
* GithubIssues
*
* Created by Alexander Ljungberg on May 11, 2011.
* Copyright 2011, WireLoad Inc. All rights reserved.
*/
/*!
Represent a GitHub label.
*/
@implementation ISLabel : CPObject
{
unsigned labelID @accessors;
CPString name @accessors;
CPURL url @accessors;
CPColor color @accessors;
unsigned numberOfIssues @accessors;
}
+ (CPSet)keyPathsForValuesAffectingSidebarRepresentation
{
return [CPSet setWithObjects:"name", "color"];
}
+ (id)labelWithJSObject:(JSObject)anObject
{
var newLabel = [ISLabel new];
[newLabel setName:anObject['name']];
[newLabel setUrl:[CPURL URLWithString:anObject['url']]];
[newLabel setColor:[CPColor colorWithHexString:anObject['color']]];
[newLabel setLabelID:[[[newLabel url] pathComponents] lastObject]];
return newLabel;
}
- (id)copy
{
var newLabel = [ISLabel new];
newLabel.name = name;
newLabel.url = url;
newLabel.color = color;
newLabel.numberOfIssues = numberOfIssues;;
return newLabel;
}
- (BOOL)isEqual:(ISLabel)anotherLabel
{
// If the URLs are the same then they represent the same label
// on Github, thus they must be equal.
return [anotherLabel url] === url;
}
- (id)init
{
self = [super init];
numberOfIssues = 0;
return self;
}
- (BOOL)isUsed
{
return numberOfIssues > 0;
}
/*!
This is a proxy used to be able to bind the main label sidebar column to a keypath which properly
notifies when any of the values in the compound dataview change.
*/
- (ISLabel)sidebarRepresentation
{
return self;
}
@end