Sasha Zoria
Sasha Zoria

Reputation: 771

How to move objects between 6 arrays Vue

I have drag and drop like Trello. There are 6 arrays with objects (cards). I need to move this cards between arrays by clicking popup in the card, in this popup i have to choose in which array (bord) this card should be moved.

    queued: [ // array
     {
       project: 'AI development',
       client: 'Tesla',
       fixed: false,
       price: 5000,
       id: 1
    },
    {
      project: 'Blockchain integration',
      client: 'BWM',
      fixed: false,
      price: 2500,
      id: 112
      },
    {
      project: 'Chatbot',
      client: 'T-Mobile',
      fixed: false,
      price: 6500,
      id: 13
    }
       ]
    planningArr : [ // array
    {
      project: 'Landing page',
      client: 'Amazon',
      fixed: false,
      price: 1000,
      id: 14
    },
    {
      project: 'Website',
      client: 'Google',
      fixed: false,
      price: 2000,
      id: 100
    },
    {
      project: 'Website',
      client: 'Google',
      fixed: false,
      price: 500,
      id: 1121
    }
      ],
designArr: [ // array
{
      project: 'Logo design',
      client: 'Symu.com',
      fixed: false,
      price: 2000,
      id: 19
 }
]

Here i showed only three arrays. I think i have to use splice and push, but i have no idea in which way these methods should be used.

Upvotes: 2

Views: 111

Answers (1)

Rishikesh Dhokare
Rishikesh Dhokare

Reputation: 3589

1) To remove from an array, supposed you want to remove the card with AI development

var card = {
  project: 'AI development',
  client: 'Tesla',
  fixed: false,
  price: 5000,
  id: 1
}

queued.splice(queued.indexOf(card),1);

2) To add it to array, suppose in planningArr

planningArr.push(card)

Upvotes: 1

Related Questions