From 0671d0b126c095f477f591dfb89a4af132bdb661 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Wed, 11 Dec 2013 18:43:38 +0800 Subject: [PATCH] filemanger authentication changes and also announcement preview fixed and also text search for files Conflicts: app/views/admin/assets/index.html.erb --- app/assets/javascripts/admin/filemanager.js | 10 ++++++++-- app/controllers/admin/assets_controller.rb | 13 ++++++++++--- app/controllers/pages_controller.rb | 9 +++++++++ app/views/admin/assets/_form.html.erb | 11 ----------- app/views/admin/assets/index.html.erb | 2 +- 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/app/assets/javascripts/admin/filemanager.js b/app/assets/javascripts/admin/filemanager.js index 9abd9d17..48edb697 100644 --- a/app/assets/javascripts/admin/filemanager.js +++ b/app/assets/javascripts/admin/filemanager.js @@ -108,8 +108,10 @@ $(document).ready(function(){ }) var currentEdit = null; $(document).on("ajax:success","form[data-remote=true]",function(evt, data, xhr){ - currentEdit.replaceWith($(data)); - $("#editform").modal("hide"); + if(currentEdit){ + currentEdit.replaceWith($(data)); + $("#editform").modal("hide"); + } }) $("#asset_sort_list").on(clickEvent,".editform",function(){ @@ -120,6 +122,10 @@ $(document).ready(function(){ return false; }) + $("#editform").on("hidden",function(){ + currentEdit = null; + }) + function getUrlParam( paramName ) { var reParam = new RegExp( '(?:[\?&]|&)' + paramName + '=([^&]+)', 'i' ) ; var match = window.location.search.match(reParam) ; diff --git a/app/controllers/admin/assets_controller.rb b/app/controllers/admin/assets_controller.rb index f91be58a..4a268d3d 100644 --- a/app/controllers/admin/assets_controller.rb +++ b/app/controllers/admin/assets_controller.rb @@ -1,9 +1,18 @@ class Admin::AssetsController < OrbitBackendController + open_for_user + open_for_admin + before_filter :setup_vars def index - @assets = (params[:sort] || @filter) ? get_sorted_and_filtered("asset") : Asset.all.desc(:created_at) + + if params[:filter] + @assets = current_user.assets.where(title: /#{params[:filter]}/i) + else + @assets = current_user.assets.desc(:created_at) + end + if params[:type] == "image" @assets = @assets.where(:content_type => /^image/) end @@ -55,7 +64,6 @@ class Admin::AssetsController < OrbitBackendController render :layout=>false else flash[:error] = t('create.fail') - @asset_categories = AssetCategory.all @tags = get_tags respond_to do |format| format.js { @@ -75,7 +83,6 @@ class Admin::AssetsController < OrbitBackendController render layout: false else flash[:error] = t('update.fail') - @asset_categories = AssetCategory.all @tags = get_tags respond_to do |format| format.html { render :action => :edit } diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index e283865d..641ff77a 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -188,11 +188,20 @@ class PagesController < ApplicationController @item = Item.where(:category => category_ids).first else if params[:action] && params[:action] == "show_from_link" + if params[:preview] + model = "preview".classify.constantize rescue nil + if !model.nil? + item = model.find(params[:id]) + @item = Item.where(:category => [item.object['category_id']]).first if !module_app.has_category.blank? + end + else model = params[:app_action].classify.constantize rescue nil if !model.nil? item = model.find(params[:id]) @item = Item.where(:category => [item.category_id.to_s]).first if !module_app.has_category.blank? end + end + end end diff --git a/app/views/admin/assets/_form.html.erb b/app/views/admin/assets/_form.html.erb index 830b8e19..fafc1474 100644 --- a/app/views/admin/assets/_form.html.erb +++ b/app/views/admin/assets/_form.html.erb @@ -28,17 +28,6 @@ <% end %> -
- -
- <% @tags.each do |tag| %> - - <% end %> -
-
diff --git a/app/views/admin/assets/index.html.erb b/app/views/admin/assets/index.html.erb index ec622250..ef474df0 100644 --- a/app/views/admin/assets/index.html.erb +++ b/app/views/admin/assets/index.html.erb @@ -222,7 +222,7 @@
-
+