[luci] Dependencies and ListValue

Christian Gagneraud chris at techworks.ie
Thu Jul 5 13:16:17 CEST 2012


On 05/07/12 12:05, Christian Gagneraud wrote:
> On 05/07/12 10:14, Conor O'Gorman wrote:
>> On Wed, 2012-07-04 at 19:29 +0100, Christian Gagneraud wrote:
>>> Hi there,
>>>
>>> I'm trying to have a ListValue whose values presence within the list
>>> depends on another option (a ListValue as well).
>>>
>>> So this is how I'm doing:
>>> tmp1 = section:option(ListValue, "tmp1" , translate("TMP1"))
>>> tmp1:value("", translate("-- Please select --"))
>>> tmp1:value("one", "One")
>>> tmp1:value("two", "Two")
>>>
>>> tmp2 = section:option(ListValue, "tmp2" , translate("TMP2"))
>>> tmp2.override_depends=true -- This doesn't help!
>>> tmp2:value("test1", "Test1", {tmp1="one"}, {tmp1="two"})
>>> tmp2:value("test2", "Test2", {tmp1="one"})
>>>
>>> And I would like to have no choice for tmp2 when tmp1="", 2 choices when
>>> tmp="one" and one choice when tmp1="two"
>>>
>>
>> I put that code into a model and it worked for me, using the bootstrap
>> theme. But when I tried on the standard openwrt theme, the page gave an
>> error. The code to implement the dependencies is in full_valuefooter.htm
>> which uses deps and subdeps.
>
> Hi Conor,
>
> I tried changing the theme, but it makes no difference here.
> Then I tried my test code in a brand new file, and i discovered that the
> problem appears only when using the table template (section.template =
> "cbi/tblsection").
> If i comment out this line, it works as expected both with bootstrap and
> openwrt themes.
>
> I had a look at full_valuefooter.htm and tblsection.htm, but to be
> honest it all look Chinese to me.
>
> My bet is that tblsection template implies cell_valuefooter.htm instead
> of full_valuefooter.htm. And looking at cell_valuefooter.htm I can see
> that it doesn't care about subdeps, which, AFAIU, is used by
> ListValue:value().
> I will try to copy/paste stuff from full_valuefooter.htm, but i don't
> really understand the code...

OK, so I blindly copy/pasted the javascript generation code, and it 
works now perfectly with tblsection template!
Couldn't this part of code be shared between the 2 files?

Chris

>
> If anyone familiar with Luci could have a look at this, I would be very
> grateful.
>
> Thx for your help.
>
> Chris
>
>>
>> Conor
>>
>>
>> _______________________________________________
>> luci mailing list
>> luci at lists.subsignal.org
>> https://lists.subsignal.org/mailman/listinfo/luci
>>
>
>


-- 
Christian Gagneraud,
Embedded systems engineer.
Techworks Marine
1 Harbour road
Dun Laoghaire
Co. Dublin
Ireland
Tel: + 353 (0) 1 236 5990
Web: http://www.techworks.ie/




More information about the luci mailing list