Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue settings addressbook popovermenu #618

Merged
merged 17 commits into from Sep 7, 2018
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 22 additions & 0 deletions css/settings/settings-addressbook.scss
Expand Up @@ -21,6 +21,24 @@
*
*/


.new-addressbook {
padding: 6px 0;
input {
border: none;
margin: 0;
}
#new-addressbook-form {
width: 100%;
display: inline-flex;
border: #dbdbdb solid 1px;
border-radius: 3px;
}
input.new-addressbook__submit {
opacity: 0.6;
}
}

.addressbook {
display: flex;
align-items: center;
Expand All @@ -33,7 +51,10 @@
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
padding-left: 7px;
opacity: 0.7;
}

&__share,
&__menu .icon-more {
width: 44px;
Expand All @@ -45,6 +66,7 @@
opacity: .7;
}
}

&__share {
margin-left: auto;
}
Expand Down
38 changes: 19 additions & 19 deletions js/contacts.js

Large diffs are not rendered by default.

68 changes: 39 additions & 29 deletions src/components/Settings/SettingsAddressbook.vue
Expand Up @@ -22,14 +22,23 @@
-->
<template>
<div>
<li :class="{'disabled': !addressbook.enabled}" class="addressbook">
<li v-if="editingName" class="new-addressbook">
sleepypioneer marked this conversation as resolved.
Show resolved Hide resolved
<form id="new-addressbook-form" name="new-addressbook-form"
class="new-addressbook__form" addressbooks="[object Object]"
@submit.prevent="updateAddressbookName">
<!-- rename addressbook input -->
<input :placeholder="addressbook.displayName"
v-model="newName" type="text">
<input type="submit" value=""
class="new-addressbook__submit inline-button icon-confirm action pull-right">
</form>
</li>
<li v-else :class="{'disabled': !addressbook.enabled}" class="addressbook">
<!-- addressbook name -->
<span class="addressbook__name">{{ addressbook.displayName }}</span>
<!-- sharing button -->
<a href="#" class="addressbook__share icon-shared"
@click="toggleShare" />
<!-- rename addressbook name -->
<rename-addressbook-field v-if="editingName" />
<!-- popovermenu -->
<a v-click-outside="closeMenu" href="#" class="addressbook__menu"
@click="toggleMenu">
Expand Down Expand Up @@ -75,7 +84,7 @@ export default {
menuOpen: false,
shareOpen: false,
editingName: false,
newName: '' // new name for addressbook
newName: this.addressbook.displayName // new name for addressbook
}
},
computed: {
Expand All @@ -85,48 +94,47 @@ export default {
// building the popover menu
menu() {
return [{
href: '#',
href: '/remote.php/dav/addressbooks/users/admin/Contacts/',
sleepypioneer marked this conversation as resolved.
Show resolved Hide resolved
icon: 'icon-public',
text: 'Copy link',
action: () => {
alert('share link')
}
text: t('settings', 'Copy link'),
action: ''
sleepypioneer marked this conversation as resolved.
Show resolved Hide resolved
},
{
href: '#',
href: '/remote.php/dav/addressbooks/users/admin/Contacts/?export',
icon: 'icon-download',
text: 'Download',
action: () => {
alert('download')
}
text: t('settings', 'Download'),
action: ''
},
{
icon: 'icon-rename',
text: 'Rename',
action: () => {
/* this.editingName = true */
}
text: t('settings', 'Rename'),
action: this.renameAddressbook
},
{
icon: 'checkbox',
text: 'Enabled',
text: this.enabled ? t('settings', 'Enabled') : t('settings', 'Disabled'),
sleepypioneer marked this conversation as resolved.
Show resolved Hide resolved
input: 'checkbox',
model: this.enabled,
action: () => {
alert('change') // eslint-disable-line
this.$store.dispatch('toggleAddressbookEnabled', this.addressbook)
}
action: this.toggleAddressbookEnabled
},
{
icon: 'icon-delete',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember that we do not want the user to delete her/his last addressbook 🤔 👍
We might require a small check there!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool can you give me a pointer to somewhere this check is done so I have a template to follow?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess add a conditional check on the computed for the menu.

if (addressbooks.length > 1) {
    menu.push({itemObject})
}

There a re different check like that, for example, you cannot change the enable state of a readonly addressbook, nor rename it, stuff like that :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arh got you, good point not thought of this 😀

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but wait why wouldn't we let them delete the last one? @skjnldsv

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, but we need to be prepare for the contact to not find anything and adding a message saying "please create an addressbook before adding any contact" or somthing :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which solution do you prefer 😸 ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's easier to prevent the removal of the last one than adding checks everywhere to force the user to add a new one. :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool 😎 thank you 👍

text: 'Delete',
action: () => {
this.$store.dispatch('deleteAddressbook', this.addressbook)
}
text: t('settings', 'Delete'),
action: this.deleteAddressbook
}]
}
},
mounted() {
// required if popup needs to stay opened after menu click
this.popupItem = this.$el
sleepypioneer marked this conversation as resolved.
Show resolved Hide resolved
},
methods: {
toggleAddressbookEnabled() {
this.$store.dispatch('toggleAddressbookEnabled', this.addressbook)
},
deleteAddressbook() {
this.$store.dispatch('deleteAddressbook', this.addressbook)
},
toggleShare() {
this.shareOpen = !this.shareOpen
},
Expand All @@ -136,11 +144,13 @@ export default {
toggleMenu() {
this.menuOpen = !this.menuOpen
},
renameAddressBook() {
renameAddressbook() {
this.editingName = true
},
updateAddressbookName() {
let addressbook = this.addressbook
let newName = this.newName
this.$store.dispatch('renameAddressbook', { addressbook, newName })
this.$store.dispatch('renameAddressbook', { addressbook, newName }).then(this.editingName = false)
sleepypioneer marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/SettingsSection.vue
Expand Up @@ -22,7 +22,7 @@

<template>
<div>
<ul id="address-book-list">
<ul id="addressbook-list">
<address-book v-for="addressbook in addressbooks" :key="addressbook.id" :addressbook="addressbook" />
</ul>
<add-address-book :addressbooks="addressbooks" />
Expand Down
4 changes: 2 additions & 2 deletions src/components/core/popoverMenu/popoverItem.vue
Expand Up @@ -32,8 +32,8 @@
<!-- If item.input is set instead, an put will be used -->
<span v-else-if="item.input" class="menuitem">
<input :id="item.key" :type="item.input" :class="item.input"
v-model="item.model" @change="item.action">
<label :for="item.key">{{ item.text }}</label>
v-model="item.model">
<label :for="item.key" @click="item.action">{{ item.text }}</label>
sleepypioneer marked this conversation as resolved.
Show resolved Hide resolved
</span>
<!-- If item.action is set instead, a button will be used -->
<button v-else-if="item.action" @click="item.action">
Expand Down
32 changes: 29 additions & 3 deletions src/store/addressbooks.js
Expand Up @@ -182,9 +182,7 @@ const mutations = {
}
}
})
console.log(addressbook) // eslint-disable-line
sharee = addressbook.shares.find(search => search === sharee)
console.log(sharee) // eslint-disable-line
sharee.writeable = !sharee.writeable
}

Expand Down Expand Up @@ -227,7 +225,35 @@ const actions = {
},

/**
* Retrieve the contacts for the specified address book
* Delete Addressbook
* @param {Object} context Current context
* @param {Object} addressbook
*/
deleteAddressbook(context, addressbook) {
context.commit('deleteAddressbook', addressbook)
},

/**
* Toggle whether a Addressbook is Enabled
* @param {Object} context Current context
* @param {Object} addressbook
*/
toggleAddressbookEnabled(context, addressbook) {
context.commit('toggleAddressbookEnabled', addressbook)
},

/**
* Rename a Addressbook
* @param {Object} context Current context
* @param {Object} data.addressbook
* @param {String} data.newName
*/
renameAddressbook(context, { addressbook, newName }) {
context.commit('renameAddressbook', { addressbook, newName })
},

/**
* Retrieve the contacts of the specified addressbook
* and commit the results
*
* @param {Object} context
Expand Down