aelve / guide

A workspace for research teams
https://guide.aelve.com
106 stars 10 forks source link

Quick-fix for Edit'Set* cases when old Text value is empty #131

Closed babhishek21 closed 8 years ago

babhishek21 commented 8 years ago

Quick Fix to issue #96.

I am an absolute noob when it comes to Haskell.

neongreen commented 8 years ago

I hope my use of the if-then-else construct was justified

Yep.

I don't fully understand why oldValue == Text.empty or (Text.null oldValue) don't work

Text.null doesn't work because of how Haskell import syntax works. In T.null, T is the module alias and null is the name of the function. Now:

(By the way, you don't need parens around (T.null oldNotes) because if is a keyword, not a function, and so Haskell can figure out unambiguously that T.null oldNotes is the condition here.)

oldValue == T.empty

T.null oldValue is the preferred version. Generally in Haskell you use pattern-matching, case or predicates like null and isNothing when possible, though foo == "blah" is still more acceptable than foo == "" – this has to do with the fact that when you use foo == [] on lists in general, it works in less cases than null foo (because e.g. you can't compare an [Int -> Int] list with anything but you can still check whether it's empty or not). There are also other arguments here: http://stackoverflow.com/questions/3853922/null-instead-of.

Other than that, the table column for the empty old value still exists.

Can you fix this as well? It's not hard, you only need to conditionally execute the code that adds the table cell – e.g.

unless (T.null oldEcosystem) $ 
  td_ $ blockquote_ $ toHtml (toMarkdownBlock oldEcosystem)
neongreen commented 8 years ago

(Well, and check that CSS doesn't get broken when there's only one cell.)

babhishek21 commented 8 years ago

Other than that, the table column for the empty old value still exists.

Can you fix this as well?

Done. :smile:

(Well, and check that CSS doesn't get broken when there's only one cell.)

The CSS did not break. In fact it looks the same as the case when you add a pro or a con. This is what it looks like: image