SpeciesFileGroup/taxonworks

View on GitHub
app/javascript/vue/tasks/images/new_image/store/actions/applyTags.js

Summary

Maintainability
A
0 mins
Test Coverage
import { Tag } from '@/routes/endpoints'

export default ({ state }, payload) => {
  const { objectType, objectIds } = payload

  const requests = state.tagsForImage.map((tag) =>
    Tag.createBatch({
      keyword_id: tag.id,
      object_id: objectIds,
      object_type: objectType
    })
  )

  Promise.all(requests).then((_) => {
    state.settings.applied.tags = true
    TW.workbench.alert.create('All tag(s) was successfully created.', 'notice')
  })
}