lib/engine2/meta/infra_meta.rb in engine2-1.0.2 vs lib/engine2/meta/infra_meta.rb in engine2-1.0.3

- old
+ new

@@ -2,19 +2,20 @@ module Engine2 SCHEMES::define_scheme :infra! do |user_info_model = UserInfo| define_action :infra! do self.* do - extend MetaPanelSupport, MetaMenuSupport + extend MetaPanelSupport, MetaMenuSupport, MetaAPISupport panel_panel_template false panel_template 'infra/index' + loc! logged_on: LOCS[:logged_on] menu :menu do properties group_class: "btn-group-sm" option :inspect_modal, icon: :wrench, button_loc: false # , show: "action.logged_on" option :logout_form, icon: :"log-out" # , show: "action.logged_on" - option :login_form, icon: :"log-in", disabled: 'action.action_pending' # , show: "!action.logged_on" + option :login_form, icon: :"log-in", disabled: 'action.action_pending()' # , show: "!action.logged_on" end @meta_type = :infra def invoke handler @@ -61,11 +62,11 @@ def (self.*).invoke handler db_name = handler.params[:db] handler.permit db = Sequel::DATABASES.find{|d|d.uri == db_name || (d.uri && d.uri.start_with?(db_name))} handler.permit model = db.models[handler.params[:model].to_sym] { - model: { + model!: { info: { name: model.to_s, table: model.table_name }, assoc: model.association_reflections, @@ -229,19 +230,21 @@ # File.rename(temp.path, "#{UPLOAD_DIR}/#{rackname}") # {rackname: rackname} # end # end - class LoginFormMeta < FormMeta + class LoginFormMeta < Meta + include MetaFormSupport meta_type :login_form def pre_run super panel_class 'modal-default' panel_title LOCS[:login_title] info! :name, loc: LOCS[:user_name] menu(:panel_menu).modify_option :approve, name: :login, icon: :"log-in" + @meta[:fields] = [:name, :password] end def invoke handler {record: {}, new: true} end @@ -249,16 +252,21 @@ class LoginMeta < Meta include MetaApproveSupport meta_type :login + def validate_record handler, record + super + record.values[:password] = nil + end + def after_approve handler, record handler.session[:user] = record end def record handler, record - {errors: nil, user: handler.user.to_hash} + {errors: nil, user!: handler.user.to_hash} end end class LogoutFormMeta < Meta include MetaPanelSupport, MetaMenuSupport @@ -266,17 +274,14 @@ def pre_run super panel_template 'scaffold/message' panel_title LOCS[:logout_title] panel_class 'modal-default' + @meta[:message] = LOCS[:logout_message] menu :panel_menu do option :logout, icon: "ok", loc: LOCS[:ok] option :cancel, icon: "remove" end - end - - def invoke handler - {message: LOCS[:logout_message]} end end class LogoutMeta < Meta meta_type :logout