/*jslint es6: true, this: true*/
/*global window, Vue*/
(function () {
"use strict";
Vue.component("domain-rules", {
props: ["domainNames", "selectedDomain"],
template: `
`,
data: function () {
return {
newDomain: "",
errorMessage: ""
};
},
methods: {
newDomainSubmitted: function () {
const state = this.$root.$data;
if (this.newDomain.length === 0) {
this.errorMessage = "Domain rule field cannot be empty.";
return;
}
if (state.domainNames.indexOf(this.newDomain) !== -1) {
this.errorMessage = "There are already settings for this domain pattern.";
return;
}
state.addDomainRule(this.newDomain);
this.newDomain = "";
},
onRadioChange: function () {
this.$root.$data.setSelectedDomain(this.selectedDomain);
},
onRemoveClick: function (aDomain) {
this.$root.$data.deleteDomainRule(aDomain);
},
isDefault: function (domainName) {
return domainName === "(default)";
}
}
});
}());