-
Notifications
You must be signed in to change notification settings - Fork 533
Adding Vue-Multiselect #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
cef52cb
9df5b5e
24c49d9
7e3472d
c5b6f33
dba3ed7
f870dae
acfa264
54a3502
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,6 +95,7 @@ | |
}, | ||
"dependencies": { | ||
"babel-runtime": "6.9.2", | ||
"vue": "1.0.24" | ||
"vue": "1.0.24", | ||
"vue-multiselect": "^1.0.1" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove from dependencies and load as an external optional component. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't have a cdnjs or jsdelivr link for vue-multiselect. I used rawgit, I hope it is enough. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, rawgit enough. It is only a developer example file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do I do that ? I have forked the project, but I don't know how to update my fork. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made a fiddle: http://www.webpackbin.com/4yy1cQ2OW There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Easy way to rebase package.json, copy from master from this repo, and paste your branch :) And there won't be diff. |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<template lang="jade"> | ||
multiselect( | ||
:id="schema.selectOptions.id", | ||
:options="options", | ||
:multiple="schema.multiSelect", | ||
:selected="value", | ||
:key="schema.selectOptions.key || null", | ||
:label="schema.selectOptions.label || null", | ||
:searchable="schema.selectOptions.searchable", | ||
:clear-on-select="schema.selectOptions.clearOnSelect", | ||
:hide-selected="schema.selectOptions.hideSelected", | ||
:placeholder="schema.placeholder", | ||
:max-height="schema.selectOptions.maxHeight", | ||
:allow-empty="schema.selectOptions.allowEmpty", | ||
:reset-after="schema.selectOptions.resetAfter", | ||
:close-on-select="schema.selectOptions.closeOnSelect", | ||
:custom-label="schema.selectOptions.customLabel || null", | ||
:taggable="schema.selectOptions.taggable", | ||
:tag-placeholder="schema.selectOptions.tagPlaceholder", | ||
:max="schema.selectOptions.max", | ||
@update="updateSelected", | ||
@select="onSelect", | ||
@remove="onRemove", | ||
@search-change="onSearchChange", | ||
@tag="addTag", | ||
@open="onOpen", | ||
@close="onClose", | ||
:show-labels="schema.selectOptions.showLabels" | ||
// TODO: add other options from multiSelectMixin | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add every fields from multiselect |
||
</template> | ||
<script> | ||
// import { isObject } from "lodash"; | ||
import abstractField from "./abstractField"; | ||
import Multiselect from "vue-multiselect"; | ||
|
||
export default { | ||
mixins: [abstractField], | ||
components: { | ||
Multiselect | ||
}, | ||
computed: { | ||
options() { | ||
let values = this.schema.values; | ||
if (typeof(values) == "function") { | ||
return values.apply(this, [this.model, this.schema]); | ||
} else { | ||
return values; | ||
} | ||
} | ||
}, | ||
|
||
methods: { | ||
updateSelected(value, id) { | ||
this.value = value; | ||
}, | ||
onSelect(selectedOption, id) { | ||
console.log("onSelect", selectedOption, id); | ||
}, | ||
onRemove(removedOption, id) { | ||
console.log("onRemove", removedOption, id); | ||
}, | ||
onSearchChange(searchQuery, id) { | ||
console.log("onSearchChange", searchQuery, id); | ||
}, | ||
addTag(newTag, id) { | ||
console.log("addTag", newTag, id); | ||
// TODO: implement tag object by sending this function into schema definition | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please call the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think about the other events, are they useless or should I add them like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leave this events in the field code, just comment out the console messages. But I think we only need the |
||
/* const tag = { | ||
name: newTag, | ||
// Just for example needs as we use Array of Objects that should have other properties filled. | ||
// For primitive values you can simply push the tag into options and selected arrays. | ||
code: newTag.substring(0, 2) + Math.floor((Math.random() * 10000000)) | ||
}*/ | ||
this.options.push(newTag); | ||
this.value.push(newTag); | ||
}, | ||
onOpen(id) { | ||
console.log("onOpen", id); | ||
}, | ||
onClose(value, id) { | ||
console.log("onClose", value, id); | ||
} | ||
} | ||
}; | ||
</script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add an
onNewTag
event handler to the selectOptions:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also adding
onSearch
(fromonSearchChange
) since it is a very useful function (to create dynamics option list for country and all kind of filtering).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, great!