Files
habitica/website/client/components/inventory/items/cards-modal.vue
T
negue 4108a22d78 [WIP] bootstrap-vue upgrade (#9178)
* update bootstrap-vue to 1.0.0-beta.9 - remove all individual bootstrap components and use BootstrapVue into Vue

* change modal action names from show::modal to bv::show::modal

* check if drops are undefined

* fix modal widths - sellModal now using input instead of dropbox

* upgrade to bootstrap 4.0beta

* include package-lock changes

* fix app menu dropdown position

* upgrade bootstrap to beta2 (was missing grid offset and other fixes) - refix header menu position

* fix tags popup (auto width to max not working) - fix filter panel width (adding width: 100% works until max-width)

* show hide logo on different screensize (new css breakpoints - http://getbootstrap.com/docs/4.0/utilities/display/ )

* fix package-lock?

* fix active button style / app header toggle button

* fix package-lock !

* update package lock after merge - new mixin "openedItemRows" to save the "show more/show less" in stable

* mixin naming style

* fix buyQuestModal marginTop

* fix customMenuDropdown position

* fix userDropdown items
2017-11-08 18:40:37 +01:00

68 lines
1.9 KiB
Vue

<template lang="pug">
b-modal#card(:title="$t(cardType + 'Card')", size='md', :hide-footer="true")
.modal-header
.pull-right(:class='`inventory_special_${cardType}`')
h4 {{ $t(cardType + 'Card') }}
.modal-body
div(style='padding:10px')
p {{ $t('toAndFromCard', { toName: user.profile.name, fromName}) }}
hr
div(v-markdown='cardMessage')
.modal-footer
small.pull-left {{ $t(cardType + 'CardExplanation')}}
button.btn.btn-default(@click='readCard()') {{ $t('ok') }}
</template>
<style scoped>
</style>
<script>
import axios from 'axios';
import { mapState } from 'client/libs/store';
import markdown from 'client/directives/markdown';
export default {
props: ['cardOptions'],
directives: {
markdown,
},
computed: {
...mapState({
user: 'user.data',
}),
cardType () {
let type = '';
if (this.cardOptions && this.cardOptions.cardType) type = this.cardOptions.cardType;
return type;
},
numberOfVariations () {
let numberOfVariations = 0;
if (this.cardOptions && this.cardOptions.messageOptions) numberOfVariations = this.cardOptions.messageOptions;
return numberOfVariations;
},
cardMessage () {
let random = Math.random() * this.numberOfVariations;
let selection = Math.floor(random);
return this.$t(`${this.cardType}${selection}`);
},
fromName () {
let fromName = '';
let card = this.user.items.special[`${this.cardType}Received`];
if (card && card[0]) fromName = card[0];
return fromName;
},
},
methods: {
async readCard () {
await axios.post(`/api/v3/user/read-card/${this.cardType}`);
this.user.items.special[`${this.cardType}Received`].shift();
this.user.flags.cardReceived = false;
this.close();
},
close () {
this.$root.$emit('bv::hide::modal', 'card');
},
},
};
</script>