Setting date to today in ArticleForm using button
This commit is contained in:
parent
8a67263a74
commit
8b9445f29b
@ -7,13 +7,13 @@
|
||||
<div class='form-group'>
|
||||
<label for='date-published'>Publication date</label>
|
||||
<input v-model='date_created' type='date' name='date-published' id='date-published' class='form-control form-control-sm'>
|
||||
<input type='button' class='btn btn-default today-button' @click.prevent="setToday(1)" value='today'><br>
|
||||
<input type='button' class='btn btn-default today-button' @click.prevent="setToday('date-published')" value='today'><br>
|
||||
</div>
|
||||
|
||||
<div class='form-group'>
|
||||
<label for='date-modified'>Modification date</label>
|
||||
<input v-model='date_modified' type='date' name='date-modified' id='date-modified' class='form-control form-control-sm'>
|
||||
<input type='button' class='btn btn-default today-button' @click.prevent="setToday(2)" value='today'><br>
|
||||
<input type='button' class='btn btn-default today-button' @click.prevent="setToday('date-modified')" value='today'><br>
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<label for='meta-title'>meta title</label>
|
||||
@ -47,6 +47,14 @@ export default {
|
||||
"date_modified": this.date_modified,
|
||||
"title": this.title
|
||||
}
|
||||
},
|
||||
// Input-ready current day.
|
||||
// Based on https://gomakethings.com/setting-a-date-input-to-todays-date-with-vanilla-js/.
|
||||
today (){
|
||||
let obj = new Date()
|
||||
return obj.getFullYear().toString() + "-"
|
||||
+ (obj.getMonth() +1).toString().padStart(2,0) + "-"
|
||||
+ obj.getDate().toString().padStart(2,0)
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@ -64,14 +72,11 @@ export default {
|
||||
},
|
||||
},
|
||||
methods : {
|
||||
// WIP : sets meta date to today.
|
||||
// params: date= 1 => set date_created
|
||||
// date = 2 => set date_modified
|
||||
setToday : function(date) {
|
||||
this.$store.commit('today', date)
|
||||
},
|
||||
sendMeta: function(){
|
||||
this.$store.commit('updateMeta', this.meta)
|
||||
},
|
||||
setToday(id){
|
||||
document.getElementById(id).value = this.today
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user