2 lines
10 KiB
JavaScript
2 lines
10 KiB
JavaScript
"use strict";(self.webpackChunknotes=self.webpackChunknotes||[]).push([["dashboard-lazy"],{4335(e,n,o){o.d(n,{default:()=>Z});var a=o(4095),s=o(5800),r=o(9636),i=o(3814),l=o(9954),c=o(6802),d=o(5168),u=o(5471),g=o(5353);const m={setSettings(t,e){t.settings=e},setNoteMode(t,e){(0,u.hZ)(t.settings,"noteMode",e)},setSaving(t,e){t.isSaving=e},setManualSave(t,e){t.isManualSave=e},setDocumentTitle(t,e){t.documentTitle=e},updateSearchText(t,e){t.searchText=e}},A={state:{settings:{},isSaving:!1,isManualSave:!1,documentTitle:null,searchText:""},getters:{},mutations:m,actions:{}},h=["id","etag","title","content","modified","favorite","category"],f={numNotes:t=>()=>t.notes.length,noteExists:t=>e=>void 0!==t.notesIds[e],getNote:t=>e=>void 0===t.notesIds[e]?null:t.notesIds[e],getCategories:t=>(e,n)=>{function o(t,e,n){let o=-1;for(;n--&&o++<t.length&&(o=t.indexOf(e,o),!(o<0)););return o}const a={};for(const n of t.notes){let t=n.category;if(e>0){const n=o(t,"/",e);n>0&&(t=t.substring(0,n))}void 0===a[t]?a[t]=1:a[t]+=1}const s=[];for(const t in a)n?s.push({name:t,count:a[t]}):t&&s.push(t);return n?s.sort((t,e)=>t.name.localeCompare(e.name)):s.sort(),s},getFilteredNotes:(t,e,n,o)=>()=>{const e=n.app.searchText.toLowerCase(),o=t.notes.filter(n=>!(null!==t.selectedCategory&&t.selectedCategory!==n.category&&!n.category.startsWith(t.selectedCategory+"/"))&&(""===e||-1!==n.title.toLowerCase().indexOf(e)));return o.sort(null===t.selectedCategory?function(t,e){return t.favorite&&!e.favorite?-1:!t.favorite&&e.favorite?1:e.modified-t.modified}:function(t,e){const n=t.category.localeCompare(e.category);return 0!==n?n:t.favorite&&!e.favorite?-1:!t.favorite&&e.favorite?1:t.title.localeCompare(e.title)}),o},getFilteredTotalCount:(t,e,n,o)=>()=>{const e=n.app.searchText.toLowerCase();if(null===t.selectedCategory||""===e)return 0;return t.notes.filter(n=>t.selectedCategory!==n.category&&!n.category.startsWith(t.selectedCategory+"/")&&-1!==n.title.toLowerCase().indexOf(e)).length},getSelectedCategory:t=>()=>t.selectedCategory,getSelectedNote:t=>()=>t.selectedNote},p={updateNote(t,e){const n=t.notesIds[e.id];var o,a,s;n?(o=e,a=n,void 0===(s=["id","etag","content"])&&(s=[]),h.forEach(t=>{s.includes(t)||(a[t]=o[t])}),void 0!==e.content&&void 0!==e.etag&&(n.content=e.content,n.etag=e.etag,(0,u.hZ)(n,"unsaved",e.unsaved),(0,u.hZ)(n,"error",e.error),(0,u.hZ)(n,"errorType",e.errorType))):(t.notes.push(e),(0,u.hZ)(t.notesIds,e.id,e))},setNoteAttribute(t,e){const n=t.notesIds[e.noteId];n&&(0,u.hZ)(n,e.attribute,e.value)},removeNote(t,e){t.notes=t.notes.filter(t=>t.id!==e),u.default.delete(t.notesIds,e)},removeAllNotes(t){t.notes=[],t.notesIds={}},setCategories(t,e){t.categories=e},setSelectedCategory(t,e){t.selectedCategory=e},setSelectedNote(t,e){t.selectedNote=e}},v={updateNotes(t,{noteIds:e,notes:n}){if(!n||!e)return console.error("This should not happen, please see issue #886"),console.info(n),console.info(e),void console.trace();for(const e of n)t.commit("updateNote",e);t.state.notes.forEach(n=>{e.includes(n.id)||t.commit("removeNote",n.id)})}},b={state:{categories:[],notes:[],notesIds:{},selectedCategory:null,selectedNote:null,filterString:""},getters:f,mutations:p,actions:v},C={addToQueue(t,{noteId:e,type:n}){const o={noteId:e,type:n},a=e+"-"+n;(0,u.hZ)(t.queue,a,o)},clearQueue(t){t.queue={}},setSyncETag(t,e){e&&(t.etag=e)},setSyncLastModified(t,e){const n=Date.parse(e);n&&(t.lastModified=n/1e3)},clearSyncCache(t){t.etag=null,t.lastModified=0},setSyncActive(t,e){t.active=e}},y={state:{queue:{},etag:null,lastModified:0,active:!1},getters:{},mutations:C,actions:{}};u.default.use(g.Ay);new g.il({modules:{app:A,notes:b,sync:y}});function N(t){return t=`apps/notes${t}`,(0,i.Jv)(t)}function x(e,n=null){if(n?.response){const o=n.response?.status;switch(o){case 404:(0,d.Qg)(e+" "+t("notes","Note not found."));break;case 423:(0,d.Qg)(e+" "+t("notes","Note is locked."));break;case 507:(0,d.Qg)(e+" "+t("notes","Insufficient storage."));break;default:(0,d.Qg)(e+" HTTP "+o+" ("+n.response.data?.errorType+")")}}else(0,d.Qg)(e+" "+t("notes","See JavaScript console and server log for details."))}const I={name:"Dashboard",components:{NcButton:a.A,NcDashboardWidget:s.A,NcDashboardWidgetItem:r.A,Plus:l.A},data:()=>({loading:!0,items:[],hasMoreItems:!1}),computed:{showMoreUrl(){return this.hasMoreItems?(0,i.Jv)("/apps/notes"):null},hasFavorites(){return this.items.length>0&&this.items[0].favorite},createNoteUrl:()=>(0,i.Jv)("/apps/notes/new"),getItemTargetUrl:()=>t=>(0,i.Jv)(`/apps/notes/note/${t.id}`)},created(){this.loadDashboardData()},methods:{loadDashboardData(){c.Ay.get(N("/notes/dashboard")).then(t=>t.data).catch(e=>{throw console.error(e),x(t("notes","Fetching notes for dashboard has failed."),e),e}).then(t=>{this.items=t.items,this.hasMoreItems=t.hasMoreItems,this.loading=!1})},subtext(e){return e.excerpt||(""===(n=e.category)?t("notes","Uncategorized"):n.replace(/\//g," / "));var n}}};var D=o(5072),k=o.n(D),S=o(7825),T=o.n(S),w=o(7659),M=o.n(w),U=o(5056),W=o.n(U),B=o(540),P=o.n(B),E=o(1113),L=o.n(E),F=o(4635),Q={};Q.styleTagTransform=L(),Q.setAttributes=W(),Q.insert=M().bind(null,"head"),Q.domAPI=T(),Q.insertStyleElement=P();k()(F.A,Q);F.A&&F.A.locals&&F.A.locals;const Z=(0,o(4486).A)(I,function(){var t=this,e=t._self._c;return e("div",{staticClass:"dashboard-box"},[e("NcDashboardWidget",{attrs:{"empty-content-icon":"icon-notes","empty-content-message":t.t("notes","No notes yet"),items:t.items,loading:t.loading},scopedSlots:t._u([{key:"default",fn:function({item:n}){return[e("NcDashboardWidgetItem",{attrs:{"target-url":t.getItemTargetUrl(n),"main-text":n.title,"sub-text":t.subtext(n)}},[e("div",{staticClass:"note-item",class:{"note-item-favorite":n.favorite,"note-item-no-favorites":!t.hasFavorites},attrs:{slot:"avatar"},slot:"avatar"})])]}}])}),t._v(" "),t.loading?t._e():e("div",{staticClass:"buttons-footer"},[e("NcButton",{attrs:{href:t.createNoteUrl}},[e("Plus",{attrs:{slot:"icon",size:20},slot:"icon"}),t._v("\n\t\t\t"+t._s(t.t("notes","New note"))+"\n\t\t")],1)],1)],1)},[],!1,null,"34333f59",null).exports},4635(t,e,n){n.d(e,{A:()=>i});var o=n(1354),a=n.n(o),s=n(6314),r=n.n(s)()(a());r.push([t.id,"\n.dashboard-box[data-v-34333f59] {\n\tposition: relative;\n\theight: 100%;\n}\n.note-item-favorite[data-v-34333f59] {\n\tbackground: var(--icon-starred-yellow);\n}\n.note-item[data-v-34333f59] {\n\twidth: var(--default-clickable-area);\n\theight: var(--default-clickable-area);\n\tline-height: var(--default-clickable-area);\n\tflex-shrink: 0;\n\tbackground-size: 50%;\n\tbackground-repeat: no-repeat;\n\tbackground-position: center;\n}\n.note-item-no-favorites[data-v-34333f59] {\n\tdisplay: none;\n}\n.notes-empty-content-label[data-v-34333f59] {\n\tmargin-bottom: 20px;\n}\n.buttons-footer[data-v-34333f59] {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tmargin-top: 8px;\n}\n","",{version:3,sources:["webpack://./src/components/Dashboard.vue"],names:[],mappings:";AAyGA;CACA,kBAAA;CACA,YAAA;AACA;AAEA;CACA,sCAAA;AACA;AAEA;CACA,oCAAA;CACA,qCAAA;CACA,0CAAA;CACA,cAAA;CACA,oBAAA;CACA,4BAAA;CACA,2BAAA;AACA;AAEA;CACA,aAAA;AACA;AAEA;CACA,mBAAA;AACA;AAEA;CACA,aAAA;CACA,mBAAA;CACA,uBAAA;CACA,eAAA;AACA",sourcesContent:['\x3c!--\n - SPDX-FileCopyrightText: 2020 F7cloud GmbH and F7cloud contributors\n - SPDX-License-Identifier: AGPL-3.0-or-later\n--\x3e\n\n<template>\n\t<div class="dashboard-box">\n\t\t<NcDashboardWidget\n\t\t\tempty-content-icon="icon-notes"\n\t\t\t:empty-content-message="t(\'notes\', \'No notes yet\')"\n\t\t\t:items="items"\n\t\t\t:loading="loading"\n\t\t>\n\t\t\t<template #default="{ item }">\n\t\t\t\t<NcDashboardWidgetItem\n\t\t\t\t\t:target-url="getItemTargetUrl(item)"\n\t\t\t\t\t:main-text="item.title"\n\t\t\t\t\t:sub-text="subtext(item)"\n\t\t\t\t>\n\t\t\t\t\t<div slot="avatar"\n\t\t\t\t\t\tclass="note-item"\n\t\t\t\t\t\t:class="{ \'note-item-favorite\': item.favorite, \'note-item-no-favorites\': !hasFavorites }"\n\t\t\t\t\t/>\n\t\t\t\t</NcDashboardWidgetItem>\n\t\t\t</template>\n\t\t</NcDashboardWidget>\n\t\t<div v-if="!loading" class="buttons-footer">\n\t\t\t<NcButton :href="createNoteUrl">\n\t\t\t\t<Plus slot="icon" :size="20" />\n\t\t\t\t{{ t(\'notes\', \'New note\') }}\n\t\t\t</NcButton>\n\t\t</div>\n\t</div>\n</template>\n\n<script>\nimport NcButton from \'@f7cloud/vue/components/NcButton\'\nimport NcDashboardWidget from \'@f7cloud/vue/components/NcDashboardWidget\'\nimport NcDashboardWidgetItem from \'@f7cloud/vue/components/NcDashboardWidgetItem\'\nimport { generateUrl } from \'@f7cloud/router\'\n\nimport Plus from \'vue-material-design-icons/Plus.vue\'\n\nimport { getDashboardData } from \'../NotesService.js\'\nimport { categoryLabel } from \'../Util.js\'\n\nexport default {\n\tname: \'Dashboard\',\n\n\tcomponents: {\n\t\tNcButton,\n\t\tNcDashboardWidget,\n\t\tNcDashboardWidgetItem,\n\t\tPlus,\n\t},\n\n\tdata() {\n\t\treturn {\n\t\t\tloading: true,\n\t\t\titems: [],\n\t\t\thasMoreItems: false,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\tshowMoreUrl() {\n\t\t\treturn this.hasMoreItems ? generateUrl(\'/apps/notes\') : null\n\t\t},\n\n\t\thasFavorites() {\n\t\t\treturn this.items.length > 0 && this.items[0].favorite\n\t\t},\n\n\t\tcreateNoteUrl() {\n\t\t\treturn generateUrl(\'/apps/notes/new\')\n\t\t},\n\n\t\tgetItemTargetUrl() {\n\t\t\treturn (note) => {\n\t\t\t\treturn generateUrl(`/apps/notes/note/${note.id}`)\n\t\t\t}\n\t\t},\n\t},\n\n\tcreated() {\n\t\tthis.loadDashboardData()\n\t},\n\n\tmethods: {\n\t\tloadDashboardData() {\n\t\t\tgetDashboardData().then(data => {\n\t\t\t\tthis.items = data.items\n\t\t\t\tthis.hasMoreItems = data.hasMoreItems\n\t\t\t\tthis.loading = false\n\t\t\t})\n\t\t},\n\n\t\tsubtext(item) {\n\t\t\treturn item.excerpt || categoryLabel(item.category)\n\t\t},\n\t},\n}\n<\/script>\n\n<style scoped>\n.dashboard-box {\n\tposition: relative;\n\theight: 100%;\n}\n\n.note-item-favorite {\n\tbackground: var(--icon-starred-yellow);\n}\n\n.note-item {\n\twidth: var(--default-clickable-area);\n\theight: var(--default-clickable-area);\n\tline-height: var(--default-clickable-area);\n\tflex-shrink: 0;\n\tbackground-size: 50%;\n\tbackground-repeat: no-repeat;\n\tbackground-position: center;\n}\n\n.note-item-no-favorites {\n\tdisplay: none;\n}\n\n.notes-empty-content-label {\n\tmargin-bottom: 20px;\n}\n\n.buttons-footer {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tmargin-top: 8px;\n}\n</style>\n'],sourceRoot:""}]);const i=r}}]);
|
|
//# sourceMappingURL=notes-dashboard-lazy.js.map?v=31fee1ae054e22775aab
|