UNPKG

@nextcloud/vue

Version:
147 lines (146 loc) 5.19 kB
require('../assets/NcDashboardWidget-DzJMoJ_B.css'); "use strict"; const Check = require("./Check-Du8mPz_B.cjs"); const _l10n = require("./_l10n-DM-VRK9x.cjs"); const NcAvatar = require("./NcAvatar-bd-5zXWN.cjs"); const NcDashboardWidgetItem = require("./NcDashboardWidgetItem-BhGOOhKF.cjs"); const Components_NcEmptyContent = require("../Components/NcEmptyContent.cjs"); const _pluginVue2_normalizer = require("./_plugin-vue2_normalizer-V0q-tHlQ.cjs"); _l10n.register(_l10n.t33); const _sfc_main = { name: "NcDashboardWidget", components: { NcAvatar: NcAvatar.NcAvatar, NcDashboardWidgetItem: NcDashboardWidgetItem.NcDashboardWidgetItem, NcEmptyContent: Components_NcEmptyContent, Check: Check.Check }, props: { /** * An array containing the items to show (specific structure must be respected, * except if you override item rendering in the default slot). */ items: { type: Array, default: () => { return []; } }, /** * If this is set, a "show more" text is displayed on the widget's bottom. * It's a link pointing to this URL. */ showMoreUrl: { type: String, default: "" }, /** * The text of show more button. * * Expected to be in the form "More {itemName} …" */ showMoreLabel: { type: String, default: _l10n.t("More items …") }, /** * A boolean to put the widget in a loading state. */ loading: { type: Boolean, default: false }, /** * An object containing context menu entries that will be displayed for each item. */ itemMenu: { type: Object, default: () => { return {}; } }, /** * Whether both the items and the empty content message are shown. * Usefull for e.g. showing "No mentions" and a list of elements. */ showItemsAndEmptyContent: { type: Boolean, default: false }, /** * The text to show in the empty content area. */ emptyContentMessage: { type: String, default: "" }, /** * The text to show in the half empty content area. */ halfEmptyContentMessage: { type: String, default: "" } }, computed: { // forward menu events to my parent handlers() { const h = {}; for (const evName in this.itemMenu) { h[evName] = (it) => { this.$emit(evName, it); }; } return h; }, displayedItems() { const nbItems = this.showMoreUrl && this.items.length >= this.maxItemNumber ? this.maxItemNumber - 1 : this.maxItemNumber; return this.items.slice(0, nbItems); }, showHalfEmptyContentArea() { return this.showItemsAndEmptyContent && this.halfEmptyContentString && this.items.length !== 0; }, halfEmptyContentString() { return this.halfEmptyContentMessage || this.emptyContentMessage; }, maxItemNumber() { return this.showItemsAndEmptyContent ? 5 : 7; }, showMore() { return this.showMoreUrl && this.items.length >= this.maxItemNumber; } } }; var _sfc_render = function render() { var _vm = this, _c = _vm._self._c; return _c("div", { staticClass: "dashboard-widget" }, [_vm.showHalfEmptyContentArea ? _c("NcEmptyContent", { staticClass: "half-screen", attrs: { "description": _vm.halfEmptyContentString }, scopedSlots: _vm._u([{ key: "icon", fn: function() { return [_vm._t("halfEmptyContentIcon", function() { return [_c("Check")]; })]; }, proxy: true }], null, true) }) : _vm._e(), _c("ul", _vm._l(_vm.displayedItems, function(item) { return _c("li", { key: item.id }, [_vm._t("default", function() { return [_c("NcDashboardWidgetItem", _vm._g(_vm._b({ attrs: { "item-menu": _vm.itemMenu } }, "NcDashboardWidgetItem", item, false), _vm.handlers))]; }, { "item": item })], 2); }), 0), _vm.loading ? _c("div", _vm._l(7, function(i) { return _c("div", { key: i, staticClass: "item-list__entry" }, [_c("NcAvatar", { staticClass: "item-avatar", attrs: { "size": 44 } }), _vm._m(0, true)], 1); }), 0) : _vm.items.length === 0 ? _vm._t("empty-content", function() { return [_vm.emptyContentMessage ? _c("NcEmptyContent", { attrs: { "description": _vm.emptyContentMessage }, scopedSlots: _vm._u([{ key: "icon", fn: function() { return [_vm._t("emptyContentIcon")]; }, proxy: true }], null, true) }) : _vm._e()]; }) : _vm.showMore ? _c("a", { staticClass: "more", attrs: { "href": _vm.showMoreUrl, "target": "_blank", "tabindex": "0" } }, [_vm._v(" " + _vm._s(_vm.showMoreLabel) + " ")]) : _vm._e()], 2); }; var _sfc_staticRenderFns = [function() { var _vm = this, _c = _vm._self._c; return _c("div", { staticClass: "item__details" }, [_c("h3", [_vm._v(" ")]), _c("p", { staticClass: "message" }, [_vm._v("   ")])]); }]; var __component__ = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent( _sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, "7631d51f" ); const NcDashboardWidget = __component__.exports; exports.NcDashboardWidget = NcDashboardWidget; //# sourceMappingURL=NcDashboardWidget-DKUU16oT.cjs.map