Skip to content

Commit 91b7c30

Browse files
committed
feat(fe): store last visited view page
1 parent 9db447c commit 91b7c30

File tree

2 files changed

+116
-92
lines changed

2 files changed

+116
-92
lines changed

web2/src/App.vue

Lines changed: 110 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,131 @@
11
<template>
22
<v-app v-if="state === 'success'" class="app">
33
<EditDialog
4-
v-model="passwordDialog"
5-
save-button-text="Save"
6-
title="Change password"
7-
v-if="user"
8-
event-name="i-user"
4+
v-model="passwordDialog"
5+
save-button-text="Save"
6+
title="Change password"
7+
v-if="user"
8+
event-name="i-user"
99
>
1010
<template v-slot:form="{ onSave, onError, needSave, needReset }">
1111
<ChangePasswordForm
12-
:project-id="projectId"
13-
:item-id="user.id"
14-
@save="onSave"
15-
@error="onError"
16-
:need-save="needSave"
17-
:need-reset="needReset"
12+
:project-id="projectId"
13+
:item-id="user.id"
14+
@save="onSave"
15+
@error="onError"
16+
:need-save="needSave"
17+
:need-reset="needReset"
1818
/>
1919
</template>
2020
</EditDialog>
2121

2222
<EditDialog
23-
v-model="userDialog"
24-
save-button-text="Save"
25-
title="Edit User"
26-
v-if="user"
27-
event-name="i-user"
23+
v-model="userDialog"
24+
save-button-text="Save"
25+
title="Edit User"
26+
v-if="user"
27+
event-name="i-user"
2828
>
2929
<template v-slot:form="{ onSave, onError, needSave, needReset }">
3030
<UserForm
31-
:project-id="projectId"
32-
:item-id="user.id"
33-
@save="onSave"
34-
@error="onError"
35-
:need-save="needSave"
36-
:need-reset="needReset"
31+
:project-id="projectId"
32+
:item-id="user.id"
33+
@save="onSave"
34+
@error="onError"
35+
:need-save="needSave"
36+
:need-reset="needReset"
3737
/>
3838
</template>
3939
</EditDialog>
4040

4141
<EditDialog
42-
v-model="taskLogDialog"
43-
save-button-text="Delete"
44-
:max-width="1000"
45-
:hide-buttons="true"
46-
@close="onTaskLogDialogClosed()"
42+
v-model="taskLogDialog"
43+
save-button-text="Delete"
44+
:max-width="1000"
45+
:hide-buttons="true"
46+
@close="onTaskLogDialogClosed()"
4747
>
4848
<template v-slot:title={}>
4949
<div class="text-truncate" style="max-width: calc(100% - 36px);">
5050
<router-link
5151
class="breadcrumbs__item breadcrumbs__item--link"
5252
:to="`/project/${projectId}/templates/${template ? template.id : null}`"
5353
@click="taskLogDialog = false"
54-
>{{ template ? template.alias : null }}</router-link>
54+
>{{ template ? template.alias : null }}
55+
</router-link>
5556
<v-icon>mdi-chevron-right</v-icon>
5657
<span class="breadcrumbs__item">Task #{{ task ? task.id : null }}</span>
5758
</div>
5859

5960
<v-spacer></v-spacer>
6061
<v-btn
61-
icon
62-
@click="taskLogDialog = false; onTaskLogDialogClosed()"
62+
icon
63+
@click="taskLogDialog = false; onTaskLogDialogClosed()"
6364
>
6465
<v-icon>mdi-close</v-icon>
6566
</v-btn>
6667
</template>
6768
<template v-slot:form="{}">
68-
<TaskLogView :project-id="projectId" :item-id="task ? task.id : null" />
69+
<TaskLogView :project-id="projectId" :item-id="task ? task.id : null"/>
6970
</template>
7071
</EditDialog>
7172

7273
<EditDialog
73-
v-model="newProjectDialog"
74-
save-button-text="Create"
75-
title="New Project"
76-
event-name="i-project"
74+
v-model="newProjectDialog"
75+
save-button-text="Create"
76+
title="New Project"
77+
event-name="i-project"
7778
>
7879
<template v-slot:form="{ onSave, onError, needSave, needReset }">
7980
<ProjectForm
80-
item-id="new"
81-
@save="onSave"
82-
@error="onError"
83-
:need-save="needSave"
84-
:need-reset="needReset"
81+
item-id="new"
82+
@save="onSave"
83+
@error="onError"
84+
:need-save="needSave"
85+
:need-reset="needReset"
8586
/>
8687
</template>
8788
</EditDialog>
8889

8990
<v-snackbar
90-
v-model="snackbar"
91-
:color="snackbarColor"
92-
:timeout="3000"
93-
top
91+
v-model="snackbar"
92+
:color="snackbarColor"
93+
:timeout="3000"
94+
top
9495
>
9596
{{ snackbarText }}
9697
<v-btn
97-
text
98-
@click="snackbar = false"
98+
text
99+
@click="snackbar = false"
99100
>
100101
Close
101102
</v-btn>
102103
</v-snackbar>
103104

104105
<v-navigation-drawer
105-
app
106-
dark
107-
color="#005057"
108-
fixed
109-
width="260"
110-
v-model="drawer"
111-
mobile-breakpoint="960"
112-
v-if="$route.path.startsWith('/project/')"
106+
app
107+
dark
108+
color="#005057"
109+
fixed
110+
width="260"
111+
v-model="drawer"
112+
mobile-breakpoint="960"
113+
v-if="$route.path.startsWith('/project/')"
113114
>
114115
<v-menu bottom max-width="235" max-height="100%" v-if="project">
115116
<template v-slot:activator="{ on, attrs }">
116117
<v-list class="pa-0 overflow-y-auto">
117118
<v-list-item
118-
key="project"
119-
class="app__project-selector"
120-
v-bind="attrs"
121-
v-on="on"
119+
key="project"
120+
class="app__project-selector"
121+
v-bind="attrs"
122+
v-on="on"
122123
>
123124
<v-list-item-icon>
124125
<v-avatar
125-
:color="getProjectColor(project)"
126-
size="24"
127-
style="font-size: 13px; font-weight: bold;"
126+
:color="getProjectColor(project)"
127+
size="24"
128+
style="font-size: 13px; font-weight: bold;"
128129
>
129130
<span class="white--text">{{ getProjectInitials(project) }}</span>
130131
</v-avatar>
@@ -144,16 +145,16 @@
144145
</template>
145146
<v-list>
146147
<v-list-item
147-
v-for="(item, i) in projects"
148-
:key="i"
149-
:to="`/project/${item.id}`"
150-
@click="selectProject(item.id)"
148+
v-for="(item, i) in projects"
149+
:key="i"
150+
:to="`/project/${item.id}`"
151+
@click="selectProject(item.id)"
151152
>
152153
<v-list-item-icon>
153154
<v-avatar
154-
:color="getProjectColor(item)"
155-
size="24"
156-
style="font-size: 13px; font-weight: bold;"
155+
:color="getProjectColor(item)"
156+
size="24"
157+
style="font-size: 13px; font-weight: bold;"
157158
>
158159
<span class="white--text">{{ getProjectInitials(item) }}</span>
159160
</v-avatar>
@@ -196,7 +197,7 @@
196197
</v-list-item-content>
197198
</v-list-item>
198199

199-
<v-list-item key="templates" :to="`/project/${projectId}/templates`">
200+
<v-list-item key="templates" :to="templatesUrl">
200201
<v-list-item-icon>
201202
<v-icon>mdi-check-all</v-icon>
202203
</v-list-item-icon>
@@ -262,9 +263,9 @@
262263
<template v-slot:activator="{ on, attrs }">
263264
<v-list class="pa-0">
264265
<v-list-item
265-
key="project"
266-
v-bind="attrs"
267-
v-on="on"
266+
key="project"
267+
v-bind="attrs"
268+
v-on="on"
268269
>
269270
<v-list-item-icon>
270271
<v-icon>mdi-account</v-icon>
@@ -330,29 +331,29 @@
330331
<v-app v-else-if="state === 'loading'">
331332
<v-main>
332333
<v-container
333-
fluid
334-
fill-height
335-
align-center
336-
justify-center
337-
class="pa-0"
334+
fluid
335+
fill-height
336+
align-center
337+
justify-center
338+
class="pa-0"
338339
>
339340
<v-progress-circular
340-
:size="70"
341-
color="primary"
342-
indeterminate
341+
:size="70"
342+
color="primary"
343+
indeterminate
343344
></v-progress-circular>
344345
</v-container>
345346
</v-main>
346347
</v-app>
347348
<v-app v-else-if="state === 'error'">
348349
<v-main>
349350
<v-container
350-
fluid
351-
flex-column
352-
fill-height
353-
align-center
354-
justify-center
355-
class="pa-0 text-center"
351+
fluid
352+
flex-column
353+
fill-height
354+
align-center
355+
justify-center
356+
class="pa-0 text-center"
356357
>
357358
<v-alert text color="error" class="d-inline-block">
358359
<h3 class="headline">
@@ -383,15 +384,18 @@
383384
.v-data-table tbody tr.v-data-table__expanded__content {
384385
box-shadow: none !important;
385386
}
387+
386388
.v-data-table a {
387389
text-decoration-line: none;
390+
388391
&:hover {
389392
text-decoration-line: underline;
390393
}
391394
}
392395
393396
.breadcrumbs__item--link {
394397
text-decoration-line: none;
398+
395399
&:hover {
396400
text-decoration-line: underline;
397401
}
@@ -403,6 +407,7 @@
403407
404408
.app__project-selector {
405409
height: 64px;
410+
406411
.v-list-item__icon {
407412
margin-top: 20px !important;
408413
}
@@ -432,9 +437,11 @@
432437
433438
.v-data-table > .v-data-table__wrapper > table > tbody > tr {
434439
background: transparent !important;
440+
435441
& > td {
436442
white-space: nowrap;
437443
}
444+
438445
& > td:first-child {
439446
//font-weight: bold !important;
440447
}
@@ -525,8 +532,8 @@ export default {
525532
watch: {
526533
async projects(val) {
527534
if (val.length === 0
528-
&& this.$route.path.startsWith('/project/')
529-
&& this.$route.path !== '/project/new') {
535+
&& this.$route.path.startsWith('/project/')
536+
&& this.$route.path !== '/project/new') {
530537
await this.$router.push({ path: '/project/new' });
531538
}
532539
},
@@ -555,6 +562,17 @@ export default {
555562
isAuthenticated() {
556563
return document.cookie.includes('semaphore=');
557564
},
565+
566+
templatesUrl() {
567+
let viewId = localStorage.getItem(`project${this.projectId}__lastVisitedViewId`);
568+
if (viewId) {
569+
viewId = parseInt(viewId, 10);
570+
if (!Number.isNaN(viewId)) {
571+
return `/project/${this.projectId}/views/${viewId}/templates`;
572+
}
573+
}
574+
return `/project/${this.projectId}/templates`;
575+
},
558576
},
559577
560578
async created() {
@@ -704,8 +722,8 @@ export default {
704722
705723
// try to find project and switch to it if URL not pointing to any project
706724
if (this.$route.path === '/'
707-
|| this.$route.path === '/project'
708-
|| (this.$route.path.startsWith('/project/'))) {
725+
|| this.$route.path === '/project'
726+
|| (this.$route.path.startsWith('/project/'))) {
709727
await this.trySelectMostSuitableProject();
710728
}
711729
@@ -733,7 +751,7 @@ export default {
733751
}
734752
735753
if ((projectId == null || !this.projects.some((p) => p.id === projectId))
736-
&& localStorage.getItem('projectId')) {
754+
&& localStorage.getItem('projectId')) {
737755
projectId = parseInt(localStorage.getItem('projectId'), 10);
738756
}
739757
@@ -775,7 +793,7 @@ export default {
775793
776794
getProjectColor(projectData) {
777795
const projectIndex = this.projects.length
778-
- this.projects.findIndex((p) => p.id === projectData.id);
796+
- this.projects.findIndex((p) => p.id === projectData.id);
779797
return PROJECT_COLORS[projectIndex % PROJECT_COLORS.length];
780798
},
781799

web2/src/views/project/Templates.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ export default {
242242
mixins: [ItemListPageBase],
243243
async created() {
244244
socket.addListener((data) => this.onWebsocketDataReceived(data));
245+
245246
await this.loadData();
246247
},
247248
data() {
@@ -295,6 +296,11 @@ export default {
295296
this.viewItemsLoading = true;
296297
try {
297298
await this.loadItems();
299+
if (this.viewId) {
300+
localStorage.setItem(`project${this.projectId}__lastVisitedViewId`, this.viewId);
301+
} else {
302+
localStorage.removeItem(`project${this.projectId}__lastVisitedViewId`);
303+
}
298304
} finally {
299305
this.viewItemsLoading = false;
300306
}

0 commit comments

Comments
 (0)