class Admin::DigitalArchivesController < OrbitAdminController def index @table_fields = [:title,t("digital_archive.character"),:category,t("digital_archive.location"),t("digital_archive.item_date")] @digital_content_archives = DigitalContentArchive.all @tags = @module_app.tags @categories = @module_app.categories @filter_fields = filter_fields(@categories, @tags) @digital_content_archives = DigitalContentArchive.order_by(sort).with_categories(filters("category")).with_tags(filters("tag")) @digital_content_archives = search_data(@digital_content_archives,[:title]).page(params[:page]).per(10) end def new @digital_archive = DigitalContentArchive.new @tags = @module_app.tags @categories = @module_app.categories end def create @digital_archive = DigitalContentArchive.new(digital_archive_vars) @digital_archive.save redirect_to admin_digital_archives_path end def digital_archive_vars params.require(:digital_content_archive).permit! end def setup_vars @module_app = ModuleApp.where(:key => "digital_archive").first end def show @digital_content_archive = DigitalContentArchive.find(params[:id]) end def destroy digital_content_archive = DigitalContentArchive.find(params[:id]) digital_content_archive.destroy redirect_to admin_digital_archives_path end def edit @digital_archive = DigitalContentArchive.find(params[:id]) if can_edit_or_delete?(@digital_archive) @tags = @module_app.tags @categories = @module_app.categories else render_401 end end def update digital_archive = DigitalContentArchive.find(params[:id]) digital_archive.update_attributes(digital_archive_vars) digital_archive.save redirect_to admin_digital_archives_path end def sort unless params[:sort].blank? case params[:sort] when "status" @sort = [[:is_top, params[:order]], [:is_hot, params[:order]], [:is_hidden,params[:order]]] when "category" @sort = {:category_id=>params[:order]} when "title" @sort = {:title=>params[:order]} when "last_modified" @sort = {:update_user_id=>params[:order]} end else @sort = {:created_at=>'desc'} end @sort end end