55
66import { CardApi } from './../services/CardApi.js'
77import moment from 'moment'
8- import Vue from 'vue'
98
109const apiClient = new CardApi ( )
1110
@@ -180,6 +179,7 @@ export default {
180179 . sort ( ( a , b ) => a . order - b . order || a . createdAt - b . createdAt )
181180 } ,
182181 cardById : state => ( id ) => {
182+ alert ( 'cardById' )
183183 return state . cards . find ( ( card ) => card . id === id )
184184 } ,
185185 } ,
@@ -190,7 +190,7 @@ export default {
190190 const existingIndex = state . cards . findIndex ( _card => _card . id === card . id )
191191 if ( existingIndex !== - 1 ) {
192192 const existingCard = state . cards . find ( _card => _card . id === card . id )
193- Vue . set ( state . cards , existingIndex , Object . assign ( { } , existingCard , card ) )
193+ state . cards [ existingIndex ] = { ... existingCard , ... card }
194194 } else {
195195 state . cards . push ( card )
196196 }
@@ -204,15 +204,15 @@ export default {
204204 updateCard ( state , card ) {
205205 const existingIndex = state . cards . findIndex ( _card => _card . id === card . id )
206206 if ( existingIndex !== - 1 ) {
207- Vue . set ( state . cards , existingIndex , Object . assign ( { } , state . cards [ existingIndex ] , card ) )
207+ state . cards [ existingIndex ] = { ... state . cards [ existingIndex ] , ... card }
208208 }
209209 } ,
210210 updateCardsReorder ( state , cards ) {
211211 for ( const newCard of cards ) {
212212 const existingIndex = state . cards . findIndex ( _card => _card . id === newCard . id )
213213 if ( existingIndex !== - 1 ) {
214- Vue . set ( state . cards [ existingIndex ] , ' order' , newCard . order )
215- Vue . set ( state . cards [ existingIndex ] , ' stackId' , newCard . stackId )
214+ state . cards [ existingIndex ] . order = newCard . order
215+ state . cards [ existingIndex ] . stackId = newCard . stackId
216216 }
217217 }
218218 } ,
@@ -234,26 +234,26 @@ export default {
234234 updateCardProperty ( state , { card, property } ) {
235235 const existingIndex = state . cards . findIndex ( _card => _card . id === card . id )
236236 if ( existingIndex !== - 1 ) {
237- Vue . set ( state . cards [ existingIndex ] , property , card [ property ] )
238- Vue . set ( state . cards [ existingIndex ] , 'lastModified' , Date . now ( ) / 1000 )
237+ state . cards [ existingIndex ] [ property ] = card [ property ]
238+ state . cards [ existingIndex ] . lastModifiedBy = Date . now ( ) / 1000
239239 }
240240 } ,
241241 cardSetAttachmentCount ( state , { cardId, count } ) {
242242 const existingIndex = state . cards . findIndex ( _card => _card . id === cardId )
243243 if ( existingIndex !== - 1 ) {
244- Vue . set ( state . cards [ existingIndex ] , ' attachmentCount' , count )
244+ state . cards [ existingIndex ] . attachmentCount = count
245245 }
246246 } ,
247247 cardIncreaseAttachmentCount ( state , cardId ) {
248248 const existingIndex = state . cards . findIndex ( _card => _card . id === cardId )
249249 if ( existingIndex !== - 1 ) {
250- Vue . set ( state . cards [ existingIndex ] , ' attachmentCount' , state . cards [ existingIndex ] . attachmentCount + 1 )
250+ state . cards [ existingIndex ] . attachmentCount = state . cards [ existingIndex ] . attachmentCount + 1
251251 }
252252 } ,
253253 cardDecreaseAttachmentCount ( state , cardId ) {
254254 const existingIndex = state . cards . findIndex ( _card => _card . id === cardId )
255255 if ( existingIndex !== - 1 ) {
256- Vue . set ( state . cards [ existingIndex ] , ' attachmentCount' , state . cards [ existingIndex ] . attachmentCount - 1 )
256+ state . cards [ existingIndex ] . attachmentCount = state . cards [ existingIndex ] . attachmentCount - 1
257257 }
258258 } ,
259259 addNewCard ( state , card ) {
@@ -344,6 +344,7 @@ export default {
344344 commit ( 'removeUserFromCard' , user )
345345 } ,
346346 async addLabel ( { commit } , data ) {
347+ alert ( 'hello world' )
347348 await apiClient . assignLabelToCard ( data )
348349 commit ( 'updateCardProperty' , { property : 'labels' , card : data . card } )
349350 } ,
0 commit comments