Skip to content

Commit

Permalink
feat: automatically set end time after start time blurred
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael Kabo committed Jul 16, 2024
1 parent ee6ee9a commit 68f5ce9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
19 changes: 12 additions & 7 deletions public/js/modules/event-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ $(document).ready(function () {
});

$('#editModal').on('shown.bs.modal', function (e) {
console.log('hii');
const ta = document.querySelector("#editModal textarea");
ta.style.display = 'none';
autosize(ta);
ta.style.display = '';
// Call the update method to recalculate the size:
autosize.update(ta);
console.log('hii');
const ta = document.querySelector("#editModal textarea");
ta.style.display = 'none';
autosize(ta);
ta.style.display = '';
// Call the update method to recalculate the size:
autosize.update(ta);
});

function editEventForm() {
Expand Down Expand Up @@ -65,6 +65,11 @@ function editEventForm() {
window.eventData.maxAttendees !== null;
this.data.publicCheckbox = window.eventData.showOnPublicList;
},
updateEventEnd() {
if (this.data.eventEnd === "" || this.data.eventEnd < this.data.eventStart) {
this.data.eventEnd = this.data.eventStart;
}
},
async submitForm() {
this.submitting = true;
this.errors = [];
Expand Down
5 changes: 5 additions & 0 deletions public/js/modules/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ function newEventForm() {
this.data.maxAttendeesCheckbox = false;
this.data.publicCheckbox = false;
},
updateEventEnd() {
if (this.data.eventEnd === "" || this.data.eventEnd < this.data.eventStart) {
this.data.eventEnd = this.data.eventStart;
}
},
async submitForm() {
this.submitting = true;
this.errors = [];
Expand Down
2 changes: 1 addition & 1 deletion views/partials/eventForm.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<div class="form-group">
<label for="eventStart" >Starts</label>
<div class="form-group">
<input type="datetime-local" class="form-control" id="eventStart" name="eventStart" x-model="data.eventStart">
<input type="datetime-local" class="form-control" id="eventStart" name="eventStart" x-model="data.eventStart" x-on:blur="updateEventEnd">
</div>
</div>
<div class="form-group">
Expand Down

0 comments on commit 68f5ce9

Please sign in to comment.