{"size": 956, "ext": "js", "max_stars_repo_path": "src/CrispBulkUpdate.js", "max_stars_repo_name": "gojilabs/crisp-table-js", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/CrispBulkUpdate.js", "max_issues_repo_name": "gojilabs/crisp-table-js", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/CrispBulkUpdate.js", "max_forks_repo_name": "gojilabs/crisp-table-js", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.1578947368, "max_line_length": 76, "alphanum_fraction": 0.6872384937}
// context
import { CrispContext } from './CrispContext'

// components
import CrispFieldsModalBase from './CrispFieldsModalBase'

class CrispBulkUpdate extends CrispFieldsModalBase {
  static contextType = CrispContext

  filterColumnsFieldName = 'bulk_editable'
  buttonIcon = 'fa-pencil'

  constructor(props, context) {
    super(props)
    this.modalTitle = `${context.tableData.title} Bulk Update`
  }

  onSubmit = (collectedData) => {
    this.context.bulkEdit(collectedData, () => window.location.reload(true))
  }

  getFooterText = () => {
    const { selectedRows, tableData } = this.context
    return `Applying this change to ${
      selectedRows.length
    } ${tableData.title.toLocaleLowerCase()} record${
      selectedRows.length > 1 ? 's' : ''
    }`
  }

  getErrorText = () => {
    const { errorMessage } = this.context
    return errorMessage ? `Cannot update records - ${errorMessage}` : null
  }
}

export default CrispBulkUpdate
