Skip to content

Commit

Permalink
sync table name
Browse files Browse the repository at this point in the history
  • Loading branch information
qinmingyuan committed Oct 22, 2024
1 parent 6833125 commit 0f53e05
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/com/panel/meta_models_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Panel::MetaModelsController < Panel::BaseController

def index
q_params = {}
q_params.merge! params.permit(:business_identifier)
q_params.merge! params.permit(:business_identifier, :table_name)

@meta_models = MetaModel.default_where(q_params).order(record_name: :asc).page(params[:page])
end
Expand Down
2 changes: 2 additions & 0 deletions app/models/com/model/meta_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Model::MetaModel
included do
attribute :name, :string
attribute :record_name, :string, index: true
attribute :table_name, :string
attribute :description, :string
attribute :defined_db, :boolean, default: false
attribute :customizable, :boolean, default: false, comment: '是否允许用户定制'
Expand All @@ -22,6 +23,7 @@ def record_class

def sync_business_identifier
self.business_identifier = record_name.split('::')[-2].to_s.downcase
self.table_name = record_class.table_name
end

def display_name
Expand Down
9 changes: 9 additions & 0 deletions app/views/com/panel/meta_models/_index/_filter_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<%= form_with theme: 'search', model: model_klass.new, url: { action: params[:action] }, data: { switch_target: 'src' }, class: params.key?('table_name') ? '' : 'display-none' do |f| %>
<div class="field-body">
<%= f.text_field :table_name, autocomplete: 'off' %>
<div class="field is-narrow">
<%= f.submit %>
<%= link_to t('.clear'), filter_params(except: [:table_name]), class: 'button is-light' %>
</div>
</div>
<% end %>

0 comments on commit 0f53e05

Please sign in to comment.