Skip to content

Commit e3d6e56

Browse files
authored
Merge pull request #1004 from JonnyTischbein/remove-sidebar
Sidebar: removed
2 parents 40fcc6e + 32b4598 commit e3d6e56

File tree

10 files changed

+126
-343
lines changed

10 files changed

+126
-343
lines changed

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"markdown-it": "^13.0.2",
2626
"markdown-it-task-checkbox": "^1.0.6",
2727
"vue": "^2.7.15",
28-
"vue-fragment": "1.6.0",
28+
"vue-fragment": "^1.5.1",
2929
"vue-material-design-icons": "^5.2.0",
3030
"vue-observe-visibility": "^1.0.0",
3131
"vue-router": "^3.5.3",
@@ -46,4 +46,4 @@
4646
"extends @nextcloud/browserslist-config"
4747
],
4848
"version": "4.8.1"
49-
}
49+
}

src/App.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
</div>
3838
</NcAppContent>
3939
<router-view v-else @note-deleted="onNoteDeleted" />
40-
41-
<router-view name="sidebar" />
4240
</NcContent>
4341
</template>
4442

src/components/NoteItem.vue

Lines changed: 101 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
:title="title"
44
:active="isSelected"
55
:to="{ name: 'note', params: { noteId: note.id.toString() } }"
6+
@update:menuOpen="onMenuChange"
67
@click="onNoteSelected(note.id)"
78
>
89
<template #subtitle>
@@ -29,42 +30,80 @@
2930
<NcActionButton :icon="actionFavoriteIcon" @click="onToggleFavorite">
3031
{{ actionFavoriteText }}
3132
</NcActionButton>
32-
<NcActionButton @click="onToggleSidebar">
33-
<SidebarIcon slot="icon" :size="20" />
34-
{{ t('notes', 'Details') }}
33+
34+
<NcActionButton v-if="!showCategorySelect" @click="showCategorySelect = true">
35+
<template #icon>
36+
<FolderIcon :size="20" />
37+
</template>
38+
{{ categoryTitle }}
3539
</NcActionButton>
36-
<NcActionButton v-if="!note.readonly" :icon="actionDeleteIcon" @click="onDeleteNote">
37-
{{ t('notes', 'Delete note') }}
40+
<NcActionInput
41+
v-else
42+
:value="note.category"
43+
type="multiselect"
44+
label="label"
45+
track-by="id"
46+
:multiple="false"
47+
:options="categories"
48+
:disabled="loading.category"
49+
:taggable="true"
50+
@input="onCategoryChange"
51+
@search-change="onCategoryChange"
52+
>
53+
<template #icon>
54+
<FolderIcon :size="20" />
55+
</template>
56+
{{ t('notes', 'Change category') }}
57+
</NcActionInput>
58+
59+
<NcActionButton v-if="!renaming" @click="startRenaming">
60+
<PencilIcon slot="icon" :size="20" />
61+
{{ t('notes', 'Rename') }}
3862
</NcActionButton>
63+
<NcActionInput v-else
64+
v-model.trim="newTitle"
65+
:disabled="!renaming"
66+
:placeholder="t('notes', 'Rename note')"
67+
:show-trailing-button="true"
68+
@input="onInputChange($event)"
69+
@submit="onRename"
70+
>
71+
<PencilIcon slot="icon" :size="20" />
72+
</NcActionInput>
73+
3974
<NcActionSeparator />
40-
<NcActionButton icon="icon-files-dark" @click="onCategorySelected">
41-
{{ actionCategoryText }}
75+
76+
<NcActionButton v-if="!note.readonly" :icon="actionDeleteIcon" @click="onDeleteNote">
77+
{{ t('notes', 'Delete note') }}
4278
</NcActionButton>
4379
</template>
4480
</NcListItem>
4581
</template>
4682

4783
<script>
48-
import { NcListItem, NcActionButton } from '@nextcloud/vue'
84+
import { NcListItem, NcActionButton, NcActionSeparator, NcActionInput } from '@nextcloud/vue'
4985
import AlertOctagonIcon from 'vue-material-design-icons/AlertOctagon.vue'
5086
import FileDocumentOutlineIcon from 'vue-material-design-icons/FileDocumentOutline.vue'
87+
import FolderIcon from 'vue-material-design-icons/Folder.vue'
88+
import PencilIcon from 'vue-material-design-icons/Pencil.vue'
5189
import StarIcon from 'vue-material-design-icons/Star.vue'
52-
import SidebarIcon from 'vue-material-design-icons/PageLayoutSidebarRight.vue'
5390
import { categoryLabel, routeIsNewNote } from '../Util.js'
5491
import { showError } from '@nextcloud/dialogs'
55-
import store from '../store.js'
56-
import { setFavorite, setTitle, fetchNote, deleteNote } from '../NotesService.js'
92+
import { setFavorite, setTitle, fetchNote, deleteNote, setCategory } from '../NotesService.js'
5793
5894
export default {
5995
name: 'NoteItem',
6096
6197
components: {
6298
AlertOctagonIcon,
6399
FileDocumentOutlineIcon,
100+
FolderIcon,
64101
NcActionButton,
65102
NcListItem,
66-
SidebarIcon,
67103
StarIcon,
104+
NcActionSeparator,
105+
NcActionInput,
106+
PencilIcon,
68107
},
69108
70109
props: {
@@ -78,7 +117,11 @@ export default {
78117
return {
79118
loading: {
80119
note: false,
120+
category: false,
81121
},
122+
newTitle: '',
123+
renaming: false,
124+
showCategorySelect: false,
82125
}
83126
},
84127
@@ -111,9 +154,24 @@ export default {
111154
actionDeleteIcon() {
112155
return 'icon-delete' + (this.loading.delete ? ' loading' : '')
113156
},
157+
categories() {
158+
return [
159+
{
160+
id: '',
161+
label: categoryLabel(''),
162+
},
163+
...this.$store.getters.getCategories(0, false).map((category) => ({
164+
id: category,
165+
label: categoryLabel(category),
166+
})),
167+
]
168+
},
114169
},
115-
116170
methods: {
171+
onMenuChange(state) {
172+
this.actionsOpen = state
173+
this.showCategorySelect = false
174+
},
117175
onNoteSelected(noteId) {
118176
this.$emit('note-selected', noteId)
119177
},
@@ -131,24 +189,49 @@ export default {
131189
this.actionsOpen = false
132190
this.$emit('category-selected', this.note.category)
133191
},
134-
onToggleSidebar() {
135-
this.actionsOpen = false
136-
store.commit('setSidebarOpen', !store.state.app.sidebarOpen)
192+
startRenaming() {
193+
this.renaming = true
194+
this.newTitle = this.note.title
195+
this.$emit('start-renaming', this.note.id)
196+
},
197+
onInputChange(event) {
198+
this.newTitle = event.target.value.toString()
137199
},
138-
onRename(newTitle) {
200+
async onCategoryChange(result) {
201+
this.showCategorySelect = false
202+
const category = result?.id ?? result?.label ?? null
203+
if (category !== null && this.note.category !== category) {
204+
this.loading.category = true
205+
await setCategory(this.note.id, category)
206+
this.loading.category = false
207+
}
208+
},
209+
async onRename() {
210+
const newTitle = this.newTitle.toString()
211+
if (!newTitle) {
212+
return
213+
}
139214
this.loading.note = true
140215
setTitle(this.note.id, newTitle)
141-
.catch(() => {
216+
.then(() => {
217+
this.newTitle = ''
218+
})
219+
.catch((e) => {
220+
console.error('Failed to rename note', e)
221+
showError(this.t('notes', 'Error while renaming note.'))
142222
})
143223
.finally(() => {
144224
this.loading.note = false
145225
})
226+
146227
if (routeIsNewNote(this.$route)) {
147228
this.$router.replace({
148229
name: 'note',
149230
params: { noteId: this.note.id.toString() },
150231
})
151232
}
233+
this.renaming = false
234+
152235
},
153236
async onDeleteNote() {
154237
this.loading.delete = true

src/components/NotePlain.vue

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<NcAppContent :class="{ loading: loading || isManualSave, 'icon-error': !loading && (!note || note.error), 'sidebar-open': sidebarOpen }">
2+
<NcAppContent :class="{ loading: loading || isManualSave, 'icon-error': !loading && (!note || note.error)}">
33
<div v-if="!loading && note && !note.error && !note.deleting"
44
id="note-container"
55
class="note-container"
@@ -47,13 +47,6 @@
4747
</div>
4848
<span class="action-buttons">
4949
<NcActions :open.sync="actionsOpen" container=".action-buttons" menu-align="right">
50-
<NcActionButton v-show="!sidebarOpen && !fullscreen"
51-
icon="icon-details"
52-
@click="onToggleSidebar"
53-
>
54-
<SidebarIcon slot="icon" :size="20" />
55-
{{ t('notes', 'Details') }}
56-
</NcActionButton>
5750
<NcActionButton
5851
v-tooltip.left="t('notes', 'CTRL + /')"
5952
@click="onTogglePreview"
@@ -109,7 +102,6 @@ import EditIcon from 'vue-material-design-icons/LeadPencil.vue'
109102
import EyeIcon from 'vue-material-design-icons/Eye.vue'
110103
import FullscreenIcon from 'vue-material-design-icons/Fullscreen.vue'
111104
import NoEditIcon from 'vue-material-design-icons/PencilOff.vue'
112-
import SidebarIcon from 'vue-material-design-icons/PageLayoutSidebarRight.vue'
113105
import SyncAlertIcon from 'vue-material-design-icons/SyncAlert.vue'
114106
115107
import { config } from '../config.js'
@@ -133,7 +125,6 @@ export default {
133125
NcAppContent,
134126
NcModal,
135127
NoEditIcon,
136-
SidebarIcon,
137128
SyncAlertIcon,
138129
TheEditor,
139130
ThePreview,
@@ -179,9 +170,6 @@ export default {
179170
isManualSave() {
180171
return store.state.app.isManualSave
181172
},
182-
sidebarOpen() {
183-
return store.state.app.sidebarOpen
184-
},
185173
},
186174
187175
watch: {
@@ -293,11 +281,6 @@ export default {
293281
this.actionsOpen = false
294282
},
295283
296-
onToggleSidebar() {
297-
store.commit('setSidebarOpen', !store.state.app.sidebarOpen)
298-
this.actionsOpen = false
299-
},
300-
301284
onVisibilityChange() {
302285
if (document.visibilityState === 'visible') {
303286
this.stopRefreshTimer()
@@ -436,9 +419,6 @@ export default {
436419
transition-duration: var(--animation-quick);
437420
transition-property: padding-right;
438421
}
439-
.sidebar-open .note-container {
440-
padding-right: 0px;
441-
}
442422
}
443423
444424
/* distraction free styles */

src/components/NoteRich.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="text-editor-wrapper" :class="{ loading: loading, 'icon-error': !loading && (!note || note.error), 'sidebar-open': sidebarOpen, 'is-mobile': isMobile }">
2+
<div class="text-editor-wrapper" :class="{ loading: loading, 'icon-error': !loading && (!note || note.error), 'is-mobile': isMobile }">
33
<div v-show="!loading" ref="editor" class="text-editor" />
44
</div>
55
</template>
@@ -41,9 +41,6 @@ export default {
4141
isNewNote() {
4242
return routeIsNewNote(this.$route)
4343
},
44-
sidebarOpen() {
45-
return store.state.app.sidebarOpen
46-
},
4744
},
4845
4946
watch: {

src/components/NotesList.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
<NoteItem v-for="note in notes"
44
:key="note.id"
55
:note="note"
6+
:renaming="isRenaming(note.id)"
67
@note-selected="onNoteSelected"
8+
@start-renaming="onStartRenaming"
79
/>
810
</ul>
911
</template>
@@ -24,11 +26,22 @@ export default {
2426
required: true,
2527
},
2628
},
27-
29+
data() {
30+
return {
31+
renamingNotes: [],
32+
}
33+
},
2834
methods: {
2935
onNoteSelected(noteId) {
3036
this.$emit('note-selected', noteId)
3137
},
38+
onStartRenaming(noteId) {
39+
this.renamingNotes.push(noteId)
40+
},
41+
isRenaming(noteId) {
42+
return this.renamingNotes.includes(noteId)
43+
},
44+
3245
},
3346
}
3447
</script>

0 commit comments

Comments
 (0)