diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-11-19 18:51:38 +0100 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-11-19 18:52:50 +0100 |
commit | 85c3b1a00ff3261333ad68e816d9535eb10f6c4d (patch) | |
tree | 3205faf713e18f6d0f4ef3524e4222b390dd231e /src/components | |
parent | bfa38cba598fb7c3391334b6cd7fa9a7095dfc43 (diff) |
JSDoc cleanup and better code comments
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/ContactDetails.vue | 19 | ||||
-rw-r--r-- | src/components/ContactDetails/ContactDetailsAddNewProp.vue | 20 | ||||
-rw-r--r-- | src/components/ContactDetails/ContactDetailsAvatar.vue | 13 | ||||
-rw-r--r-- | src/components/ContactDetails/ContactDetailsProperty.vue | 6 | ||||
-rw-r--r-- | src/components/ContactsList/ContactsListItem.vue | 4 | ||||
-rw-r--r-- | src/components/Properties/PropertyGroups.vue | 10 | ||||
-rw-r--r-- | src/components/Settings/SettingsAddressbookShare.vue | 4 |
7 files changed, 57 insertions, 19 deletions
diff --git a/src/components/ContactDetails.vue b/src/components/ContactDetails.vue index 5ba9138c..c559bd9a 100644 --- a/src/components/ContactDetails.vue +++ b/src/components/ContactDetails.vue @@ -109,10 +109,9 @@ <property-select :prop-model="addressbookModel" :value.sync="addressbook" :is-first-property="true" :is-last-property="true" :property="{}" class="property--addressbooks property--last" /> - <!-- Groups always visible. --> + <!-- Groups always visible --> <property-groups :prop-model="groupsModel" :value.sync="groups" :contact="contact" - :is-read-only="isReadOnly" :is-first-property="true" :is-last-property="true" - class="property--addressbooks property--last" /> + :is-read-only="isReadOnly" class="property--groups property--last" /> <!-- new property select --> <add-new-prop v-if="!isReadOnly" :contact="contact" /> @@ -180,7 +179,7 @@ export default { /** * Warning messages * - * @returns {Object|Boolean} + * @returns {Object|boolean} */ warning() { if (!this.contact.dav) { @@ -200,7 +199,7 @@ export default { /** * Conflict message * - * @returns {String|Boolean} + * @returns {string|boolean} */ conflict() { if (this.contact.conflict) { @@ -288,10 +287,15 @@ export default { } }, + /** + * Fake model to use the propertyGroups component + * + * @returns {Object} + */ groupsModel() { return { - readableName: t('contacts', 'Groups') - // icon: 'icon-address-book' + readableName: t('contacts', 'Groups'), + icon: 'icon-contacts' } }, @@ -306,7 +310,6 @@ export default { return this.contact.groups }, set: function(data) { - console.log(data); let property = this.contact.vCard.getFirstProperty('categories') if (!property) { // Ical.js store comma separated by an Array of array of string diff --git a/src/components/ContactDetails/ContactDetailsAddNewProp.vue b/src/components/ContactDetails/ContactDetailsAddNewProp.vue index 5ec61970..74baa7a0 100644 --- a/src/components/ContactDetails/ContactDetailsAddNewProp.vue +++ b/src/components/ContactDetails/ContactDetailsAddNewProp.vue @@ -56,12 +56,26 @@ export default { }, computed: { + /** + * List of properties that the contact already have + * + * @returns {string[]} + */ usedProperties() { return this.contact.jCal[1].map(prop => prop[0]) }, + + /** + * List of every properties you are allowed to add + * on this contact + * + * @returns {Object[]} + */ availableProperties() { return Object.keys(rfcProps.properties) + // only allow to add multiple properties OR props that are not yet in the contact .filter(prop => prop.multiple || this.usedProperties.indexOf(prop) === -1) + // usable array of objects .map(key => { return { id: key, @@ -72,6 +86,12 @@ export default { }, methods: { + /** + * Add a new prop to the contact + * + * @param {Object} data destructuring object + * @param {string} data.id the id of the property. e.g fn + */ addProp({ id }) { let defaultData = rfcProps.properties[id].defaultValue let property = this.contact.vCard.addPropertyWithValue(id, defaultData ? defaultData.value : '') diff --git a/src/components/ContactDetails/ContactDetailsAvatar.vue b/src/components/ContactDetails/ContactDetailsAvatar.vue index c142c82f..c98264b6 100644 --- a/src/components/ContactDetails/ContactDetailsAvatar.vue +++ b/src/components/ContactDetails/ContactDetailsAvatar.vue @@ -57,6 +57,11 @@ export default { } }, methods: { + /** + * Handler to store a new photo on the current contact + * + * @param {Object} event the event object containing the image + */ processFile(event) { if (event.target.files) { let file = event.target.files[0] @@ -73,10 +78,18 @@ export default { reader.readAsDataURL(file) } }, + + /** + * Toggle the full image preview + */ toggleSize() { // maximise or minimise avatar photo this.maximizeAvatar = !this.maximizeAvatar }, + + /** + * Remove the contact's picture + */ removePhoto() { this.contact.vCard.removeProperty('photo') this.maximizeAvatar = !this.maximizeAvatar diff --git a/src/components/ContactDetails/ContactDetailsProperty.vue b/src/components/ContactDetails/ContactDetailsProperty.vue index f5de4fd5..129a4dd2 100644 --- a/src/components/ContactDetails/ContactDetailsProperty.vue +++ b/src/components/ContactDetails/ContactDetailsProperty.vue @@ -113,7 +113,7 @@ export default { /** * Return the type of the prop e.g. FN * - * @returns {String} + * @returns {string} */ propName() { return this.property.name @@ -122,7 +122,7 @@ export default { * Return the type or property * * @see src/models/rfcProps - * @returns {String} + * @returns {string} */ propType() { // if we have a force type set, use it! @@ -147,7 +147,7 @@ export default { * but make sure to include the selected one * in the final list * - * @returns {Array<Object>} + * @returns {Object[]} */ sortedModelOptions() { if (this.propModel.options) { diff --git a/src/components/ContactsList/ContactsListItem.vue b/src/components/ContactsList/ContactsListItem.vue index 8bda16a7..4453390b 100644 --- a/src/components/ContactsList/ContactsListItem.vue +++ b/src/components/ContactsList/ContactsListItem.vue @@ -58,7 +58,7 @@ export default { /** * Is this matching the current search ? * - * @returns {Boolean} + * @returns {boolean} */ matchSearch() { if (this.searchQuery !== '') { @@ -69,7 +69,7 @@ export default { /** * avatar color based on server toRgb method and the displayName - * @returns {String} the color in css format + * @returns {string} the color in css format */ colorAvatar() { try { diff --git a/src/components/Properties/PropertyGroups.vue b/src/components/Properties/PropertyGroups.vue index 70407a00..0ee7f23c 100644 --- a/src/components/Properties/PropertyGroups.vue +++ b/src/components/Properties/PropertyGroups.vue @@ -23,6 +23,8 @@ <template> <div v-if="propModel" class="grid-span-2 property"> + <!-- NO title if first element for groups --> + <div class="property__row"> <div class="property__label">{{ propModel.readableName }}</div> @@ -107,7 +109,7 @@ export default { /** * Dispatch contact addition to group * - * @param {String} groupName the group name + * @param {string} groupName the group name */ async addContactToGroup(groupName) { await this.$store.dispatch('addContactToGroup', { @@ -120,7 +122,7 @@ export default { /** * Dispatch contact removal from group * - * @param {String} groupName the group name + * @param {string} groupName the group name */ removeContactToGroup(groupName) { this.$store.dispatch('removeContactToGroup', { @@ -132,8 +134,8 @@ export default { /** * Validate groupname and dispatch creation * - * @param {String} groupName the group name - * @returns {Boolean} + * @param {string} groupName the group name + * @returns {boolean} */ validateGroup(groupName) { // Only allow characters without vcard special chars diff --git a/src/components/Settings/SettingsAddressbookShare.vue b/src/components/Settings/SettingsAddressbookShare.vue index 10350fea..0095ae02 100644 --- a/src/components/Settings/SettingsAddressbookShare.vue +++ b/src/components/Settings/SettingsAddressbookShare.vue @@ -91,7 +91,7 @@ export default { * @param {string} data.user the userId * @param {string} data.displayName the displayName * @param {string} data.uri the sharing principalScheme uri - * @param {Boolean} data.isGroup is this a group ? + * @param {boolean} data.isGroup is this a group ? */ shareAddressbook({ user, displayName, uri, isGroup }) { let addressbook = this.addressbook @@ -101,7 +101,7 @@ export default { /** * Use the cdav client call to find matches to the query from the existing Users & Groups * - * @param {String} query + * @param {string} query */ findSharee: debounce(async function(query) { this.isLoading = true |