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

View File

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