Add logic for adding & removing domains
parent
1d5b1a66b0
commit
b337a0d0dc
|
@ -49,6 +49,26 @@ $highlight: #f2c94c;
|
||||||
color: $dark-blue;
|
color: $dark-blue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
i {
|
||||||
|
font-size: .75em;
|
||||||
|
|
||||||
|
&.fa-plus {
|
||||||
|
margin: 0 .35rem 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.fa-times {
|
||||||
|
margin: 0 0 0 .35rem;
|
||||||
|
transition: color $transition;
|
||||||
|
|
||||||
|
&:hover,
|
||||||
|
&:focus {
|
||||||
|
color: $primary;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,16 +29,22 @@ limitations under the License.
|
||||||
<div class="main container">
|
<div class="main container">
|
||||||
<div class="tabs">
|
<div class="tabs">
|
||||||
<ul>
|
<ul>
|
||||||
<li v-for="(data, index) in domains" :class="index === active ? 'is-active' : undefined">
|
<li v-for="data in activeDomains" :class="data[1] === active ? 'is-active' : undefined">
|
||||||
<a @click="active = index">{{ data.server.domain.computed }}{{ changes(index) }}</a>
|
<a @click="active = data[1]">
|
||||||
|
{{ data[0].server.domain.computed }}{{ changes(data[1]) }}
|
||||||
|
<i class="fas fa-times" @click="remove(data[1])"></i>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a @click="add"><i class="fas fa-plus"></i> Add site</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<template v-for="(data, index) in domains">
|
<template v-for="data in activeDomains">
|
||||||
<Domain :key="index"
|
<Domain :key="data[1]"
|
||||||
:data="data"
|
:data="data[0]"
|
||||||
:style="{ display: index === active ? 'block' : 'none' }"
|
:style="{ display: data[1] === active ? 'block' : 'none' }"
|
||||||
></Domain>
|
></Domain>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
@ -67,11 +73,15 @@ limitations under the License.
|
||||||
i18n,
|
i18n,
|
||||||
domains: [
|
domains: [
|
||||||
clone(Domain.delegated),
|
clone(Domain.delegated),
|
||||||
clone(Domain.delegated),
|
|
||||||
],
|
],
|
||||||
active: 0,
|
active: 0,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
activeDomains() {
|
||||||
|
return this.$data.domains.map((domain, index) => [domain, index]).filter(d => d[0] !== null);
|
||||||
|
},
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
changes(index) {
|
changes(index) {
|
||||||
const data = this.$data.domains[index];
|
const data = this.$data.domains[index];
|
||||||
|
@ -83,6 +93,14 @@ limitations under the License.
|
||||||
if (changes) return ` (${changes.toLocaleString()})`;
|
if (changes) return ` (${changes.toLocaleString()})`;
|
||||||
return '';
|
return '';
|
||||||
},
|
},
|
||||||
|
add() {
|
||||||
|
this.$data.domains.push(clone(Domain.delegated));
|
||||||
|
this.$data.active = this.$data.domains.length - 1;
|
||||||
|
},
|
||||||
|
remove(index) {
|
||||||
|
this.$set(this.$data.domains, index, null);
|
||||||
|
if (this.$data.active === index) this.$data.active = 0;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue