Skip to content

Commit

Permalink
Code cleanup up to SPBNullCard
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonia Heinen committed Jul 12, 2024
1 parent 72f6a9d commit e3326dd
Show file tree
Hide file tree
Showing 45 changed files with 172 additions and 129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,26 @@ buildFromRemoteProject: aJsonObject intoColumns: aDictionairy
"TODO: refactor this into smaller methods!"
columnID := (aJsonObject at: 'fieldValueByName') at: 'optionId'.
column := aDictionairy at: columnID.
column ifNil: [self error: 'The Card has no matching Column'.].
column
ifNil: [self error: 'The Card has no matching Column'.].
contentType := aJsonObject at: 'type'.
content := aJsonObject at: 'content'.
title := content at: 'title'.
body := content at: 'body'.
cardId := aJsonObject at: 'id'.
instance := self newWithTitle: title body: body id: cardId into: column.
isDraftIssue := contentType = 'DRAFT_ISSUE'.
isDraftIssue ifTrue: [instance isNote: true.].
isDraftIssue
ifTrue: [instance isNote: true.].
isIssueOrPR := (contentType = 'ISSUE') or: [contentType = 'PULL_REQUEST'].
instance
issueId: (content at: 'id');
assignees: (((content at: 'assignees') at: 'nodes') collect: [:each| SPBAssignee newFrom: each.]) asOrderedCollection;
labels: OrderedCollection new;
isClosed: (isDraftIssue not and: [content at: 'closed']).
isIssueOrPR ifTrue: [
instance labels: (((content at: 'labels') at: 'nodes') collect: [:each| SPBLabel newFrom: each.]) asOrderedCollection].
isIssueOrPR
ifTrue: [
instance labels: (((content at: 'labels') at: 'nodes') collect: [:each| SPBLabel newFrom: each.]) asOrderedCollection].
instance buildUI.
instance openInWorld.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
defaultCardExtent

^ 270@100.
^ 270 @ 100.
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,25 @@ applyUserInterfaceTheme

| textColor font |
super applyUserInterfaceTheme.
self color: ((self userInterfaceTheme get: #color for: PluggableButtonMorph) ifNil: [Color red]);
borderWidth: self borderWidthMultiplier * ((self userInterfaceTheme get: #borderWidth for: PluggableButtonMorph) ifNil: [1]);
borderColor: ((self userInterfaceTheme get: #borderColor for: PluggableButtonMorph) ifNil: [Color red]).
textColor := (self userInterfaceTheme get: #textColor for: PluggableButtonMorph) ifNil: [Color white].
self isHighlighted ifTrue: [
"make color and borderColor darker or lighter depending on color"
"if color is dark, make it lighter, else darker"
"this is what color makeForegroundColor is taking care of - it returns white or black"
self color: (self color alphaMixed: 0.75 with: self color makeForegroundColor).
self borderColor: (self color alphaMixed: 0.75 with: self color makeForegroundColor).
textColor := self color makeForegroundColor.
].
self color: ((self userInterfaceTheme get: #color for: PluggableButtonMorph)
ifNil: [Color red]);
borderWidth: self borderWidthMultiplier * ((self userInterfaceTheme get: #borderWidth for: PluggableButtonMorph)
ifNil: [1]);
borderColor: ((self userInterfaceTheme get: #borderColor for: PluggableButtonMorph)
ifNil: [Color red]).
textColor := (self userInterfaceTheme get: #textColor for: PluggableButtonMorph)
ifNil: [Color white].
self isHighlighted
ifTrue: [
"make color and borderColor darker or lighter depending on color"
"if color is dark, make it lighter, else darker"
"this is what color makeForegroundColor is taking care of - it returns white or black"
self color: (self color alphaMixed: 0.75 with: self color makeForegroundColor).
self borderColor: (self color alphaMixed: 0.75 with: self color makeForegroundColor).
textColor := self color makeForegroundColor.].
font := (self userInterfaceTheme get: #font for: PluggableButtonMorph).
self assigneeModel textColor: textColor; font: font.
self statusModel textColor: textColor; font: font.
self assigneeModel textColor: textColor;
font: font.
self statusModel textColor: textColor;
font: font.
self titleModel textColor: textColor.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
updating-local
calculateLabelPositionFor: aNumber

| label previousLabel firstAttempt |
| label previousLabel positionIfSameRow |
previousLabel := self labelModels at: aNumber - 1.
label := self labelModels at: aNumber.

firstAttempt := (previousLabel position x + previousLabel extent x + self labelBorderOffset) @ previousLabel position y.
firstAttempt x + label extent x <= (self extent x - self labelBorderOffset) ifTrue: [^ firstAttempt].
positionIfSameRow := (previousLabel position x + previousLabel extent x + self labelBorderOffset) @ previousLabel position y.
positionIfSameRow x + label extent x <= (self extent x - self labelBorderOffset)
ifTrue: [^ positionIfSameRow].

^ self labelBorderOffset @
(previousLabel position y + (previousLabel extent y + self inbetweenLabelOffset)).
3 changes: 2 additions & 1 deletion Squello-Core.package/SPBCard.class/instance/initialize.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ initialize
buildIndicatorDetection;
isHighlighted: false.

self isClosed ifNil: [self isClosed: false].
self isClosed
ifNil: [self isClosed: false].
6 changes: 4 additions & 2 deletions Squello-Core.package/SPBCard.class/instance/isClosed.st
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
accessing
isClosed

isClosed ifNil: [self isClosed: false].
^ isClosed
isClosed
ifNil: [self isClosed: false.
self updateStatus.].
^ isClosed.
3 changes: 2 additions & 1 deletion Squello-Core.package/SPBCard.class/instance/labels.st
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
accessing
labels

^ labels ifNil: [labels := OrderedCollection new].
^ labels
ifNil: [labels := OrderedCollection new].
12 changes: 6 additions & 6 deletions Squello-Core.package/SPBCard.class/instance/moveToTop.st
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
context menu
moveToTop

|index|
index := column cards indexOf: self.
column addCardToTop: self.
column cards removeAt: index+1.
column resizeToFitCards.
column alignCards.
| index |
index := column cards indexOf: self.
column addCardToTop: self.
column cards removeAt: index + 1.
column resizeToFitCards.
column alignCards.
15 changes: 7 additions & 8 deletions Squello-Core.package/SPBCard.class/instance/openContextMenu.st
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
context menu
openContextMenu

| menu |

menu := MenuMorph new defaultTarget: self.
menu add: 'remove all Labels' action: #removeAllLabels.
menu add: 'remove all Assignees' action: #removeAllAssignees.
menu add: 'move to top' action: #moveToTop.
menu add: 'toggle closed' action: #toggleClosed.
menu popUpInWorld.
| menu |
menu := MenuMorph new defaultTarget: self.
menu add: 'remove all Labels' action: #removeAllLabels.
menu add: 'remove all Assignees' action: #removeAllAssignees.
menu add: 'move to top' action: #moveToTop.
menu add: 'toggle closed' action: #toggleClosed.
menu popUpInWorld.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
context menu
removeAllAssignees

|size|
size := assignees size.
1 to: size do:[:a|self removeAssignee: assignees first].
"labels do:[:label | self removeLabel: label]."
self column board sidebar
changed: #potentialAssigneesList;
changed: #activeCardAssigneeList.
| size |
size := assignees size.
1 to: size do:[:a | self removeAssignee: assignees first.].
self column board sidebar
changed: #potentialAssigneesList;
changed: #activeCardAssigneeList.
13 changes: 6 additions & 7 deletions Squello-Core.package/SPBCard.class/instance/removeAllLabels.st
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
context menu
removeAllLabels

|size|
size := labels size.
1 to: size do:[:a|self removeLabel: labels first].
"labels do:[:label | self removeLabel: label]."
self column board sidebar
changed: #potentialLabelsList;
changed: #activeCardLabelList.
| size |
size := labels size.
1 to: size do:[:a | self removeLabel: labels first].
self column board sidebar
changed: #potentialLabelsList;
changed: #activeCardLabelList.
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ resizeIndicatorFields
self upperHalfIndicator
extent: self cardIndicatorExtent.
self lowerHalfIndicator
position: self position + (0@ self extent y / 2);
position: self position + (0 @ self extent y / 2);
extent: self cardIndicatorExtent.
4 changes: 3 additions & 1 deletion Squello-Core.package/SPBCard.class/instance/setCardHeight.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ updating-local
setCardHeight

| labelHeightsSum |
labelHeightsSum := self labelModels size = 0 ifTrue: [0] ifFalse: [self labelModels last position y + self labelModels last extent y - self labelModels first position y].
labelHeightsSum := self labelModels size = 0
ifTrue: [0]
ifFalse: [self labelModels last position y + self labelModels last extent y - self labelModels first position y].
self extent:
self class defaultCardExtent x @
((self titleModel extent y + labelHeightsSum + self labelTitleOffset + self statusModel extent y)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ accessing
setupMouseEvents

self on: #startDrag send: #startDragging to: self.
self on: #mouseDown send: #value: to:[:evt|
self on: #mouseDown send: #value: to:[:evt |
evt redButtonPressed ifTrue:[self becomeActiveCard].
evt yellowButtonPressed ifTrue:[self openContextMenu] ].
3 changes: 2 additions & 1 deletion Squello-Core.package/SPBCard.class/instance/title.st
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
accessing
title

^ title ifNil: [title := ''].
^ title
ifNil: [title := ''].
3 changes: 2 additions & 1 deletion Squello-Core.package/SPBCard.class/instance/toggleClosed.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
updating
toggleClosed

self isNote ifTrue: [^ self].
self isNote
ifTrue: [^ self].
self isClosed: self isClosed not.
self boardProvider updateCard: self.
8 changes: 6 additions & 2 deletions Squello-Core.package/SPBCard.class/instance/updateStatus.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
updating-local
updateStatus

self isNote ifTrue: [self statusModel contents: 'Note'. ^ self.].
self isClosed ifTrue: [self statusModel contents: 'Closed'. ^ self.].
self isNote
ifTrue: [self statusModel contents: 'Note'.
^ self.].
self isClosed
ifTrue: [self statusModel contents: 'Closed'.
^ self.].
self statusModel contents: 'Open'.
34 changes: 17 additions & 17 deletions Squello-Core.package/SPBCard.class/methodProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"class" : {
"buildFromLocal:into:" : "FP 7/2/2024 11:34",
"buildFromRemote:into:" : "FP 7/2/2024 11:07",
"buildFromRemoteProject:intoColumns:" : "FP 6/19/2024 18:07",
"buildFromRemoteProject:intoColumns:" : "AH 7/12/2024 15:40",
"buildNew:into:" : "mcr 8/3/2022 14:53",
"buildNewFromRemote:into:" : "mcr 8/3/2022 14:56",
"defaultCardExtent" : "AH 6/16/2024 14:53",
"defaultCardExtent" : "AH 7/12/2024 15:41",
"indicatorCardEdgeOffset" : "lo 8/1/2022 12:23",
"newFrom:with:" : "FP 6/19/2024 16:48",
"newFromLocal:with:" : "FP 7/2/2024 11:08",
Expand All @@ -17,7 +17,7 @@
"addLabel:" : "lo 7/31/2022 16:27",
"addLabelLocal:" : "tk 8/2/2022 23:12",
"alignLabels" : "mcr 8/4/2022 01:36",
"applyUserInterfaceTheme" : "AH 6/15/2024 15:01",
"applyUserInterfaceTheme" : "AH 7/12/2024 15:30",
"assigneeModel" : "tk 8/2/2022 23:27",
"assigneeModel:" : "tk 8/2/2022 23:27",
"assigneeOffset" : "lo 8/1/2022 11:45",
Expand All @@ -37,7 +37,7 @@
"buildStatusText" : "AH 5/25/2024 16:59",
"buildTitle" : "AH 6/14/2024 12:14",
"buildUI" : "AH 6/16/2024 13:06",
"calculateLabelPositionFor:" : "AH 6/20/2024 23:55",
"calculateLabelPositionFor:" : "AH 7/12/2024 15:32",
"cardId" : "FP 6/19/2024 16:52",
"cardId:" : "FP 6/19/2024 16:51",
"cardIndicatorExtent" : "lo 8/1/2022 11:52",
Expand All @@ -57,8 +57,8 @@
"id:" : "FP 6/19/2024 17:00",
"inbetweenLabelOffset" : "lo 8/1/2022 11:18",
"indicateDroppointWith:" : "mcr 8/4/2022 01:45",
"initialize" : "AH 6/14/2024 13:20",
"isClosed" : "FP 5/27/2024 11:24",
"initialize" : "AH 7/12/2024 15:33",
"isClosed" : "AH 7/12/2024 15:34",
"isClosed:" : "AH 5/25/2024 19:19",
"isHighlighted" : "AH 6/14/2024 13:14",
"isHighlighted:" : "AH 7/8/2024 11:25",
Expand All @@ -71,41 +71,41 @@
"labelModels" : "tk 8/2/2022 23:28",
"labelModels:" : "tk 8/2/2022 23:28",
"labelTitleOffset" : "lo 8/1/2022 11:18",
"labels" : "lo 8/3/2022 09:47",
"labels" : "AH 7/12/2024 15:34",
"labels:" : "lo 7/31/2022 16:29",
"lowerHalfIndicator" : "tk 8/2/2022 23:22",
"lowerHalfIndicator:" : "tk 8/2/2022 23:22",
"moveCardWith:" : "lo 8/3/2022 13:14",
"moveToTop" : "L.L. 6/23/2024 20:59",
"openContextMenu" : "L.L. 6/23/2024 20:53",
"moveToTop" : "AH 7/12/2024 15:35",
"openContextMenu" : "AH 7/12/2024 15:35",
"padding" : "AH 6/14/2024 12:14",
"removeAllAssignees" : "L.L. 6/23/2024 20:40",
"removeAllLabels" : "L.L. 6/23/2024 20:38",
"removeAllAssignees" : "AH 7/12/2024 15:36",
"removeAllLabels" : "AH 7/12/2024 15:36",
"removeAssignee:" : "lo 7/31/2022 16:38",
"removeAssigneeLocal:" : "lo 7/31/2022 16:39",
"removeLabel:" : "lo 7/31/2022 16:41",
"removeLabelLocal:" : "lo 7/31/2022 16:40",
"resizeCard" : "tk 8/2/2022 23:27",
"resizeIndicatorFields" : "tk 8/2/2022 23:23",
"resizeIndicatorFields" : "AH 7/12/2024 15:36",
"setCardColumn:" : "jh 8/3/2022 00:34",
"setCardColumnAtTop:" : "jh 8/3/2022 00:33",
"setCardHeight" : "AH 6/20/2024 23:54",
"setupMouseEvents" : "L.L. 6/7/2024 17:09",
"setCardHeight" : "AH 7/12/2024 15:36",
"setupMouseEvents" : "AH 7/12/2024 15:37",
"startDragging" : "mcr 8/3/2022 12:29",
"statusModel" : "AH 5/25/2024 16:59",
"statusModel:" : "AH 5/25/2024 16:59",
"statusOffset" : "AH 6/16/2024 14:55",
"title" : "lo 7/31/2022 16:09",
"title" : "AH 7/12/2024 15:37",
"title:" : "mcr 5/21/2022 20:52",
"titleModel" : "tk 8/2/2022 23:24",
"titleModel:" : "tk 8/2/2022 23:24",
"toggleClosed" : "AH 6/1/2024 18:27",
"toggleClosed" : "AH 7/12/2024 15:37",
"update:with:" : "lo 8/3/2022 13:13",
"updateAssigneeCount" : "tk 8/2/2022 23:27",
"updateBalloonText" : "mcr 8/4/2022 01:50",
"updateDescription:" : "jh 7/29/2022 11:38",
"updateLabelIcons" : "AH 6/20/2024 23:31",
"updateStatus" : "AH 5/25/2024 17:02",
"updateStatus" : "AH 7/12/2024 15:38",
"updateTitle:" : "tk 8/2/2022 23:24",
"upperHalfIndicator" : "tk 8/2/2022 23:23",
"upperHalfIndicator:" : "tk 8/2/2022 23:23" } }
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ createSingleCard: aNumber into: anSPBColumn
| cardJson |
cardJson := self api querySingleCard: aNumber.

"at the moment we can just display issues and pull requests (which have a content_url)"
(cardJson at: 'content_url') ifNil: [^ self].

^ SPBCard buildNewFromRemote: cardJson into: anSPBColumn.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"createCardsFromColumn:" : "FP 5/20/2024 20:01",
"createColumn:" : "jh 7/31/2022 13:54",
"createNewCard:into:" : "mcr 8/3/2022 13:59",
"createSingleCard:into:" : "mcr 8/4/2022 02:10",
"createSingleCard:into:" : "AH 7/12/2024 15:20",
"deleteAssignee:fromCard:" : "LW 7/30/2022 15:42",
"deleteLabel:fromCard:" : "lo 7/13/2022 19:44",
"fetchCardsIntoColumns:" : "FP 6/19/2024 18:28",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ defaultBoardJson: aString
"1":{"name":"ToDo","id":1,"cards":[]},
"2":{"name":"InProgress","id":2,"cards":[]},
"3":{"name":"Done","id":3,"cards":[]}},
"title":"', aString, '"}' ) parseAsJson.
"title":"', aString, '"}') parseAsJson.
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
columns
moveCard: anSPBCard after: anotherSPBCard toColumn: anSPBColumn

"do nothing"
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
columns
moveCardToTop: aSPBCard toColumn: aSPBColumn


"do nothing"
Loading

0 comments on commit e3326dd

Please sign in to comment.