Skip to content

Commit

Permalink
allow name edition from sidebar title
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Veyssier <[email protected]>
  • Loading branch information
julien-nc committed May 19, 2024
1 parent 5e3d992 commit edc9acd
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions src/components/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<NcAppSidebar
:open="open"
:name="title"
:name-editable="nameEditable"
:title="title"
:compact="true"
:background="backgroundImageUrl"
Expand All @@ -10,16 +11,17 @@
:active="activeTab"
@update:active="onActiveChanged"
@update:open="$emit('update:open', $event)"
@update:name="tmpName = $event"
@submit-name="onNameSubmit"
@close="$emit('close')">
<!--template #description /-->
<template v-if="false" slot="secondary-actions">
<NcActionButton icon="icon-edit" @click="alert('Edit')">
Edit
<template #secondary-actions>
<NcActionButton @click="onRenameClick">
<template #icon>
<PencilIcon />
</template>
{{ t('cospend', 'Rename') }}
</NcActionButton>
<NcActionButton icon="icon-delete" @click="alert('Delete')">
Delete
</NcActionButton>
<NcActionLink icon="icon-external" title="Link" href="https://nextcloud.com" />
</template>
<NcAppSidebarTab v-if="!pageIsPublic"
id="sharing"
Expand Down Expand Up @@ -110,6 +112,7 @@
</template>

<script>
import PencilIcon from 'vue-material-design-icons/Pencil.vue'
import LightningBoltIcon from 'vue-material-design-icons/LightningBolt.vue'
import ShapeIcon from 'vue-material-design-icons/Shape.vue'
import TagIcon from 'vue-material-design-icons/Tag.vue'
Expand All @@ -121,7 +124,6 @@ import CurrencyIcon from './icons/CurrencyIcon.vue'
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
import NcAppSidebar from '@nextcloud/vue/dist/Components/NcAppSidebar.js'
import NcAppSidebarTab from '@nextcloud/vue/dist/Components/NcAppSidebarTab.js'
import NcActionLink from '@nextcloud/vue/dist/Components/NcActionLink.js'
import SharingTabSidebar from './SharingTabSidebar.vue'
import SettingsTabSidebar from './SettingsTabSidebar.vue'
Expand All @@ -140,7 +142,6 @@ export default {
NcActionButton,
NcAppSidebar,
NcAppSidebarTab,
NcActionLink,
SharingTabSidebar,
SettingsTabSidebar,
CategoryOrPmManagement,
Expand All @@ -151,6 +152,7 @@ export default {
CogIcon,
ShareVariantIcon,
TagIcon,
PencilIcon,
},
props: {
open: {
Expand All @@ -177,6 +179,8 @@ export default {
data() {
return {
backgroundImageUrl: generateUrl('/apps/theming/img/core/filetypes/folder.svg?v=' + (window.OCA?.Theming?.cacheBuster || 0)),
nameEditable: false,
tmpName: '',
}
},
computed: {
Expand Down Expand Up @@ -247,6 +251,17 @@ export default {
focusOnAddMember() {
this.$refs.settingsTab.focusOnAddMember()
},
onRenameClick() {
this.nameEditable = true
this.tmpName = this.project.name
},
onNameSubmit() {
this.nameEditable = false
if (this.project.name !== this.tmpName) {
cospend.projects[this.projectId].name = this.tmpName
this.$emit('project-edited', this.projectId)
}
},
},
}
</script>
Expand Down

0 comments on commit edc9acd

Please sign in to comment.