* InfoLog: if one of status, percent or datecompleted changed, change others to reasonable values

This commit is contained in:
Ralf Becker 2012-03-18 14:44:16 +00:00
parent 819c806460
commit 5b4c2898b1
3 changed files with 60 additions and 6 deletions

View File

@ -26,3 +26,57 @@ function add_email_from_ab(ab_id,info_cc)
} }
return false; return false;
} }
/**
* If one of info_status, info_percent or info_datecompleted changed --> set others to reasonable values
*
* @param string changed_id id of changed element
* @param string status_id
* @param string percent_id
* @param string datecompleted_id
*/
function status_changed(changed_id, status_id, percent_id, datecompleted_id)
{
var status = document.getElementById(status_id);
var percent = document.getElementById(percent_id);
var datecompleted = document.getElementById(datecompleted_id+'[str]');
var completed;
switch(changed_id)
{
case status_id:
completed = status.value == 'done' || status.value == 'billed';
if (completed || status.value == 'not-started') percent.value = completed ? 100 : 0;
break;
case percent_id:
completed = percent.value == 100;
if (completed != (status.value == 'done' || status.value == 'billed') ||
(status.value == 'not-started') != (percent.value == 0))
{
status.value = percent.value == 0 ? 'not-started' : (percent.value == 100 ? 'done' : 'ongoing');
}
break;
case datecompleted_id+'[str]':
case datecompleted_id:
completed = datecompleted.value != '';
if (completed != (status.value == 'done' || status.value == 'billed'))
{
status.value = completed ? 'done' : 'not-started';
}
if (completed != (percent.value == 100))
{
percent.value = completed ? 100 : 0;
}
break;
}
if (!completed && datecompleted.value != '')
{
datecompleted.value = '';
}
else if (completed && datecompleted.value == '')
{
// todo: set current date in correct format
}
}

File diff suppressed because one or more lines are too long

View File

@ -166,7 +166,7 @@
<column width="103"/> <column width="103"/>
<column width="260"/> <column width="260"/>
<column width="90"/> <column width="90"/>
<column width="27%"/> <column/>
</columns> </columns>
<rows> <rows>
<row disabled="!@msg"> <row disabled="!@msg">
@ -242,16 +242,16 @@
<row class="row"> <row class="row">
<description value="Status" for="info_status"/> <description value="Status" for="info_status"/>
<menulist> <menulist>
<menupopup statustext="@status_help" id="info_status" onchange="if (this.value=='done' || this.value=='billed') set_element(this.form,'exec[info_percent]','100'); else if (this.value=='not-started') set_element(this.form,'exec[info_percent]','0');"/> <menupopup statustext="@status_help" id="info_status" onchange="status_changed(this.id, form::name('info_status'), form::name('info_percent'), form::name('info_datecompleted'))"/>
</menulist> </menulist>
<description value="Completed" for="info_percent"/> <description value="Completed" for="info_percent"/>
<menulist> <menulist>
<menupopup type="select-percent" statustext="Percent completed" id="info_percent" onchange="if (this.value==100 &amp;&amp; this.form['exec[info_status]'].value != 'done' &amp;&amp; this.form['exec[info_status]'].value != 'billed' &amp;&amp; this.form['exec[info_status]'].value != 'cancelled') this.form['exec[info_status]'].value='done'; else if (this.value != 100 &amp;&amp; this.form['exec[info_status]'].value != 'cancelled') this.form['exec[info_status]'].value=this.value != 0 ? 'ongoing' : 'not-started'; else if (this.value==0 &amp;&amp; this.form['exec[info_status]'].value != 'cancelled' &amp;&amp; this.form['exec[info_status]'].value != 'offer') this.form['exec[info_status]'].value='not-started'; "/> <menupopup type="select-percent" statustext="Percent completed" id="info_percent" onchange="status_changed(this.id, form::name('info_status'), form::name('info_percent'), form::name('info_datecompleted'))"/>
</menulist> </menulist>
</row> </row>
<row class="row"> <row class="row">
<description value="Date completed" for="info_datecompleted"/> <description value="Date completed" for="info_datecompleted"/>
<date-time statustext="Date completed (leave it empty to have it automatic set if status is done or billed)" id="info_datecompleted"/> <date-time statustext="Date completed (leave it empty to have it automatic set if status is done or billed)" id="info_datecompleted" onchange="status_changed(this.id, form::name('info_status'), form::name('info_percent'), form::name('info_datecompleted'))"/>
<description value="Private" for="info_access"/> <description value="Private" for="info_access"/>
<checkbox statustext="should this entry only be visible to you and people you grant privat access via the ACL" id="info_access" options="private,public"/> <checkbox statustext="should this entry only be visible to you and people you grant privat access via the ACL" id="info_access" options="private,public"/>
</row> </row>