Skip to content

Commit

Permalink
Merge pull request #9 from biocatchltd/BC-22349
Browse files Browse the repository at this point in the history
fixed bugs in rules editing
  • Loading branch information
MarvaZy authored Nov 10, 2021
2 parents 4831888 + 42672f3 commit d91f0b6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 14 deletions.
2 changes: 1 addition & 1 deletion backend/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "hekshermgmt"
version = "0.1.1"
version = "0.1.2"
description = ""
authors = ["Aviram Hassan <[email protected]>"]

Expand Down
2 changes: 1 addition & 1 deletion frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hekshermgmt",
"version": "0.1.1",
"version": "0.1.2",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand Down
31 changes: 22 additions & 9 deletions frontend/src/components/EditRuleDialog.vue
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
<template>
<v-dialog v-model="show" width="50%">
<v-dialog v-model="show" width="50%" @focusin.prevent :retain-focus="false">
<v-card>
<v-card-title>
<span class="headline">Edit Setting - {{ setting.name }}, Rule - {{ rule.rule_id }}</span>
<span class="headline">Edit Setting - {{ setting_.name }}, Rule - {{ rule_.rule_id }}</span>
</v-card-title>
<v-card-text>
<v-form ref="form" v-model="valid">
<v-container class="d-flex flex-column">
<v-container class="d-flex">
<v-text-field
outlined readonly :label="context" v-for="context in setting.configurable_features" :key="context"
outlined readonly :label="context" v-for="context in setting_.configurable_features" :key="context"
:value="changedRule['context_features'][context] || ' '" class="ml-1 mr-1"
/>
</v-container>
<rule-value v-model="changedRule.value" :setting-type="setting.type"
:initial-value="rule.value" :default-value="setting.default_value"/>
<rule-value v-model="changedRule.value" :setting-type="setting_.type"
:initial-value="rule_.value" :default-value="setting_.default_value" ref="rule_value"/>
<v-text-field readonly label="Information" :value="changedRule.information || ' '" outlined/>
</v-container>
</v-form>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="blue" text @click.prevent="show=false">
<v-btn color="blue" text @click.prevent="closeDialog()" @focusin.stop>
Cancel
</v-btn>
<v-btn color="blue" text @click="saveRule">
Expand All @@ -40,13 +40,17 @@ export default {
RuleValue
},
methods: {
async closeDialog() {
this.show = false;
this.$refs.rule_value.resetValue()
},
async saveRule() {
this.$refs.form.validate();
if (!this.valid) {
return;
}
var new_value = this.changedRule.value
if (this.setting.type.startsWith("Sequence") || this.setting.type.startsWith("Mapping")) {
if (this.setting_.type.startsWith("Sequence") || this.setting_.type.startsWith("Mapping")) {
try {
new_value = JSON.parse(this.changedRule.value);
} catch (err) {
Expand All @@ -55,7 +59,7 @@ export default {
}
}
try {
await this.$http.patch(`/api/v1/rule/${this.rule.rule_id}`, {
await this.$http.patch(`/api/v1/rule/${this.rule_.rule_id}`, {
'value': new_value
});
} catch (error) {
Expand All @@ -66,7 +70,14 @@ export default {
this.show = false;
},
initializeRuleObject() {
return JSON.parse(JSON.stringify(this.rule));
return JSON.parse(JSON.stringify(this.rule_));
},
selectRule(setting, rule) {
this.setting_ = setting
this.rule_ = rule
this.changedRule = JSON.parse(JSON.stringify(rule));
this.valid = true
this.newRuleDialog = false
}
},
computed: {
Expand All @@ -82,6 +93,8 @@ export default {
props: ['setting', 'rule', 'value'],
data() {
return {
setting_: this.setting,
rule_: this.rule,
changedRule: this.initializeRuleObject(),
newRuleDialog: false,
valid: true,
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/components/SettingRules.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
</v-card>
<v-data-table :headers="headers" :items="rules" :search="search" multi-sort>
<template v-slot:item.actions="{ item }">
<v-icon small @click.prevent="editRuleDialog=true">
<v-icon small @click="editRule(setting, item)">
mdi-pencil
</v-icon>
<edit-rule-dialog v-on:rule-saved="onRuleChange" v-model="editRuleDialog" :setting="setting" :rule="item"/>
<EditRuleDialog v-on:rule-saved="onRuleChange" v-model="editRuleDialog" :setting="setting" :rule="item" ref="edit"/>
<v-spacer/>
<v-icon small @click="deleteConfirmDialog(item)">
mdi-delete
Expand Down Expand Up @@ -80,6 +80,10 @@ export default {
return;
}
this.rules = response.data;
},
editRule(setting, rule) {
this.$refs.edit.selectRule(setting, rule);
this.editRuleDialog = true
}
},
computed: {
Expand Down

0 comments on commit d91f0b6

Please sign in to comment.