2018-04-14 11:10:38 +02:00
|
|
|
Grocy.Components.HabitCard = { };
|
|
|
|
|
2018-04-21 19:18:00 +02:00
|
|
|
Grocy.Components.HabitCard.Refresh = function(habitId)
|
2018-04-14 11:10:38 +02:00
|
|
|
{
|
2018-04-18 19:03:39 +02:00
|
|
|
Grocy.Api.Get('habits/get-habit-details/' + habitId,
|
2018-04-14 11:10:38 +02:00
|
|
|
function(habitDetails)
|
|
|
|
{
|
|
|
|
$('#habitcard-habit-name').text(habitDetails.habit.name);
|
2018-07-25 19:28:15 +02:00
|
|
|
$('#habitcard-habit-last-tracked').text((habitDetails.last_tracked || L('never')));
|
2018-04-14 11:10:38 +02:00
|
|
|
$('#habitcard-habit-last-tracked-timeago').text($.timeago(habitDetails.last_tracked || ''));
|
|
|
|
$('#habitcard-habit-tracked-count').text((habitDetails.tracked_count || '0'));
|
2018-07-25 19:28:15 +02:00
|
|
|
$('#habitcard-habit-last-done-by').text((habitDetails.last_done_by.display_name || L('Unknown')));
|
2018-04-14 11:10:38 +02:00
|
|
|
|
2018-04-16 19:11:32 +02:00
|
|
|
EmptyElementWhenMatches('#habitcard-habit-last-tracked-timeago', L('timeago_nan'));
|
2018-04-14 11:10:38 +02:00
|
|
|
},
|
|
|
|
function(xhr)
|
|
|
|
{
|
|
|
|
console.error(xhr);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
};
|