Skip to content

Commit 870f3f1

Browse files
committed
use validation button instead of time based save
1 parent 04c35df commit 870f3f1

File tree

5 files changed

+29
-11
lines changed

5 files changed

+29
-11
lines changed

templates/sheet_view/daily.html.twig

+7-8
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@
178178
{% trans %}sheet.daily.add-stools{% endtrans %}
179179
</button>
180180
{% endif %}
181+
182+
<hr><br>
183+
<button type="button" name="addSheet" id="addSheet" data-modal="success_modal" class="btn bg-green d-block mb-2">{% trans %}sheet.daily.add{% endtrans %}</button>
181184
</div>
182185
</div>
183186
</div>
@@ -187,6 +190,7 @@
187190
{% include 'sheet_view/daily-add-meal-modal.html.twig' %}
188191
{% include 'sheet_view/daily-add-sleep-modal.html.twig' %}
189192
{% include 'sheet_view/daily-add-stools-modal.html.twig' %}
193+
{% include 'utils/success-modal.html.twig' with {success_message: 'sheet.daily.add.validation'|trans(), removeJS: true} %}
190194
{% include 'utils/validation-modal.html.twig' with { validation_message: 'sheet.daily.remove.validation'|trans()} %}
191195
{% endif %}
192196

@@ -196,11 +200,8 @@
196200
{{ parent() }}
197201

198202
{% if not readonly %}
199-
200203
<script type="application/javascript">
201-
202-
let removeType = undefined;
203-
let removeTimestamp = undefined;
204+
let removeType, removeTimestamp = undefined;
204205
205206
$('[data-modal="validate_modal"]').on('click', function () {
206207
removeType = $(this).find('[name="type"]').val();
@@ -235,10 +236,8 @@
235236
e.preventDefault();
236237
});
237238
238-
$('input').on('change', function() {
239-
setTimeout( function(){
240-
$("#dailySheetForm").submit();
241-
} , 1000 );
239+
$('#addSheet').on('click', function () {
240+
$("#dailySheetForm").submit();
242241
});
243242
244243
window.onbeforeunload = function () {

templates/utils/error-modal.html.twig

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
</div>
99
</section>
1010

11+
{% if removeJS is not defined or removeJS == false %}
1112
<script type="application/javascript">
1213
(function() {
1314
var body = document.getElementsByTagName('body')[0];
@@ -49,3 +50,4 @@
4950
}
5051
})();
5152
</script>
53+
{% endif %}

templates/utils/success-modal.html.twig

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</div>
1010
</section>
1111

12-
12+
{% if removeJS is not defined or removeJS == false %}
1313
<script type="application/javascript">
1414
(function() {
1515
var body = document.getElementsByTagName('body')[0];
@@ -51,3 +51,4 @@
5151
}
5252
})();
5353
</script>
54+
{% endif %}

translations/messages.en.xlf

+9-1
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@
405405
<source>sheet.daily.stool</source>
406406
<target>Stool</target>
407407
</trans-unit>
408-
<trans-unit id="XU2GowO" resname="sheet.daily.stool.soft">
408+
<trans-unit id="rdWeWy5" resname="sheet.daily.stool.soft">
409409
<source>sheet.daily.stool.soft</source>
410410
<target>soft</target>
411411
</trans-unit>
@@ -481,6 +481,14 @@
481481
<source>sheet.daily.modal.add-meal</source>
482482
<target>Add a meal</target>
483483
</trans-unit>
484+
<trans-unit id="6dzNxl9" resname="sheet.daily.add">
485+
<source>sheet.daily.add</source>
486+
<target>Update the sheet</target>
487+
</trans-unit>
488+
<trans-unit id="fyzIugU" resname="sheet.daily.add.validation">
489+
<source>sheet.daily.add.validation</source>
490+
<target>The sheet has been updated!</target>
491+
</trans-unit>
484492
</body>
485493
</file>
486494
</xliff>

translations/messages.fr.xlf

+9-1
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@
405405
<source>sheet.daily.stool</source>
406406
<target>Selle</target>
407407
</trans-unit>
408-
<trans-unit id="XU2GowO" resname="sheet.daily.stool.soft">
408+
<trans-unit id="rdWeWy5" resname="sheet.daily.stool.soft">
409409
<source>sheet.daily.stool.soft</source>
410410
<target>molle</target>
411411
</trans-unit>
@@ -481,6 +481,14 @@
481481
<source>sheet.daily.modal.add-meal</source>
482482
<target>Ajouter un repas</target>
483483
</trans-unit>
484+
<trans-unit id="6dzNxl9" resname="sheet.daily.add">
485+
<source>sheet.daily.add</source>
486+
<target>Mettre à jour la fiche</target>
487+
</trans-unit>
488+
<trans-unit id="fyzIugU" resname="sheet.daily.add.validation">
489+
<source>sheet.daily.add.validation</source>
490+
<target>La fiche journalière a bien été mise à jour !</target>
491+
</trans-unit>
484492
</body>
485493
</file>
486494
</xliff>

0 commit comments

Comments
 (0)