Skip to content

Commit

Permalink
Fix for Vue warnings about modified props
Browse files Browse the repository at this point in the history
Signed-off-by: Walter de Boer <walterdeboer@dbso.nl>
  • Loading branch information
Walter de Boer committed Jul 4, 2023
1 parent cbc1e41 commit 8b8166e
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions src/views/policy/PolicyCondition.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import ActionableListGroupItem from "../components/ActionableListGroupItem";
},
created() {
if (this.condition) {
this.uuid = this.condition.uuid;
this.subject = this.condition.subject;
this.subjectChanged();
this.operator = this.condition.operator;
Expand All @@ -67,6 +68,7 @@ import ActionableListGroupItem from "../components/ActionableListGroupItem";
},
data() {
return {
uuid: null,
subject: null,
operator: null,
value: null,
Expand Down Expand Up @@ -257,10 +259,10 @@ import ActionableListGroupItem from "../components/ActionableListGroupItem";
});
} else if (this.subject === "VERSION_DISTANCE") {
let result = {
epoch: parseInt(common.trimToNull(this.versionDistance.epoch)),
major: parseInt(common.trimToNull(this.versionDistance.major)),
minor: parseInt(common.trimToNull(this.versionDistance.minor)),
patch: parseInt(common.trimToNull(this.versionDistance.patch))
epoch: this.parseIntNull(common.trimToNull(this.versionDistance.epoch)),
major: this.parseIntNull(common.trimToNull(this.versionDistance.major)),
minor: this.parseIntNull(common.trimToNull(this.versionDistance.minor)),
patch: this.parseIntNull(common.trimToNull(this.versionDistance.patch))
};
if (result.epoch < 0) {
Expand All @@ -279,7 +281,6 @@ import ActionableListGroupItem from "../components/ActionableListGroupItem";
result.patch = null;
}
this.versionDistance = result;
console.log('createDynamicValue', result);
return JSON.stringify(result);
} else {
return this.value;
Expand All @@ -290,15 +291,18 @@ import ActionableListGroupItem from "../components/ActionableListGroupItem";
if (!this.subject || !this.operator || !dynamicValue) {
return;
}
if (this.condition.uuid) {
if (this.uuid) {
let url = `${this.$api.BASE_URL}/${this.$api.URL_POLICY}/condition`;
this.axios.post(url, {
uuid: this.condition.uuid,
uuid: this.uuid,
subject: this.subject,
operator: this.subject === 'COMPONENT_HASH' ? 'IS' : this.operator,
value: dynamicValue
}).then((response) => {
this.condition = response.data;
this.uuid = response.data.uuid;
this.subject = response.data.subject;
this.operator = response.data.operator;
this.value = response.data.value;
this.$toastr.s(this.$t('message.updated'));
}).catch((error) => {
this.$toastr.w(this.$t('condition.unsuccessful_action'));
Expand All @@ -310,18 +314,24 @@ import ActionableListGroupItem from "../components/ActionableListGroupItem";
operator: this.subject === 'COMPONENT_HASH' ? 'IS' : this.operator,
value: dynamicValue
}).then((response) => {
this.condition = response.data;
this.uuid = response.data.uuid;
this.subject = response.data.subject;
this.operator = response.data.operator;
this.value = response.data.value;
this.$toastr.s(this.$t('message.updated'));
}).catch((error) => {
this.$toastr.w(this.$t('condition.unsuccessful_action'));
});
}
},
removeCondition: function() {
if (this.condition && this.condition.uuid) {
let url = `${this.$api.BASE_URL}/${this.$api.URL_POLICY}/condition/${this.condition.uuid}`;
if (this.uuid) {
let url = `${this.$api.BASE_URL}/${this.$api.URL_POLICY}/condition/${this.uuid}`;
this.axios.delete(url).then((response) => {
this.condition = response.data;
this.uuid = response.data.uuid;
this.subject = response.data.subject;
this.operator = response.data.operator;
this.value = response.data.value;
this.$toastr.s(this.$t('message.condition_deleted'));
this.$emit('conditionRemoved');
}).catch((error) => {
Expand Down Expand Up @@ -383,6 +393,9 @@ import ActionableListGroupItem from "../components/ActionableListGroupItem";
default:
return "";
}
},
parseIntNull: function (value) {
return value == null ? null : parseInt(value);
}
}
}
Expand Down

0 comments on commit 8b8166e

Please sign in to comment.