now new albums and images are sorted by created date and are on the top. also modified loading new images
This commit is contained in:
parent
1769924137
commit
afb11a2fa2
|
@ -243,6 +243,8 @@ $(function() {
|
||||||
})
|
})
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
|
var last_image_id = null;
|
||||||
$('.add-imgs').on({
|
$('.add-imgs').on({
|
||||||
click: function() {
|
click: function() {
|
||||||
$('#fileupload').slideToggle(300, function() {
|
$('#fileupload').slideToggle(300, function() {
|
||||||
|
@ -250,6 +252,14 @@ $(function() {
|
||||||
$('.add-imgs').html('<i class="icons-cross-2"></i> Close panel');
|
$('.add-imgs').html('<i class="icons-cross-2"></i> Close panel');
|
||||||
$('.rgbody').stop(true, false).animate({'padding-bottom': 280}, 300);
|
$('.rgbody').stop(true, false).animate({'padding-bottom': 280}, 300);
|
||||||
$("#edit-order-btn").hide();
|
$("#edit-order-btn").hide();
|
||||||
|
$.ajax({
|
||||||
|
url : "/admin/galleries/last_image_id",
|
||||||
|
data : {"albumid" : $("#fileupload_aid").val()},
|
||||||
|
dataType : "json",
|
||||||
|
type : "get"
|
||||||
|
}).done(function(d){
|
||||||
|
last_image_id = d.last_image_id;
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
$('.add-imgs').html('<i class="icons-plus"></i> Add Image');
|
$('.add-imgs').html('<i class="icons-plus"></i> Add Image');
|
||||||
$('.files').empty()
|
$('.files').empty()
|
||||||
|
@ -263,20 +273,19 @@ $(function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var fetchNewImages = function(){
|
var fetchNewImages = function(){
|
||||||
var lastid = ( $("li.rgalbum:last").length ? $("li.rgalbum:last").data("image-id") : null),
|
var albumid = $("#fileupload_aid").val();
|
||||||
albumid = $("#fileupload_aid").val();
|
|
||||||
|
|
||||||
$.getJSON('/admin/galleries/get_photoData_json?id='+albumid, function(json, textStatus) {
|
$.getJSON('/admin/galleries/get_photoData_json?id='+albumid, function(json, textStatus) {
|
||||||
photosData = json;
|
photosData = json;
|
||||||
});
|
});
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : "/admin/new_images",
|
url : "/admin/galleries/new_images",
|
||||||
data : {"last_image_id" : lastid, "album_id" : albumid},
|
data : {"last_image_id" : last_image_id, "album_id" : albumid},
|
||||||
success : function(data){
|
success : function(data){
|
||||||
var $e = $(data);
|
var $e = $(data);
|
||||||
$imgs = $e.find("img");
|
$imgs = $e.find("img");
|
||||||
$("#imgholder").append($e);
|
$("#imgholder").prepend($e);
|
||||||
$os = $e.find("a.open");
|
$os = $e.find("a.open");
|
||||||
$os.pageslide({
|
$os.pageslide({
|
||||||
loadComplete: function(instance,elem) {
|
loadComplete: function(instance,elem) {
|
||||||
|
|
|
@ -4,13 +4,17 @@ class Admin::GalleriesController < OrbitAdminController
|
||||||
before_action :log_user_action
|
before_action :log_user_action
|
||||||
layout "back_end"
|
layout "back_end"
|
||||||
def index
|
def index
|
||||||
@albums = Album.all.asc(:order)
|
@albums = Album.where(:order => -1).desc(:created_at)
|
||||||
|
albums = Album.where(:order.gt => -1).asc(:order)
|
||||||
|
@albums = @albums.concat(albums)
|
||||||
@tags = @module_app.tags
|
@tags = @module_app.tags
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@album = Album.find(params[:id])
|
@album = Album.find(params[:id])
|
||||||
@images = @album.album_images.asc(:order)
|
@images = @album.album_images.where(:order => -1).desc(:created_at)
|
||||||
|
images = @album.album_images.where(:order.gt => -1).asc(:order)
|
||||||
|
@images = @images.concat(images)
|
||||||
image_content = []
|
image_content = []
|
||||||
@images.each do |image|
|
@images.each do |image|
|
||||||
image_content << {"id" => image.id.to_s, "description" => image.description_translations,"tags" => image.tags.collect{|t| t.id.to_s}}
|
image_content << {"id" => image.id.to_s, "description" => image.description_translations,"tags" => image.tags.collect{|t| t.id.to_s}}
|
||||||
|
@ -61,7 +65,9 @@ class Admin::GalleriesController < OrbitAdminController
|
||||||
|
|
||||||
def get_photoData_json
|
def get_photoData_json
|
||||||
@album = Album.find(params[:id])
|
@album = Album.find(params[:id])
|
||||||
@images = @album.album_images
|
@images = @album.album_images.where(:order => -1).desc(:created_at)
|
||||||
|
images = @album.album_images.where(:order.gt => -1).asc(:order)
|
||||||
|
@images = @images.concat(images)
|
||||||
image_content = []
|
image_content = []
|
||||||
@images.each do |image|
|
@images.each do |image|
|
||||||
image_content << {"id" => image.id.to_s, "description" => image.description_translations,"tags" => image.tags.collect{|t| t.id.to_s}}
|
image_content << {"id" => image.id.to_s, "description" => image.description_translations,"tags" => image.tags.collect{|t| t.id.to_s}}
|
||||||
|
@ -158,17 +164,20 @@ class Admin::GalleriesController < OrbitAdminController
|
||||||
render :json=>{"files"=>a}.to_json
|
render :json=>{"files"=>a}.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def last_image_id
|
||||||
|
album = Album.find(params[:albumid])
|
||||||
|
lastimage = album.album_images.last
|
||||||
|
render :json => {"last_image_id" => lastimage.id.to_s}.to_json
|
||||||
|
end
|
||||||
|
|
||||||
def new_images
|
def new_images
|
||||||
|
@album = Album.find(params[:album_id])
|
||||||
if params[:last_image_id] != ""
|
if params[:last_image_id].present?
|
||||||
@lastimage = AlbumImage.find(params[:last_image_id])
|
lastimage = AlbumImage.find(params[:last_image_id])
|
||||||
@album = Album.find(params[:album_id])
|
@newimages = @album.album_images.where(:created_at.gt => lastimage.created_at,:order => -1).desc(:created_at)
|
||||||
@newimages = @album.album_images.where(:created_at.gt => @lastimage.created_at)
|
|
||||||
else
|
else
|
||||||
@album = Album.find(params[:album_id])
|
@newimages = @album.album_images.where(:order => -1).desc(:created_at)
|
||||||
@newimages = @album.album_images
|
|
||||||
end
|
end
|
||||||
|
|
||||||
render :layout=>false
|
render :layout=>false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ class Album
|
||||||
field :tag_names
|
field :tag_names
|
||||||
field :uid, type: String
|
field :uid, type: String
|
||||||
field :rss2_id, type: String
|
field :rss2_id, type: String
|
||||||
field :order, type: Integer, default: 0
|
field :order, type: Integer, default: -1
|
||||||
|
|
||||||
# has_and_belongs_to_many :tags, :class_name => "GalleryTag"
|
# has_and_belongs_to_many :tags, :class_name => "GalleryTag"
|
||||||
has_many :album_images, :autosave => true, :dependent => :destroy
|
has_many :album_images, :autosave => true, :dependent => :destroy
|
||||||
|
|
|
@ -9,7 +9,7 @@ class AlbumImage
|
||||||
field :title
|
field :title
|
||||||
field :description, localize: true
|
field :description, localize: true
|
||||||
field :rss2_id, type: String
|
field :rss2_id, type: String
|
||||||
field :order, type: Integer, default: 0
|
field :order, type: Integer, default: -1
|
||||||
|
|
||||||
# has_and_belongs_to_many :tags, :class_name => "GalleryTag"
|
# has_and_belongs_to_many :tags, :class_name => "GalleryTag"
|
||||||
|
|
||||||
|
|
|
@ -7,18 +7,21 @@ Rails.application.routes.draw do
|
||||||
namespace :admin do
|
namespace :admin do
|
||||||
get "galleries/get_photoData_json" => "galleries#get_photoData_json"
|
get "galleries/get_photoData_json" => "galleries#get_photoData_json"
|
||||||
|
|
||||||
|
get "galleries/new_images" => "galleries#new_images"
|
||||||
|
get "galleries/last_image_id" => "galleries#last_image_id"
|
||||||
|
post "galleries/set_cover" => "galleries#set_cover"
|
||||||
|
post "galleries/delete_photos" => "images#delete_photos"
|
||||||
|
post "galleries/update_image" => "images#update_image"
|
||||||
|
post "galleries/image_tagging" => "images#image_tagging"
|
||||||
|
post "galleries/order" => "images#changeorder"
|
||||||
|
|
||||||
resources :galleries do
|
resources :galleries do
|
||||||
get "imgs" => "galleries#imgs"
|
get "imgs" => "galleries#imgs"
|
||||||
end
|
end
|
||||||
resources :images
|
resources :images
|
||||||
post "galleries/upload_image" => "galleries#upload_image"
|
post "galleries/upload_image" => "galleries#upload_image"
|
||||||
|
|
||||||
get "new_images" => "galleries#new_images"
|
|
||||||
post "galleries/set_cover" => "galleries#set_cover"
|
|
||||||
post "galleries/delete_photos" => "images#delete_photos"
|
|
||||||
post "galleries/update_image" => "images#update_image"
|
|
||||||
post "galleries/image_tagging" => "images#image_tagging"
|
|
||||||
post "galleries/order" => "images#changeorder"
|
|
||||||
# match "image_tagging" => "album_images#image_tagging"
|
# match "image_tagging" => "album_images#image_tagging"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue