Compare commits
2 Commits
f1548aedfa
...
4f6970c423
| Author | SHA1 | Date | |
|---|---|---|---|
| 4f6970c423 | |||
| 1ff2429244 |
@@ -1,10 +1,14 @@
|
||||
<template>
|
||||
<PlayerView :id="state.player_id"
|
||||
v-slot="{ player, loot, notifications, actions }">
|
||||
<PlayerView
|
||||
:id="state.player_id"
|
||||
v-slot="{ player, loot, notifications, actions }"
|
||||
>
|
||||
<main id="app" class="container">
|
||||
<header>
|
||||
<HeaderBar :app_state="state">
|
||||
<template v-slot:title>{{ player.name }}</template>
|
||||
<template v-slot:title>
|
||||
{{ player.name }}
|
||||
</template>
|
||||
<template v-slot:links>
|
||||
<a class="navbar-item">History of Loot</a>
|
||||
<template v-if="playerIsGroup">
|
||||
@@ -24,20 +28,26 @@
|
||||
<Wealth
|
||||
:wealth="[player.cp, player.sp, player.gp, player.pp]"
|
||||
:debt="player.debt"
|
||||
@update="actions.updateWealth">
|
||||
</Wealth>
|
||||
@update="actions.updateWealth"
|
||||
></Wealth>
|
||||
<p v-show="notifications.length > 0">{{ notifications }}</p>
|
||||
</header>
|
||||
<nav>
|
||||
<div class="tabs is-centered is-boxed is-medium">
|
||||
<ul>
|
||||
<li :class="{ 'is-active': activeView == 'group' }">
|
||||
<a @click="switchView('group')">Coffre de groupe</a></li>
|
||||
<li :class="{ 'is-active': activeView == 'player' }"
|
||||
v-show="!playerIsGroup">
|
||||
<a @click="switchView('player')">Mon coffre</a></li>
|
||||
<a @click="switchView('group')">
|
||||
Coffre de groupe
|
||||
</a>
|
||||
</li>
|
||||
<li v-show="!playerIsGroup" :class="{ 'is-active': activeView == 'player' }">
|
||||
<a @click="switchView('player')">
|
||||
Mon coffre
|
||||
</a>
|
||||
</li>
|
||||
<li :class="{'is-active': activeView == 'adding' }">
|
||||
<a class="has-text-grey-light" @click="switchView('adding')">
|
||||
<a class="has-text-grey-light"
|
||||
@click="switchView('adding')">
|
||||
+ {{ playerIsGroup ? 'Nouveau Loot' : 'Acheter' }}
|
||||
</a>
|
||||
</li>
|
||||
@@ -46,9 +56,15 @@
|
||||
</nav>
|
||||
<main class="section">
|
||||
<template v-if="isAdding">
|
||||
<h2 v-show="playerIsGroup">ItemInput</h2>
|
||||
<div v-if="playerIsGroup" class="box">
|
||||
<ItemInput v-if="playerIsGroup"
|
||||
:source="state.inventory"
|
||||
@addItem="item => pending_loot.push(item)"
|
||||
></ItemInput>
|
||||
<button>Envoyer</button>
|
||||
</div>
|
||||
<AddingChest
|
||||
:items="playerIsGroup ? [] : state.inventory"
|
||||
:items="playerIsGroup ? pending_loot : state.inventory"
|
||||
:perms="playerIsGroup ? {} : { canBuy: true }"
|
||||
@buy="(data) => { switchView('player'); actions.buyItems(data); }">
|
||||
</AddingChest>
|
||||
@@ -73,6 +89,7 @@ import PlayerView from './components/PlayerView.js'
|
||||
import HeaderBar from './components/HeaderBar.vue'
|
||||
import Wealth from './components/Wealth.vue'
|
||||
import Chest from './components/Chest.vue'
|
||||
import ItemInput from './components/ItemInput.vue'
|
||||
import { AppStorage } from './AppStorage'
|
||||
|
||||
function getCookie(cname) {
|
||||
@@ -98,6 +115,7 @@ export default {
|
||||
state: AppStorage.state,
|
||||
activeView: 'group',
|
||||
shopInventory: [{id: 1, name: "Item from shop #1", base_price: 2000}],
|
||||
pending_loot: [],
|
||||
};
|
||||
},
|
||||
components: {
|
||||
@@ -105,7 +123,8 @@ export default {
|
||||
HeaderBar,
|
||||
'AddingChest': Chest, // Alias to prevent component re-use
|
||||
Chest,
|
||||
Wealth
|
||||
Wealth,
|
||||
ItemInput,
|
||||
},
|
||||
created () {
|
||||
// Initiate with active player set to value found in cookie
|
||||
|
||||
@@ -1,100 +1,96 @@
|
||||
<template>
|
||||
<div class="container is-paddingless">
|
||||
<div class="field has-addons">
|
||||
<div class="control is-expanded"
|
||||
:class="{'is-loading': is_loading }">
|
||||
<p class="heading">Ajouter un objet</p>
|
||||
<div class="field">
|
||||
<label for="item_name" class="label">Nom</label>
|
||||
<div class="control is-expanded" :class="{'is-loading': is_loading }">
|
||||
<input type="text"
|
||||
v-model="item_name"
|
||||
id="item_name"
|
||||
v-model="item.name"
|
||||
@input="autoCompletion"
|
||||
class="input"
|
||||
:class="{'is-danger': no_results,
|
||||
'is-warning': auto_open}"
|
||||
autocomplete="on">
|
||||
</input>
|
||||
autocomplete="on"
|
||||
></input>
|
||||
</div>
|
||||
<div class="dropdown" :class="{'is-active': showCompletionFrame}">
|
||||
<div class="dropdown-menu">
|
||||
<div class="dropdown-content">
|
||||
<a v-for="(result,i) in results"
|
||||
:key="i"
|
||||
@click="setResult(result)"
|
||||
class="dropdown-item"
|
||||
>{{ result.name }}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
<input type="text" class="input"
|
||||
:class="{'is-danger': !item_price}"
|
||||
v-model.number="item_price"></input>
|
||||
<input type="text"
|
||||
class="input"
|
||||
:class="{'is-danger': item.base_price == ''}"
|
||||
v-model.number="item.base_price"
|
||||
></input>
|
||||
</div>
|
||||
<div class="control">
|
||||
<button class="button is-primary"
|
||||
:disabled="no_results"
|
||||
@click="addItem"
|
||||
>+</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dropdown" :class="{'is-active': auto_open}">
|
||||
<div class="dropdown-menu">
|
||||
<div class="dropdown-content">
|
||||
<a v-for="(result,i) in results" :key="i"
|
||||
@click="setResult(result)"
|
||||
class="dropdown-item"
|
||||
>
|
||||
{{ result.name }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
props: ["source"],
|
||||
data () {
|
||||
return {
|
||||
is_loading: false,
|
||||
no_results: false,
|
||||
item_name: '',
|
||||
item_price: '',
|
||||
item: {
|
||||
name: '',
|
||||
base_price: '',
|
||||
},
|
||||
results: [],
|
||||
auto_open: false,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
autoCompletion (ev) {
|
||||
// TODO: a lot happens here that
|
||||
// need to be clarified
|
||||
if (this.item_name == '') {
|
||||
this.auto_open = false;
|
||||
autoCompletion () {
|
||||
// Unset any previous value on input (for every field except item's name)
|
||||
this.item.base_price = '';
|
||||
|
||||
if (this.item.name == '') {
|
||||
this.results = [];
|
||||
this.no_results = false;
|
||||
} else {
|
||||
this.results = this.source.filter(item => {
|
||||
return item.name.includes(this.item_name);
|
||||
});
|
||||
// Update status
|
||||
if (this.results.length == 0) {
|
||||
this.no_results = true;
|
||||
} else {
|
||||
this.no_results = false;
|
||||
this.auto_open = true;
|
||||
}
|
||||
this.results = this.source.filter(
|
||||
item => item.name.toUpperCase().includes(this.item.name.toUpperCase())
|
||||
);
|
||||
}
|
||||
},
|
||||
setResult(result) {
|
||||
this.item_name = result.name;
|
||||
this.item_price = result.sell_value;
|
||||
this.auto_open = false;
|
||||
this.item.name = result.name;
|
||||
this.item.base_price = result.base_price;
|
||||
// Clear results to close completionFrame
|
||||
this.results = [];
|
||||
},
|
||||
addItem () {
|
||||
this.$emit("addItem", {
|
||||
name: this.item_name,
|
||||
sell_value: this.item_price
|
||||
});
|
||||
this.item_name = '';
|
||||
this.item_price = '';
|
||||
// TODO: check item is valid
|
||||
this.$emit("addItem", this.item);
|
||||
this.item = {
|
||||
name: '',
|
||||
base_price: '',
|
||||
};
|
||||
this.results = [];
|
||||
this.no_results = false;
|
||||
this.auto_open = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
showCompletionFrame () { return this.results.length > 0 },
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.dropdown, .dropdown-menu { min-width: 100%; margin-top: 0; padding-top: 0;}
|
||||
.dropdown { top: -0.75rem; }
|
||||
/*.dropdown { top: -0.75rem; }*/
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user