Closed hasyrails closed 3 years ago
日付のバリデーション設定時に
start, endの情報を
card
としてではなく、form
で渡すようにしているため
ref #325
start, end更新時
$store.state.card
が変更されていない
form
がVuexのアクションを整合が取れていないprops: {
card:{
type: Object
},
},
この渡したcardをそのまま変更すると
日付バリデーションが実装できなかったので
新しく作成したのがform
というローカルデータ
form:{
start: '',
deadline: '',
},
updateCard(state, payload){
state.cards = payload.card
}
ここ。
payloadはform
なので
form.card
とは??ということでupdateCard mutationが発火しても
更新されることはない。
form
をpropsのcardと同じにする
(start, end は入力するので空で定義)
form:{
id: this.card.id,
body: this.card.body,
description: this.card.description,
start: '',
deadline: '',
schedulized: this.card.schedulized,
color: this.card.color,
card_id: this.card.id,
user_id: this.$store.getters['auth/user'].id,
},
payload.cardがないこと自体は変わらない。 updateCard mutationを変更
updateCard(state, payload){
+ const card = state.cards.find((o) => {
+ return o.id === payload.id;
+ });
+
+ const index = state.cards.findIndex((o) => {
+ return o.id === payload.id
+ })
+
+ state.cards.splice(index, 1, card)
+ },
日時を設定した後、 カードの
start
,end
が nullとして登録されている