prepare vue Address to be used too in accompanyingCourse context

i18n is managed by root component:
* ok for person and household implementation (=> they use Address root component)
* but must be imported in vue i18n file if called from another component

submitAddress is emit to parent, it allow to control final action:
* casting final submitNewAddress with POST requests (for person or household entity);
* or dispatching changes from store, casting only payload to be used.

remove and simplify some options: backurl is always used with person/household,
and never if called from another vue component.
This commit is contained in:
2021-08-13 15:43:37 +02:00
parent 4b69f97e2f
commit 2f28e02f65
4 changed files with 79 additions and 59 deletions

View File

@@ -4,25 +4,12 @@
{{ error }}
</div>
<div v-if="addAddress.options.displayResult && addAddress.result !== null"
class="chill-entity entity-address">
<div class="address multiline">
<p class="street">{{ addAddress.result.street }}
<span class="streetnumber">{{ addAddress.result.streetNumber }}</span>
</p>
<p class="postcode">
<span class="code">{{ addAddress.result.postcode.code }}</span>
<span class="name">{{ addAddress.result.postcode.name }}</span>
</p>
<p class="country">{{ addAddress.result.country.name.fr }}</p>
</div>
</div>
<add-address
v-bind:key="context.entity.type"
v-bind:context="context"
v-bind:options="addAddress.options"
v-bind:result="addAddress.result"
@submitAddress="submitAddress"
ref="addAddress">
</add-address>
</template>
@@ -78,19 +65,22 @@ export default {
bindModal: {
step1: window.binModalStep1, //boolean, default: true
step2: window.binModalStep2 //boolean, default: true
},
// Options only for root parent component
displayResult: true,
redirectToBackUrl: true
},
result: null // <== returned from addAddress component
}
}
}
}
},
methods: {
displayErrors() {
return this.$refs.addAddress.errorMsg;
},
submitAddress() {
console.log('@@@ click on Submit Address Button');
// Cast child method
this.$refs.addAddress.submitNewAddress();
// it fetch post request only for person and household
// else get returned payload then dispatch from here (parent)
}
}
}