add data editor

This commit is contained in:
b1ek 2023-03-02 23:25:51 +10:00
parent 6c8c23f8b3
commit 1ea2f3dfaa
Signed by: blek
GPG Key ID: 14546221E3595D0C
1 changed files with 50 additions and 0 deletions

50
view/admin/data_edit.pug Normal file
View File

@ -0,0 +1,50 @@
//-
This template accepts following parameters:
title - Page title
endpoint - Where the data should be returned
description - Description for user
pref_method - Method to return data with
data - Types and names of data
data is an JSON of objects with following structure:
id: {
name?: string,
type?: string(text|textarea|codearea|boolean|number|email),
def?: string
}
btn_name - Change the name of send button
extends ../layout/main.pug
block root
-
if (title == undefined)
var title = 'Data editor'
block content
h1= title
if (description)
p !{description}
hr
form(action=endpoint ? endpoint : '' method=pref_method ? pref_method : 'POST')
table
if (data)
each row, key in data
tr
td= row.name
td :
td
case row.type
when 'text'
input(type='text' name=key)
when 'textarea'
textarea(name=key)
when 'codearea'
textarea(name=key style='font-family:monospace')
when 'email'
input(type='email' name=key)
default
input(type='text' name=key)
input(type='submit' value=btn_name ? btn_name : 'Send!')