Files
luos/resources/assets/js/components/dataViews/vueCardView/VueCardViewMixins.js

57 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-07-08 20:20:05 +00:00
export default {
data() {
let that = this;
return {
2021-07-13 15:10:59 +00:00
height: 0,
2021-07-08 20:20:05 +00:00
config: {
page: 1
},
data: []
}
},
mounted: function () {
this.getData();
2021-07-13 15:10:59 +00:00
this.getBodyHeight();
2021-07-08 20:20:05 +00:00
},
methods: {
/**
* Get data similar to vue Table
*/
getData() {
let options = _.extend({}, this.config, this.options),
that = this;
this.options.requestFunction(options)
.then((data) => {
that.data = data.data;
})
2021-09-06 20:07:48 +00:00
.catch((e) => {
console.error(e);
2021-07-08 20:20:05 +00:00
});
},
/**
* Get data when press the button more view
*/
viewMore() {
2021-07-13 15:10:59 +00:00
let options = _.extend({}, this.config, this.options, { page: this.config.page + 1 }),
that = this;
this.options.requestFunctionViewMore(options)
.then((data) => {
if (data.data && data.data.length != 0) {
that.data = that.data.concat(data.data);
that.config.page += 1;
2021-08-31 20:49:23 +00:00
} else {
that.loadMore = that.$t("ID_NO_MORE_INFORMATION");
2021-07-13 15:10:59 +00:00
}
})
2021-09-06 20:07:48 +00:00
.catch((e) => {
console.error(e);
2021-07-13 15:10:59 +00:00
});
},
2021-07-13 15:17:06 +00:00
/**
* Return the height for Vue Card View body
*/
2021-07-13 15:10:59 +00:00
getBodyHeight() {
this.height = window.innerHeight - this.$root.$el.clientHeight;
2021-07-08 20:20:05 +00:00
}
}
2021-07-13 15:17:06 +00:00
}