mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
* 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
104 lines
2.2 KiB
Vue
104 lines
2.2 KiB
Vue
<template lang="pug">
|
|
.item-rows
|
|
div.items(v-resize="500", @resized="setCurrentWidth($event)")
|
|
template(v-for="item in itemsToShow(showAll)")
|
|
slot(
|
|
name="item",
|
|
:item="item"
|
|
)
|
|
|
|
div(v-if="items.length === 0")
|
|
p(v-once) {{ noItemsLabel }}
|
|
|
|
.btn.btn-flat.btn-show-more(
|
|
@click="toggleItemsToShow()",
|
|
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
|
|
}
|
|
|
|
.item-rows {
|
|
margin-right: -24px;
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
import ResizeDirective from 'client/directives/resize.directive';
|
|
import openedItemRowsMixin from 'client/mixins/openedItemRows';
|
|
|
|
import _take from 'lodash/take';
|
|
|
|
export default {
|
|
mixins: [openedItemRowsMixin],
|
|
directives: {
|
|
resize: ResizeDirective,
|
|
},
|
|
computed: {
|
|
itemsPerRow () {
|
|
return Math.floor(this.currentWidth / (this.itemWidth + this.itemMargin));
|
|
},
|
|
},
|
|
data () {
|
|
return {
|
|
currentWidth: 0,
|
|
currentPage: 0,
|
|
|
|
showAll: false,
|
|
};
|
|
},
|
|
methods: {
|
|
toggleItemsToShow () {
|
|
this.showAll = !this.showAll;
|
|
|
|
this.$_openedItemRows_toggleByType(this.type, this.showAll);
|
|
},
|
|
itemsToShow (showAll) {
|
|
let itemsLength = this.items.length;
|
|
|
|
if (itemsLength === 0)
|
|
return [];
|
|
|
|
let itemsPerRow = this.itemsPerRow;
|
|
|
|
if (showAll || itemsLength <= itemsPerRow) {
|
|
return this.items;
|
|
}
|
|
|
|
return _take(this.items, itemsPerRow);
|
|
},
|
|
setCurrentWidth ($event) {
|
|
if (this.currentWidth !== $event.width) {
|
|
this.currentWidth = $event.width;
|
|
}
|
|
},
|
|
},
|
|
props: {
|
|
items: {
|
|
type: Array,
|
|
},
|
|
type: {
|
|
type: String,
|
|
},
|
|
itemWidth: {
|
|
type: Number,
|
|
},
|
|
itemMargin: {
|
|
type: Number,
|
|
},
|
|
noItemsLabel: {
|
|
type: String,
|
|
},
|
|
},
|
|
created () {
|
|
this.showAll = this.$_openedItemRows_isToggled(this.type);
|
|
},
|
|
};
|
|
</script>
|