agricloud / foodprint

1 stars 0 forks source link

維護畫面互動行為規範 #54

Open smlsunxie opened 10 years ago

smlsunxie commented 10 years ago
  1. 移除更新鈕
  2. 按下儲存鈕,判斷 form field id 有無資料來決定呼叫 create 或是 save
  3. 不管在哪個頁籤,讀取鈕都要可以按,若再清單重新讀取資料,若再表單,重新讀取 record
  4. 切換瀏覽與維護頁籤不需要事件
  5. combobox 使用:

combo 類別的定義

Ext.define('foodprint.view.CommonOperationCombo', {
    extend: 'Ext.form.field.ComboBox',
    alias: 'widget.commonoperationcombo',

    itemId: 'commonOperationCombo',
    //預設不可編輯
    editable: false,

    //顯示為 name
    displayField: 'name',       
    store: 'OperationStore',

    //一律為 id
    valueField: 'id',                 

    initComponent: function() {
        var me = this;

        me.callParent(arguments);
    }

});

定義好的 combo 類別使用於 grid可編輯的情況或是 form 中 field 正確的設定方式

{
    xtype: 'commonoperationcombo',

    //因為顯示的為 name 所以 fieldLabel 為 displayField,處理語系時也必須以顯示欄位為主
    fieldLabel: 'operation.name',  

    //同 combo name 為 id,這樣在送出資料時才會是 operation.id
    name: 'operation.id'
}

這樣一來外觀上,會為 operation.name:operation1 但一旦內部進行 form.submit 回傳結果會是 operation.id:1 fieldLabel 顯示 name,combo 下拉的值顯示 name,背後實際的值為 id

可參考 batch editor 單身的 itemRouteForm,上述設定以正確調整於該元件的 operation.name