Skip to content

Commit

Permalink
Auto bold cells when they're marked a label
Browse files Browse the repository at this point in the history
  • Loading branch information
prabhanshuguptagit committed Jun 19, 2024
1 parent 9d639ee commit a59eb78
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 13 additions & 1 deletion src/bean/grid.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@
(util/map-on-matrix-addressed
(fn [address item]
(when (and (not= (:content item) "")
(not (nil? (:content item))))
(not (nil? (:content item)))
;; only reval formulas
(= (first (:content item)) "="))
address)))
(mapcat identity)
(remove nil?))]
Expand Down Expand Up @@ -313,6 +315,16 @@
(unmerge-cells sheet (map #(offset % start) (keys addressed-attrs))))
eval-sheet-a-few-times))

(defn add-frame-labels [sheet frame-name addresses dirn]
(-> (reduce #(set-cell-style %1 %2 :bold true) sheet addresses)
(frames/add-labels frame-name addresses dirn)
eval-sheet-a-few-times))

(defn remove-frame-labels [sheet frame-name addresses]
(-> (reduce #(set-cell-style %1 %2 :bold false) sheet addresses)
(frames/remove-labels frame-name addresses)
eval-sheet-a-few-times))

(defn pasted-area [pasted-at addresses]
(let [{:keys [start end]} (area/addresses->area addresses)]
{:start (offset start pasted-at)
Expand Down
4 changes: 2 additions & 2 deletions src/bean/ui/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,14 @@
::add-labels
(fn add-labels [db [_ frame-name addresses dirn]]
(update-in db [:sheet]
#(frames/add-labels % frame-name addresses dirn))))
#(grid/add-frame-labels % frame-name addresses dirn))))

(rf/reg-event-db
::remove-labels
(fn remove-labels [db [_ frame-name addresses]]
(-> db
(update-in [:sheet] #(frames/unmark-skipped % frame-name addresses))
(update-in [:sheet] #(frames/remove-labels % frame-name addresses)))))
(update-in [:sheet] #(grid/remove-frame-labels % frame-name addresses)))))

(rf/reg-event-db
::mark-skip-cells
Expand Down

0 comments on commit a59eb78

Please sign in to comment.