From 066328c56c02c309369614acbb3ab48696dc07cd Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 30 Mar 2019 18:50:16 +0100 Subject: [PATCH] TermHoliday Placeholder --- messages/uniworx/de.msg | 1 + src/Handler/Term.hs | 2 +- src/Utils/Form.hs | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/messages/uniworx/de.msg b/messages/uniworx/de.msg index 5ecb2a00e..2c90d5524 100644 --- a/messages/uniworx/de.msg +++ b/messages/uniworx/de.msg @@ -45,6 +45,7 @@ TermStartDayTooltip: Üblicherweise immer 1.April oder 1.Oktober TermEndDay: Letzter Tag TermEndDayTooltip: Üblicherweise immer 30.September oder 31.März TermHolidays: Feiertage +TermHolidayPlaceholder: Feiertag TermLectureStart: Beginn Vorlesungen TermLectureEnd: Ende Vorlesungen TermLectureEndTooltip: Meistens dauer das Sommersemester 14 Wochen und das Wintersemester 15 Wochen. diff --git a/src/Handler/Term.hs b/src/Handler/Term.hs index 6fbfa6c9e..64f7725a0 100644 --- a/src/Handler/Term.hs +++ b/src/Handler/Term.hs @@ -255,7 +255,7 @@ newTermForm template html = do = aforced termNewField (fslpI MsgTerm (mr MsgTermPlaceholder)) tid | otherwise = areq termNewField (fslpI MsgTerm (mr MsgTermPlaceholder)) Nothing - holidayForm = formToAForm . over (mapped._2) pure $ massInputList dayField (\_ -> "") (\_ -> Nothing) (fslI MsgTermHolidays) True (tftHolidays template) mempty + holidayForm = formToAForm . over (mapped._2) pure $ massInputList dayField (\_ -> "" & addPlaceholder (mr MsgTermHolidayPlaceholder)) (\_ -> Nothing) (fslI MsgTermHolidays) True (tftHolidays template) mempty (result, widget) <- flip (renderAForm FormStandard) html $ Term <$> tidForm <*> areq dayField (fslI MsgTermStartDay & setTooltip MsgTermStartDayTooltip) (tftStart template) diff --git a/src/Utils/Form.hs b/src/Utils/Form.hs index 0d055bbf4..96dec5423 100644 --- a/src/Utils/Form.hs +++ b/src/Utils/Form.hs @@ -99,6 +99,11 @@ addAttrs attr valus fs = fs { fsAttrs = newAttrs $ fsAttrs fs } | attr==a = ( a, T.intercalate " " $ v : valus ) : t | otherwise = p : newAttrs t +addPlaceholder :: Text -> FieldSettings site -> FieldSettings site +addPlaceholder placeholder fs = fs { fsAttrs = (placeholderAttr, placeholder) : filter ((/= placeholderAttr) . fst) (fsAttrs fs) } + where + placeholderAttr = "placeholder" + addClass :: Text -> FieldSettings site -> FieldSettings site addClass = addAttr "class"