1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| {% import ( "{{{ .Package }}}/app/controller/cutil" "{{{ .Package }}}/app/util" "{{{ .Package }}}/views/components" ) %}
{% func RichEditor(key string, id string, title string, columns util.FieldDescs, values []any, placeholder ...string) %}{% stripspace %} {% code if values == nil { values = []any{} } %} <div class="rich-editor" data-key="{%s key %}" data-title="{%s title %}" data-columns="{%j util.ToJSONCompact(columns) %}"> {%= Textarea(key, id, 8, util.ToJSON(values), placeholder...) %} </div> {% endstripspace %}{% endfunc %}
{% func RichEditorTable(key string, id string, title string, columns util.FieldDescs, values []any, placeholder ...string) %}{% stripspace %} <tr> <th class="shrink"><label for="{%s id %}">{%s title %}</label></th> <td> {%= RichEditor(key, id, title, columns, values, placeholder...) %} </td> </tr> {% endstripspace %}{% endfunc %}
{% func RichEditorCard(key string, id string, title string, ps *cutil.PageState, headerExtra string, icon string, columns util.FieldDescs, values []any, placeholder ...string) %}{% stripspace %} <div class="card"> <div class="right"> {%- if headerExtra != "" -%} {%s= headerExtra %}{% space %} {%- endif -%} <button type="button" class="toggle-editor toggle-editor-{%s key %}">Editor</button> </div> <h3 title="{%s util.StringJoin(placeholder, `; `) %}">{% if icon != "" %}{%= components.SVGIcon(icon, ps) %}{% space %}{% endif %}{%s title %}</h3> <div class="mt expanded"> {%= RichEditor(key, "input-" + key, title, columns, values, placeholder...) %} </div> </div> {% endstripspace %}{% endfunc %}
|