Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote-tracking branch 'upstream/master'

  • Loading branch information...
commit cf91345c47b05ab0b36b0fdf4d69f57b3739829c 2 parents 50f5d7a + 63944f8
@jodyalbritton authored
View
10 app/controllers/admin/galleries_controller.rb
@@ -74,6 +74,14 @@ def destroy
end
end
+ def tags
+ @tags = ActsAsTaggableOn::Tag.where("tags.name LIKE ?", "%#{params[:q]}%")
+ respond_to do |format|
+ format.json { render :json => @tags.collect{|t| {:id => t.name, :name => t.name }}}
+ end
+ end
+
+
private
# Use callbacks to share common setup or constraints between actions.
def set_gallery
@@ -82,6 +90,6 @@ def set_gallery
# Never trust parameters from the scary internet, only allow the white list through.
def gallery_params
- params.require(:gallery).permit(:name, :description)
+ params.require(:gallery).permit(:name, :description, :tag_list)
end
end
View
9 app/controllers/admin/sponsors_controller.rb
@@ -69,7 +69,12 @@ def destroy
end
end
-
+ def tags
+ @tags = ActsAsTaggableOn::Tag.where("tags.name LIKE ?", "%#{params[:q]}%")
+ respond_to do |format|
+ format.json { render :json => @tags.collect{|t| {:id => t.name, :name => t.name }}}
+ end
+ end
private
# Use callbacks to share common setup or constraints between actions.
def set_sponsor
@@ -78,6 +83,6 @@ def set_sponsor
# Never trust parameters from the scary internet, only allow the white list through.
def sponsor_params
- params.require(:sponsor).permit(:name, :description, :enabled, :category_name, :avatar, :address, :city, :state, :zip, :url, :video_url, :phone, :email)
+ params.require(:sponsor).permit(:name, :description, :enabled, :category_name, :avatar, :address, :city, :state, :zip, :url, :video_url, :phone, :email, :tag_list)
end
end
View
20 app/views/admin/galleries/_form.html.erb
@@ -22,6 +22,12 @@
</div>
</div>
<div class="form-group">
+ <%= f.label :tags, :class => "col-sm-2 control-label" %>
+ <div class="col-sm-10">
+ <%= f.text_field :tag_list, :class => "form-control", "data-pre" => @gallery.tags.map(&:attributes).to_json %>
+ </div>
+ </div>
+ <div class="form-group">
<%= f.label :description, :class => "col-sm-2 control-label" %>
<div class="col-sm-4">
<%= f.text_area :description, :class => "form-control" %>
@@ -34,3 +40,17 @@
</div>
<% end %>
+
+
+<script>
+ $(function() {
+ $("#gallery_tag_list").tokenInput("/admin/galleries/tags.json", {
+ prePopulate: $("#gallery_tag_list").data("pre"),
+ preventDuplicates: true,
+ noResultsText: "No results, press enter to create.",
+ theme: "facebook",
+ tokenValue:"name",
+ allowFreeTagging: true
+ });
+});
+</script>
View
19 app/views/admin/sponsors/_form.html.erb
@@ -25,7 +25,12 @@
<%= f.text_area :description, :class=> "form-control", :rows=> "12"%>
</div>
</div> <!-- / .form-group -->
-
+ <div class="form-group">
+ <%= f.label :tags, :class => "col-sm-2 control-label" %>
+ <div class="col-sm-10">
+ <%= f.text_field :tag_list, :class => "form-control", "data-pre" => @sponsor.tags.map(&:attributes).to_json %>
+ </div>
+ </div>
<div class="form-group">
<label for="asdasdas" class="col-sm-2 control-label">URL</label>
<div class="col-sm-10">
@@ -91,3 +96,15 @@ $(function() {
</script>
+<script>
+ $(function() {
+ $("#sponsor_tag_list").tokenInput("/admin/sponsors/tags.json", {
+ prePopulate: $("#sponsor_tag_list").data("pre"),
+ preventDuplicates: true,
+ noResultsText: "No results, press enter to create.",
+ theme: "facebook",
+ tokenValue:"name",
+ allowFreeTagging: true
+ });
+});
+</script>
View
6 config/routes.rb
@@ -50,6 +50,9 @@
resources :categories
resources :galleries do
resources :photos
+ collection do
+ get :tags
+ end
end
resources :photos do
@@ -110,6 +113,9 @@
end
resources :sponsors do
resources :attachments
+ collection do
+ get :tags
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.