Skip to content

Commit

Permalink
Remove code duplication in cardBuilder and formatting methods
Browse files Browse the repository at this point in the history
  • Loading branch information
linaScience committed Jul 30, 2022
1 parent d8c82ec commit 2f1ab20
Show file tree
Hide file tree
Showing 40 changed files with 97 additions and 117 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ buildLaneBodySpecWith: aBuilder and: anSPBLane
model: self;
hScrollBarPolicy: #never;
vScrollBarPolicy: #always;
children:
{aBuilder pasteUpSpec new
children: {aBuilder pasteUpSpec new
minimumExtent: 300@290;
model: anSPBLane;
name: anSPBLane id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ buildLaneHeaderSpecWith: aBuilder and: anSPBLane

^ aBuilder pluggablePanelSpec new
frame: (0@0 corner: 1@0.15);
children: {
self buildLaneHeaderTitleSpecWith: aBuilder and: anSPBLane.
children: {self buildLaneHeaderTitleSpecWith: aBuilder and: anSPBLane.
self buildLaneHeaderAddCardButtonSpecWith: aBuilder and: anSPBLane.
self buildLaneHeaderMoveLaneButtonSpecWith: aBuilder and: anSPBLane.
};
self buildLaneHeaderMoveLaneButtonSpecWith: aBuilder and: anSPBLane};
yourself.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ buildLaneSpecWith: aBuilder and: anSPBLane

^ aBuilder pluggablePanelSpec new
minimumExtent: (300@600);
children: {
self buildLaneHeaderSpecWith: aBuilder and: anSPBLane.
self buildLaneBodySpecWith: aBuilder and: anSPBLane.
};
children: {self buildLaneHeaderSpecWith: aBuilder and: anSPBLane.
self buildLaneBodySpecWith: aBuilder and: anSPBLane};
name: ('lane', anSPBLane id asString) asSymbol;
yourself.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ buildSidebarAssigneePanelSpecWith: aBuilder
name: #sidebarAssigneeList;
frame: (0@0.1 corner: 1@0.25);
minimumHeight: 20;
children: {
self buildSidebarAssigneeListSpecWith: aBuilder.
children: {self buildSidebarAssigneeListSpecWith: aBuilder.
self buildSidebarPotentialAssigneeListSpecWith: aBuilder};
yourself.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ buildSidebarLabelPanelSpecWith: aBuilder
name: #sidebarLabelList;
frame: (0@0.25 corner: 1@0.4);
minimumHeight: 20;
children: {
self buildSidebarLabelListSpecWith: aBuilder.
children: {self buildSidebarLabelListSpecWith: aBuilder.
self buildSidebarPotentialLabelListSpecWith: aBuilder};
yourself.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ buildSidebarSpecWith: aBuilder witdh: aNumber
frame: (aNumber@0 corner: 1@1);
wantsResizeHandles: true;
minimumWidth: 250;
children: {
self buildSidebarTitleSpecWith: aBuilder.
children: {self buildSidebarTitleSpecWith: aBuilder.
self buildSidebarAssigneePanelSpecWith: aBuilder.
self buildSidebarLabelPanelSpecWith: aBuilder.
self buildSidebarDescriptionSpecWith: aBuilder};
Expand Down
3 changes: 1 addition & 2 deletions Squello-Core.package/SPBBoard.class/instance/buildWith..st
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ buildWith: aBuilder
model: self;
label: 'Squello Project Board';
minimumExtent: 1040@400;
children: {
self buildLaneAreaSpecWith: aBuilder.
children: {self buildLaneAreaSpecWith: aBuilder.
self buildSidebarSpecWith: aBuilder};
yourself.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dropOnPotentialLabels: anSPBLabel at: index
(anSPBLabel isKindOf: SPBLabel)
ifFalse: [^ self inform: 'Can only drop labels'].
self activeCard labels remove: anSPBLabel
ifAbsent: [].
ifAbsent: [].
self activeCard updateLabelIcons.
self changed: #potentialLabelsList.
self changed: #activeCardLabelList.
Expand Down
16 changes: 8 additions & 8 deletions Squello-Core.package/SPBBoard.class/methodProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,24 @@
"buildLaneAreaChildren" : "LW 7/14/2022 12:00",
"buildLaneAreaSpecWith:" : "tk 7/14/2022 16:00",
"buildLaneAreaSpecWith:width:" : "tk 7/14/2022 16:00",
"buildLaneBodySpecWith:and:" : "jh 7/29/2022 12:49",
"buildLaneBodySpecWith:and:" : "LW 7/30/2022 15:55",
"buildLaneHeaderAddCardButtonSpecWith:and:" : "jh 7/29/2022 12:49",
"buildLaneHeaderMoveLaneButtonSpecWith:and:" : "jh 7/29/2022 12:49",
"buildLaneHeaderSpecWith:and:" : "jh 7/29/2022 12:49",
"buildLaneHeaderSpecWith:and:" : "LW 7/30/2022 15:56",
"buildLaneHeaderTitleSpecWith:and:" : "jh 7/29/2022 12:49",
"buildLaneSpecWith:and:" : "jh 7/29/2022 12:49",
"buildLaneSpecWith:and:" : "LW 7/30/2022 15:57",
"buildLanesSpecWith:" : "tk 7/14/2022 16:01",
"buildSidebarAssigneeListSpecWith:" : "LW 7/14/2022 11:39",
"buildSidebarAssigneePanelSpecWith:" : "LW 7/14/2022 11:40",
"buildSidebarAssigneePanelSpecWith:" : "LW 7/30/2022 15:57",
"buildSidebarDescriptionSpecWith:" : "LW 7/14/2022 11:40",
"buildSidebarLabelListSpecWith:" : "LW 7/14/2022 11:40",
"buildSidebarLabelPanelSpecWith:" : "LW 7/14/2022 11:40",
"buildSidebarLabelPanelSpecWith:" : "LW 7/30/2022 15:57",
"buildSidebarPotentialAssigneeListSpecWith:" : "LW 7/14/2022 11:40",
"buildSidebarPotentialLabelListSpecWith:" : "LW 7/14/2022 11:40",
"buildSidebarSpecWith:" : "tk 7/14/2022 16:01",
"buildSidebarSpecWith:witdh:" : "tk 7/14/2022 16:01",
"buildSidebarSpecWith:witdh:" : "LW 7/30/2022 15:57",
"buildSidebarTitleSpecWith:" : "LW 7/14/2022 11:41",
"buildWith:" : "jh 6/21/2022 12:01",
"buildWith:" : "LW 7/30/2022 15:57",
"changeActiveCardTo:" : "jh 7/29/2022 12:50",
"changeProvider" : "lo 7/8/2022 14:00",
"changeProvider:" : "lo 7/8/2022 15:29",
Expand All @@ -52,7 +52,7 @@
"dropOnAssignees:at:" : "NTK 7/30/2022 11:33",
"dropOnLabels:at:" : "NTK 7/30/2022 11:34",
"dropOnPotentialAssignees:at:" : "jh 7/29/2022 11:36",
"dropOnPotentialLabels:at:" : "jh 7/29/2022 12:50",
"dropOnPotentialLabels:at:" : "LW 7/30/2022 15:58",
"initialize" : "jh 7/29/2022 11:36",
"labelIcon:" : "NTK 7/30/2022 13:45",
"labelSelected" : "lo 6/5/2022 14:56",
Expand Down
2 changes: 1 addition & 1 deletion Squello-Core.package/SPBCard.class/instance/alignLabels.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ alignLabels
self labelMorphs
withIndexDo: [:each :index | index = 1
ifTrue: [each position: 4 @ (self position y + self titleMorph extent y + 10)]
ifFalse: [previousLabel := self labelMorphs at: index -1.
ifFalse: [previousLabel := self labelMorphs at: index - 1.
each position: (4 @ ((previousLabel position y) + (previousLabel extent y + 2)))]].
4 changes: 2 additions & 2 deletions Squello-Core.package/SPBCard.class/instance/startDragging.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ event handling
startDragging

ActiveHand attachMorph: self.
(self lane isLastCard: self) ifTrue:
[self lane resizeBottomDetectionIgnoreLastCard].
(self lane isLastCard: self)
ifTrue: [self lane resizeBottomDetectionIgnoreLastCard].
4 changes: 2 additions & 2 deletions Squello-Core.package/SPBCard.class/methodProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"class" : {
},
"instance" : {
"alignLabels" : "LW 7/14/2022 11:36",
"alignLabels" : "LW 7/30/2022 15:59",
"assigneeMorph" : "mcr 5/27/2022 12:18",
"assigneeMorph:" : "mcr 5/27/2022 12:18",
"assignees" : "mcr 5/27/2022 11:35",
Expand Down Expand Up @@ -32,7 +32,7 @@
"resizeCard" : "mcr 7/19/2022 20:08",
"resizeIndicatorFields" : "mcr 7/19/2022 20:00",
"setCardHeight" : "LW 7/14/2022 12:03",
"startDragging" : "NTK 7/30/2022 11:10",
"startDragging" : "LW 7/30/2022 16:01",
"title" : "mcr 5/18/2022 14:54",
"title:" : "mcr 5/21/2022 20:52",
"titleMorph" : "mcr 5/27/2022 12:18",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
building
buildCardWith: anJsonObject

^ self
card: SPBCard new;
setCardID: (anJsonObject at: 'id');
setupMouseEvents;
buildContent: (anJsonObject at: 'content_url');
buildUI;
buildIndicatorDetection.
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
building
buildFromRemote: aJsonObject into: anSPBLane

self
card: SPBCard new;
setCardID: (aJsonObject at: 'id');
setupMouseEvents;
buildContent: (aJsonObject at: 'content_url');
buildUI;
buildIndicatorDetection.
self buildCardWith: aJsonObject.
self card boardProvider: self boardProvider.
self card changeProvider: self changeProvider.
self card openInWorld.
self setCardLane: anSPBLane.

^ self card.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ buildIndicatorDetection
self card upperHalfMorph:
(SPBIndicatorDetectionCard new position: self card position - (0 @ SPBLane defaultSpaceBetweenCards);
extent: cardExtent x @ ((cardExtent y / 2) + SPBLane defaultSpaceBetweenCards);
color: Color blue;
color: Color transparent;
location: #upper;
card: self card).

self card lowerHalfMorph:
(SPBIndicatorDetectionCard new position: self card position x + (0 @ (self card extent y / 2));
extent: cardExtent x @ (cardExtent y / 2);
color: Color red;
color: Color transparent;
location: #lower;
card: self card).

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
building
buildNew: aDictionary atTop: anSPBLane

| cardJson |
cardJson := self boardProvider createCard: aDictionary into: anSPBLane.
self
card: SPBCard new;
setCardID: (cardJson at: 'id');
setupMouseEvents;
buildContent: (cardJson at: 'content_url');
buildUI;
buildIndicatorDetection.
self card boardProvider: self boardProvider.
self card changeProvider: self changeProvider.
self card openInWorld.
self buildNew: aDictionary with: anSPBLane.
self setCardLaneAtTop: anSPBLane.
^ self card.
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
building
buildNew: aDictionary into: anSPBLane

| cardJson |
cardJson := self boardProvider createCard: aDictionary into: anSPBLane.
self
card: SPBCard new;
setCardID: (cardJson at: 'id');
setupMouseEvents;
buildContent: (cardJson at: 'content_url');
buildUI;
buildIndicatorDetection.
self card boardProvider: self boardProvider.
self card changeProvider: self changeProvider.
self card openInWorld.
self buildNew: aDictionary with: anSPBLane.
self setCardLane: anSPBLane.
^ self card.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
building
buildNew: aDictionary with: anSPBLane

| cardJson |
cardJson := self boardProvider createCard: aDictionary into: anSPBLane.
self buildCardWith: cardJson.
self card boardProvider: self boardProvider.
self card changeProvider: self changeProvider.
self card openInWorld.
10 changes: 6 additions & 4 deletions Squello-Core.package/SPBCardBuilder.class/methodProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
"instance" : {
"boardProvider" : "jh 7/29/2022 12:47",
"boardProvider:" : "jh 7/29/2022 12:47",
"buildCardWith:" : "LW 7/30/2022 18:18",
"buildContent:" : "jh 7/29/2022 14:48",
"buildFromRemote:into:" : "jh 7/29/2022 11:38",
"buildIndicatorDetection" : "NTK 7/30/2022 12:43",
"buildFromRemote:into:" : "LW 7/30/2022 18:18",
"buildIndicatorDetection" : "LW 7/30/2022 18:06",
"buildLabels:" : "lo 6/5/2022 14:51",
"buildNew:atTop:" : "jh 7/29/2022 11:38",
"buildNew:into:" : "jh 7/29/2022 11:38",
"buildNew:atTop:" : "LW 7/30/2022 18:14",
"buildNew:into:" : "LW 7/30/2022 18:17",
"buildNew:with:" : "LW 7/30/2022 18:18",
"buildUI" : "mcr 7/1/2022 13:03",
"card" : "mcr 5/19/2022 09:30",
"card:" : "LW 7/14/2022 11:02",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ addAssignee: anSPBAssignee toCard: anSPBCard

"aCollection => Collection of SPBAssignees"
| payload |
payload := Dictionary newFrom: { 'assignees' -> {anSPBAssignee username} }.
payload := Dictionary newFrom: {'assignees' -> {anSPBAssignee username}}.
self api addAssignee: payload toIssue: anSPBCard issueId user: self user repo: self repo.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ labels
addLabel: anSPBLabel toCard: anSPBCard

| payload |
payload := Dictionary newFrom: { 'labels' -> {anSPBLabel title} }.
payload := Dictionary newFrom: {'labels' -> {anSPBLabel title}}.
self api addLabel: payload toIssue: anSPBCard issueId user: self user repo: self repo.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ assignees
deleteAssignee: anSPBAssignee fromCard: anSPBCard

| payload |
payload := Dictionary newFrom: { 'assignees' -> {anSPBAssignee username} }.
payload := Dictionary newFrom: {'assignees' -> {anSPBAssignee username}}.
self api deleteAssignee: payload fromIssue: anSPBCard issueId user: self user repo: self repo.
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ moveCard: anSPBCard after: anotherSPBCard toColumn: anSPBLane
"move aSPBCard after card with ID = aNumber"
| payload |
payload := Dictionary newFrom: {'position' -> ('after:' , anotherSPBCard id) . 'column_id' -> anSPBLane id}.

self api moveCard: anSPBCard id withPostData: payload.
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ parseInputBoardUrl: aString
(projects size < boardNr)
ifTrue: [^ #invalidNumber].

self
projectId: ((projects at: boardNr) at: 'id').
self projectId: ((projects at: boardNr) at: 'id').
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
"class" : {
},
"instance" : {
"addAssignee:toCard:" : "jh 7/29/2022 12:53",
"addLabel:toCard:" : "lo 7/13/2022 19:06",
"addAssignee:toCard:" : "LW 7/30/2022 15:42",
"addLabel:toCard:" : "LW 7/30/2022 15:42",
"api" : "mcr 5/28/2022 01:24",
"api:" : "jh 7/29/2022 12:54",
"checkIfUserExists:" : "NTK 7/30/2022 12:45",
"createCard:into:" : "jh 7/29/2022 12:54",
"createColumn:" : "LW 7/14/2022 12:06",
"deleteAssignee:fromCard:" : "lo 7/13/2022 19:38",
"deleteAssignee:fromCard:" : "LW 7/30/2022 15:42",
"deleteLabel:fromCard:" : "lo 7/13/2022 19:44",
"getProjects:" : "lo 7/13/2022 19:49",
"initialize" : "mcr 5/28/2022 01:23",
"listPossibleAssignees" : "LW 7/14/2022 11:05",
"listPossibleLabels" : "LW 7/14/2022 11:05",
"moveCard:after:toColumn:" : "lo 7/13/2022 20:05",
"moveCard:after:toColumn:" : "LW 7/30/2022 16:06",
"moveCardToTop:toColumn:" : "jh 7/29/2022 12:54",
"moveLane:after:" : "lo 7/13/2022 20:14",
"moveLaneToFront:" : "jh 7/29/2022 12:54",
"parseInputBoardUrl:" : "NTK 7/23/2022 10:40",
"parseInputBoardUrl:" : "LW 7/30/2022 16:06",
"projectId" : "lo 7/13/2022 20:17",
"projectId:" : "lo 7/13/2022 20:18",
"queryCard:" : "jh 7/10/2022 12:50",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
card: aSPBCard
card: anSPBCard

card := aSPBCard.
card := anSPBCard.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
},
"instance" : {
"card" : "mcr 7/19/2022 12:32",
"card:" : "mcr 7/19/2022 12:32",
"card:" : "LW 7/30/2022 15:47",
"location" : "NTK 7/30/2022 13:02",
"location:" : "NTK 7/30/2022 13:02",
"mouseEnterDragging:" : "NTK 7/30/2022 12:59",
Expand Down
3 changes: 2 additions & 1 deletion Squello-Core.package/SPBLane.class/instance/addCard.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ addCard

| cardTitle content cardBuilder newSPBCard |
cardTitle := FillInTheBlank request: 'Enter title for new card:'.
cardTitle = '' ifTrue: [^ self].
cardTitle = ''
ifTrue: [^ self].
content := Dictionary newFrom: {'title' -> cardTitle . 'body' -> ''}.
cardBuilder := SPBCardBuilder new.
cardBuilder boardProvider: self boardProvider.
Expand Down
6 changes: 3 additions & 3 deletions Squello-Core.package/SPBLane.class/instance/alignCards.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ card movement
alignCards

self cardPositions removeAll.
self cards withIndexDo:
[:each :index | index = 1
self cards
withIndexDo: [:each :index | index = 1
ifTrue: [self cardPositions add:
((self pasteup position x + 4) @
(self pasteup position y + self class defaultSpaceBetweenCards))]
ifFalse: [self cardPositions add:
((self pasteup position x + 4) @
(self pasteup position y + ((self cardPositions at: index -1) y) + ((self cards at: index - 1) height) + self class defaultSpaceBetweenCards))]].
(self pasteup position y + ((self cardPositions at: index - 1) y) + ((self cards at: index - 1) height) + self class defaultSpaceBetweenCards))]].

self cards withIndexDo:
[:each :index | each walkToPosition: (self cardPositions at: index)].
Loading

0 comments on commit 2f1ab20

Please sign in to comment.