localstorage for show-hides, sortable tables, more navigation
This commit is contained in:
parent
dd07a1307f
commit
475411bb4a
@ -90,6 +90,7 @@ data MenuTypes
|
|||||||
= NavbarLeft { menuItem :: MenuItem }
|
= NavbarLeft { menuItem :: MenuItem }
|
||||||
| NavbarRight { menuItem :: MenuItem }
|
| NavbarRight { menuItem :: MenuItem }
|
||||||
| NavbarExtra { menuItem :: MenuItem }
|
| NavbarExtra { menuItem :: MenuItem }
|
||||||
|
| NavbarSecondary { menuItem :: MenuItem }
|
||||||
|
|
||||||
-- | A convenient synonym for creating forms.
|
-- | A convenient synonym for creating forms.
|
||||||
type Form x = Html -> MForm (HandlerT UniWorX IO) (FormResult x, Widget)
|
type Form x = Html -> MForm (HandlerT UniWorX IO) (FormResult x, Widget)
|
||||||
@ -277,7 +278,7 @@ instance YesodBreadcrumbs UniWorX where
|
|||||||
|
|
||||||
defaultLinks :: [MenuTypes]
|
defaultLinks :: [MenuTypes]
|
||||||
defaultLinks = -- Define the menu items of the header.
|
defaultLinks = -- Define the menu items of the header.
|
||||||
[ NavbarLeft $ MenuItem
|
[ NavbarRight $ MenuItem
|
||||||
{ menuItemLabel = "Home"
|
{ menuItemLabel = "Home"
|
||||||
, menuItemRoute = HomeR
|
, menuItemRoute = HomeR
|
||||||
, menuItemAccessCallback = return True
|
, menuItemAccessCallback = return True
|
||||||
@ -287,7 +288,7 @@ defaultLinks = -- Define the menu items of the header.
|
|||||||
, menuItemRoute = CourseListR
|
, menuItemRoute = CourseListR
|
||||||
, menuItemAccessCallback = return True
|
, menuItemAccessCallback = return True
|
||||||
}
|
}
|
||||||
, NavbarRight $ MenuItem
|
, NavbarLeft $ MenuItem
|
||||||
{ menuItemLabel = "Users"
|
{ menuItemLabel = "Users"
|
||||||
, menuItemRoute = UsersR
|
, menuItemRoute = UsersR
|
||||||
, menuItemAccessCallback = return True -- Creates a LOOP: (Authorized ==) <$> isAuthorized UsersR False
|
, menuItemAccessCallback = return True -- Creates a LOOP: (Authorized ==) <$> isAuthorized UsersR False
|
||||||
@ -297,12 +298,12 @@ defaultLinks = -- Define the menu items of the header.
|
|||||||
, menuItemRoute = ProfileR
|
, menuItemRoute = ProfileR
|
||||||
, menuItemAccessCallback = isJust <$> maybeAuthPair
|
, menuItemAccessCallback = isJust <$> maybeAuthPair
|
||||||
}
|
}
|
||||||
, NavbarRight $ MenuItem
|
, NavbarSecondary $ MenuItem
|
||||||
{ menuItemLabel = "Login"
|
{ menuItemLabel = "Login"
|
||||||
, menuItemRoute = AuthR LoginR
|
, menuItemRoute = AuthR LoginR
|
||||||
, menuItemAccessCallback = isNothing <$> maybeAuthPair
|
, menuItemAccessCallback = isNothing <$> maybeAuthPair
|
||||||
}
|
}
|
||||||
, NavbarRight $ MenuItem
|
, NavbarSecondary $ MenuItem
|
||||||
{ menuItemLabel = "Logout"
|
{ menuItemLabel = "Logout"
|
||||||
, menuItemRoute = AuthR LogoutR
|
, menuItemRoute = AuthR LogoutR
|
||||||
, menuItemAccessCallback = isJust <$> maybeAuthPair
|
, menuItemAccessCallback = isJust <$> maybeAuthPair
|
||||||
|
|||||||
@ -70,11 +70,11 @@ getCourseListTermR tidini = do
|
|||||||
, menuItemAccessCallback = (== Authorized) <$> isAuthorized CourseEditR False
|
, menuItemAccessCallback = (== Authorized) <$> isAuthorized CourseEditR False
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
let coursesTable = encodeWidgetTable tableSortable colonnadeTerms courses
|
||||||
defaultLinkLayout pageLinks $ do
|
defaultLinkLayout pageLinks $ do
|
||||||
-- defaultLayout $ do
|
-- defaultLayout $ do
|
||||||
setTitle "Semesterkurse"
|
setTitle "Semesterkurse"
|
||||||
linkButton "Neuen Kurs anlegen" BCPrimary CourseEditR
|
$(widgetFile "courses")
|
||||||
encodeWidgetTable tableDefault colonnadeTerms courses -- (map entityVal courses)
|
|
||||||
|
|
||||||
getCourseShowR :: TermId -> Text -> Handler Html
|
getCourseShowR :: TermId -> Text -> Handler Html
|
||||||
getCourseShowR tid csh = do
|
getCourseShowR tid csh = do
|
||||||
@ -324,5 +324,3 @@ validateCourse (CourseForm{..}) =
|
|||||||
, "Anmeldungen aktivieren oder Anmeldezeitraum löschen"
|
, "Anmeldungen aktivieren oder Anmeldezeitraum löschen"
|
||||||
)
|
)
|
||||||
] ]
|
] ]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -69,7 +69,7 @@ getTermShowR = do
|
|||||||
]
|
]
|
||||||
defaultLayout $ do
|
defaultLayout $ do
|
||||||
setTitle "Freigeschaltete Semester"
|
setTitle "Freigeschaltete Semester"
|
||||||
encodeWidgetTable tableDefault colonnadeTerms termData
|
encodeWidgetTable tableSortable colonnadeTerms termData
|
||||||
|
|
||||||
|
|
||||||
getTermEditR :: Handler Html
|
getTermEditR :: Handler Html
|
||||||
|
|||||||
@ -41,5 +41,5 @@ getUsersR = do
|
|||||||
-- ++ map (\school -> headed (text2widget $ schoolName $ entityVal school) (\u -> "xx")) schools
|
-- ++ map (\school -> headed (text2widget $ schoolName $ entityVal school) (\u -> "xx")) schools
|
||||||
defaultLayout $ do
|
defaultLayout $ do
|
||||||
setTitle "Comprehensive User List"
|
setTitle "Comprehensive User List"
|
||||||
let userList = encodeWidgetTable tableDefault colonnadeUsers users
|
let userList = encodeWidgetTable tableSortable colonnadeUsers users
|
||||||
$(widgetFile "users")
|
$(widgetFile "users")
|
||||||
|
|||||||
@ -25,6 +25,9 @@ import Data.Either
|
|||||||
tableDefault :: Attribute
|
tableDefault :: Attribute
|
||||||
tableDefault = customAttribute "class" "table table-striped table-hover"
|
tableDefault = customAttribute "class" "table table-striped table-hover"
|
||||||
|
|
||||||
|
tableSortable :: Attribute
|
||||||
|
tableSortable = customAttribute "class" "js-sortable"
|
||||||
|
|
||||||
-- Colonnade Tools
|
-- Colonnade Tools
|
||||||
numberColonnade :: (IsString c) => Colonnade Headed Int c
|
numberColonnade :: (IsString c) => Colonnade Headed Int c
|
||||||
numberColonnade = headed "Nr" (fromString.show)
|
numberColonnade = headed "Nr" (fromString.show)
|
||||||
|
|||||||
6
templates/courses.hamlet
Normal file
6
templates/courses.hamlet
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<div>
|
||||||
|
<h1>Kursübersicht für Semester #{termToText $ unTermKey tidini}
|
||||||
|
^{coursesTable}
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<a href=@{CourseEditR}>Neuen Kurs anlegen
|
||||||
@ -19,7 +19,3 @@
|
|||||||
|
|
||||||
<!-- actual content -->
|
<!-- actual content -->
|
||||||
^{widget}
|
^{widget}
|
||||||
|
|
||||||
<!-- footer -->
|
|
||||||
<footer>
|
|
||||||
#{appCopyright $ appSettings master}
|
|
||||||
|
|||||||
@ -28,12 +28,14 @@
|
|||||||
--blackbase: #1A2A36;
|
--blackbase: #1A2A36;
|
||||||
--fontbase: #34303a;
|
--fontbase: #34303a;
|
||||||
--fontsec: #5b5861;
|
--fontsec: #5b5861;
|
||||||
|
--primarybase: #4C7A9C;
|
||||||
|
|
||||||
|
|
||||||
/* THEME INDEPENDENT COLORS */
|
/* THEME INDEPENDENT COLORS */
|
||||||
--errorbase: red;
|
--errorbase: red;
|
||||||
--warningbase: #fe7700;
|
--warningbase: #fe7700;
|
||||||
--validbase: #2dcc35;
|
--validbase: #2dcc35;
|
||||||
|
--infobase: var(--darkbase);
|
||||||
|
|
||||||
|
|
||||||
/* FONTS */
|
/* FONTS */
|
||||||
@ -100,12 +102,23 @@ h4 {
|
|||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
table {
|
||||||
|
margin: 21px 0;
|
||||||
|
/*width: 100%;*/
|
||||||
|
}
|
||||||
th, td {
|
th, td {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
padding: 0 2px 0 4px;
|
padding: 0 13px 0 7px;
|
||||||
|
vertical-align: baseline;
|
||||||
|
}
|
||||||
|
th:first-child,
|
||||||
|
td:first-child {
|
||||||
|
padding-left: 0;
|
||||||
|
border-left: 0;
|
||||||
|
}
|
||||||
|
th {
|
||||||
|
border-left: 2px solid var(--greybase);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* LAYOUT */
|
/* LAYOUT */
|
||||||
.main {
|
.main {
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -115,6 +128,7 @@ th, td {
|
|||||||
|
|
||||||
.main__aside {
|
.main__aside {
|
||||||
width: 300px;
|
width: 300px;
|
||||||
|
flex-shrink: 0;
|
||||||
padding-right: 20px;
|
padding-right: 20px;
|
||||||
padding-left: 4vw;
|
padding-left: 4vw;
|
||||||
background-color: var(--darkbase);
|
background-color: var(--darkbase);
|
||||||
@ -144,3 +158,57 @@ th, td {
|
|||||||
outline: 5px auto var(--lightbase);
|
outline: 5px auto var(--lightbase);
|
||||||
outline: 5px auto -webkit-focus-ring-color;
|
outline: 5px auto -webkit-focus-ring-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* GENERAL BUTTON STYLES */
|
||||||
|
input[type="submit"],
|
||||||
|
input[type="button"],
|
||||||
|
button,
|
||||||
|
.btn {
|
||||||
|
outline: 0;
|
||||||
|
border: 0;
|
||||||
|
box-shadow: 0;
|
||||||
|
background-color: var(--lightbase);
|
||||||
|
color: white;
|
||||||
|
padding: 10px 17px;
|
||||||
|
min-width: 100px;
|
||||||
|
transition: all .1s;
|
||||||
|
font-size: 16px;
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: 4px;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
input.btn-primary,
|
||||||
|
button.btn-primary,
|
||||||
|
.btn.btn-primary {
|
||||||
|
background-color: var(--primarybase);
|
||||||
|
}
|
||||||
|
|
||||||
|
input.btn-info,
|
||||||
|
button.btn-info,
|
||||||
|
.btn.btn-info {
|
||||||
|
background-color: var(--infobase)
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="submit"][disabled],
|
||||||
|
input[type="button"][disabled],
|
||||||
|
button[disabled],
|
||||||
|
.btn[disabled] {
|
||||||
|
opacity: 0.3;
|
||||||
|
background-color: var(--greybase);
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="submit"]:not([disabled]):hover,
|
||||||
|
input[type="button"]:not([disabled]):hover,
|
||||||
|
button:not([disabled]):hover,
|
||||||
|
.btn:not([disabled]):hover {
|
||||||
|
background-color: var(--lighterbase);
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="submit"].btn-info:hover,
|
||||||
|
input[type="button"].btn-info:hover,
|
||||||
|
button.btn-info:hover,
|
||||||
|
.btn.btn-info:hover {
|
||||||
|
background-color: var(--greybase)
|
||||||
|
}
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
<a href=@{SubmissionListR}>Dateien hochladen und abrufen
|
<a href=@{SubmissionListR}>Dateien hochladen und abrufen
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
<div .js-show-hide.js-show-hide--collapsed>
|
<div .js-show-hide data-collapsed=true>
|
||||||
<h2 .js-show-hide__toggle>Tabellen
|
<h2 .js-show-hide__toggle>Tabellen
|
||||||
<table .js-sortable>
|
<table .js-sortable>
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@ -16,12 +16,31 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
var toggle = toggles[el.dataset.index];
|
var toggle = toggles[el.dataset.index];
|
||||||
toggle.collapsed = !toggle.collapsed;
|
toggle.collapsed = !toggle.collapsed;
|
||||||
toggle.parent.classList.toggle('js-show-hide--collapsed', toggle.collapsed);
|
toggle.parent.classList.toggle('js-show-hide--collapsed', toggle.collapsed);
|
||||||
|
updateLocalStorage();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateLocalStorage(id) {
|
||||||
|
let jsonToggles = JSON.stringify(toggles.map(t => {
|
||||||
|
return {id: t.index, collapsed: t.collapsed};
|
||||||
|
}));
|
||||||
|
window.localStorage.setItem('showHidesToggles', jsonToggles);
|
||||||
|
}
|
||||||
|
|
||||||
|
function collapsedStateInLocalStorage(id, fallBack) {
|
||||||
|
let lsData = JSON.parse(window.localStorage.getItem('showHidesToggles'));
|
||||||
|
if (lsData[id]) {
|
||||||
|
return lsData[id].collapsed;
|
||||||
|
}
|
||||||
|
return fallBack;
|
||||||
|
}
|
||||||
|
|
||||||
elements.forEach(function(el, i) {
|
elements.forEach(function(el, i) {
|
||||||
el.dataset.index = i;
|
el.dataset.index = i;
|
||||||
var coll = el.parentElement.classList.contains('js-show-hide--collapsed');
|
var coll = collapsedStateInLocalStorage(i, el.parentElement.dataset.collapsed === 'true');
|
||||||
|
if (coll) {
|
||||||
|
el.parentElement.classList.add('js-show-hide--collapsed')
|
||||||
|
}
|
||||||
Array.from(el.parentElement.children).forEach(function(el) {
|
Array.from(el.parentElement.children).forEach(function(el) {
|
||||||
if (!el.classList.contains('js-show-hide__toggle')) {
|
if (!el.classList.contains('js-show-hide__toggle')) {
|
||||||
el.classList.add('js-show-hide__target');
|
el.classList.add('js-show-hide__target');
|
||||||
|
|||||||
@ -13,8 +13,8 @@ table.js-sortable th.sorted-asc::after,
|
|||||||
table.js-sortable th.sorted-desc::after {
|
table.js-sortable th.sorted-desc::after {
|
||||||
content: '';
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
right: 0;
|
||||||
top: 0;
|
top: 15px;
|
||||||
width: 0;
|
width: 0;
|
||||||
height: 0;
|
height: 0;
|
||||||
transform: translateY(-100%);
|
transform: translateY(-100%);
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
<div .asidenav>
|
<div .asidenav>
|
||||||
<div .asidenav__box>
|
<div .asidenav__box>
|
||||||
<h3 .asidenav__box-title>NavbarLefts
|
|
||||||
<ul .asidenav__list>
|
<ul .asidenav__list>
|
||||||
$forall menuType <- menuTypes
|
$forall menuType <- menuTypes
|
||||||
$case menuType
|
$case menuType
|
||||||
@ -8,6 +7,7 @@
|
|||||||
<li .asidenav__list-item :Just route == mcurrentRoute:.asidenav__list-item--active>
|
<li .asidenav__list-item :Just route == mcurrentRoute:.asidenav__list-item--active>
|
||||||
<a .asidenav__link href=@{route}>#{label}
|
<a .asidenav__link href=@{route}>#{label}
|
||||||
$of _
|
$of _
|
||||||
|
|
||||||
<div .asidenav__box>
|
<div .asidenav__box>
|
||||||
<h3 .asidenav__box-title>WiSe 17/18
|
<h3 .asidenav__box-title>WiSe 17/18
|
||||||
<ul .asidenav__list>
|
<ul .asidenav__list>
|
||||||
|
|||||||
@ -134,7 +134,7 @@
|
|||||||
var nextInput = document.createElement('input');
|
var nextInput = document.createElement('input');
|
||||||
var remover = document.createElement('div');
|
var remover = document.createElement('div');
|
||||||
cont.classList.add('file-input__container');
|
cont.classList.add('file-input__container');
|
||||||
desc.classList.add('file-input__label');
|
desc.classList.add('file-input__label', 'btn');
|
||||||
remover.classList.add('file-input__remover');
|
remover.classList.add('file-input__remover');
|
||||||
nextInput.setAttribute('name', name);
|
nextInput.setAttribute('name', name);
|
||||||
nextInput.setAttribute('type', 'file');
|
nextInput.setAttribute('type', 'file');
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* GENERAL STYLES FOR FORMS */
|
/* GENERAL STYLES FOR FORMS */
|
||||||
|
|
||||||
/* FORMS */
|
/* TEXT INPUTS */
|
||||||
input[type="text"],
|
input[type="text"],
|
||||||
input[type="password"],
|
input[type="password"],
|
||||||
input[type="url"],
|
input[type="url"],
|
||||||
@ -27,36 +27,9 @@ input[type="email"]:focus {
|
|||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="submit"],
|
/* BUTTON STYLE SEE default-layout.lucius */
|
||||||
input[type="button"],
|
|
||||||
button {
|
|
||||||
outline: 0;
|
|
||||||
border: 0;
|
|
||||||
box-shadow: 0;
|
|
||||||
background-color: var(--lightbase);
|
|
||||||
color: white;
|
|
||||||
padding: 10px 17px;
|
|
||||||
min-width: 100px;
|
|
||||||
transition: all .1s;
|
|
||||||
font-size: 16px;
|
|
||||||
cursor: pointer;
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type="submit"][disabled],
|
|
||||||
input[type="button"][disabled],
|
|
||||||
button[disabled] {
|
|
||||||
opacity: 0.3;
|
|
||||||
background-color: var(--greybase);
|
|
||||||
cursor: default;
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type="submit"]:not([disabled]):hover,
|
|
||||||
input[type="button"]:not([disabled]):hover,
|
|
||||||
button:not([disabled]):hover {
|
|
||||||
background-color: var(--lighterbase);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/* TEXTAREAS */
|
||||||
textarea {
|
textarea {
|
||||||
outline: 0;
|
outline: 0;
|
||||||
border: 0;
|
border: 0;
|
||||||
@ -75,7 +48,7 @@ textarea:focus {
|
|||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
border-bottom-color: var(--lightbase);
|
border-bottom-color: var(--lightbase);
|
||||||
}
|
}
|
||||||
|
/* FORM GROUPS */
|
||||||
.form-group {
|
.form-group {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: grid;
|
display: grid;
|
||||||
@ -267,12 +240,13 @@ input[type="file"] {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
.file-input__label {
|
.file-input__label {
|
||||||
background-color: var(--lighterbase);
|
|
||||||
text-align: left;
|
text-align: left;
|
||||||
position: relative;
|
position: relative;
|
||||||
min-width: 40px;
|
|
||||||
height: 30px;
|
height: 30px;
|
||||||
}
|
}
|
||||||
|
.file-input__label.btn {
|
||||||
|
padding: 5px 13px;
|
||||||
|
}
|
||||||
.file-input__label::after,
|
.file-input__label::after,
|
||||||
.file-input__label::before {
|
.file-input__label::before {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|||||||
@ -3,12 +3,12 @@
|
|||||||
<ul .navbar__list.list--inline>
|
<ul .navbar__list.list--inline>
|
||||||
$forall menuType <- menuTypes
|
$forall menuType <- menuTypes
|
||||||
$case menuType
|
$case menuType
|
||||||
$of NavbarLeft (MenuItem label route _)
|
|
||||||
<li .navbar__list-item :Just route == mcurrentRoute:.navbar__list-item--active>
|
|
||||||
<a .navbar__link href=@{route}>#{label}
|
|
||||||
$of NavbarRight (MenuItem label route _)
|
$of NavbarRight (MenuItem label route _)
|
||||||
<li .navbar__list-item :Just route == mcurrentRoute:.navbar__list-item--active>
|
<li .navbar__list-item :Just route == mcurrentRoute:.navbar__list-item--active>
|
||||||
<a .navbar__link href=@{route}>#{label}
|
<a .navbar__link href=@{route}>#{label}
|
||||||
|
$of NavbarSecondary (MenuItem label route _)
|
||||||
|
<li .navbar__list-item.navbar__list-item--secondary :Just route == mcurrentRoute:.navbar__list-item--active>
|
||||||
|
<a .navbar__link href=@{route}>#{label}
|
||||||
$of _
|
$of _
|
||||||
|
|
||||||
<div .navbar__pushdown>
|
<div .navbar__pushdown>
|
||||||
|
|||||||
@ -25,12 +25,22 @@
|
|||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.navbar__list-item--secondary {
|
||||||
|
margin-left: 20px;
|
||||||
|
background-color: var(--fontsec);
|
||||||
|
}
|
||||||
|
.navbar__list-item--secondary + .navbar__list-item--secondary {
|
||||||
|
margin-left: 0;
|
||||||
|
border-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.navbar__list-item--active > .navbar__link {
|
.navbar__list-item--active > .navbar__link {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
color: var(--darkbase);
|
color: var(--darkbase);
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar .navbar__list-item > .navbar__link:hover {
|
.navbar .navbar__list-item > .navbar__link:hover {
|
||||||
|
color: var(--whitebase);
|
||||||
background-color: var(--darkbase);
|
background-color: var(--darkbase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user