Added shit.
This commit is contained in:
1 parent
86598c0fb7
commit
af687df9de
10 files changed
+73
-19
No files matched your search
@@ -0,0 +1,47 @@
|
||||
(function () {
|
||||
function _isNumeric(str) {
|
||||
if (typeof str != "string") {
|
||||
return false
|
||||
}
|
||||
return !isNaN(str) && !isNaN(parseFloat(str));
|
||||
}
|
||||
|
||||
function _cast(str) {
|
||||
return _isNumeric(str) ? parseFloat(str) : str;
|
||||
}
|
||||
|
||||
function _addAssocToDict(obj, key, value) {
|
||||
let splittedKey = Array.isArray(key) ? key : key.split(".");
|
||||
const keyToAdd = splittedKey.shift();
|
||||
const isTerminal = splittedKey.length === 0;
|
||||
if (isTerminal) {
|
||||
obj[keyToAdd] = _cast(value);
|
||||
return obj;
|
||||
}
|
||||
if (!(keyToAdd in obj)) {
|
||||
obj[keyToAdd] = {};
|
||||
}
|
||||
return _addAssocToDict(obj[keyToAdd], splittedKey, value);
|
||||
}
|
||||
|
||||
function _createPayload(params) {
|
||||
let ret = {};
|
||||
for (let key of Object.keys(params)) {
|
||||
_addAssocToDict(ret, key, params[key]);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
htmx.defineExtension('json-enc', {
|
||||
onEvent: function (name, evt) {
|
||||
if (name === "htmx:configRequest") {
|
||||
evt.detail.headers['Content-Type'] = "application/json";
|
||||
}
|
||||
},
|
||||
|
||||
encodeParameters: function (xhr, parameters, elt) {
|
||||
xhr.overrideMimeType('text/json');
|
||||
return (JSON.stringify(_createPayload(parameters)));
|
||||
}
|
||||
});
|
||||
})();
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -24,9 +24,6 @@
|
||||
</div>
|
||||
|
||||
<div id="action-form"></div>
|
||||
|
||||
|
||||
<div id="submit-button"></div>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>ledger</title>
|
||||
<link rel="stylesheet" href="/static/uikit.min.css" />
|
||||
<script src="/static/uikit.min.js"></script>
|
||||
<script src="/static/uikit-icons.min.js"></script>
|
||||
<script src="/static/htmx.org@1.8.5"></script>
|
||||
<script src="/static/json-enc.js"></script>
|
||||
<link rel="stylesheet" href="/static/vendor/uikit.min.css" />
|
||||
<script src="/static/vendor/uikit.min.js"></script>
|
||||
<script src="/static/vendor/uikit-icons.min.js"></script>
|
||||
<script src="/static/vendor/htmx.org@1.8.5"></script>
|
||||
<script src="/static/embedded-json-enc.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
|
||||
<label class="uk-label">
|
||||
<input type="text" name="event.name">
|
||||
|
||||
<div class="uk-margin">
|
||||
<label class="uk-form-label"> Name
|
||||
<input class="uk-input" type="text" placeholder="Narnia Dollar" aria-label="Default"
|
||||
name="event.Event1.name">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="uk-margin">
|
||||
<label class="uk-form-label"> Age
|
||||
<input class="uk-input" type="number" placeholder="Narnia Dollar" aria-label="Default"
|
||||
name="event.Event1.age">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{%include "partials/actions/submit_button.html"%}
|
||||
+9
-9
@@ -445,15 +445,15 @@ mod cli_test {
|
||||
assert_eq!(logic.process_events_count, 1);
|
||||
}
|
||||
|
||||
// #[test]
|
||||
// fn run_web_ui() {
|
||||
// let cmd = command_line_parser();
|
||||
// let m = cmd.get_matches_from(vec!["test", "webui", "run"]);
|
||||
// let mut logic = TestCommandLineLogic::new();
|
||||
// let mut conn = Connection::open_in_memory().unwrap();
|
||||
// process_command_line(&mut conn, &m, &mut logic);
|
||||
// assert_eq!(logic.run_webui_count, 1);
|
||||
// }
|
||||
#[test]
|
||||
fn run_web_ui() {
|
||||
let cmd = command_line_parser();
|
||||
let m = cmd.get_matches_from(vec!["test", "wui", "run"]);
|
||||
let mut logic = TestCommandLineLogic::new();
|
||||
let mut conn = Connection::open_in_memory().unwrap();
|
||||
process_command_line(&mut conn, &m, &mut logic);
|
||||
assert_eq!(logic.run_webui_count, 1);
|
||||
}
|
||||
}
|
||||
|
||||
struct ProCommandLineLogic {}
|
||||
|
||||
Reference in new issue
Block a user