From 8b9445f29bca86d5ca7b867579b7bfac31d61c77 Mon Sep 17 00:00:00 2001 From: theo1 Date: Mon, 19 Oct 2020 14:51:38 +0200 Subject: [PATCH] Setting date to today in ArticleForm using button --- md-parser/src/components/ArticleForm.vue | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/md-parser/src/components/ArticleForm.vue b/md-parser/src/components/ArticleForm.vue index dc8b52a..c418158 100644 --- a/md-parser/src/components/ArticleForm.vue +++ b/md-parser/src/components/ArticleForm.vue @@ -7,13 +7,13 @@
-
+
-
+
@@ -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 } }