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

View File

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

View File

@ -85,22 +85,44 @@
</template>
<script>
const hexRegex = /[0-9A-Fa-f ]/;
const hexRegex = /[0-9A-Fa-f ]/;
const defaultPattern = {
name: '',
value: '',
color: '#FF7474',
searchType: 'SUBSTRING',
directionType: 'BOTH',
actionType: 'FIND',
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: {
name: '',
value: '',
color: '#FF7474',
searchType: 'SUBSTRING',
directionType: 'BOTH',
actionType: 'FIND',
serviceId: null,
},
newPattern: {},
};
},
watch: {
initialPattern() {
console.debug('initialService changed, reassigning...', this.initialPattern);
this.newPattern = {...defaultPattern, ...this.initialPattern,};
},
},
computed: {
serviceOptions: function () {
let services = this.$store.state.services;

View File

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

View File

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