From 30a6b76520bf5c4ecb5f70e89b7efb2bade452cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Kr=C3=BCger?= Date: Tue, 24 May 2022 10:31:34 +0200 Subject: [PATCH] gluon-web-model: add Section:element and Element, add Warning template --- .../lib/gluon/web/view/model/warning.html | 14 +++++++++++ .../usr/lib/lua/gluon/web/model/classes.lua | 25 ++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 package/gluon-web-model/files/lib/gluon/web/view/model/warning.html diff --git a/package/gluon-web-model/files/lib/gluon/web/view/model/warning.html b/package/gluon-web-model/files/lib/gluon/web/view/model/warning.html new file mode 100644 index 00000000..41688b77 --- /dev/null +++ b/package/gluon-web-model/files/lib/gluon/web/view/model/warning.html @@ -0,0 +1,14 @@ +<%- if self.title or self.content then -%> +
> + <%- if self.content then -%> + <%=self.content%> + <%- else -%> + <%=self.title%>
+ <%=self.description%> + <%- end -%> +
+<%- end -%> diff --git a/package/gluon-web-model/luasrc/usr/lib/lua/gluon/web/model/classes.lua b/package/gluon-web-model/luasrc/usr/lib/lua/gluon/web/model/classes.lua index 2ec0d71f..88f378c0 100644 --- a/package/gluon-web-model/luasrc/usr/lib/lua/gluon/web/model/classes.lua +++ b/package/gluon-web-model/luasrc/usr/lib/lua/gluon/web/model/classes.lua @@ -196,7 +196,6 @@ function Template:__init__(template) self.template = template end - local AbstractValue = class(Node) M.AbstractValue = AbstractValue @@ -411,6 +410,25 @@ function TextValue:__init__(...) end +local Element = class(Node) +M.Element = Element + +function Element:__init__(template, kv, ...) + Node.__init__(self, ...) + + self.default = nil + self.size = nil + self.optional = false + + self.template = template + + for key, value in pairs(kv) do + self[key] = value + end + + self.error = false +end + local Section = class(Node) M.Section = Section @@ -427,6 +445,11 @@ function Section:option(t, ...) return obj end +function Section:element(...) + local obj = Element(...) + self:append(obj) + return obj +end local Form = class(Node) M.Form = Form