ovh / ovh-ui-kit

OVHcloud UI Kit - Master UI Framework
https://ovh.github.io/ovh-ui-kit
BSD 3-Clause "New" or "Revised" License
58 stars 20 forks source link

feat(select): add on-confirm-remove property #810

Closed y4nnL closed 1 year ago

y4nnL commented 1 year ago

Select

Attribute on-confirm-remove

When multiple is true, you may provide this handler before an item is removed from the selection. This handler is passed the item to remove and must return a promise. If the return value of that promise is truthy, the item is removed from the selection, otherwise it is kept.

<oui-select
    model="$ctrl.model"
    items="$ctrl.items"
    multiple="true"
    on-confirm-remove="$ctrl.onConfirmRemove(item)">
</oui-select>
async onConfirmRemove(item) {
  try {
    const removed = await doSomeAsyncTasksWith(item);
    return removed;
  } catch (e) {
    return false;
  }
}