1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-16 19:21:52 +00:00

add Recipes(scaffolding)

This commit is contained in:
Rokt33r
2015-06-23 19:18:00 +09:00
parent 7c2cbfb32e
commit 0e6fe35ca4
36 changed files with 801 additions and 62 deletions

View File

@@ -0,0 +1,16 @@
/* global angular */
angular.module('codexen')
.controller('DeleteRecipeModalController', function ($modalInstance, Recipe, recipe) {
var vm = this
vm.submit = function () {
Recipe.delete(recipe.id)
.success(function (recipe) {
$modalInstance.close(recipe)
})
}
vm.cancel = function () {
$modalInstance.dismiss()
}
})

View File

@@ -0,0 +1,42 @@
/* global angular */
angular.module('codexen')
.controller('EditRecipeModalController', function (Recipe, Tag, $modalInstance, recipe) {
var vm = this
vm.recipe = recipe
vm.submit = function () {
var params = {
title: vm.recipe.title,
content: vm.recipe.content,
Tags: angular.isArray(vm.recipe.Tags) ? vm.recipe.Tags.map(function (tag) { return tag.name }) : []
}
Recipe.update(vm.recipe.id, params)
.success(function (data) {
$modalInstance.close(data)
})
}
// vm.tags = []
vm.tagCandidates = []
vm.refreshTagCandidates = function (tagName) {
if (tagName == null || tagName === '') return null
return Tag.findByName(tagName)
.success(function (data) {
console.log('tags fetched!!', data)
vm.tagCandidates = data
})
}
vm.transform = function (tagName) {
return {
id: 0,
name: tagName
}
}
vm.cancel = function () {
$modalInstance.dismiss()
}
})

View File

@@ -17,6 +17,7 @@ angular.module('codexen')
Snippet.update(vm.snippet.id, params)
.success(function (data) {
console.log('updated res :', data)
$rootScope.$broadcast('snippetUpdated', snippet)
$modalInstance.close(data)
})
}

View File

@@ -0,0 +1,42 @@
/* global angular */
angular.module('codexen')
.controller('NewRecipeModalController', function (Recipe, Tag, $modalInstance) {
var vm = this
vm.content = ''
vm.submit = function () {
var params = {
title: vm.title,
content: vm.content,
Tags: angular.isArray(vm.Tags) ? vm.Tags.map(function (tag) { return tag.name }) : []
}
Recipe.create(params)
.success(function (data) {
$modalInstance.close(data)
})
}
// vm.tags = []
vm.tagCandidates = []
vm.refreshTagCandidates = function (tagName) {
if (tagName == null || tagName === '') return null
return Tag.findByName(tagName)
.success(function (data) {
console.log('tags fetched!!', data)
vm.tagCandidates = data
})
}
vm.transform = function (tagName) {
return {
id: 0,
name: tagName
}
}
vm.cancel = function () {
$modalInstance.dismiss()
}
})

View File

@@ -1,6 +1,6 @@
/* global angular */
angular.module('codexen')
.controller('NewSnippetModalController', function ($modalInstance, aceModes, $log, Snippet, $rootScope, Tag) {
.controller('NewSnippetModalController', function ($modalInstance, aceModes, $log, Snippet, Tag) {
var vm = this
vm.aceModes = aceModes