UI to delete habits
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
(defNew [&prop &mut :EntryType type
|
||||
&prop :Array<EntryLabel> labels])
|
||||
&prop &mut :Array<EntryLabel> labels])
|
||||
|
||||
(method toString []
|
||||
"$(case type
|
||||
|
@@ -113,7 +113,15 @@
|
||||
(otherwise (break))))))
|
||||
|
||||
(method :Array<Entry> allEntries []
|
||||
(cast (concat dailyEntries monthlyEntries intervalEntries bonusEntries todoEntries)))
|
||||
(cast (concat
|
||||
dailyEntries
|
||||
monthlyEntries
|
||||
intervalEntries
|
||||
bonusEntries
|
||||
todoEntries)))
|
||||
|
||||
(method :Array<Entry> allUndeletedEntries []
|
||||
(filter (allEntries) isNotDeleted))
|
||||
|
||||
(method :Int totalPoints []
|
||||
(apply + (for l (flatten (for e (allEntries) e.labels)) l.points)))
|
||||
@@ -149,8 +157,17 @@
|
||||
(function todayString []
|
||||
(let [d (Date.now)] "$(d.getDate)-$(+ 1 (d.getMonth))-$(d.getFullYear)"))
|
||||
|
||||
(function isDeleted [:Entry e]
|
||||
(or (.startsWith .label (first e.labels) "~")
|
||||
(case e.type
|
||||
(Todo !(= 0 .points (activeLabel e)))
|
||||
(otherwise false))))
|
||||
|
||||
(function isNotDeleted [:Entry e]
|
||||
!(isDeleted e))
|
||||
|
||||
(function isActive [:Entry e]
|
||||
(when (.startsWith .label (first e.labels) "~")
|
||||
(when (isDeleted e)
|
||||
(return false))
|
||||
(case e.type
|
||||
((Daily days lastDayDone)
|
||||
@@ -203,6 +220,10 @@
|
||||
(new Entry type (for label labels (objectWith [points 0] label))))
|
||||
(save))
|
||||
|
||||
(method deleteEntry [:Entry e]
|
||||
(set e.labels (for label e.labels (object points label.points label "~")))
|
||||
(save))
|
||||
|
||||
(method addRewardFile [path startingPoints puzzleWidth puzzleHeight piecesPerPoint]
|
||||
(rewardFiles.push (objectWith [skipped false] path startingPoints puzzleWidth puzzleHeight piecesPerPoint))
|
||||
(save))
|
||||
|
@@ -265,6 +265,20 @@
|
||||
(set save.data.backgroundIndex #{(save.data.backgroundIndex + 1) % backgroundOptions.length;}#)
|
||||
(save.flush)
|
||||
(refreshModel)))
|
||||
(set entryWindow.textColor FlxColor.RED)
|
||||
(_makeText "Delete a habit or task" 0
|
||||
->_
|
||||
(defAndCall method deleteHabitOrTask
|
||||
(entryWindow.hide)
|
||||
(let [delWindow (SimpleWindow.promptForChoice "Delete which habit/task? (You will keep all your points)"
|
||||
(model.allUndeletedEntries)
|
||||
->:Void [:Entry e] {
|
||||
(model.deleteEntry e)
|
||||
(refreshModel)
|
||||
(entryWindow.show)
|
||||
}
|
||||
null null FlxColor.WHITE 0.9 0.9 true)]
|
||||
(set delWindow.cameras [uiCamera]))))
|
||||
(when (= rewardFileIndex (- m.rewardFiles.length 1))
|
||||
(_makeText "Abandon this puzzle" 0
|
||||
->_
|
||||
|
@@ -51,7 +51,7 @@
|
||||
|
||||
(prop :Map<FlxSprite,Action> _actions (new Map))
|
||||
(prop :Map<FlxSprite,FlxColor> _colors (new Map))
|
||||
(method makeText [:String text &opt :FlxColor color :Action onClick]
|
||||
(method makeText [:String text &opt :FlxColor color :Action onClick :Bool noShortcut]
|
||||
(let [ftext (new FlxText nextControlX nextControlY 0 text textSize)]
|
||||
(set ftext.color (or color textColor))
|
||||
(dictSet _colors ftext ftext.color)
|
||||
@@ -67,7 +67,8 @@
|
||||
(when onClick
|
||||
(dictSet _actions ftext onClick)
|
||||
// TODO right click?
|
||||
(keyHandler.registerItem text ->:Void (onClick ftext)))
|
||||
(unless noShortcut
|
||||
(keyHandler.registerItem text ->:Void (onClick ftext))))
|
||||
ftext))
|
||||
|
||||
// TODO makeButton
|
||||
@@ -138,7 +139,8 @@
|
||||
:FlxColor titleColor
|
||||
:FlxColor choiceColor
|
||||
:Float percentWidth
|
||||
:Float percentHeight]
|
||||
:Float percentHeight
|
||||
:Bool noShortcuts]
|
||||
(let [window (new SimpleWindow prompt bgColor titleColor percentWidth percentHeight)
|
||||
choiceColor (or choiceColor titleColor FlxColor.WHITE)]
|
||||
(doFor choice choices
|
||||
@@ -146,6 +148,7 @@
|
||||
->:Void s {
|
||||
(window.hide)
|
||||
(onChoice choice)
|
||||
}))
|
||||
}
|
||||
noShortcuts))
|
||||
(window.show)
|
||||
window))
|
Reference in New Issue
Block a user