Commit 4a1b70f7b2d55bf26be35a2544e3b8e76bdc0585
1 parent
af7bed2a
Exists in
master
and in
4 other branches
add tags to admin project form
Showing
3 changed files
with
48 additions
and
34 deletions
Show diff stats
app/assets/javascripts/projects.js
| @@ -40,3 +40,19 @@ $(document).ready(function(){ | @@ -40,3 +40,19 @@ $(document).ready(function(){ | ||
| 40 | function focusSearch() { | 40 | function focusSearch() { |
| 41 | $("#search").focus(); | 41 | $("#search").focus(); |
| 42 | } | 42 | } |
| 43 | + | ||
| 44 | +function taggifyForm(){ | ||
| 45 | + var tag_field = $('#tag_field').tagify(); | ||
| 46 | + | ||
| 47 | + tag_field.tagify('inputField').autocomplete({ | ||
| 48 | + source: '/tags.json' | ||
| 49 | + }); | ||
| 50 | + | ||
| 51 | + | ||
| 52 | + $('form').submit( function() { | ||
| 53 | + var tag_field = $('#tag_field') | ||
| 54 | + tag_field.val( tag_field.tagify('serialize') ); | ||
| 55 | + return true; | ||
| 56 | + }); | ||
| 57 | +} | ||
| 58 | + |
app/views/admin/projects/_form.html.haml
| 1 | = form_for [:admin, @admin_project] do |f| | 1 | = form_for [:admin, @admin_project] do |f| |
| 2 | -if @admin_project.errors.any? | 2 | -if @admin_project.errors.any? |
| 3 | #error_explanation | 3 | #error_explanation |
| 4 | - %h2= "#{pluralize(@admin_project.errors.count, "error")} prohibited this admin_project from being saved:" | 4 | + %h2= "#{pluralize(@admin_project.errors.count, "error")} prohibited this admin_project from being saved:" |
| 5 | %ul | 5 | %ul |
| 6 | - @admin_project.errors.full_messages.each do |msg| | 6 | - @admin_project.errors.full_messages.each do |msg| |
| 7 | %li= msg | 7 | %li= msg |
| 8 | 8 | ||
| 9 | - .span-24 | ||
| 10 | - .span-12 | ||
| 11 | - .field | ||
| 12 | - = f.label :name | ||
| 13 | - %br | ||
| 14 | - = f.text_field :name | ||
| 15 | - .field | ||
| 16 | - = f.label :code | ||
| 17 | - %br | ||
| 18 | - = f.text_field :code | ||
| 19 | - .field | ||
| 20 | - = f.label :path | ||
| 21 | - %br | ||
| 22 | - = f.text_field :path | ||
| 23 | - .span-10 | ||
| 24 | - .field | ||
| 25 | - = f.label :description | ||
| 26 | - %br | ||
| 27 | - = f.text_area :description | 9 | + .form-row |
| 10 | + = f.label :name | ||
| 11 | + %br | ||
| 12 | + = f.text_field :name | ||
| 13 | + .form-row | ||
| 14 | + = f.label :code | ||
| 15 | + %br | ||
| 16 | + = f.text_field :code | ||
| 17 | + .form-row | ||
| 18 | + = f.label :path | ||
| 19 | + %br | ||
| 20 | + = f.text_field :path | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + .form-row | ||
| 24 | + = f.label :tag_list | ||
| 25 | + %br | ||
| 26 | + = f.text_area :tag_list, :placeholder => "project tags", :style => "height:50px", :id => :tag_field | ||
| 27 | + | ||
| 28 | + .form-row | ||
| 29 | + = f.label :description | ||
| 30 | + %br | ||
| 31 | + = f.text_area :description | ||
| 28 | .clear | 32 | .clear |
| 29 | .actions | 33 | .actions |
| 30 | = f.submit 'Save', :class => "lbutton" | 34 | = f.submit 'Save', :class => "lbutton" |
| 35 | + | ||
| 36 | +:javascript | ||
| 37 | + $(function(){ | ||
| 38 | + taggifyForm(); | ||
| 39 | + }) |
app/views/projects/_form.html.haml
| @@ -29,8 +29,8 @@ | @@ -29,8 +29,8 @@ | ||
| 29 | %tr | 29 | %tr |
| 30 | %td= f.label :tag_list | 30 | %td= f.label :tag_list |
| 31 | %td= f.text_area :tag_list, :placeholder => "project tags", :style => "height:50px", :id => :tag_field | 31 | %td= f.text_area :tag_list, :placeholder => "project tags", :style => "height:50px", :id => :tag_field |
| 32 | - | ||
| 33 | - .field | 32 | + |
| 33 | + .form-row | ||
| 34 | = f.label :description | 34 | = f.label :description |
| 35 | %br/ | 35 | %br/ |
| 36 | = f.text_area :description, :style => "height:140px;width:932px;" | 36 | = f.text_area :description, :style => "height:140px;width:932px;" |
| @@ -55,16 +55,5 @@ | @@ -55,16 +55,5 @@ | ||
| 55 | 55 | ||
| 56 | :javascript | 56 | :javascript |
| 57 | $(function(){ | 57 | $(function(){ |
| 58 | - var tag_field = $('#tag_field').tagify(); | ||
| 59 | - | ||
| 60 | - tag_field.tagify('inputField').autocomplete({ | ||
| 61 | - source: '/tags.json' | ||
| 62 | - }); | ||
| 63 | - | ||
| 64 | - | ||
| 65 | - $('form').submit( function() { | ||
| 66 | - var tag_field = $('#tag_field') | ||
| 67 | - tag_field.val( tag_field.tagify('serialize') ); | ||
| 68 | - return true; | ||
| 69 | - }); | 58 | + taggifyForm(); |
| 70 | }) | 59 | }) |