Skip to content
This repository has been archived by the owner on Jan 16, 2018. It is now read-only.

Commit

Permalink
[feature] Add tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Noëlie Andrieu committed Jan 19, 2017
1 parent d1228c0 commit 557c641
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
18 changes: 18 additions & 0 deletions app/collections/tags.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Tags extends Backbone.Collection
initialize: ->
@listenToOnce @, 'sync', -> (new TagsListener()).watch @


# We convert all tags to lowercase and remove duplicates at pers time
parse: (tags) ->
_.uniq tags, (tag) -> tag.name.toLowerCase()
Expand Down Expand Up @@ -59,6 +60,23 @@ module.exports = class FilteredTags extends Filtered
.value()



create: (data={}, options={}) ->
callback = options.success or null

cozy.init { isV2: true }
cozy.create 'io.cozy.tags', data
.then (resp) =>
# Add model to collection
# if data is correct
@add resp, options

callback resp, @ if callback

, () =>
console.log '(save.error) TAG', arguments


update: ->
@updateRefs()
super
9 changes: 7 additions & 2 deletions app/views/models/contact.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,17 @@ module.exports = class ContactViewModel extends Backbone.ViewModel

viewEvents:
'edit:cancel': 'reset'
'form:submit': _.ary @::save, 0
'delete': _.ary @::destroy, 0

# TODO: handle all these cases
'tags:update': 'updateTags'
'tags:add': 'addNewTag'
'form:field:add': 'onAddField'
'form:submit': _.ary @::save, 0

# TODO: handle all these cases
'export': 'downloadAsVCF'
'delete': _.ary @::destroy, 0



proxy: ['toString', 'toHighlightedString', 'match']
Expand Down

0 comments on commit 557c641

Please sign in to comment.