chore: replace error emitter with vue.emit
This commit is contained in:
@@ -76,8 +76,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import emitter from '../lib/emitter.mjs';
|
||||
|
||||
const getMultiValues = node => Array.from(node.selectedOptions).map(o => o.value);
|
||||
|
||||
export default {
|
||||
@@ -86,17 +84,10 @@ export default {
|
||||
uses: Array,
|
||||
conditions: Array,
|
||||
flavors: Array,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
error: '',
|
||||
};
|
||||
},
|
||||
created() {
|
||||
emitter.on('error', this.setError);
|
||||
},
|
||||
beforeDestroy() {
|
||||
emitter.off('error', this.setError);
|
||||
error: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
handleSubmit() {
|
||||
@@ -108,15 +99,11 @@ export default {
|
||||
flavors: getMultiValues(this.$refs.flavors),
|
||||
};
|
||||
|
||||
this.error = '';
|
||||
this.$emit('search', requirements);
|
||||
},
|
||||
resetForm() {
|
||||
this.$el.reset();
|
||||
},
|
||||
setError(msg) {
|
||||
this.error = msg;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
:uses="uses"
|
||||
:conditions="conditions"
|
||||
:flavors="flavors"
|
||||
:error="error"
|
||||
@search="onSearch"
|
||||
/>
|
||||
</div>
|
||||
@@ -40,6 +41,7 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
error: '',
|
||||
matches: [],
|
||||
requirements: {
|
||||
name: '',
|
||||
@@ -100,6 +102,8 @@ export default {
|
||||
this.matches = this.strains.slice(0, limit);
|
||||
},
|
||||
updateMatches(limit = 40) {
|
||||
this.error = '';
|
||||
|
||||
if (!this.hasName && !this.hasFilters) {
|
||||
this.showDefaults(limit);
|
||||
return;
|
||||
@@ -127,7 +131,7 @@ export default {
|
||||
});
|
||||
} catch (err) {
|
||||
this.matches = [];
|
||||
emitter.emit('error', err.message);
|
||||
this.error = err.message;
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user