Merge branch 'master' of gitlab.cip.ifi.lmu.de:jost/UniWorX
This commit is contained in:
commit
1cc314b653
@ -38,6 +38,7 @@ export class AsyncTable {
|
|||||||
change: [],
|
change: [],
|
||||||
select: [],
|
select: [],
|
||||||
};
|
};
|
||||||
|
_ignoreRequest = false;
|
||||||
|
|
||||||
constructor(element, app) {
|
constructor(element, app) {
|
||||||
if (!element) {
|
if (!element) {
|
||||||
@ -174,6 +175,10 @@ export class AsyncTable {
|
|||||||
}
|
}
|
||||||
}, INPUT_DEBOUNCE);
|
}, INPUT_DEBOUNCE);
|
||||||
input.addEventListener('input', debouncedInput);
|
input.addEventListener('input', debouncedInput);
|
||||||
|
input.addEventListener('input', () => {
|
||||||
|
// set flag to ignore any currently pending requests (not debounced)
|
||||||
|
this._ignoreRequest = true;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
this._tableFilterInputs.input.forEach((input) => {
|
this._tableFilterInputs.input.forEach((input) => {
|
||||||
@ -183,6 +188,10 @@ export class AsyncTable {
|
|||||||
}
|
}
|
||||||
}, INPUT_DEBOUNCE);
|
}, INPUT_DEBOUNCE);
|
||||||
input.addEventListener('input', debouncedInput);
|
input.addEventListener('input', debouncedInput);
|
||||||
|
input.addEventListener('input', () => {
|
||||||
|
// set flag to ignore any currently pending requests (not debounced)
|
||||||
|
this._ignoreRequest = true;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
this._tableFilterInputs.change.forEach((input) => {
|
this._tableFilterInputs.change.forEach((input) => {
|
||||||
@ -224,6 +233,7 @@ export class AsyncTable {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
this._ignoreRequest = false;
|
||||||
this._updateTableFrom(url, callback);
|
this._updateTableFrom(url, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,8 +350,13 @@ export class AsyncTable {
|
|||||||
url: url,
|
url: url,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
}).then(
|
}).then(
|
||||||
(response) => this._app.htmlHelpers.parseResponse(response)
|
(response) => this._app.htmlHelpers.parseResponse(response),
|
||||||
).then((response) => {
|
).then((response) => {
|
||||||
|
// check if request should be ignored
|
||||||
|
if (this._ignoreRequest) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
setLocalStorageParameter('currentTableUrl', url.href);
|
setLocalStorageParameter('currentTableUrl', url.href);
|
||||||
// reset table
|
// reset table
|
||||||
this._removeListeners();
|
this._removeListeners();
|
||||||
|
|||||||
@ -689,7 +689,7 @@ jsonField hide = Field{..}
|
|||||||
inputType
|
inputType
|
||||||
| hide = "hidden"
|
| hide = "hidden"
|
||||||
| otherwise = "text"
|
| otherwise = "text"
|
||||||
fieldParse [v] [] = return . bimap (SomeMessage . MsgJSONFieldDecodeFailure) Just . eitherDecodeStrict' $ encodeUtf8 v
|
fieldParse [encodeUtf8 -> v] [] = return . bimap (SomeMessage . MsgJSONFieldDecodeFailure) Just $ eitherDecodeStrict' v <|> eitherDecodeStrict' (urlDecode True v)
|
||||||
fieldParse [] [] = return $ Right Nothing
|
fieldParse [] [] = return $ Right Nothing
|
||||||
fieldParse _ _ = return . Left $ SomeMessage MsgValueRequired
|
fieldParse _ _ = return . Left $ SomeMessage MsgValueRequired
|
||||||
fieldView theId name attrs val isReq = liftWidgetT [whamlet|
|
fieldView theId name attrs val isReq = liftWidgetT [whamlet|
|
||||||
|
|||||||
@ -641,8 +641,12 @@ dbTable PSValidator{..} dbtable@DBTable{ dbtIdent = dbtIdent'@(toPathPiece -> db
|
|||||||
, fieldEnctype = UrlEncoded
|
, fieldEnctype = UrlEncoded
|
||||||
}
|
}
|
||||||
|
|
||||||
piPrevious <- lift . runInputMaybe $ ireq (jsonField True) (wIdent "pagination")
|
piPreviousPost <- lift . runInputPost $ iopt (jsonField True) (wIdent "pagination")
|
||||||
let piPreviousRes = maybe FormMissing FormSuccess piPrevious
|
piPreviousGet <- lift . runInputGet $ iopt (jsonField True) (wIdent "pagination")
|
||||||
|
let
|
||||||
|
piPreviousRes = maybe FormMissing FormSuccess $ piPreviousPost <|> piPreviousGet
|
||||||
|
$logDebugS "dbTable" [st|#{wIdent "pagination"}: #{tshow piPreviousRes}|]
|
||||||
|
|
||||||
previousKeys <- throwExceptT . runMaybeT $ encodedSecretBoxOpen =<< MaybeT (lift . lookupPostParam $ wIdent "previous")
|
previousKeys <- throwExceptT . runMaybeT $ encodedSecretBoxOpen =<< MaybeT (lift . lookupPostParam $ wIdent "previous")
|
||||||
|
|
||||||
piInput <- lift . runInputGetResult $ PaginationInput
|
piInput <- lift . runInputGetResult $ PaginationInput
|
||||||
|
|||||||
@ -626,18 +626,25 @@ formResult' (FormFailure _) = Nothing
|
|||||||
formResult' (FormSuccess x) = Just x
|
formResult' (FormSuccess x) = Just x
|
||||||
|
|
||||||
runInputGetMaybe, runInputPostMaybe, runInputMaybe :: MonadHandler m => FormInput m a -> m (Maybe a)
|
runInputGetMaybe, runInputPostMaybe, runInputMaybe :: MonadHandler m => FormInput m a -> m (Maybe a)
|
||||||
runInputGetMaybe form = do
|
runInputGetMaybe = fmap formResult' . runInputGetResult
|
||||||
res <- runInputGetResult form
|
runInputPostMaybe = fmap formResult' . runInputPostResult
|
||||||
return $ case res of
|
|
||||||
FormSuccess suc -> Just suc
|
|
||||||
_other -> Nothing
|
|
||||||
runInputPostMaybe form = do
|
|
||||||
res <- runInputPostResult form
|
|
||||||
return $ case res of
|
|
||||||
FormSuccess suc -> Just suc
|
|
||||||
_other -> Nothing
|
|
||||||
runInputMaybe form = runMaybeT $ MaybeT (runInputPostMaybe form) <|> MaybeT (runInputGetMaybe form)
|
runInputMaybe form = runMaybeT $ MaybeT (runInputPostMaybe form) <|> MaybeT (runInputGetMaybe form)
|
||||||
|
|
||||||
|
runInputResult :: MonadHandler m => FormInput m a -> m (FormResult a)
|
||||||
|
runInputResult form = do
|
||||||
|
postRes <- runInputPostResult form
|
||||||
|
getRes <- runInputGetResult form
|
||||||
|
return $ case (postRes, getRes) of
|
||||||
|
(FormSuccess a, _) -> FormSuccess a
|
||||||
|
(_, FormSuccess b) -> FormSuccess b
|
||||||
|
(postRes', _) -> postRes'
|
||||||
|
|
||||||
|
runInput :: (MonadHandler m, RenderMessage (HandlerSite m) FormMessage) => FormInput m a -> m a
|
||||||
|
runInput = runInputResult >=> \case
|
||||||
|
FormFailure errs -> invalidArgs errs
|
||||||
|
FormMissing -> invalidArgsI [MsgValueRequired]
|
||||||
|
FormSuccess a -> return a
|
||||||
|
|
||||||
hoistAForm :: HandlerSite m ~ HandlerSite n => (forall a. m a -> n a) -> AForm m b -> AForm n b
|
hoistAForm :: HandlerSite m ~ HandlerSite n => (forall a. m a -> n a) -> AForm m b -> AForm n b
|
||||||
hoistAForm f (AForm g) = AForm (\x y z ->f $ g x y z)
|
hoistAForm f (AForm g) = AForm (\x y z ->f $ g x y z)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user