Add weekly goal field to new goal form
Tagesziel and Wochenziel sync automatically (weekly = daily * 7). Only daily is stored. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a8f6692de4
commit
8729b0d1ed
2 changed files with 14 additions and 4 deletions
|
|
@ -294,12 +294,19 @@ function openNew(){
|
||||||
var c=tpl('tpl-new-goal');
|
var c=tpl('tpl-new-goal');
|
||||||
showSheet(c,true);
|
showSheet(c,true);
|
||||||
var name=c.querySelector('.ng-name'), unit=c.querySelector('.ng-unit');
|
var name=c.querySelector('.ng-name'), unit=c.querySelector('.ng-unit');
|
||||||
var daily=c.querySelector('.ng-daily'), days=c.querySelector('.ng-days'), sub=c.querySelector('.ng-sub');
|
var daily=c.querySelector('.ng-daily'), weekly=c.querySelector('.ng-weekly');
|
||||||
|
var days=c.querySelector('.ng-days'), sub=c.querySelector('.ng-sub');
|
||||||
|
daily.addEventListener('input',function(){
|
||||||
|
if(daily.value) weekly.value=Math.round(parseFloat(daily.value)*7*100)/100;
|
||||||
|
});
|
||||||
|
weekly.addEventListener('input',function(){
|
||||||
|
if(weekly.value) daily.value=Math.round(parseFloat(weekly.value)/7*100)/100;
|
||||||
|
});
|
||||||
setTimeout(function(){name.focus();},50);
|
setTimeout(function(){name.focus();},50);
|
||||||
c.querySelector('.ng-can').onclick=closeOv;
|
c.querySelector('.ng-can').onclick=closeOv;
|
||||||
sub.onclick=function(){
|
sub.onclick=function(){
|
||||||
var nv=(name.value||'').trim(), uv=(unit.value||'').trim()||'Stück';
|
var nv=(name.value||'').trim(), uv=(unit.value||'').trim()||'Stück';
|
||||||
var dv=parseInt(daily.value,10)||1, dyv=parseInt(days.value,10)||30;
|
var dv=parseFloat(daily.value)||1, dyv=parseInt(days.value,10)||30;
|
||||||
if(!nv){ name.focus(); return; }
|
if(!nv){ name.focus(); return; }
|
||||||
sub.disabled=true;
|
sub.disabled=true;
|
||||||
api('POST','goals',{name:nv,unit:uv,daily:dv,days:dyv,start:TODAY.toISOString()})
|
api('POST','goals',{name:nv,unit:uv,daily:dv,days:dyv,start:TODAY.toISOString()})
|
||||||
|
|
|
||||||
|
|
@ -258,9 +258,12 @@
|
||||||
<div class="ff"><label>Übung / Gewohnheit</label><input class="fi ng-name" type="text" placeholder="Liegestütz, Plank …"/></div>
|
<div class="ff"><label>Übung / Gewohnheit</label><input class="fi ng-name" type="text" placeholder="Liegestütz, Plank …"/></div>
|
||||||
<div class="fgrid">
|
<div class="fgrid">
|
||||||
<div class="ff"><label>Einheit</label><input class="fi ng-unit" type="text" value="Stück"/></div>
|
<div class="ff"><label>Einheit</label><input class="fi ng-unit" type="text" value="Stück"/></div>
|
||||||
<div class="ff"><label>Tagesziel</label><input class="fi ng-daily" type="number" min="1" value="50"/></div>
|
<div class="ff"><label>Dauer in Tagen</label><input class="fi ng-days" type="number" min="7" max="365" value="30"/></div>
|
||||||
|
</div>
|
||||||
|
<div class="fgrid">
|
||||||
|
<div class="ff"><label>Tagesziel</label><input class="fi ng-daily" type="number" min="0.01" step="any" value="50"/></div>
|
||||||
|
<div class="ff"><label>Wochenziel</label><input class="fi ng-weekly" type="number" min="0.01" step="any" value="350"/></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="ff"><label>Dauer in Tagen</label><input class="fi ng-days" type="number" min="7" max="365" value="30"/></div>
|
|
||||||
<div class="factions">
|
<div class="factions">
|
||||||
<button class="btn-p ng-sub">Ziel starten</button>
|
<button class="btn-p ng-sub">Ziel starten</button>
|
||||||
<button class="btn-c ng-can">Abbrechen</button>
|
<button class="btn-c ng-can">Abbrechen</button>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue