Skip to content

Commit

Permalink
refactor SCMView class to fit idioms and stuileguide
Browse files Browse the repository at this point in the history
  • Loading branch information
Belana Zwadsich committed Jun 26, 2022
1 parent 483132b commit 74ecfc1
Show file tree
Hide file tree
Showing 22 changed files with 70 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
as yet unclassified
initialization
createWith: aSCMCalendarManager

^ self new
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
as yet unclassified
defaults
defaultView

^ #agenda
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
defaults
agendaDaysPerPage

^ 1
2 changes: 1 addition & 1 deletion packages/SCM-Core.package/SCMView.class/instance/clear.st
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
actions
loading
clear

self submorphs copy
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
actions
initialization
configureLayout

self
layoutPolicy: TableLayout new;
vResizing: #spaceFill;
hResizing: #spaceFill;
color: Color white;
borderWidth: 0;
borderWidth: self defaultBorderWidth;
cellPositioning: #topLeft;
listCentering: #center;
wrapCentering: #topLeft;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
defaults
defaultBorderWidth

^ 0
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
actions
accessing
getNextWrapped: anIndex withLimit: anInteger

^ (anIndex \\\ anInteger) + 1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
actions
initialization
initialize

super initialize.
self
configureLayout
startDate: DateAndTime today asDate "better than 'Date today' because it sets the right time zone!"
configureLayout;
startDate: self today
2 changes: 1 addition & 1 deletion packages/SCM-Core.package/SCMView.class/instance/load..st
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
actions
loading
load: aSCMViewType

self currentView: aSCMViewType.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
actions
loading
loadAgendaView

self addMorph: ((self viewTypes at: #agenda)
createWithEvents: (self calendarManager activeEventsAfter: self startDate maxEvents: self defaultMaxEvents)
createWithEvents: self retrieveAgendaEvents
andStartDate: self startDate)
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
actions
loading
loadNextView

| viewTypesKeys index |

viewTypesKeys := self viewTypes keysInOrder.
index := viewTypesKeys indexOf: self currentView.
self load: (viewTypesKeys
at: (self getNextWrapped: index withLimit: viewTypesKeys size))
at: (self getNextWrapped: index withLimit: viewTypesKeys size))
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
actions
loading
loadWeekView

self addMorph: ((self viewTypes at: #week)
createWithEvents: (self calendarManager activeEventsInWeek)
andStartDate: self startDate asWeek asDate next)
createWithEvents: self retrieveWeekEvents
andStartDate: self monday)
4 changes: 4 additions & 0 deletions packages/SCM-Core.package/SCMView.class/instance/monday.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
monday

^ self startDate asWeek asDate next
2 changes: 1 addition & 1 deletion packages/SCM-Core.package/SCMView.class/instance/reload.st
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
actions
loading
reload

self clear.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
loading
retrieveAgendaEvents

^ self calendarManager activeEventsAfter: self startDate maxEvents: self defaultMaxEvents
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
loading
retrieveWeekEvents

^ self calendarManager activeEventsInWeek
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
actions
navigating
showNextPage

| dayIncrease |

self currentView = #agenda
ifTrue: [dayIncrease := 1]
ifFalse: [dayIncrease := 7].
ifTrue: [dayIncrease := self agendaDaysPerPage]
ifFalse: [dayIncrease := self weekDaysPerPage].
self startDate: (self startDate addDays: dayIncrease).
self reload
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
actions
navigating
showPreviousPage

| dayDecrease |

self currentView = #agenda
ifTrue: [dayDecrease := 1]
ifFalse: [dayDecrease := 7].

ifTrue: [dayDecrease := self agendaDaysPerPage]
ifFalse: [dayDecrease := self weekDaysPerPage].
self startDate: (self startDate subtractDays: dayDecrease).
self reload
2 changes: 1 addition & 1 deletion packages/SCM-Core.package/SCMView.class/instance/switch.st
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
actions
navigating
switch

self clear.
Expand Down
5 changes: 5 additions & 0 deletions packages/SCM-Core.package/SCMView.class/instance/today.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
accessing
today
" 'asDate' is necessary for the right time zone"

^ DateAndTime today asDate
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
defaults
weekDaysPerPage

^ 7
25 changes: 16 additions & 9 deletions packages/SCM-Core.package/SCMView.class/methodProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,30 @@
"createWith:" : "AN 6/12/2022 17:08",
"defaultView" : "AN 6/12/2022 16:37" },
"instance" : {
"agendaDaysPerPage" : "BZ 6/26/2022 10:39",
"calendarManager" : "NMK 6/7/2022 18:18",
"calendarManager:" : "NMK 6/12/2022 20:14",
"clear" : "NMK 6/12/2022 20:14",
"configureLayout" : "NMK 6/19/2022 20:08",
"configureLayout" : "BZ 6/26/2022 09:52",
"currentView" : "NMK 6/7/2022 17:54",
"currentView:" : "NMK 6/12/2022 20:15",
"defaultBorderWidth" : "BZ 6/26/2022 09:52",
"defaultMaxEvents" : "NMK 6/12/2022 20:15",
"getNextWrapped:withLimit:" : "NMK 6/19/2022 20:15",
"initialize" : "NMK 6/25/2022 09:42",
"load:" : "NMK 6/12/2022 20:19",
"loadAgendaView" : "NMK 6/25/2022 09:50",
"loadNextView" : "NMK 6/19/2022 20:14",
"loadWeekView" : "NMK 6/25/2022 09:12",
"initialize" : "BZ 6/26/2022 10:01",
"load:" : "BZ 6/26/2022 10:04",
"loadAgendaView" : "BZ 6/26/2022 10:14",
"loadNextView" : "BZ 6/26/2022 10:34",
"loadWeekView" : "BZ 6/26/2022 10:21",
"monday" : "BZ 6/26/2022 10:21",
"reload" : "NMK 6/24/2022 11:27",
"showNextPage" : "NMK 6/25/2022 09:46",
"showPreviousPage" : "NMK 6/25/2022 09:47",
"retrieveAgendaEvents" : "BZ 6/26/2022 10:15",
"retrieveWeekEvents" : "BZ 6/26/2022 10:17",
"showNextPage" : "BZ 6/26/2022 10:38",
"showPreviousPage" : "BZ 6/26/2022 10:41",
"startDate" : "NMK 6/20/2022 18:38",
"startDate:" : "NMK 6/12/2022 20:22",
"switch" : "NMK 6/12/2022 20:21",
"viewTypes" : "NMK 6/20/2022 18:38" } }
"today" : "BZ 6/26/2022 10:16",
"viewTypes" : "NMK 6/20/2022 18:38",
"weekDaysPerPage" : "BZ 6/26/2022 10:39" } }

0 comments on commit 74ecfc1

Please sign in to comment.