Stefan Ritt wrote: |
Adam Blandford wrote: |
Hi
I have a logbook including the attributes: Author, Topic Date, Phase, Reference, Subject, Start Time, End Time, Duration
The Phase attribute has a number of MOptions including: Design, Manufacture, Testing, Results, Transport
I only want the attributes Start Time, End Time, and Duration to be shown if the Transport Phase is selected. I have tried using the conditional attributes
MOptions Phase = Design{1}, Manufacture{1}, Testing{1}, Results{1}, Transport{2}
and
{1} Show Attributes Edit = Author, Topic Date, Phase, Subject, Start Time, End Time, Duration
{2} Show Attributes Edit = Author, Topic Date, Phase, Subject
This works to show the attributes when the relevant Phase is selected but the Edit page shows the Phase options including the {1}/{2}. Is there are way that these conditionals are not displayed?
Also, I would like the "Duration" Atrribute to be a calculated value showing the time difference between Start Time and End Time. Is this possible?
Thanks,
Adam
|
The conditional attributes work only with Options, but not with MOptions as written in the documentation. I tried your set-up with Options and it worked ok. If you attribute Phase is non-exclusive, meaning it could be Manufacture and Testing at the same time, then you have to play some tricks with an additional attribute like
Attributes = Author, Topic Date, ..., Duration, Transport
MOptions Phase = Design, Manufacture, Testing, Results, Transport
Options Transport = Yes{2}, No{1}
{1} Show Attributes Edit = ...
{2} Show Attributes Edit = ...
An automatic calculation of Duration is unfortunately not implemented.
|
On the matter of automatic calculation of fields, it is possible using included javascript but you have to do the work yourself. For example, we have a log which computes responsivity as the ratio of a photocurrent and optical power. With log attributes called "Photocurrent", "Optical Power" and "Responsivity" there is a file in the logbooks directory called photomixer_javascript.html containing something like:
<script>
if (document.form1.Photocurrent) {
document.form1.Photocurrent.onchange = new Function(
"mod();"+
"var power = parseFloat(document.form1.Optical_Power.value);"+
"var current = parseFloat(document.form1.Photocurrent.value);"+
"if (!isNan(power) && !isNan(current) && power != 0.0) {"+
" document.form1.Responsivity.value = Math.round(current/power*100)/100.0"+
"}"
);
document.form1.Optical_Power.onchange = document.form1.Photocurrent.onchange;
}
</script>
and the elogd.cfg file includes
Bottom text = photomixer_javascript.html
for the relevant log.
The assignments to the onchange handlers are guarded because this javascript is included on all pages for that log, including the list pages where there is no such field as Photocurrent, (or Optical_Power) and the event handler function is defined dynamically for the same reason. |