_.each(tagGroups, function (tags) {
     tagGroupRepo.add(tags,{
         success: function () {
             persistedTagGroupCount++;
             if (persistedTagGroupCount === newTagGroupCount) {
                 persistBookmarks();
             }
         }
     })
 });
        create: function (bookmark, tags, op) {
            var me = this;

            if (tags) {
                tagGroupRepo.add(tags, {
                    success: function (tagGroup) {
                        bookmark.tagGroupId = tagGroup.id;
                        me.add(bookmark, op);
                    },
                    failure: op.failure
                })
            } else {
                me.add(bookmark, op);
            }
        },
 create: function (bookmark, tags, op) {
     if (tags) {
         tagGroupRepo.add(tags, {
             success: function (tagGroup) {
                 bookmark.tagGroupId = tagGroup.id;
                 idb.create(dbKey, bookmark, op);
             },
             failure: function (error) {
                 console.log(error);
             }
         })
     } else {
         idb.create(dbKey, bookmark, op);
     }
 },
        add: function (bookmark, op) {
            var me = this;

            if (bookmark.tags) {
                tagGroupRepo.add(bookmark.tags, {
                    success: function (tagGroup) {
                        bookmark.tagGroupId = tagGroup.id;
                        delete bookmark.tags;
                        idb.add(dbKey, bookmark, 'url', op);
                    },
                    failure: op.failure
                })
            } else {
                idb.add(dbKey, bookmark, 'url', op);
            }

        },
Esempio n. 5
0
        $scope.save = function () {
            $scope.isSaving = true;

            var tags = _.map($scope.selectedTags, function (str) {
                return str.toLowerCase();
            });
            tagGroupRepo.add(tags, {
                success: function (tagGroup) {
                    bookmarkRepo.add({
                        title: $scope.title,
                        url: $scope.url,
                        dateAdded: new Date(),
                        tagGroupId: tagGroup.id
                    }, {
                        success: function () {
                            window.close();
                        },
                        failure: function (results) {
                            console.log(results);
                        }
                    });
                }
            })
        };