File tree Expand file tree Collapse file tree 13 files changed +160
-72
lines changed
app-server/src/trpc/api/pages/deletion
packages/@deeplib/misc/src Expand file tree Collapse file tree 13 files changed +160
-72
lines changed Original file line number Diff line number Diff line change @@ -56,15 +56,46 @@ export async function deletePermanently({
5656 } ) ;
5757 }
5858
59- // Delete page permanently
59+ // Check if page is free
60+
61+ let numFreePages ;
6062
61- await ctx . dataAbstraction . patch (
63+ const pageIsFree = await ctx . dataAbstraction . hget (
6264 'page' ,
6365 input . pageId ,
64- { permanent_deletion_date : addDays ( new Date ( ) , - 1 ) } ,
65- { dtrx } ,
66+ 'free' ,
6667 ) ;
6768
69+ if ( pageIsFree ) {
70+ numFreePages = await ctx . dataAbstraction . hget (
71+ 'user' ,
72+ ctx . userId ,
73+ 'num-free-pages' ,
74+ ) ;
75+ }
76+
77+ // Delete page permanently
78+
79+ await Promise . all ( [
80+ ctx . dataAbstraction . patch (
81+ 'page' ,
82+ input . pageId ,
83+ { permanent_deletion_date : addDays ( new Date ( ) , - 1 ) } ,
84+ { dtrx } ,
85+ ) ,
86+
87+ ...( pageIsFree
88+ ? [
89+ ctx . dataAbstraction . patch (
90+ 'user' ,
91+ ctx . userId ,
92+ { num_free_pages : numFreePages + 1 } ,
93+ { dtrx } ,
94+ ) ,
95+ ]
96+ : [ ] ) ,
97+ ] ) ;
98+
6899 checkRedlockSignalAborted ( signals ) ;
69100 } ) ;
70101 } ,
Original file line number Diff line number Diff line change @@ -41,16 +41,28 @@ export async function restore({
4141
4242 // Check if page is deleted
4343
44+ const permanentDeletionDate = await ctx . dataAbstraction . hget (
45+ 'page' ,
46+ input . pageId ,
47+ 'permanent-deletion-date' ,
48+ ) ;
49+
50+ if ( permanentDeletionDate == null ) {
51+ throw new TRPCError ( {
52+ code : 'BAD_REQUEST' ,
53+ message : 'Page is not deleted.' ,
54+ } ) ;
55+ }
56+
57+ // Check if page is free and permanently deleted
58+
4459 if (
45- ( await ctx . dataAbstraction . hget (
46- 'page' ,
47- input . pageId ,
48- 'permanent-deletion-date' ,
49- ) ) == null
60+ new Date ( ) > permanentDeletionDate &&
61+ ( await ctx . dataAbstraction . hget ( 'page' , input . pageId , 'free' ) )
5062 ) {
5163 throw new TRPCError ( {
5264 code : 'BAD_REQUEST' ,
53- message : 'Page is not deleted.' ,
65+ message : 'Cannot restore a permanently deleted free page .' ,
5466 } ) ;
5567 }
5668
Original file line number Diff line number Diff line change @@ -149,6 +149,10 @@ export function useKeyboardShortcuts() {
149149 return true ;
150150 }
151151
152+ if ( event . code === 'Backspace' && activeElem == null ) {
153+ await internals . pages . goBackward ( ) ;
154+ return true ;
155+ }
152156 if ( event . code === 'Backspace' && activeElem != null ) {
153157 await page . editing . start ( activeElem ) ;
154158 page . editing . react . editor ?. commands . deleteSelection ( ) ;
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ export class Pages {
109109 }
110110
111111 async setupPage ( pageId : string ) {
112- internals . pages . react . page ?. deactivate ( ) ;
112+ this . react . page ?. deactivate ( ) ;
113113
114114 let page ;
115115
@@ -121,7 +121,7 @@ export class Pages {
121121 this . pageCache . add ( page ) ;
122122 }
123123
124- internals . pages . react . page = page ;
124+ this . react . page = page ;
125125
126126 pagesStore ( ) . loading = false ;
127127
@@ -231,6 +231,30 @@ export class Pages {
231231 }
232232 }
233233
234+ async goBackward ( ) {
235+ const pageIndex = this . react . pathPageIds . indexOf ( this . react . pageId ! ) ;
236+
237+ if ( pageIndex > 0 ) {
238+ await this . goToPage (
239+ this . react . pathPageIds [
240+ this . react . pathPageIds . indexOf ( this . react . pageId ! ) - 1
241+ ] ,
242+ ) ;
243+ }
244+ }
245+
246+ async goForward ( ) {
247+ const pageIndex = this . react . pathPageIds . indexOf ( this . react . pageId ! ) ;
248+
249+ if ( pageIndex < this . react . pathPageIds . length - 1 ) {
250+ await this . goToPage (
251+ this . react . pathPageIds [
252+ this . react . pathPageIds . indexOf ( this . react . pageId ! ) + 1
253+ ] ,
254+ ) ;
255+ }
256+ }
257+
234258 destroy ( ) {
235259 for ( const page of this . pageCache . react . cache ) {
236260 page . destroy ( ) ;
Original file line number Diff line number Diff line change 8585 flat
8686 class =" toolbar-btn"
8787 :to =" { name: 'pricing' }"
88+ :style =" {
89+ 'background-color':
90+ $route.name === 'pricing'
91+ ? 'rgba(255,255,255,0.15)'
92+ : undefined,
93+ }"
8894 />
8995
9096 <template v-if =" isIncluded (quasarMode , [' ssr' , ' spa' ])" >
95101 flat
96102 class =" toolbar-btn"
97103 :to =" { name: 'download' }"
104+ :style =" {
105+ 'background-color':
106+ $route.name === 'download'
107+ ? 'rgba(255,255,255,0.15)'
108+ : undefined,
109+ }"
98110 />
99111 </template >
100112
105117 flat
106118 class =" toolbar-btn"
107119 :to =" { name: 'whitepaper' }"
120+ :style =" {
121+ 'background-color':
122+ $route.name === 'whitepaper'
123+ ? 'rgba(255,255,255,0.15)'
124+ : undefined,
125+ }"
108126 />
109127 </template >
110128
Original file line number Diff line number Diff line change 77 :disable ="
88 internals.pages.react.pageId === internals.pages.react.pathPageIds[0]
99 "
10- @click =" goBackward()"
10+ @click =" internals.pages. goBackward()"
1111 >
1212 <q-tooltip
1313 anchor =" center right"
2929 internals.pages.react.pageId ===
3030 internals.pages.react.pathPageIds.at(-1)
3131 "
32- @click =" goForward()"
32+ @click =" internals.pages. goForward()"
3333 >
3434 <q-tooltip
3535 anchor =" center right"
8888import TakeScreenshotDialog from ' ../../MainToolbar/TakeScreenshotDialog.vue' ;
8989
9090const page = computed (() => internals .pages .react .page );
91-
92- async function goBackward() {
93- await internals .pages .goToPage (
94- internals .pages .react .pathPageIds [
95- internals .pages .react .pathPageIds .indexOf (internals .pages .react .pageId ! ) -
96- 1
97- ],
98- );
99- }
100-
101- async function goForward() {
102- await internals .pages .goToPage (
103- internals .pages .react .pathPageIds [
104- internals .pages .react .pathPageIds .indexOf (internals .pages .react .pageId ! ) +
105- 1
106- ],
107- );
108- }
10991 </script >
11092
11193<style lang="scss" scoped>
Original file line number Diff line number Diff line change @@ -178,7 +178,7 @@ const groupOptions = computed(() => [
178178 .filter ((item ) => item != null ),
179179]);
180180
181- const destGroupId = ref < string >( );
181+ const destGroupId = ref ( ' ' );
182182
183183// Group creation
184184
@@ -235,7 +235,7 @@ async function _createPage() {
235235
236236 const response = await createPage ({
237237 parentPageId: page .value .id ,
238- destGroupId: page .value . react . groupId ,
238+ destGroupId: destGroupId .value ,
239239
240240 pageRelativeTitle: pageRelativeTitle .value ,
241241
Original file line number Diff line number Diff line change 4242 </template >
4343 <template v-else >(Select a role)</template >
4444 </template >
45+
46+ <template #option =" scope " >
47+ <q-item
48+ v-bind =" scope.itemProps"
49+ style =" max-width : 220px "
50+ >
51+ <q-item-section >
52+ <q-item-label >{{ scope.opt.name }}</q-item-label >
53+ <q-item-label caption >{{ scope.opt.description }}</q-item-label >
54+ </q-item-section >
55+ </q-item >
56+ </template >
4557 </q-select >
4658 </q-card-section >
4759 </template >
Original file line number Diff line number Diff line change 2727 </template >
2828 <template v-else >(Select a role)</template >
2929 </template >
30+
31+ <template #option =" scope " >
32+ <q-item
33+ v-bind =" scope.itemProps"
34+ style =" max-width : 220px "
35+ >
36+ <q-item-section >
37+ <q-item-label >{{ scope.opt.name }}</q-item-label >
38+ <q-item-label caption >{{ scope.opt.description }}</q-item-label >
39+ </q-item-section >
40+ </q-item >
41+ </template >
3042 </q-select >
3143 </q-card-section >
3244 </template >
Original file line number Diff line number Diff line change 3131 </template >
3232 <template v-else >(Select a role)</template >
3333 </template >
34+
35+ <template #option =" scope " >
36+ <q-item
37+ v-bind =" scope.itemProps"
38+ style =" max-width : 220px "
39+ >
40+ <q-item-section >
41+ <q-item-label >{{ scope.opt.name }}</q-item-label >
42+ <q-item-label caption >{{ scope.opt.description }}</q-item-label >
43+ </q-item-section >
44+ </q-item >
45+ </template >
3446 </q-select >
3547 </q-card-section >
3648 </template >
You can’t perform that action at this time.
0 commit comments