mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
* change quest banner backgrond * itemRows in inventory * use itemRows in inventory/items - showLess/showMore as default labels - extend white space if theres no button available * hide popover if dragging is active - show dragging info on first click (without to move) * use itemRows in inventory/stable * fix some strings * highlight currently dragging item in inventory/items - auto attach info on click - z-index * fix shopItem label color * fix floating npcs in banner * hatched-pet-dialog in items / stable * change all ctx to context
80 lines
1.7 KiB
Vue
80 lines
1.7 KiB
Vue
<template lang="pug">
|
|
.item-rows
|
|
div.items(v-resize="500", @resized="currentWidth = $event.width")
|
|
template(v-for="item in itemsToShow(showAll)")
|
|
slot(
|
|
name="item",
|
|
:item="item",
|
|
)
|
|
|
|
div(v-if="items.length === 0")
|
|
p(v-once) {{ noItemsLabel }}
|
|
|
|
.btn.btn-show-more(
|
|
@click="showAll = !showAll",
|
|
v-if="items.length > itemsPerRow()"
|
|
) {{ showAll ? $t('showLess') : $t('showMore') }}
|
|
|
|
div.fill-height(v-else)
|
|
|
|
</template>
|
|
|
|
<style lang="scss" scoped>
|
|
.fill-height {
|
|
height: 38px; // button + margin + padding
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
import ResizeDirective from 'client/directives/resize.directive';
|
|
|
|
import _take from 'lodash/take';
|
|
import _drop from 'lodash/drop';
|
|
|
|
export default {
|
|
directives: {
|
|
resize: ResizeDirective,
|
|
},
|
|
data () {
|
|
return {
|
|
currentWidth: 0,
|
|
currentPage: 0,
|
|
|
|
showAll: false,
|
|
};
|
|
},
|
|
methods: {
|
|
itemsToShow (showAll) {
|
|
let itemsPerRow = this.itemsPerRow();
|
|
let rowsToShow = showAll ? Math.ceil(this.items.length / itemsPerRow) : 1;
|
|
let result = [];
|
|
|
|
for (let i = 0; i < rowsToShow; i++) {
|
|
let skipped = _drop(this.items, i * itemsPerRow);
|
|
let row = _take(skipped, itemsPerRow);
|
|
result = result.concat(row);
|
|
}
|
|
|
|
return result;
|
|
},
|
|
itemsPerRow () {
|
|
return Math.floor(this.currentWidth / (this.itemWidth + this.itemMargin));
|
|
},
|
|
},
|
|
props: {
|
|
items: {
|
|
type: Array,
|
|
},
|
|
itemWidth: {
|
|
type: Number,
|
|
},
|
|
itemMargin: {
|
|
type: Number,
|
|
},
|
|
noItemsLabel: {
|
|
type: String,
|
|
},
|
|
},
|
|
};
|
|
</script>
|