Show
Ignore:
Timestamp:
10/27/09 22:42:40 (4 years ago)
Author:
jow
Message:

libs/cbi: fixes for widget templates

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • luci/trunk/libs/cbi/luasrc/view/cbi/firewall_zonelist.htm

    r5406 r5430  
    2121    local zone, net, iface 
    2222    local zones = fwm:get_zones() 
    23     local value = self:cfgvalue(section) or self.default 
     23    local value = self:formvalue(section) 
     24    if not value or value == "-" then value = self:cfgvalue(section) or self.default end 
     25 
    2426    local selected = false 
     27    local checked = { } 
    2528 
    26     if value and #value == 0 then value = nil end 
     29    if value and #value == 0 then 
     30        value = nil 
     31    elseif type(value) == "table" then 
     32        for _, value in ipairs(value) do 
     33            checked[value] = true 
     34        end 
     35    elseif value then 
     36        checked[value] = true        
     37    end 
    2738-%> 
    2839 
    29 <ul style="margin:0; list-style-type:none"> 
     40<ul style="margin:0; list-style-type:none; text-align:left"> 
    3041    <% 
    3142        for _, zone in utl.spairs(zones, function(a,b) return (zones[a]:name() < zones[b]:name()) end) do 
    32             selected = selected or (value == zone:name()) 
     43            if zone:name() ~= self.exclude then 
     44                selected = selected or (value == zone:name()) 
    3345    %> 
    3446    <li style="padding:0.5em"> 
    35         <input class="cbi-input-radio" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)" type="radio"<%=attr("id", cbid .. "." .. zone:name()) .. attr("name", cbid) .. attr("value", zone:name()) .. ifattr(value == zone:name(), "checked", "checked")%> /> &nbsp; 
     47        <input class="cbi-input-radio" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "." .. zone:name()) .. attr("name", cbid) .. attr("value", zone:name()) .. ifattr(checked[zone:name()], "checked", "checked")%> /> &nbsp; 
    3648        <label<%=attr("for", cbid .. "." .. zone:name())%> style="background-color:<%=zone:get_color()%>; padding:0.5em"> 
    3749            <strong><%=zone:name()%>:</strong> 
     
    4052                for _, net in ipairs(zone:get_networks()) do 
    4153                    net = nwm:get_network(net) 
     54                    if net then 
     55            %> 
     56                &nbsp; 
     57                <%- if net:name() == self.network then -%> 
     58                    <span style="background-color:#FFFFFF; border:1px solid #000000; padding:2px; font-weight:bold"><%=net:name()%>: 
     59                <%- else -%> 
     60                    <span style="background-color:#FFFFFF; border:1px solid #CCCCCC; padding:2px"><%=net:name()%>: 
     61                <%- end -%> 
     62                <% 
    4263                    for _, iface in ipairs(net and net:get_interfaces() or {}) do 
    4364                        if not iface:is_bridgeport() then 
    4465                            empty = false 
    45              %> 
    46                 <img title="<%=iface:get_type_i18n()%>" style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" /> 
    47                 <% if iface:name() == self.iface then %><strong><%=iface:shortname()%></strong><% else %><%=iface:shortname()%><% end %> &nbsp; 
    48             <% end end end %> 
     66                 %> 
     67                    <img<%=attr("title", iface:get_i18n())%> style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" /> 
     68                <% end end %> 
     69                </span> 
     70            <% end end %> 
    4971            <% if empty then %><em><%:a_s_ipt_zone_empty (no interfaces attached)%></em><% end %> 
    5072        </label> 
    5173    </li> 
    52     <% end %> 
     74    <% end end %> 
    5375 
    54     <% if not self.nocreate then %> 
     76    <% if self.widget ~= "checkbox" and not self.nocreate then %> 
    5577    <li style="padding:0.5em"> 
    5678        <input class="cbi-input-radio" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)" type="radio"<%=attr("id", cbid .. "_new") .. attr("name", cbid) .. attr("value", "-") .. ifattr(not selected, "checked", "checked")%> /> &nbsp;