logic for top-priority habit entries
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
(defNew [&prop &mut :EntryType type
|
(defNew [&prop &mut :EntryType type
|
||||||
&prop &mut :Array<EntryLabel> labels])
|
&prop &mut :Array<EntryLabel> labels
|
||||||
|
&prop &mut :Bool topPriority])
|
||||||
|
|
||||||
(method toString []
|
(method toString []
|
||||||
"$(case type
|
"$?(when topPriority "! ")$(case type
|
||||||
((Daily days lastDayDone)
|
((Daily days lastDayDone)
|
||||||
(+
|
(+
|
||||||
(.join (for day days
|
(.join (for day days
|
||||||
|
@@ -41,6 +41,8 @@
|
|||||||
path (parts.join " ")]
|
path (parts.join " ")]
|
||||||
(objectWith path startingPoints puzzleWidth puzzleHeight piecesPerPoint skipped))))
|
(objectWith path startingPoints puzzleWidth puzzleHeight piecesPerPoint skipped))))
|
||||||
((Some line)
|
((Some line)
|
||||||
|
(let [topPriority (line.startsWith "! ")]
|
||||||
|
(when topPriority (set line (line.substr 2)))
|
||||||
(.push
|
(.push
|
||||||
(case lastHeader
|
(case lastHeader
|
||||||
("DAILY" dailyEntries)
|
("DAILY" dailyEntries)
|
||||||
@@ -109,7 +111,8 @@
|
|||||||
(for l (line.split "/")
|
(for l (line.split "/")
|
||||||
(object
|
(object
|
||||||
label (StringTools.trim (StringTools.replace l "|" ""))
|
label (StringTools.trim (StringTools.replace l "|" ""))
|
||||||
points (count (l.split "") ->c (= c "|")))))))
|
points (count (l.split "") ->c (= c "|"))))
|
||||||
|
topPriority))))
|
||||||
(otherwise (break))))))
|
(otherwise (break))))))
|
||||||
|
|
||||||
(method :Array<Entry> allEntries []
|
(method :Array<Entry> allEntries []
|
||||||
@@ -166,7 +169,7 @@
|
|||||||
(function isNotDeleted [:Entry e]
|
(function isNotDeleted [:Entry e]
|
||||||
!(isDeleted e))
|
!(isDeleted e))
|
||||||
|
|
||||||
(function isActive [:Entry e]
|
(function _isActive [:Entry e]
|
||||||
(when (isDeleted e)
|
(when (isDeleted e)
|
||||||
(return false))
|
(return false))
|
||||||
(case e.type
|
(case e.type
|
||||||
@@ -196,22 +199,47 @@
|
|||||||
(Todo (= 0 .points (activeLabel e)))
|
(Todo (= 0 .points (activeLabel e)))
|
||||||
(otherwise true)))
|
(otherwise true)))
|
||||||
|
|
||||||
(method :Array<Entry> activeDailyEntries []
|
// Check if an entry is active PRE-top priority filtering
|
||||||
(filter dailyEntries isActive))
|
(method :Array<Entry> _activeDailyEntries []
|
||||||
|
(filter dailyEntries _isActive))
|
||||||
|
|
||||||
(method :Array<Entry> activeMonthlyEntries []
|
(method :Array<Entry> _activeMonthlyEntries []
|
||||||
(filter monthlyEntries isActive))
|
(filter monthlyEntries _isActive))
|
||||||
|
|
||||||
(method :Array<Entry> activeIntervalEntries []
|
(method :Array<Entry> _activeIntervalEntries []
|
||||||
(filter intervalEntries isActive))
|
(filter intervalEntries _isActive))
|
||||||
|
|
||||||
(method :Array<Entry> activeBonusEntries []
|
(method :Array<Entry> _activeBonusEntries []
|
||||||
(filter bonusEntries isActive))
|
(filter bonusEntries _isActive))
|
||||||
|
|
||||||
(method :Array<Entry> activeTodoEntries []
|
(method :Array<Entry> _activeTodoEntries []
|
||||||
(filter todoEntries isActive))
|
(filter todoEntries _isActive))
|
||||||
|
|
||||||
(method addEntry [:EntryType type :Array<String> labels]
|
(method :Array<Entry> _allActiveEntries []
|
||||||
|
(cast (concat
|
||||||
|
(_activeDailyEntries)
|
||||||
|
(_activeMonthlyEntries)
|
||||||
|
(_activeIntervalEntries)
|
||||||
|
(_activeBonusEntries)
|
||||||
|
(_activeTodoEntries))))
|
||||||
|
|
||||||
|
(method :Bool topPriorityIsActive []
|
||||||
|
(apply or (for e (_allActiveEntries) e.topPriority)))
|
||||||
|
|
||||||
|
(defMacro topPriority [name]
|
||||||
|
`(method :Array<Entry> ,name []
|
||||||
|
(let [_active (,(ReaderExp.Symbol (+ "_" (symbolNameValue name))))]
|
||||||
|
(if (topPriorityIsActive)
|
||||||
|
(filter _active ->e e.topPriority)
|
||||||
|
_active))))
|
||||||
|
|
||||||
|
(topPriority activeDailyEntries)
|
||||||
|
(topPriority activeMonthlyEntries)
|
||||||
|
(topPriority activeIntervalEntries)
|
||||||
|
(topPriority activeBonusEntries)
|
||||||
|
(topPriority activeTodoEntries)
|
||||||
|
|
||||||
|
(method addEntry [:EntryType type :Array<String> labels :Bool topPriority]
|
||||||
(.push (case type
|
(.push (case type
|
||||||
(Todo todoEntries)
|
(Todo todoEntries)
|
||||||
(Bonus bonusEntries)
|
(Bonus bonusEntries)
|
||||||
@@ -219,7 +247,7 @@
|
|||||||
((Daily _ _) dailyEntries)
|
((Daily _ _) dailyEntries)
|
||||||
((Monthly _ _) monthlyEntries)
|
((Monthly _ _) monthlyEntries)
|
||||||
(otherwise (throw "")))
|
(otherwise (throw "")))
|
||||||
(new Entry type (for label labels (objectWith [points 0] label))))
|
(new Entry type (for label labels (objectWith [points 0] label)) topPriority))
|
||||||
(save))
|
(save))
|
||||||
|
|
||||||
(method deleteEntry [:Entry e]
|
(method deleteEntry [:Entry e]
|
||||||
|
@@ -837,7 +837,7 @@
|
|||||||
(labelsAdding.push entryNameText.text))
|
(labelsAdding.push entryNameText.text))
|
||||||
(unless labelsAdding
|
(unless labelsAdding
|
||||||
(return))
|
(return))
|
||||||
(model.addEntry typeAdding labelsAdding)
|
(model.addEntry typeAdding labelsAdding false) // TODO allow choosing priority!
|
||||||
(refreshModel)
|
(refreshModel)
|
||||||
(entryNameText.kill)
|
(entryNameText.kill)
|
||||||
(set entryNameText null)
|
(set entryNameText null)
|
||||||
|
Reference in New Issue
Block a user