mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-09-17 05:52:20 +09:00
Hello world
First open source release of Campfire 🎉
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import BaseAutocompleteHandler from "lib/autocomplete/base_autocomplete_handler"
|
||||
import Selection from "lib/autocomplete/selection"
|
||||
|
||||
export default class extends BaseAutocompleteHandler {
|
||||
#selection
|
||||
|
||||
constructor(element, select, url) {
|
||||
super(element, url)
|
||||
this.#selection = new Selection(select)
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
this.#selection.disconnect()
|
||||
}
|
||||
|
||||
|
||||
insertAutocompletable(autocompletable) {
|
||||
this.#selection.add(autocompletable.value, autocompletable.name, { avatarUrl: autocompletable.avatar_url })
|
||||
this.element.value = ""
|
||||
}
|
||||
|
||||
get pattern() {
|
||||
return new RegExp(`^(.*?)$`)
|
||||
}
|
||||
|
||||
remove(value) {
|
||||
this.#selection.remove(value)
|
||||
}
|
||||
|
||||
removeLastSelection() {
|
||||
this.#selection.removeLast()
|
||||
}
|
||||
|
||||
search(term) {
|
||||
super.updateWithContentAndPosition(term, 0)
|
||||
}
|
||||
|
||||
setAutocompletables(autocompletables) {
|
||||
super.setAutocompletables(this.#filterSelectedAutocompletables(autocompletables))
|
||||
}
|
||||
|
||||
#filterSelectedAutocompletables(autocompletables) {
|
||||
const selectedValues = this.#selection.values.concat(Current.user.id)
|
||||
return autocompletables.filter(autocompletable => !selectedValues.includes(autocompletable.value))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user