Pass parameters to PatternModal

This commit is contained in:
Sergey Shkurov 2023-04-29 02:58:43 +02:00
parent 154338f128
commit 41c982b1dd
5 changed files with 42 additions and 23 deletions

View File

@ -55,7 +55,7 @@
</div> </div>
</b-dropdown-item-button> </b-dropdown-item-button>
<AddPattern/> <AddPattern :creating="patternModalIsCreating" :initial-pattern="patternModalEditingPattern" />
</b-dropdown> </b-dropdown>
</template> </template>
<!--suppress JSUnresolvedReference --> <!--suppress JSUnresolvedReference -->
@ -65,6 +65,12 @@
export default { export default {
name: 'PatternsDropdown', name: 'PatternsDropdown',
components: {AddPattern: PatternModal, }, components: {AddPattern: PatternModal, },
data() {
return {
patternModalIsCreating: true,
patternModalEditingPattern: {},
};
},
mounted() { mounted() {
this.updatePatterns(); this.updatePatterns();
}, },
@ -90,7 +96,10 @@
return this.$store.state.services.find(o => o.port === port)?.name ?? '<Deleted service>' return this.$store.state.services.find(o => o.port === port)?.name ?? '<Deleted service>'
}, },
showAddPattern() { showAddPattern() {
this.patternModalIsCreating = true;
this.patternModalEditingPattern = {};
this.$bvModal.show('patternModal'); this.$bvModal.show('patternModal');
console.debug('Showing patternModal...');
}, },
showLookBack(pattern) { showLookBack(pattern) {
// Не знаю, как сделать это без костылей // Не знаю, как сделать это без костылей

View File

@ -67,7 +67,3 @@
}, },
}; };
</script> </script>
<style scoped>
</style>

View File

@ -85,12 +85,9 @@
</template> </template>
<script> <script>
const hexRegex = /[0-9A-Fa-f ]/; const hexRegex = /[0-9A-Fa-f ]/;
export default { const defaultPattern = {
name: 'AddPattern',
data() {
return {
newPattern: {
name: '', name: '',
value: '', value: '',
color: '#FF7474', color: '#FF7474',
@ -98,8 +95,33 @@
directionType: 'BOTH', directionType: 'BOTH',
actionType: 'FIND', actionType: 'FIND',
serviceId: null, serviceId: null,
},
}; };
export default {
name: 'AddPattern',
props: {
creating: Boolean,
initialPattern: {
name: String,
value: String,
color: String,
searchType: String,
directionType: String,
actionType: String,
serviceId: Number,
},
},
data() {
return {
newPattern: {},
};
},
watch: {
initialPattern() {
console.debug('initialService changed, reassigning...', this.initialPattern);
this.newPattern = {...defaultPattern, ...this.initialPattern,};
},
}, },
computed: { computed: {
serviceOptions: function () { serviceOptions: function () {

View File

@ -142,7 +142,3 @@
}, },
}; };
</script> </script>
<style scoped>
</style>

View File

@ -62,7 +62,3 @@
}, },
}; };
</script> </script>
<style scoped>
</style>