translations and modal styles

This commit is contained in:
Westly Wright 2020-08-02 09:36:24 -07:00
parent d43806e762
commit 1b2430daa5
No known key found for this signature in database
GPG Key ID: 4FAB3D8673DC54A3
2 changed files with 162 additions and 126 deletions

View File

@ -174,6 +174,15 @@ containerResourceLimit:
requestsCpu: CPU Reservation requestsCpu: CPU Reservation
requestsMemory: Memory Reservation requestsMemory: Memory Reservation
cruResource:
previewYaml: Preview Yaml
cancel: Cancelling will destroy your changes.
back: Going back will destroy your changes.
confirmYaml: "No, Review Yaml"
backToForm: Go Back To Form
confirmCancel: "Yes, Cancel"
confirmBack: "Yes, Go Back"
footer: footer:
docs: Docs docs: Docs
download: Download CLI download: Download CLI

View File

@ -40,7 +40,7 @@ export default {
return { return {
isCancelModal: false, isCancelModal: false,
showAsForm: true, showAsForm: true,
resourceYaml: '', resourceYaml: ''
}; };
}, },
methods: { methods: {
@ -48,12 +48,17 @@ export default {
if (isCancel) { if (isCancel) {
// this.$modal.show('cancel') pass translation options // this.$modal.show('cancel') pass translation options
this.isCancelModal = true; this.isCancelModal = true;
} else {
this.isCancelModal = false;
} }
this.$modal.show('cancel-modal'); this.$modal.show('cancel-modal');
}, },
confirmCancel(isCancel) { confirmCancel(isCancel) {
this.$modal.hide('cancel-modal');
if (isCancel) { if (isCancel) {
this.isCancelModal = false;
this.$router.replace({ this.$router.replace({
name: this.doneRoute, name: this.doneRoute,
params: { resource: this.resource.type } params: { resource: this.resource.type }
@ -78,157 +83,152 @@ export default {
</script> </script>
<template> <template>
<form <section>
v-if="showAsForm" <form v-if="showAsForm" class="create-resource-container">
class="create-resource-container" <div v-if="subtypes.length && !selectedSubtype" class="subtypes-container">
> <slot name="subtypes">
<div v-if="subtypes.length && !selectedSubtype" class="subtypes-container"> <div
<slot name="subtypes"> v-for="subtype in subtypes"
<div :key="subtype.id"
v-for="subtype in subtypes" class="subtype-banner"
:key="subtype.id" :class="{ selected: subtype.id === selectedSubtype }"
class="subtype-banner" @click="$emit('selectType', subtype.id)"
:class="{ selected: subtype.id === selectedSubtype }"
@click="$emit('selectType', subtype.id)"
>
<slot name="subtype-logo">
<div class="subtype-logo round-image">
<img
v-if="subtype.bannerImage"
src="subtype.bannerImage"
alt="${ resource.type }: ${ subtype.label }"
/>
<div v-else-if="subtype.bannerAbbrv" class="banner-abbrv">
<span
v-if="$store.getters['i18n/exists'](subtype.bannerAbbrv)"
>{{ t(subtype.bannerAbbrv) }}</span>
<span v-else>{{ subtype.bannerAbbrv.slice(0, 1).toUpperCase() }}</span>
</div>
<div v-else>
{{ subtype.id.slice(0, 1).toUpperCase() }}
</div>
</div>
</slot>
<slot name="subtype-content">
<div class="subtype-content">
<div class="title">
<h5>
<span
v-if="$store.getters['i18n/exists'](subtype.label)"
v-html="t(subtype.label)"
></span>
<span v-else>{{ subtype.label }}</span>
</h5>
</div>
<div class="description">
<span
v-if="$store.getters['i18n/exists'](subtype.description)"
v-html="t(subtype.description)"
></span>
<span v-else>{{ subtype.description }}</span>
</div>
</div>
</slot>
</div>
</slot>
</div>
<div v-if="selectedSubtype || !subtypes.length" class="resource-container">
<slot name="define" />
</div>
<div class="controls-row">
<slot name="form-footer">
<button type="button" class="btn role-secondary" @click="$emit('cancel')">
<t k="generic.cancel" />
</button>
<div>
<button v-if="selectedSubtype || !subtypes.length" type="button" class="btn role-secondary" @click="showPreviewYaml">
Preview Yaml
</button>
<button
:disabled="!canCreate"
type="button"
class="btn role-primary"
@click="$emit('finish')"
> >
<t k="generic.create" /> <slot name="subtype-logo">
<div class="subtype-logo round-image">
<img
v-if="subtype.bannerImage"
src="subtype.bannerImage"
alt="${ resource.type }: ${ subtype.label }"
/>
<div v-else-if="subtype.bannerAbbrv" class="banner-abbrv">
<span
v-if="$store.getters['i18n/exists'](subtype.bannerAbbrv)"
>{{ t(subtype.bannerAbbrv) }}</span>
<span v-else>{{ subtype.bannerAbbrv.slice(0, 1).toUpperCase() }}</span>
</div>
<div v-else>
{{ subtype.id.slice(0, 1).toUpperCase() }}
</div>
</div>
</slot>
<slot name="subtype-content">
<div class="subtype-content">
<div class="title">
<h5>
<span
v-if="$store.getters['i18n/exists'](subtype.label)"
v-html="t(subtype.label)"
></span>
<span v-else>{{ subtype.label }}</span>
</h5>
</div>
<div class="description">
<span
v-if="$store.getters['i18n/exists'](subtype.description)"
v-html="t(subtype.description)"
></span>
<span v-else>{{ subtype.description }}</span>
</div>
</div>
</slot>
</div>
</slot>
</div>
<div v-if="selectedSubtype || !subtypes.length" class="resource-container">
<slot name="define" />
</div>
<div class="controls-row">
<slot name="form-footer">
<button type="button" class="btn role-secondary" @click="$emit('cancel')">
<t k="generic.cancel" />
</button> </button>
</div>
</slot>
</div>
</form>
<section v-else> <div>
<ResourceYaml <button
ref="resourceyaml" v-if="selectedSubtype || !subtypes.length"
:value="resource" type="button"
:mode="mode" class="btn role-secondary"
:yaml="resourceYaml" @click="showPreviewYaml"
:offer-preview="false" >
:done-route="doneRoute" <t k="cruResource.previewYaml" />
:done-override="resource.doneOverride"
>
<template #yamlFooter="{yamlSave}">
<div class="controls-row">
<slot name="cru-yaml-footer">
<button type="button" class="btn role-secondary" @click="checkCancel(true)">
<t k="generic.cancel" />
</button> </button>
<button
:disabled="!canCreate"
type="button"
class="btn role-primary"
@click="$emit('finish')"
>
<t k="generic.create" />
</button>
</div>
</slot>
</div>
</form>
<div v-if="selectedSubtype || !subtypes.length"> <section v-else>
<button type="button" class="btn role-secondary" @click="checkCancel(false)"> <ResourceYaml
<t k="generic.back" /> ref="resourceyaml"
:value="resource"
:mode="mode"
:yaml="resourceYaml"
:offer-preview="false"
:done-route="doneRoute"
:done-override="resource.doneOverride"
>
<template #yamlFooter="{yamlSave}">
<div class="controls-row">
<slot name="cru-yaml-footer">
<button type="button" class="btn role-secondary" @click="checkCancel(true)">
<t k="generic.cancel" />
</button> </button>
<button
type="button" <div v-if="selectedSubtype || !subtypes.length">
class="btn role-primary" <button type="button" class="btn role-secondary" @click="checkCancel(false)">
@click="yamlSave" <t k="generic.back" />
> </button>
<t k="generic.create" /> <button type="button" class="btn role-primary" @click="yamlSave">
</button> <t k="generic.create" />
</div> </button>
</slot> </div>
</div> </slot>
</template> </div>
</ResourceYaml> </template>
</ResourceYaml>
</section>
<modal <modal
class="confirm-modal" class="confirm-modal"
name="cancel-modal" name="cancel-modal"
:width="350" :width="400"
height="auto" height="auto"
styles="background-color: var(--nav-bg); border-radius: var(--border-radius); overflow: scroll; max-height: 100vh;"
> >
<div class="header"> <div class="header">
<h4 class="text-default-text"> <h4 class="text-default-text">
Go Back To Form <t k="cruResource.backToForm" />
</h4> </h4>
</div> </div>
<div class="body"> <div class="body">
<p v-if="isCancelModal"> <p v-if="isCancelModal">
Cancelling will destroy your changes. <t k="cruResource.cancel" />
</p> </p>
<p v-else> <p v-else>
Going back will destroy your changes. <t k="cruResource.back" />
</p> </p>
</div> </div>
<div class="footer"> <div class="footer">
<button type="button" class="btn role-secondary" @click="$modal.hide('cancel-modal')">
No, Review Yaml
</button>
<button <button
type="button" type="button"
class="btn role-primary" class="btn role-secondary"
@click="confirmCancel(isCancelModal)" @click="$modal.hide('cancel-modal')"
> >
<span v-if="isCancelModal"> <t k="cruResource.confirmYaml" />
Yes, Cancel. </button>
</span> <button type="button" class="btn role-primary" @click="confirmCancel(isCancelModal)">
<span v-else> <span v-if="isCancelModal"><t k="cruResource.confirmCancel" /></span>
Yes, go back. <span v-else><t k="cruResource.confirmBack" /></span>
</span>
</button> </button>
</div> </div>
</modal> </modal>
@ -236,6 +236,33 @@ export default {
</template> </template>
<style lang='scss'> <style lang='scss'>
.confirm-modal {
.v--modal-box {
background-color: var(--default);
box-shadow: none;
min-height: 200px;
.body {
min-height: 75px;
padding: 10px 0 0 15px;
p {
margin-top: 10px;
}
}
.header {
background-color: #4F3335;
padding: 15px 0 0 15px;
}
.header,
.footer {
height: 50px;
}
.footer {
border-top: 1px solid var(--border);
text-align: center;
padding: 10px 0 0 15px;
}
}
}
.subtypes-container { .subtypes-container {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;