-
Notifications
You must be signed in to change notification settings - Fork 173
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
Add new props #613
Add new props #613
Changes from all commits
33d002b
972c17c
cf0a8ff
d2f266e
cef4c97
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<!-- | ||
- @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com> | ||
- | ||
- @author John Molakvoæ <skjnldsv@protonmail.com> | ||
- | ||
- @license GNU AGPL version 3 or any later version | ||
- | ||
- This program is free software: you can redistribute it and/or modify | ||
- it under the terms of the GNU Affero General Public License as | ||
- published by the Free Software Foundation, either version 3 of the | ||
- License, or (at your option) any later version. | ||
- | ||
- This program is distributed in the hope that it will be useful, | ||
- but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
- GNU Affero General Public License for more details. | ||
- | ||
- You should have received a copy of the GNU Affero General Public License | ||
- along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
- | ||
--> | ||
|
||
<template> | ||
<div class="grid-span-2 property"> | ||
|
||
<!-- title --> | ||
<property-title :icon="'icon-add'" :readable-name="t('contacts', 'Add new property')" /> | ||
|
||
<div class="property__row"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BEM! 💥 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An issue? Or was it just a comment stating the awesomeness of bem? :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's the css way of stating the awesomeness of an app maintainer :) |
||
<div class="property__label" /> | ||
|
||
<!-- type selector --> | ||
<multiselect :options="availableProperties" :placeholder="t('contacts', 'Choose property type')" class="multiselect-vue property__value" | ||
track-by="id" label="name" @input="addProp" /> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import rfcProps from '../../models/rfcProps.js' | ||
import Contact from '../../models/contact' | ||
import propertyTitle from '../Properties/PropertyTitle' | ||
|
||
import Multiselect from 'vue-multiselect' | ||
|
||
export default { | ||
name: 'ContactDetailsAddNewProp', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you remove "new" from the name or find another way of shortening it? Or like above use just "contact" or "details" but not both? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Like 'ContactAddNewProp' ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's what I meant. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes we totally can. Can you create a pull request or an issue? :) |
||
|
||
components: { | ||
propertyTitle, | ||
Multiselect | ||
}, | ||
|
||
props: { | ||
contact: { | ||
type: Contact, | ||
default: null | ||
} | ||
}, | ||
|
||
computed: { | ||
availableProperties() { | ||
return Object.keys(rfcProps.properties).map(key => { | ||
return { | ||
id: key, | ||
name: rfcProps.properties[key].readableName | ||
} | ||
}) | ||
} | ||
}, | ||
|
||
methods: { | ||
addProp({ id }) { | ||
let defaultData = rfcProps.properties[id].defaultValue | ||
let property = this.contact.vCard.addPropertyWithValue(id, defaultData ? defaultData.value : '') | ||
if (defaultData && defaultData.type) { | ||
property.setParameter('type', defaultData.type) | ||
} | ||
} | ||
} | ||
} | ||
</script> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,17 +35,19 @@ export default function parseVcf(data = '', addressbook) { | |
|
||
importState.total = vCards.length | ||
|
||
return vCards.map(vCard => { | ||
// Not using map because we want to only push valid contacts | ||
// map force to return at least undefined | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 Good to know and it's nice to see a real life example of reduce being used. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😊 |
||
return vCards.reduce((contacts, vCard) => { | ||
try { | ||
// console.log(vCards.indexOf(vCard)) | ||
let contact = new Contact(vCard, addressbook) | ||
importState.accepted++ | ||
return contact | ||
contacts.push(contact) | ||
} catch (e) { | ||
// Parse error! Do not stop here... | ||
importState.denied++ | ||
// eslint-disable-next-line | ||
console.error(e) | ||
} | ||
}) | ||
return contacts | ||
}, []) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had actually been talking about whether to use both "contact" and "details" or not when naming the component we created for the avatar management issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! What did you settle for? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ContactAvatar, like you. My concern is just that we also have the list avatar to think of.