From 50f946418c3fbd5fd32f5218b177920a065a53ac Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Thu, 6 Dec 2012 00:53:52 +0000 Subject: Interfaces: Move iface structure to a separate file and use it in view to determine which options to display The previous method meant that each option was defined in both the model and in the view. Now, everything is defined in the model, and the view just hides / shows as desired. --- interfaces-update-html.lsp | 156 ++++++++++++--------------------------------- 1 file changed, 40 insertions(+), 116 deletions(-) (limited to 'interfaces-update-html.lsp') diff --git a/interfaces-update-html.lsp b/interfaces-update-html.lsp index 06c88e0..579b9b2 100644 --- a/interfaces-update-html.lsp +++ b/interfaces-update-html.lsp @@ -1,89 +1,35 @@ <% local form, viewlibrary, page_info = ... require("htmlviewfunctions") html = require("acf.html") +require("json") + +-- iface is a local table with cfes for the various parts of interface definitions +-- Depending on the address family and corresponding method, different options are valid +local iface = require("alpine-baselayout/interfaces-definitions") +for name,value in pairs(iface.optional) do + form.value[name].class = "optional" +end %>

<%= html.html_escape(form.label) %><% if page_info.action == "update" then io.write(html.html_escape(" - "..form.value.name.value)) end %>

<% - if page_info.action == "update" then - form.value.name.readonly = true - end - local order = {"name", "comment", "auto", "family", "method", "pre-up", "up", "down", "post-down"} - htmlviewfunctions.displayform(form, order) + htmlviewfunctions.displayform(form, nil, nil, page_info, 2) %> -- cgit v1.2.3