7

ActiveAdminを使用してバックエンドを自動化するこのシステムがあり、ActiveAdminのテーブルでインプレース編集を使用しようとした人はいないかと思いました。

それが役立つシナリオがいくつかあります。Key-Valueテーブル(State、Categoryなど)とマスター/詳細ビュー(OrderおよびOrde​​rItems)...

誰かがそれを実装しようとしましたか?良いポインタはありますか?

4

2 に答える 2

9

best_in_place Editorを使用しましたが、一般的なビューではなく、カスタマイズされたビューでのみ使用しました。

https://github.com/bernat/best_in_place

gem "best_in_place"
bundle
rails g best_in_place:setup

best_in_placeスクリプトを次の場所に追加します/app/assets/javascripts/active_admin.js

//= require best_in_place

$(document).ready(function() {
  /* Activating Best In Place */  
  jQuery(".best_in_place").best_in_place() });

カスタムビューパーシャルでは、次のようなものを使用できます

.panel
  %h3 Your Resource Table
  .panel_contents
    .attributes_table
      %table
        %tbody
          %tr
            %th Name
            %td= best_in_place resource, :name, :type => :input, :path => [:admin, resource]
            ...
            ...

ActiveAdminはすでにRESTfulアクションを設定しており、BestInPlaceはRESTful PUTを使用して更新も行っているため、すべてが自動的に機能するはずです:)

このようなものを使用することもできますが、私はまだこれをテストしていません。

index do
  column(:name) { |i| best_in_place i, :name, :type => :input, :path => [:admin, i] } 
end
于 2011-11-10T16:05:50.643 に答える
5

実際、アクティブ管理ビュー用のベストインプレースモンキーパッチは非常に簡単です。

# app/admin/active_admin/views.rb
module ActiveAdmin::ViewHelpers
  extend BestInPlace::BestInPlaceHelpers
end
于 2012-07-11T23:17:50.383 に答える