Libraryless. Click here for Pure Java version (15224L/98K).
sclass HCRUD_Data { new Map<S, Renderer> renderers; new SS fieldHelp; abstract sclass Renderer { swappable O preprocessValue(O value) { ret value; } } srecord TextArea(int cols, int rows) extends Renderer { // star constructor syntax not working here (transpiler bug) TextArea(int cols, int rows, IF1 preprocessValue) { this.cols = cols; this.rows = rows; this.preprocessValue = preprocessValue; } } sclass AceEditor extends TextArea { *() {} *(int *cols, int *rows) {} } srecord TextField(int cols) extends Renderer {} srecord AbstractComboBox extends Renderer { bool editable; // help find item to select swappable S valueToEntry(O value) { ret strOrNull(value); } } srecord ComboBox(LS entries) extends AbstractComboBox { ComboBox(S... entries) { this(asList(entries)); } ComboBox(bool editable, S... entries) { this(entries); this.editable = editable; } ComboBox(bool editable, LS entries) { this(entries); this.editable = editable; } // star constructor syntax not working here (transpiler bug) ComboBox(LS entries, IF1<O, S> valueToEntry) { this.entries = entries; this.valueToEntry = valueToEntry; } } srecord DynamicComboBox(S info) extends AbstractComboBox { } srecord CheckBox() extends Renderer {} srecord FlexibleLengthList(Renderer itemRenderer) extends Renderer {} S itemName() { ret "object"; } S itemNamePlural() { ret plural(itemName()); } //LS fields() { null; } L<MapSO> list() { null; } L<MapSO> list(IntRange range) { ret subListOrFull(list(), range); } S idField() { ret "id"; } MapSO emptyObject() { null; } MapSO getObject(O id) { null; } swappable MapSO getObjectForDuplication(O id) { ret getObject(id); } // return ID O createObject(SS fullMap, S fieldPrefix) { throw unimplemented(); } // return text msg S deleteObject(O id) { throw unimplemented(); } bool objectCanBeDeleted(O id) { true; } // return text msg S updateObject(O id, SS fullMap, S fieldPrefix) { throw unimplemented(); } // return null for standard input field Renderer getRenderer(S field) { ret renderers.get(field); } // returns HTML S fieldHelp(S field) { ret fieldHelp.get(field); } returnSelf addRenderer(S field, Renderer renderer) { renderers.put(field, renderer); } returnSelf fieldHelp(S field, S help, S... more) { fieldHelp.put(field, help); for (int i = 0; i+1 < l(more); i += 2) fieldHelp.put(more[i], more[i+1]); } S fieldNameToHTML(S name) { S help = fieldHelp.get(name); ret spanTitle(help, htmlencode2(humanizeLabel(name))); } Set<S> filteredFields() { null; } LS comboBoxSearch(S info, S query) { null; } }
download show line numbers debug dex
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1026000 |
Snippet name: | HCRUD_Data |
Eternal ID of this version: | #1026000/35 |
Text MD5: | 7bad8de04fb4fd75bd8c26b0cb392850 |
Transpilation MD5: | 45abbe9c83453d121a10f79784bb8ea0 |
Author: | stefan |
Category: | javax / html |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-01-20 16:42:19 |
Source code size: | 2897 bytes / 97 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 185 / 496 |
Version history: | 34 change(s) |
Referenced in: | [show references] |
Formerly at http://tinybrain.de/1026000 & http://1026000.tinybrain.de