Skip to content

Commit

Permalink
feat(plugin's options): the text option to set custom no data text
Browse files Browse the repository at this point in the history
  • Loading branch information
iliyaZelenko committed Sep 18, 2019
1 parent 1abdf8d commit 9698298
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 7 deletions.
6 changes: 5 additions & 1 deletion gh-pages-src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ import(`../src/styles/themes/${theme}.styl`)
// import(`../dist/themes/${theme}.css`)

Vue.use(Vuetify)
Vue.use(CoolSelectPlugin)
Vue.use(CoolSelectPlugin, {
text: {
noData: 'Нет доступных данных'
}
})

Vue.use(VueAnalytics, {
id: 'UA-127403551-2',
Expand Down
2 changes: 1 addition & 1 deletion src/component.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
class="IZ-select__no-data"
>
<slot name="no-data">
No data available
{{ $coolSelect.options.text.noData }}
</slot>
</div>

Expand Down
18 changes: 18 additions & 0 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,21 @@ export function scrollIfNeeded (element, container) {
}
}
}

export default function mergeDeep (target, source) {
let output = Object.assign({}, target)
if (isObject(target) && isObject(source)) {
Object.keys(source).forEach(key => {
if (isObject(source[key])) {
if (!(key in target)) {
Object.assign(output, { [key]: source[key] })
} else {
output[key] = mergeDeep(target[key], source[key])
}
} else {
Object.assign(output, { [key]: source[key] })
}
})
}
return output
}
12 changes: 11 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// import '~/styles/themes/material-design.styl'
import component from '~/component.vue'
import EventEmitter from '~/eventEmitter'
import mergeDeep from '~/helpers'

export const CoolSelectPlugin = new Singleton()
export {
Expand All @@ -14,8 +15,17 @@ export {

function Singleton () {
return {
install (Vue, options = {}) {
install (Vue, optionsInput = {}) {
const optionsDefault = {
text: {
noData: 'No data available'
}
}
const options = mergeDeep(optionsDefault, optionsInput)

Vue.prototype.$coolSelect = {
options
}
}
}
}
8 changes: 4 additions & 4 deletions src/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ export default {
default: 'https://i.imgur.com/fLYd7PN.gif',
note: 'sets custom loading spinner/indicator. https://loading.io/'
},
errorMessage: {
type: String,
default: null
},
disabled: {
type: Boolean,
default: false,
Expand Down Expand Up @@ -139,6 +135,10 @@ export default {
default: () => '',
note: 'custom "class" attribute for the input field. You can specify dynamic class.'
},
errorMessage: {
type: String,
default: null
},
successful: {
type: Boolean,
default: false,
Expand Down

0 comments on commit 9698298

Please sign in to comment.