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