1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-30 01:51:53 +00:00

add list/show routes

This commit is contained in:
Rokt33r
2015-06-09 03:21:58 +09:00
parent 5ad5da47d2
commit f2daf5e9f4
12 changed files with 37 additions and 24 deletions

View File

@@ -14,12 +14,12 @@ angular.module('codexen')
callSign: vm.snippet.callSign,
mode: vm.snippet.mode == null ? null : vm.snippet.mode.toLowerCase(),
content: vm.snippet.content,
tags: angular.isArray(vm.snippet.tags) ? vm.snippet.tags.map(function (tag) { return {_id: tag._id, name: tag.name} }) : []
tags: angular.isArray(vm.snippet.tags) ? vm.snippet.tags.map(function (tag) { return tag.name }) : []
}
Snippet.update(vm.snippet._id, params)
.success(function (data) {
$modalInstance.close(data.snippet)
$modalInstance.close(data)
console.log('snippet created!', data)
})
}

View File

@@ -11,12 +11,12 @@ angular.module('codexen')
callSign: vm.callSign,
mode: vm.mode == null ? null : vm.mode.toLowerCase(),
content: vm.content,
tags: angular.isArray(vm.tags) ? vm.tags.map(function (tag) { return {_id: tag._id, name: tag.name} }) : []
tags: angular.isArray(vm.tags) ? vm.tags.map(function (tag) { return tag.name }) : []
}
Snippet.create(params)
.success(function (data) {
$modalInstance.close(data.snippet)
$modalInstance.close(data)
})
}

View File

@@ -7,14 +7,16 @@ angular.module('codexen')
var snippetId = $state.params.id
Snippet.show(snippetId)
Snippet.show(snippetId, {
'include': ['Tag']
})
.success(function (data) {
vm.snippet = data.snippet
vm.snippet = data
vm.isLoaded = true
})
vm.delete = function () {
Snippet.delete(vm.snippet._id)
Snippet.delete(vm.snippet.id)
.success(function () {
$rootScope.$broadcast('snippetDeleted')
})

View File

@@ -7,13 +7,13 @@ angular.module('codexen')
var loadSnippets = function () {
if ($auth.isAuthenticated) {
console.log($auth.getPayload())
var userId = $auth.getPayload().sub
Snippet.findByUser(userId)
Snippet.findMine({
'include': ['Tag']
})
.success(function (data) {
console.log('snippets fetched', data.snippets)
console.log('snippets fetched', data)
vm.isLoaded = true
vm.snippets = data.snippets
vm.snippets = data
vm.isGuest = false
})
}else {