diff --git a/messages/de.msg b/messages/de.msg index 70a11676a..0ec55519f 100644 --- a/messages/de.msg +++ b/messages/de.msg @@ -1,7 +1,7 @@ SummerTerm year@Integer: Sommersemester #{tshow year} WinterTerm year@Integer: Wintersemester #{tshow year}/#{tshow $ succ year} PSLimitNonPositive: “pagesize” muss größer als null sein -Page n@Int64 num@Int64: Seite #{tshow n} von #{tshow num} +Page n@Int64: #{tshow n} TermEdited tid@TermIdentifier: Semester #{termToText tid} erfolgreich editiert. TermNewTitle: Semester editiere/anlegen. InvalidInput: Eingaben bitte korrigieren. diff --git a/src/Foundation.hs b/src/Foundation.hs index b4acfa24d..d02a5e08c 100644 --- a/src/Foundation.hs +++ b/src/Foundation.hs @@ -96,9 +96,14 @@ data MenuItem = MenuItem { menuItemLabel :: Text , menuItemIcon :: Maybe Text , menuItemRoute :: Route UniWorX - , menuItemAccessCallback :: Handler Bool + , menuItemAccessCallback' :: Handler Bool } +menuItemAccessCallback :: MenuItem -> Handler Bool +menuItemAccessCallback MenuItem{..} = (&&) <$> ((==) Authorized <$> authCheck) <*> menuItemAccessCallback' + where + authCheck = handleAny (\_ -> return . Unauthorized $ error "authCheck caught exception") $ isAuthorized menuItemRoute False + data MenuTypes -- Semantische Rolle: = NavbarAside { menuItem :: MenuItem } -- TODO | NavbarExtra { menuItem :: MenuItem } -- TODO @@ -357,49 +362,49 @@ defaultLinks = -- Define the menu items of the header. { menuItemLabel = "Home" , menuItemIcon = Just "home" , menuItemRoute = HomeR - , menuItemAccessCallback = return True + , menuItemAccessCallback' = return True } , NavbarRight $ MenuItem { menuItemLabel = "Profile" , menuItemIcon = Just "profile" , menuItemRoute = ProfileR - , menuItemAccessCallback = isJust <$> maybeAuthPair + , menuItemAccessCallback' = isJust <$> maybeAuthPair } , NavbarSecondary $ MenuItem { menuItemLabel = "Login" , menuItemIcon = Just "login" , menuItemRoute = AuthR LoginR - , menuItemAccessCallback = isNothing <$> maybeAuthPair + , menuItemAccessCallback' = isNothing <$> maybeAuthPair } , NavbarSecondary $ MenuItem { menuItemLabel = "Logout" , menuItemIcon = Just "logout" , menuItemRoute = AuthR LogoutR - , menuItemAccessCallback = isJust <$> maybeAuthPair + , menuItemAccessCallback' = isJust <$> maybeAuthPair } , NavbarAside $ MenuItem { menuItemLabel = "Aktuelle Veranstaltungen" , menuItemIcon = Just "book" , menuItemRoute = CourseListR -- should be CourseListActiveR or similar in the future - , menuItemAccessCallback = return True + , menuItemAccessCallback' = return True } , NavbarAside $ MenuItem { menuItemLabel = "Alte Veranstaltungen" , menuItemIcon = Just "book" , menuItemRoute = CourseListR -- should be CourseListInactiveR or similar in the future - , menuItemAccessCallback = return True + , menuItemAccessCallback' = return True } , NavbarAside $ MenuItem { menuItemLabel = "Veranstaltungen" , menuItemIcon = Just "book" , menuItemRoute = CourseListR - , menuItemAccessCallback = return True + , menuItemAccessCallback' = return True } , NavbarAside $ MenuItem { menuItemLabel = "Benutzer" , menuItemIcon = Just "user" , menuItemRoute = UsersR - , menuItemAccessCallback = return True -- Creates a LOOP: (Authorized ==) <$> isAuthorized UsersR False + , menuItemAccessCallback' = return True -- Creates a LOOP: (Authorized ==) <$> isAuthorized UsersR False } ] diff --git a/src/Handler/Course.hs b/src/Handler/Course.hs index 1d22bc287..1945f323a 100644 --- a/src/Handler/Course.hs +++ b/src/Handler/Course.hs @@ -68,7 +68,7 @@ getCourseListTermR tidini = do { menuItemLabel = "Neuer Kurs" , menuItemIcon = Just "book" , menuItemRoute = CourseNewR - , menuItemAccessCallback = (== Authorized) <$> isAuthorized CourseNewR False + , menuItemAccessCallback' = return True } ] let coursesTable = encodeWidgetTable tableSortable colonnadeTerms courses @@ -97,7 +97,7 @@ getCourseShowR tid csh = do { menuItemLabel = "Übungsblätter" , menuItemIcon = Nothing , menuItemRoute = CSheetR tid csh SheetListR - , menuItemAccessCallback = (== Authorized) <$> isAuthorized (CSheetR tid csh SheetListR) False + , menuItemAccessCallback' = return True } ] defaultLinkLayout pageActions $ do diff --git a/src/Handler/Sheet.hs b/src/Handler/Sheet.hs index b6a3b148f..3baa7ece0 100644 --- a/src/Handler/Sheet.hs +++ b/src/Handler/Sheet.hs @@ -168,7 +168,7 @@ getSheetList courseEnt = do { menuItemLabel = "Neues Übungsblatt" , menuItemIcon = Nothing , menuItemRoute = CSheetR tid csh SheetNewR - , menuItemAccessCallback = (== Authorized) <$> isAuthorized CourseNewR False + , menuItemAccessCallback' = return True } ] defaultLinkLayout pageActions $ do diff --git a/src/Handler/Term.hs b/src/Handler/Term.hs index 2461a05fc..46f464cc1 100644 --- a/src/Handler/Term.hs +++ b/src/Handler/Term.hs @@ -94,7 +94,7 @@ getTermShowR = do { menuItemLabel = "Neues Semester" , menuItemIcon = Nothing , menuItemRoute = TermEditR - , menuItemAccessCallback = (== Authorized) <$> isAuthorized TermEditR True + , menuItemAccessCallback' = return True } ] defaultLinkLayout pageActions $ do diff --git a/src/Handler/Utils/Table/Pagination.hs b/src/Handler/Utils/Table/Pagination.hs index ef3ab45ec..8969d1a7d 100644 --- a/src/Handler/Utils/Table/Pagination.hs +++ b/src/Handler/Utils/Table/Pagination.hs @@ -152,11 +152,18 @@ dbTable PSValidator{..} DBTable{ dbtIdent = (toPathPiece -> dbtIdent), .. } = do getParams <- handlerToWidget $ queryToQueryText . Wai.queryString . reqWaiRequest <$> getRequest let table = $(widgetFile "table/colonnade") pageCount = max 1 . ceiling $ rowCount % psLimit + pageNumbers = [0..pred pageCount] tblLink f = decodeUtf8 . Builder.toLazyByteString . renderQueryText True $ f getParams + withSortLinks Sortable{ sortableContent = Cell{..}, .. } = Cell { cellContents = $(widgetFile "table/sortable-header") - , .. + , cellAttrs = maybe mempty (const sortableAttr) sortableKey <> cellAttrs } + where + directions = [dir | (k, dir) <- psSorting, Just k == sortableKey ] + sortableAttr = Html5.class_ . fromString . unwords $ "sortable" : foldMap toAttr directions + toAttr SortAsc = ["sorted-asc"] + toAttr SortDesc = ["sorted-desc"] $(widgetFile "table/layout") where tblLayout :: Widget -> Handler Html diff --git a/templates/default-layout.lucius b/templates/default-layout.lucius index cc33bfe58..3574d3a43 100644 --- a/templates/default-layout.lucius +++ b/templates/default-layout.lucius @@ -20,7 +20,8 @@ --fontbase: #34303a; --fontsec: #5b5861; /* THEME 4 */ - --darkbase: #263C4C; + --darkerbase: #274a65; + --darkbase: #425d79; --lightbase: #598EB5; --lighterbase: #5F98C2; --whitebase: #FCFFFA; diff --git a/templates/standalone/modal.lucius b/templates/standalone/modal.lucius index a511f58c6..f9e1db4e2 100644 --- a/templates/standalone/modal.lucius +++ b/templates/standalone/modal.lucius @@ -70,7 +70,7 @@ justify-content: center; width: 30px; height: 30px; - background-color: var(--darkbase); + background-color: var(--darkerbase); border-radius: 2px; cursor: pointer; z-index: 20; diff --git a/templates/table/colonnade.julius b/templates/table/colonnade.julius deleted file mode 100644 index 840cccd6a..000000000 --- a/templates/table/colonnade.julius +++ /dev/null @@ -1,61 +0,0 @@ -(function collonadeClosure() { - 'use strict'; - - document.addEventListener('DOMContentLoaded', function DOMContentLoaded() { - - var ASC = 'asc'; - var DESC = 'desc'; - - // TODO: Make use of interpolated dbtIdent - var table = document.querySelector('table'); - var ths = Array.from(table.querySelectorAll('th')); - - // attach click handler to each table-header - ths.map(function(th) { - var link = th.querySelector('a'); - if (link) { - link.addEventListener('click', clickHandler); - } - }); - - // handles click on table header - function clickHandler(event) { - event.preventDefault(); - var url = new URL(window.location.origin + window.location.pathname + this.getAttribute('href')); - var order = this.parentNode.dataset.order || ASC; - // TODO: not working here... getting whole page as response... - url.searchParams.set('table-only', 'true'); - updateTableFrom(url); - markSorted(this.parentNode, order); - } - - function markSorted(th, order) { - ths.forEach(function(th) { - th.classList.remove('sorted-asc', 'sorted-desc'); - }); - th.classList.add('sorted-' + order); - th.dataset.order = order; - } - - // fetches new sorted table from url with params and replaces contents of current table - function updateTableFrom(url) { - fetch(url, { - headers: { - 'Accept': 'text/html' - } - }).then(function(response) { - var contentType = response.headers.get("content-type"); - if (!response.ok) { - throw ('Looks like there was a problem fetching ' + url.toString() + '. Status Code: ' + response.status); - } - return response.text(); - }).then(function(data) { - // replace contents of table body - table.querySelector('tbody').innerHTML = data; - }).catch(function(err) { - console.error(err); - }); - } - - }); -})(); diff --git a/templates/table/colonnade.lucius b/templates/table/colonnade.lucius index 4fcdad6e2..dc7abd2b1 100644 --- a/templates/table/colonnade.lucius +++ b/templates/table/colonnade.lucius @@ -1,7 +1,14 @@ table th { - cursor: pointer; position: relative; padding-right: 20px; + + &.sortable { + cursor: pointer; + } + + a { + font-weight: 800; + } } table th.sorted-asc, @@ -9,12 +16,11 @@ table th.sorted-desc { color: var(--lightbase); } -table th.sorted-asc::after, -table th.sorted-desc::after { +table th.sortable::after, +table th.sortable::before { content: ''; position: absolute; right: 0; - top: 15px; width: 0; height: 0; transform: translateY(-100%); @@ -22,7 +28,15 @@ table th.sorted-desc::after { border-right: 8px solid transparent; } -table th.sorted-asc::after { +table th.sortable::before { + top: 21px; + border-top: 8px solid rgba(0, 0, 0, 0.1); +} +table th.sortable::after { + top: 9px; + border-bottom: 8px solid rgba(0, 0, 0, 0.1); +} +table th.sorted-asc::before { border-top: 8px solid var(--lightbase); } diff --git a/templates/table/layout.hamlet b/templates/table/layout.hamlet index 009e4eb2c..a6578422c 100644 --- a/templates/table/layout.hamlet +++ b/templates/table/layout.hamlet @@ -1,6 +1,10 @@ -
- ^{table} +$newline never +
+
+ ^{table} $if pageCount > 1 -

- $# TODO: foreach (reachable pages) print link to that page - _{MsgPage (succ psPage) pageCount} +