This commit is contained in:
BOHUNG 2020-01-13 11:23:34 +08:00
parent ae85fe2859
commit 2df2919aad
2 changed files with 36 additions and 42 deletions

View File

@ -2,7 +2,6 @@
require 'rubyXL'
class Admin::PatchfilesController < OrbitAdminController
include Admin::PatchfilesHelper
before_action ->(module_app = @app_title) { set_variables module_app }
before_action :getfont , :create_first_field
#before_action :load_access_levels
def initialize
@ -11,23 +10,17 @@ class Admin::PatchfilesController < OrbitAdminController
end
def index
@tags = @module_app.tags
@categories = @module_app.categories.enabled
@filter_fields = filter_fields(@categories, @tags)
@table_fields = [:status, :category, :title, :start_date, :end_date, :last_modified]
#@tags = @module_app.tags
#@categories = @module_app.categories.enabled
#@filter_fields = filter_fields(@categories, @tags)
#@table_fields = [:status, :category, :title, :start_date, :end_date, :last_modified]
if request.xhr?
render :partial => "index"
end
end
def edit
params["filefield"]["file_show"].each do |name,status|
@file_to_show.file_show[name][:status] = status.to_i rescue nil
end
if params["filefield"]["refresh_btn"] == "true"
@default_field = Filefield.new()
@file_to_show.file_show = @default_field.file_show
@file_to_show.save
redirect_to admin_patchfiles_path and return
@file_to_show.file_show[name][:status] = status.to_i
end
params["filefield"]["sub_file_fields"].each do |name,files|
files.each do |index,file_and_status|
@ -186,6 +179,7 @@ class Admin::PatchfilesController < OrbitAdminController
end
end
def create_first_field
@app_title = "patchfile"
if Patchfilefield.where("title"=>(@app_title + "_back")).take_while{true}.count == 0
@field = Patchfilefield.new()
@field.title = @app_title +"_back"

View File

@ -1,37 +1,37 @@
require "yaml"
module Patchfile
class Engine < ::Rails::Engine
initializer "patchfile" do
OrbitApp.registration "Patchfile", :type => "ModuleApp" do
base_url File.expand_path File.dirname(__FILE__)
taggable "patchfilefield"
categorizable
authorizable
side_bar do
head_label_i18n 'patchfile.patchfile', icon_class: "icons-megaphone"
available_for "users"
active_for_controllers (['admin/patchfiles'])
head_link_path "admin_patchfiles_path"
# initializer "patchfile" do
# OrbitApp.registration "Patchfile", :type => "ModuleApp" do
# base_url File.expand_path File.dirname(__FILE__)
# taggable "patchfilefield"
# categorizable
# authorizable
# side_bar do
# head_label_i18n 'patchfile.patchfile', icon_class: "icons-megaphone"
# available_for "users"
# active_for_controllers (['admin/patchfiles'])
# head_link_path "admin_patchfiles_path"
context_link 'patchfile.patchfile',
:link_path=>"admin_patchfiles_path" ,
:priority=>1,
:active_for_action=>{'admin/patchfiles'=>'index'},
:available_for => 'users'
context_link 'CKEDITOR',
:link_path=>"admin_patchfiles_showckeditor_path" ,
#:link_to=>"admin_patchfiles_path"+"/showckeditor" ,
:priority=>2,
:active_for_action=>{'admin/patchfiles'=>'showckeditor'},
:available_for => 'users'
# context_link 'patchfile.patchfile',
# :link_path=>"admin_patchfiles_path" ,
# :priority=>1,
# :active_for_action=>{'admin/patchfiles'=>'index'},
# :available_for => 'users'
# context_link 'CKEDITOR',
# :link_path=>"admin_patchfiles_showckeditor_path" ,
# #:link_to=>"admin_patchfiles_path"+"/showckeditor" ,
# :priority=>2,
# :active_for_action=>{'admin/patchfiles'=>'showckeditor'},
# :available_for => 'users'
end
end
# temp = YAML.load_file(File.join(Rails.root,"config","mongoid.yml"))
# dbsettings = temp["production"]["sessions"]["default"]
# s = Moped::Session.new(dbsettings["hosts"])
# s.use dbsettings["database"]
# s[:bulletins].indexes.create({expirable_created_at: 1},{ expireAfterSeconds: 180 })
end
# end
# end
# # temp = YAML.load_file(File.join(Rails.root,"config","mongoid.yml"))
# # dbsettings = temp["production"]["sessions"]["default"]
# # s = Moped::Session.new(dbsettings["hosts"])
# # s.use dbsettings["database"]
# # s[:bulletins].indexes.create({expirable_created_at: 1},{ expireAfterSeconds: 180 })
# end
end
end