1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 01:36:22 +00:00

bind delete button

This commit is contained in:
Rokt33r
2015-05-29 18:58:46 +09:00
parent e5b265e497
commit 7c9d276a1f
6 changed files with 27 additions and 140 deletions

View File

@@ -22,9 +22,16 @@ angular.module('codexen.services')
return $http.get(url)
}
var destroy = function (id) {
var url = apiUrl + 'snippets/id/' + id
return $http.delete(url)
}
return {
findByUser: findByUser,
create: create,
show: show
show: show,
delete: destroy
}
})

View File

@@ -1,6 +1,6 @@
/* global angular */
angular.module('codexen.states')
.controller('SnippetsDetailController', function (Snippet, $state) {
.controller('SnippetsDetailController', function (Snippet, $state, $rootScope) {
var vm = this
vm.isLoaded = false
@@ -8,8 +8,16 @@ angular.module('codexen.states')
var snippetId = $state.params.id
Snippet.show(snippetId)
.success(function (data) {
vm.snippet = data.snippet
vm.isLoaded = true
.success(function (data) {
vm.snippet = data.snippet
vm.isLoaded = true
})
vm.delete = function () {
Snippet.delete(vm.snippet._id)
.success(function () {
$rootScope.$broadcast('snippetDeleted')
$state.go('snippets')
})
}
})

View File

@@ -7,7 +7,7 @@
<span class="detail-header-control pull-right">
<button type="button" name="button" class="btn btn-default"><i class="fa fa-share"></i></button>
<button type="button" name="button" class="btn btn-default"><i class="fa fa-edit"></i></button>
<button type="button" name="button" class="btn btn-danger"><i class="fa fa-trash"></i></button>
<button ng-click="vm.delete()" type="button" name="button" class="btn btn-danger"><i class="fa fa-trash"></i></button>
</span>
</div>
@@ -18,7 +18,7 @@
</div>
<div ng-if="vm.isLoaded" class="">
<p class="tags">
<p class="tags" ng-if="vm.snippet.tags">
<small><i class="fa fa-tags"></i></small> <a ng-repeat="tag in vm.snippet.tags" ng-bind="tag.name" href="#" class="label label-default"></a>
</p>
<label>Description</label>

View File

@@ -37,4 +37,8 @@ angular.module('codexen.states')
laodSnippets()
})
$scope.$on('snippetDeleted', function () {
laodSnippets()
})
})

View File

@@ -34,7 +34,7 @@
</div>
</div>
<p ng-bind="snippet.description"></p>
<p class="tags">
<p class="tags" ng-if="snippet.tags.length">
<small><i class="fa fa-tags"></i></small> <a ng-repeat="tag in snippet.tags" ng-bind="tag.name" href="#" class="label label-default"></a>
</p>
</li>

132
test.js
View File

@@ -1,132 +0,0 @@
var data = {
ABAP: ["abap"],
ABC: ["abc"],
ActionScript:["as"],
ADA: ["ada|adb"],
Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"],
AsciiDoc: ["asciidoc|adoc"],
Assembly_x86:["asm"],
AutoHotKey: ["ahk"],
BatchFile: ["bat|cmd"],
C9Search: ["c9search_results"],
C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp"],
Cirru: ["cirru|cr"],
Clojure: ["clj|cljs"],
Cobol: ["CBL|COB"],
coffee: ["coffee|cf|cson|^Cakefile"],
ColdFusion: ["cfm"],
CSharp: ["cs"],
CSS: ["css"],
Curly: ["curly"],
D: ["d|di"],
Dart: ["dart"],
Diff: ["diff|patch"],
Dockerfile: ["^Dockerfile"],
Dot: ["dot"],
Dummy: ["dummy"],
DummySyntax: ["dummy"],
Eiffel: ["e"],
EJS: ["ejs"],
Elixir: ["ex|exs"],
Elm: ["elm"],
Erlang: ["erl|hrl"],
Forth: ["frt|fs|ldr"],
FTL: ["ftl"],
Gcode: ["gcode"],
Gherkin: ["feature"],
Gitignore: ["^.gitignore"],
Glsl: ["glsl|frag|vert"],
golang: ["go"],
Groovy: ["groovy"],
HAML: ["haml"],
Handlebars: ["hbs|handlebars|tpl|mustache"],
Haskell: ["hs"],
haXe: ["hx"],
HTML: ["html|htm|xhtml"],
HTML_Ruby: ["erb|rhtml|html.erb"],
INI: ["ini|conf|cfg|prefs"],
Io: ["io"],
Jack: ["jack"],
Jade: ["jade"],
Java: ["java"],
JavaScript: ["js|jsm"],
JSON: ["json"],
JSONiq: ["jq"],
JSP: ["jsp"],
JSX: ["jsx"],
Julia: ["jl"],
LaTeX: ["tex|latex|ltx|bib"],
Lean: ["lean|hlean"],
LESS: ["less"],
Liquid: ["liquid"],
Lisp: ["lisp"],
LiveScript: ["ls"],
LogiQL: ["logic|lql"],
LSL: ["lsl"],
Lua: ["lua"],
LuaPage: ["lp"],
Lucene: ["lucene"],
Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"],
Markdown: ["md|markdown"],
Mask: ["mask"],
MATLAB: ["matlab"],
MEL: ["mel"],
MUSHCode: ["mc|mush"],
MySQL: ["mysql"],
Nix: ["nix"],
ObjectiveC: ["m|mm"],
OCaml: ["ml|mli"],
Pascal: ["pas|p"],
Perl: ["pl|pm"],
pgSQL: ["pgsql"],
PHP: ["php|phtml"],
Powershell: ["ps1"],
Praat: ["praat|praatscript|psc|proc"],
Prolog: ["plg|prolog"],
Properties: ["properties"],
Protobuf: ["proto"],
Python: ["py"],
R: ["r"],
RDoc: ["Rd"],
RHTML: ["Rhtml"],
Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"],
Rust: ["rs"],
SASS: ["sass"],
SCAD: ["scad"],
Scala: ["scala"],
Scheme: ["scm|rkt"],
SCSS: ["scss"],
SH: ["sh|bash|^.bashrc"],
SJS: ["sjs"],
Smarty: ["smarty|tpl"],
snippets: ["snippets"],
Soy_Template:["soy"],
Space: ["space"],
SQL: ["sql"],
SQLServer: ["sqlserver"],
Stylus: ["styl|stylus"],
SVG: ["svg"],
Tcl: ["tcl"],
Tex: ["tex"],
Text: ["txt"],
Textile: ["textile"],
Toml: ["toml"],
Twig: ["twig"],
Typescript: ["ts|typescript|str"],
Vala: ["vala"],
VBScript: ["vbs|vb"],
Velocity: ["vm"],
Verilog: ["v|vh|sv|svh"],
VHDL: ["vhd|vhdl"],
XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"],
XQuery: ["xq"],
YAML: ["yaml|yml"],
Django: ["html"]
}
var arr = []
for(var key in data){
arr.push({name:key, mode:data[key]})
}
console.log(JSON.stringify(arr, null, ' '))