Move to today in cuentas.show

This commit is contained in:
2022-04-02 23:32:27 -04:00
parent 10e5383a3e
commit 560fb356fa
2 changed files with 17 additions and 0 deletions

View File

@ -95,6 +95,7 @@ const transacciones = {
buttons: { buttons: {
prev: '#prev_button', prev: '#prev_button',
left: '#left_button', left: '#left_button',
today: '#today_button',
right: '#right_button', right: '#right_button',
next: '#next_button' next: '#next_button'
}, },
@ -342,6 +343,11 @@ const transacciones = {
this.checkButtons() this.checkButtons()
$(this.mes).calendar('set date', this.date) $(this.mes).calendar('set date', this.date)
}, },
today: function() {
this.date = new Date()
this.checkButtons()
$(this.mes).calendar('set date', this.date)
},
changeYear: function(dif) { changeYear: function(dif) {
let d = this.date let d = this.date
d.setFullYear(this.date.getFullYear() + dif) d.setFullYear(this.date.getFullYear() + dif)
@ -356,6 +362,11 @@ const transacciones = {
} else { } else {
$(this.buttons.right).removeClass('disabled') $(this.buttons.right).removeClass('disabled')
} }
if (this.date.toDateString() === f.toDateString()) {
$(this.buttons.today).addClass('disabled')
} else {
$(this.buttons.today).removeClass('disabled')
}
if (this.date.getFullYear() === f.getFullYear()) { if (this.date.getFullYear() === f.getFullYear()) {
$(this.buttons.next).addClass('disabled') $(this.buttons.next).addClass('disabled')
} else { } else {
@ -422,6 +433,9 @@ const transacciones = {
}) })
}, },
buttons: () => { buttons: () => {
$(this.buttons.today).click((e) => {
this.today()
})
$(this.buttons.right).click((e) => { $(this.buttons.right).click((e) => {
this.changeMonth(1) this.changeMonth(1)
}) })

View File

@ -18,6 +18,9 @@
<div class="ui icon button" id="left_button"> <div class="ui icon button" id="left_button">
<i class="left angle icon"></i> <i class="left angle icon"></i>
</div> </div>
<div class="ui icon disabled button" id="today_button">
<i class="calendar day icon"></i>
</div>
<div class="ui icon disabled button" id="right_button"> <div class="ui icon disabled button" id="right_button">
<i class="right angle icon"></i> <i class="right angle icon"></i>
</div> </div>