Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[WIP] fix media_set parents display and popup

  • Loading branch information...
commit 066a901d18e422be97656e323d12db3d508bbabc 1 parent 11df04d
@sellittf sellittf authored
View
32 app/assets/javascripts/mediaset-popup/mediaset-popup.js.coffee
@@ -52,12 +52,10 @@ load_children = (target)->
console.log "ERROR LOADING"
data:
with:
- media_set:
- media_resources:
- type: true
- image:
- as:"base64"
- size:"small"
+ children: true
+ image:
+ as:"base64"
+ size:"small"
type: "GET"
load_parents = (target)->
@@ -65,7 +63,7 @@ load_parents = (target)->
setup_parents(target, $(target).data("loaded_parents"))
else
$.ajax
- url: "/media_sets/"+target.tmplItem().data.id+".json"
+ url: "/media_resources/"+target.tmplItem().data.id+".json"
beforeSend: (request, settings) ->
#before
success: (data, status, request) ->
@@ -75,12 +73,10 @@ load_parents = (target)->
console.log "ERROR LOADING"
data:
with:
- media_set:
- parent_sets:
- type: true
- image:
- as:"base64"
- size:"small"
+ parents: true
+ image:
+ as:"base64"
+ size:"small"
type: "GET"
setup_children = (target, data)->
@@ -88,9 +84,9 @@ setup_children = (target, data)->
# remove loading
$($(target).data("popup")).find(".children .loading").remove()
# setup resources
- media_entries = (resource for resource in data.media_resources when resource.type is "media_entry")
- media_sets = (resource for resource in data.media_resources when resource.type is "media_set")
- resources = data.media_resources[0...6]
+ media_entries = (resource for resource in data.children when resource.type is "media_entry")
+ media_sets = (resource for resource in data.children when resource.type is "media_set")
+ resources = data.children[0...6]
displayed_media_entries = (resource for resource in resources when resource.type is "media_entry")
displayed_media_sets = (resource for resource in resources when resource.type is "media_set")
for resource in resources
@@ -106,14 +102,14 @@ setup_parents = (target, data)->
# remove loading
$($(target).data("popup")).find(".parents .loading").remove()
# setup resources
- resources = data.parent_sets[0...3]
+ resources = data.parents[0...3]
displayed_media_sets = (resource for resource in resources when resource.type is "media_set")
for resource in resources
do (resource) ->
$($(target).data("popup")).find(".parents").append $.tmpl("tmpl/mediaset-popup/resource", resource)
# setup text
$($(target).data("popup")).find(".parents").append $("<div class='text'></div>")
- if resources? then $($(target).data("popup")).find(".parents .text").append("<p>"+(data.parent_sets.length-displayed_media_sets.length)+" weitere Sets</p>")
+ if resources? then $($(target).data("popup")).find(".parents .text").append("<p>"+(data.parents.length-displayed_media_sets.length)+" weitere Sets</p>")
open_popup = (target)->
# close all other mediaset popups
View
1  app/controllers/media_sets_controller.rb
@@ -122,6 +122,7 @@ def show(with = params[:with],
paginate({:page => page, :per_page => per_page})
@can_edit_set = current_user.authorized?(:edit, @media_set)
+ @parents = @media_set.parent_sets.accessible_by_user(current_user)
@pagination = { :page => resources.current_page,
:per_page => resources.per_page,
:total => resources.total_entries,
View
35 app/views/media_sets/_show.json.rjson
@@ -18,37 +18,4 @@ if (with || nil)
end
end
-=begin
-[:id, :user_id, :created_at, :updated_at].each do |k|
- h[k] = @media_set.send(k)
-end
-
-h[:owner_id] = @media_set.user_id
-
-h[:media_entries] = @media_entries.map do |media_entry|
- render :partial => "media_entries/show.json.rjson", :locals => {:media_entry => media_entry}
-end
-
-###############################################################
-
- json[:is_set] = true # TODO use :type instead of :is_set # TODO drop as default
- if(with = options[:with])
- if(with[:media_set] and with[:media_set].is_a?(Hash))
- if with[:media_set].has_key?(:child_sets) and (with[:media_set][:child_sets].is_a?(Hash) or not with[:media_set][:child_sets].to_i.zero?)
- json[:child_sets] = child_sets.accessible_by_user(options[:current_user]).as_json(:with => {:media_set => with[:media_set][:media_sets]})
- end
- if with[:media_set].has_key?(:parent_sets) and (with[:media_set][:parent_sets].is_a?(Hash) or not with[:media_set][:parent_sets].to_i.zero?)
- json[:parent_sets] = parent_sets.accessible_by_user(options[:current_user]).as_json({:with => {:media_set => with[:media_set][:parent_sets]}}.merge(:current_user => options[:current_user]))
- end
- if with[:media_set].has_key?(:media_entries) and (with[:media_set][:media_entries].is_a?(Hash) or not with[:media_set][:media_entries].to_i.zero?)
- json[:media_entries] = media_entries.accessible_by_user(options[:current_user]).as_json(:with => {:media_entry => with[:media_set][:media_entries]})
- end
- # child media_resources
-
-
- end
- end
-
-=end
-
-h
+h
View
4 app/views/media_sets/show.html.haml
@@ -87,7 +87,7 @@
.inner
.media_set_highlights_shadow.left
.media_set_highlights_shadow.right
- - unless (@parents = @media_set.parent_sets).empty?
+ - unless @parents.empty?
%div.page_title_left.set_parents_title
.icon_set_parents
= _("Set enthalten in")
@@ -99,7 +99,7 @@
= render :partial => "media_entries/index"
:ruby
- with = {:type => true,
+ with = {:media_type => true,
:image=>{:as=>"base64", :size=>"large"},
:meta_data => {:meta_context_names => ["core"]}}
View
4 app/views/upload/set_media_sets.html.haml
@@ -5,8 +5,6 @@
:javascript
$(document).ready(function () {
- json = #{begin
- @media_entries.as_json(user: current_user, with_thumb: true, with: {media_resource: {type: 1, image:{as:"base64"}}})
- end.to_json}
+ json = #{@media_entries.as_json(user: current_user, with_thumb: true, with: {media_resource: {type: 1, image:{as:"base64"}}}).to_json}
$("#results").html($.tmpl("tmpl/media_resource/image", json));
});
Please sign in to comment.
Something went wrong with that request. Please try again.