Merge branch 'master' into 623-kursassoziierte-studienfacher-abschaffen

This commit is contained in:
Gregor Kleen 2020-08-26 13:45:37 +02:00
commit ab841a65a3
8 changed files with 72 additions and 27 deletions

View File

@ -34,7 +34,7 @@ npm install:
- install -v -T -m 0644 ${APT_SOURCES_LIST} /etc/apt/sources.list - install -v -T -m 0644 ${APT_SOURCES_LIST} /etc/apt/sources.list
- apt-get update -y - apt-get update -y
- npm install -g n - npm install -g n
- n 13.5.0 - n 14.8.0
- export PATH="${N_PREFIX}/bin:$PATH" - export PATH="${N_PREFIX}/bin:$PATH"
- npm install -g npm - npm install -g npm
- hash -r - hash -r
@ -149,7 +149,7 @@ frontend:test:
- install -v -T -m 0644 ${APT_SOURCES_LIST} /etc/apt/sources.list - install -v -T -m 0644 ${APT_SOURCES_LIST} /etc/apt/sources.list
- apt-get update -y - apt-get update -y
- npm install -g n - npm install -g n
- n 13.5.0 - n 14.8.0
- export PATH="${N_PREFIX}/bin:$PATH" - export PATH="${N_PREFIX}/bin:$PATH"
- npm install -g npm - npm install -g npm
- hash -r - hash -r

View File

@ -2,6 +2,13 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [19.2.1](https://gitlab2.rz.ifi.lmu.de/uni2work/uni2work/compare/v19.2.0...v19.2.1) (2020-08-26)
### Bug Fixes
* improve hidecolumns behaviour ([9a4f30b](https://gitlab2.rz.ifi.lmu.de/uni2work/uni2work/commit/9a4f30b811fdf8c58ec5c50c185628eb3158931a))
## [19.2.0](https://gitlab2.rz.ifi.lmu.de/uni2work/uni2work/compare/v19.1.5...v19.2.0) (2020-08-24) ## [19.2.0](https://gitlab2.rz.ifi.lmu.de/uni2work/uni2work/compare/v19.1.5...v19.2.0) (2020-08-24)

View File

@ -5,17 +5,26 @@ import * as defer from 'lodash.defer';
class Overhang { class Overhang {
colSpan; colSpan;
rowSpan; rowSpan;
cell;
constructor(colSpan, rowSpan) { constructor(colSpan, rowSpan, cell) {
this.colSpan = colSpan; this.colSpan = colSpan;
this.rowSpan = rowSpan; this.rowSpan = rowSpan;
this.cell = cell;
if (new.target === Overhang) if (new.target === Overhang)
Object.freeze(this); Object.freeze(this);
} }
nextLine() { nextLine() {
return new Overhang(this.colSpan, Math.max(0, this.rowSpan - 1)); return new Overhang(this.colSpan, Math.max(0, this.rowSpan - 1), this.cell);
}
reduceCol(n) {
if (this.colSpan > n)
return new Overhang(this.colSpan - n, this.rowSpan, this.cell);
else
return null;
} }
isHole() { isHole() {
@ -57,11 +66,10 @@ export class TableIndices {
this._table = table; this._table = table;
let overhangs = new Array(); let currentOverhangs = new Array();
let currentRow = 0; let currentRow = 0;
for (const rowParent of this._table.rows) { for (const rowParent of this._table.rows) {
let currentOverhangs = Array.from(overhangs);
let newOverhangs = new Array(); let newOverhangs = new Array();
let cellBefore = 0; let cellBefore = 0;
@ -76,18 +84,38 @@ export class TableIndices {
break; break;
else else
newOverhangs.push(overhang.nextLine()); newOverhangs.push(overhang.nextLine());
if (DEBUG_MODE > 1)
console.log('From overhang', overhang);
cellBefore += overhang.colSpan; cellBefore += overhang.colSpan;
} }
currentOverhangs = currentOverhangs.slice(i); currentOverhangs = currentOverhangs.slice(i);
let remCols = this.colSpan(cell);
while (remCols > 0 && currentOverhangs[0]) {
let firstOverhang = currentOverhangs[0].reduceCol(this.colSpan(cell));
if (firstOverhang) {
if (DEBUG_MODE > 1)
console.log('Replace first overhang', remCols, currentOverhangs[0], firstOverhang);
currentOverhangs[0] = firstOverhang;
break;
} else {
if (DEBUG_MODE > 1)
console.log('Drop first overhang', remCols, currentOverhangs[0], firstOverhang);
remCols -= currentOverhangs[0].colSpan;
currentOverhangs.shift();
}
}
this._cellToIndices.set(cell, { row: currentRow, col: cellBefore }); this._cellToIndices.set(cell, { row: currentRow, col: cellBefore });
let rows = range(currentRow, currentRow + this.rowSpan(cell)); let rows = range(currentRow, currentRow + this.rowSpan(cell));
let columns = range(cellBefore, cellBefore + this.colSpan(cell)); let columns = range(cellBefore, cellBefore + this.colSpan(cell));
if (DEBUG_MODE > 0) { if (DEBUG_MODE > 1) {
console.log('Result', rows, columns);
cell.dataset.rows = JSON.stringify(rows); cell.dataset.rows = JSON.stringify(rows);
cell.dataset.columns = JSON.stringify(columns); cell.dataset.columns = JSON.stringify(columns);
} }
@ -104,11 +132,14 @@ export class TableIndices {
} }
} }
newOverhangs.push(new Overhang(this.colSpan(cell), this.rowSpan(cell) - 1)); newOverhangs.push(new Overhang(this.colSpan(cell), this.rowSpan(cell) - 1, cell));
if (DEBUG_MODE > 1)
console.log('From current cell', this.colSpan(cell));
cellBefore += this.colSpan(cell); cellBefore += this.colSpan(cell);
} }
overhangs = newOverhangs; currentOverhangs = Array.from(newOverhangs);
currentRow++; currentRow++;
} }

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "uni2work", "name": "uni2work",
"version": "19.2.0", "version": "19.2.1",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "uni2work", "name": "uni2work",
"version": "19.2.0", "version": "19.2.1",
"description": "", "description": "",
"keywords": [], "keywords": [],
"author": "", "author": "",

View File

@ -1,5 +1,5 @@
name: uniworx name: uniworx
version: 19.2.0 version: 19.2.1
dependencies: dependencies:
- base - base

View File

@ -74,7 +74,6 @@ import Control.Monad.State (evalStateT, execStateT)
import Control.Monad.Trans.Maybe import Control.Monad.Trans.Maybe
import Control.Monad.State.Class (modify) import Control.Monad.State.Class (modify)
import qualified Control.Monad.State.Class as State import qualified Control.Monad.State.Class as State
import Control.Monad.Trans.Writer.Lazy (censor)
import Data.Map ((!)) import Data.Map ((!))
import qualified Data.Map as Map import qualified Data.Map as Map
@ -1277,22 +1276,22 @@ dbTable PSValidator{..} dbtable@DBTable{ dbtIdent = dbtIdent'@(toPathPiece -> db
_other -> False _other -> False
genHeaders :: forall h. Cornice h _ _ (DBCell m x) -> SortableP h -> WriterT x m Widget genHeaders :: forall h. Cornice h _ _ (DBCell m x) -> SortableP h -> WriterT x m Widget
genHeaders cornice SortableP{..} = execWriterT . go mempty $ annotate cornice genHeaders cornice SortableP{..} = fmap wrap' . execWriterT . go mempty $ annotate cornice
where where
go :: forall (p' :: Pillar) r'. go :: forall (p' :: Pillar) r'.
[(Int, Int, Int)] [(Int, Int, Int)]
-> AnnotatedCornice (Maybe Int) h p' r' (DBCell m x) -> AnnotatedCornice (Maybe Int) h p' r' (DBCell m x)
-> WriterT Widget (WriterT x m) () -> WriterT (Seq (Seq (Widget, Int))) (WriterT x m) ()
go rowspanAcc (AnnotatedCorniceBase _ (Colonnade (toList -> v))) = censor wrap . forM_ (zip (inits v) v) $ \(before, OneColonnade Sized{..} _) -> do go rowspanAcc (AnnotatedCorniceBase _ (Colonnade (toList -> v))) = mapWriterT (over (mapped . _2) pure) . forM_ (zip (inits v) v) $ \(before, OneColonnade Sized{..} _) -> do
let (_, cellSize') = compCellSize rowspanAcc (map oneColonnadeHead before) Sized{..} let (_, cellSize') = compCellSize rowspanAcc (map oneColonnadeHead before) Sized{..}
whenIsJust cellSize' $ \cellSize -> tellM $ fromContent Sized { sizedSize = cellSize, sizedContent } whenIsJust cellSize' $ \cellSize -> tellM . fmap pure $ fromContent Sized { sizedSize = cellSize, sizedContent }
go rowspanAcc (AnnotatedCorniceCap _ v@(toList -> oneCornices)) = do go rowspanAcc (AnnotatedCorniceCap _ v@(toList -> oneCornices)) = do
rowspanAcc' <- (execStateT ?? rowspanAcc) . hoist (censor wrap) . forM_ (zip (inits oneCornices) oneCornices) $ \(before, OneCornice h (size -> sz')) -> do rowspanAcc' <- (execStateT ?? rowspanAcc) . hoist (mapWriterT $ over (mapped . _2) pure) . forM_ (zip (inits oneCornices) oneCornices) $ \(before, OneCornice h (size -> sz')) -> do
let sz = Sized sz' h let sz = Sized sz' h
let (beforeSize, cellSize') = compCellSize rowspanAcc (concatMap (map oneColonnadeHead . toList . getColonnade . uncapAnnotated . oneCorniceBody) before) sz let (beforeSize, cellSize') = compCellSize rowspanAcc (concatMap (map oneColonnadeHead . toList . getColonnade . uncapAnnotated . oneCorniceBody) before) sz
whenIsJust cellSize' $ \cellSize -> do whenIsJust cellSize' $ \cellSize -> do
let Sized{..} = sz let Sized{..} = sz
lift . tellM $ fromContent Sized { sizedSize = cellSize, sizedContent } lift . tellM . fmap pure $ fromContent Sized { sizedSize = cellSize, sizedContent }
if | [n] <- mapMaybe (\(key, val) -> guardOnM (is _Rowspan key) $ readMay val) (toSortable sizedContent ^. _sortableContent . cellAttrs) if | [n] <- mapMaybe (\(key, val) -> guardOnM (is _Rowspan key) $ readMay val) (toSortable sizedContent ^. _sortableContent . cellAttrs)
-> State.modify $ (:) (n, beforeSize, cellSize) -> State.modify $ (:) (n, beforeSize, cellSize)
| otherwise -> return () | otherwise -> return ()
@ -1309,11 +1308,14 @@ dbTable PSValidator{..} dbtable@DBTable{ dbtIdent = dbtIdent'@(toPathPiece -> db
guard $ beforeSize < firstCol + sz guard $ beforeSize < firstCol + sz
return . Sum $ sz - (beforeSize - firstCol) return . Sum $ sz - (beforeSize - firstCol)
wrap :: Widget -> Widget wrap' :: Seq (Seq (Widget, Int)) -> Widget
wrap row = case dbsTemplate of wrap' wRows = view _2 $ Foldable.foldl (\(stackHeight', acc) row -> (Nothing, (acc <>) . wrap stackHeight' $ foldOf (folded . _1) row)) (stackHeight, mempty) wRows
where stackHeight = maximumOf (folded . to (ala Sum foldMap . fmap (view _2))) wRows
wrap :: Maybe Int -> Widget -> Widget
wrap stackHeight row = case dbsTemplate of
DBSTCourse{} -> row DBSTCourse{} -> row
DBSTDefault{} -> $(widgetFile "table/header") DBSTDefault{} -> $(widgetFile "table/header")
fromContent :: Sized Int h (DBCell m x) -> WriterT x m Widget fromContent :: Sized Int h (DBCell m x) -> WriterT x m (Widget, Int)
fromContent Sized{ sizedSize = cellSize, sizedContent = toSortable -> Sortable{..} } = do fromContent Sized{ sizedSize = cellSize, sizedContent = toSortable -> Sortable{..} } = do
widget <- sortableContent ^. cellContents widget <- sortableContent ^. cellContents
let let
@ -1322,9 +1324,13 @@ dbTable PSValidator{..} dbtable@DBTable{ dbtIdent = dbtIdent'@(toPathPiece -> db
isSorted dir = fromMaybe False $ (==) <$> (SortingSetting <$> sortableKey <*> pure dir) <*> listToMaybe psSorting isSorted dir = fromMaybe False $ (==) <$> (SortingSetting <$> sortableKey <*> pure dir) <*> listToMaybe psSorting
attrs = sortableContent ^. cellAttrs attrs = sortableContent ^. cellAttrs
piSorting' = [ sSet | sSet <- fromMaybe [] piSorting, Just (sortKey sSet) /= sortableKey ] piSorting' = [ sSet | sSet <- fromMaybe [] piSorting, Just (sortKey sSet) /= sortableKey ]
case dbsTemplate of rowspan = preview _head $ do
DBSTCourse{} -> return $(widgetFile "table/course/header") (key, val) <- attrs
DBSTDefault{} -> return $(widgetFile "table/cell/header") guard $ is _Rowspan key
hoistMaybe $ readMay val
return . (, fromMaybe 1 rowspan) $ case dbsTemplate of
DBSTCourse{} -> $(widgetFile "table/course/header")
DBSTDefault{} -> $(widgetFile "table/cell/header")
in do in do
wHeaders <- maybe (return Nothing) (fmap Just . genHeaders (dbtColonnade ^. _Cornice)) pSortable wHeaders <- maybe (return Nothing) (fmap Just . genHeaders (dbtColonnade ^. _Cornice)) pSortable
now <- liftIO getCurrentTime now <- liftIO getCurrentTime

View File

@ -1,6 +1,7 @@
$newline never $newline never
<tr .table__row.table__row--head> <tr .table__row.table__row--head>
$if numberColumn $maybe rowspan <- stackHeight
<th .table__th uw-hide-columns--no-hide .table__th--number> $if numberColumn
<th .table__th uw-hide-columns--no-hide .table__th--number :rowspan /= 1:rowspan=#{rowspan}>
$# cell/header.hamlet $# cell/header.hamlet
^{row} ^{row}