A
A
Aleksandr2017-07-10 17:10:16
JavaScript
Aleksandr, 2017-07-10 17:10:16

Filter an array?

<ui_graph_search :values="getStatus" @select="changeArray('status_id', 'where', $event)" :multiple="true">Статус</ui_graph_search>
<ui_chip removeByCallback v-for="selected in filterArray.status_id" @delete="removeFromWhereIn('status_id', 'where', $event)" :item="selected">{{ selected.name }}</ui_chip>

changeArray(name, subname, value) {
      this.filterArray[name].push(value)
}

I can’t figure out how to write a condition so that push(value) does not work if the same object hits the second time?
There are two statuses:
1) active
2)
inactive When the user clicks on "active", an object with ID = 1 is written to this.filterArray[name], and then an array of objects is obtained by "Not active" ID = 2. If you double click on "Active" it will display this object twice, how to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Negwereth, 2017-07-10
@Sashjkeee

Use a Map to store data by key.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question