Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#157731614 Add Dropset Support #20

Merged
merged 1 commit into from
Jun 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ def load_fixtures(context, settings_path=None):
call_command("loaddata", path + "gym_config.json")

# Manager
# path = os.path.join(current_dir, 'manager', 'fixtures/')
path = os.path.join(current_dir, 'wger', 'manager', 'fixtures/')
call_command("loaddata", path + "categories.json")

# Exercises
path = os.path.join(current_dir, 'wger', 'exercises', 'fixtures/')
Expand Down
65 changes: 65 additions & 0 deletions wger/core/static/images/muscles/main/muscle-16.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions wger/core/static/images/muscles/main/muscle-17.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions wger/core/static/images/muscles/main/muscle-18.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions wger/core/static/images/muscles/main/muscle-19.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 65 additions & 0 deletions wger/core/static/images/muscles/secondary/muscle-16.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions wger/core/static/images/muscles/secondary/muscle-17.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions wger/core/static/images/muscles/secondary/muscle-18.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions wger/core/static/images/muscles/secondary/muscle-19.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
92 changes: 90 additions & 2 deletions wger/core/static/js/wger-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,20 @@ function setProfileField(field, newValue) {
});
}

function changeWorkoutType (event) {

if (event.value === '1') {
$('#id_sets').val(4);
$('#id_sets_value').html($('#id_sets').val());
updateAllExerciseFormset();
} else {
$('#id_sets').val(1);
$('#id_sets_value').html($('#id_sets').val());
updateAllExerciseFormset();
}
}


/*
Get a single field from the user's profile.
Synchronous request, use sparingly!
Expand Down Expand Up @@ -521,8 +535,13 @@ function wgerInitEditSet() {

// Slider to set the number of sets
$('#id_sets').on('change', function () {
updateAllExerciseFormset();
$('#id_sets_value').html($('#id_sets').val());
if ($('#workout-type').val() =='2'){
$('#id_sets').val(1);
$('#id_sets_value').html($('#id_sets').val());
}else{
updateAllExerciseFormset();
$('#id_sets_value').html($('#id_sets').val());
}
});

/*
Expand Down Expand Up @@ -697,4 +716,73 @@ $(document).ready(function () {
'/' + token;
window.location.href = targetUrl;
});

// Handle the add entry event
// Handle the add entry event
$('.addEntry').on('click', function (event) {
event.preventDefault();
var $formset;
// get associated exercise
var entryMatches = $(this).closest('.workout-log-table').find('.exercise-id');
var exerciseId = entryMatches[0].value;
// generate id from number of actual entries
var generatedId = $(this).closest('#workout-wrap').find('.actual').length
// append a new entry
var name = 'name-'+generatedId
var entry = `<td>
<div>
<input class="form-control narrow-input" id="id_form-`+ generatedId +`-reps" name="form-`+ generatedId +`-reps" type="number">
<span class="help-block">

</span>
</div>
</td>
<td>
<div>
<select class="form-control narrow-input" id="id_form-`+ generatedId +`-repetition_unit" name="form-`+ generatedId +`-repetition_unit">
<option value="">---------</option>
<option value="6">Kilometers</option>
<option value="5">Miles</option>
<option value="4">Minutes</option>
<option value="1" selected="selected">Repetitions</option>
<option value="3">Seconds</option>
<option value="2">Until Failure</option>
</select>
<span class="help-block">

</span>
</div>
</td>
<td>
<div>
<input class="form-control narrow-input" id="id_form-`+ generatedId +`-weight" name="form-`+ generatedId +`-weight" step="any" type="number" value="0">
<span class="help-block">

</span>
</div>
</td>
<td>
<div>
<select class="form-control narrow-input" id="id_form-`+ generatedId +`-weight_unit" name="form-`+ generatedId +`-weight_unit">
<option value="">---------</option>
<option value="3">Body Weight</option>
<option value="5">Kilometers Per Hour</option>
<option value="6">Miles Per Hour</option>
<option value="4">Plates</option>
<option value="1" selected="selected">kg</option>
<option value="2">lb</option>
</select>
<span class="help-block">

</span>
</div>
</td>`
$formset = $(this).closest('.workout-log-table').find('.form-body')
$formset.append('<tr class=\'actual\'>'+ entry +'</tr>');
$formset.trigger('create')
// create associated exercise input at the new created set
var setWraps = $(this).closest('.workout-log-table').find('.actual')
$(setWraps[setWraps.length-1]).append("<input type='hidden' name="+ name +" class='exercise-id' value ="+ exerciseId +">")
$(this).closest('#workout-wrap').find("#max-sets").val(generatedId+1)
});
});
2 changes: 1 addition & 1 deletion wger/core/templates/mobile/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
}

// Init the modal dialog for editing forms
wgerFormModalDialog();
// wgerFormModalDialog();

// Check for RO-access before allowing sharing
wgerToggleReadOnlyAccess();
Expand Down
45 changes: 25 additions & 20 deletions wger/core/templates/tags/render_day.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@
</script>

<table class="table table-bordered workout-table" id="table-day-{{ day.obj.id }}" data-id="{{ day.obj.id }}">
<thead>
<tr id="day-{{ day.obj.id }}">
<th colspan="2" style="background: none repeat scroll 0% 0% #F5F5F5;">
<thead>
<tr id="day-{{ day.obj.id }}">
<th colspan="2" style="background: none repeat scroll 0% 0% #F5F5F5;">

{{ day.days_of_week.text }} – {{ day.obj.description }}
{% if editable %}
<span class="editoptions" style="float: right;">
<a href="{% url 'manager:day:delete' day.obj.id %}"
title="{% trans 'Delete' %}">
<span class="{% fa_class 'trash' %}"></span></a>
<a href="{% url 'manager:day:edit' day.obj.id %}"
title="{% trans 'Edit' %}"
class="wger-modal-dialog">
<span class="{% fa_class 'pencil-square-o' %}"></span></a>
<a href="{% url 'manager:day:log' day.obj.id %}"
title="{% trans 'Add weight log to this day' %}">
<span class="{% fa_class 'line-chart' %}"></span></a>
</span>
{% endif %}
</th>
</tr>
{{ day.days_of_week.text }} – {{ day.obj.description }}
{% if editable %}
<span class="editoptions" style="float: right;">
<a href="{% url 'manager:day:delete' day.obj.id %}"
title="{% trans 'Delete' %}">
<span class="{% fa_class 'trash' %}"></span></a>
<a href="{% url 'manager:day:edit' day.obj.id %}"
title="{% trans 'Edit' %}"
class="wger-modal-dialog">
<span class="{% fa_class 'pencil-square-o' %}"></span></a>
<a href="{% url 'manager:day:log' day.obj.id %}"
title="{% trans 'Add weight log to this day' %}">
<span class="{% fa_class 'line-chart' %}"></span></a>
</span>
{% endif %}
</th>
</tr>
</thead>
<tbody>
{% for set in day.set_list %}
Expand Down Expand Up @@ -91,6 +91,11 @@ <h4 class="media-heading">
{{ exercise.obj.name }}
</h4>
<p>{{exercise.setting_text}}</p>
{% if exercise.setting_obj_list %}
<p>
{{ set.category }}
</p>
{% endif %}

{% if editable %}
{% if not exercise.setting_list %}
Expand Down
1 change: 1 addition & 0 deletions wger/core/tests/base_testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class BaseTestCase(object):
fixtures = ('days_of_week',
'gym_config',
'groups',
'test-categories',
'setting_repetition_units',
'setting_weight_units',
'test-languages',
Expand Down
Loading