OSDN Git Service

プラグイン?的な扱いで社員情報編集用の機能を追加。
authorMasamitsu Oikawa <oicawa@gmail.com>
Sun, 12 Jun 2011 04:35:58 +0000 (13:35 +0900)
committerMasamitsu Oikawa <oicawa@gmail.com>
Sun, 12 Jun 2011 04:35:58 +0000 (13:35 +0900)
但し、ナビゲーターにて「社員情報」をクリックすると、1回目はタブが表示されず、2回目以降に表示されるバグがある。原因不明。。
また、不要なファイルを削除。

app/controller/Menu.js [new file with mode: 0644]
data/menu/list.json [new file with mode: 0644]
data/menu/updateList.json [new file with mode: 0644]
routines/member/Edit.js [new file with mode: 0644]
routines/member/List.js [new file with mode: 0644]
routines/member/Model.js [new file with mode: 0644]
routines/member/Root.js [new file with mode: 0644]
routines/member/Store.js [new file with mode: 0644]
routines/member/data.json [new file with mode: 0644]
routines/member/update.json [new file with mode: 0644]

diff --git a/app/controller/Menu.js b/app/controller/Menu.js
new file mode 100644 (file)
index 0000000..f83630b
--- /dev/null
@@ -0,0 +1,42 @@
+Ext.define(
+  'Decshee.controller.Menu',
+  {
+    extend: 'Ext.app.Controller',
+
+    views: [
+      'menu.List',
+      'menu.Entry'
+    ],
+
+    stores: [
+      'menu.List'
+    ],
+
+    models: [
+      'menu.Entry'
+    ],
+
+    init: function() {
+      console.log('[START] init');
+      this.control(
+        {
+          'menulist': {
+            itemdblclick: this.showTab
+          }
+        }
+      );
+      console.log('[ END ] init');
+    },
+
+    showTab: function(grid, record) {
+      console.log('Double clicked on ' + record.get('caption'));
+      var caption = record.get('caption');
+      var id = record.get('id');
+
+      console.log('clicked the ShowMenu entry { text: ' + caption +  ', id:' + id + '}');
+      var viewport = grid.up('viewport');
+      var maintabs = viewport.child ('#maintabs');
+      maintabs.showTab(record);
+    }
+  }
+);
\ No newline at end of file
diff --git a/data/menu/list.json b/data/menu/list.json
new file mode 100644 (file)
index 0000000..a7422ca
--- /dev/null
@@ -0,0 +1,8 @@
+{
+  success: true,
+  menus: [
+    { caption: '社員情報', id: 'member'},
+    { caption: '組織情報', id: 'belonging'},
+    { caption: '権限情報', id: 'role'}
+  ]        
+}
\ No newline at end of file
diff --git a/data/menu/updateList.json b/data/menu/updateList.json
new file mode 100644 (file)
index 0000000..7146d7e
--- /dev/null
@@ -0,0 +1 @@
+{ success: true }
\ No newline at end of file
diff --git a/routines/member/Edit.js b/routines/member/Edit.js
new file mode 100644 (file)
index 0000000..462959b
--- /dev/null
@@ -0,0 +1,54 @@
+Ext.define(
+  'Decshee.routines.member.Edit',
+  {
+    extend: 'Ext.window.Window',
+    alias : 'widget.memberedit',
+
+    title : '社員情報詳細',
+    layout: 'fit',
+    autoShow: true,
+
+    initComponent: function() {
+      this.items = [
+        {
+          xtype: 'form',
+          items: [
+            {
+              xtype: 'textfield',
+              name : 'name',
+              fieldLabel: '氏名'
+            },
+            {
+              xtype: 'textfield',
+              name : 'email',
+              fieldLabel: 'Email'
+            }
+          ]
+        }
+      ];
+
+      this.buttons = [
+        {
+          text: '保存',
+          action: 'save',
+          handler: function(button){
+            console.log('clicked the Save button.');
+            var win = button.up('window');
+            var form = win.down('form');
+            var record = form.getRecord();
+            var values = form.getValues();
+            record.set(values);
+            win.close();
+            this.getStore().sync();
+          }
+        },
+        {
+          text: 'キャンセル',
+          scope: this,
+          handler: this.close
+        }
+      ];
+
+      this.callParent(arguments);
+    }
+  });
\ No newline at end of file
diff --git a/routines/member/List.js b/routines/member/List.js
new file mode 100644 (file)
index 0000000..232bfcc
--- /dev/null
@@ -0,0 +1,37 @@
+Ext.define(
+  'Decshee.routines.member.List',
+  {
+    extend: 'Ext.grid.Panel',
+    requires: [
+      'Decshee.routines.member.Store',
+      'Decshee.routines.member.Edit'
+    ],
+    alias : 'widget.memberlist',
+    title : '社員情報一覧',
+
+    store : Ext.create('Decshee.routines.member.Store'),
+    // store : 'Decshee.routines.member.Store',
+
+    initComponent: function() {
+      console.log('[START]Decshee.routines.member.List.initComponent');
+      this.columns = [
+        { header: '氏名',  dataIndex: 'name',  flex: 1 },
+        { header: 'Email', dataIndex: 'email', flex: 1 }
+      ];
+      this.callParent(arguments);
+      console.log('[ END ]Decshee.routines.member.List.initComponent');
+    },
+
+    listeners: {
+      itemdblclick: function(grid, record, item, index, e) {
+        console.log(record);
+        this.showForm(record);
+      }
+    },
+
+    showForm: function(record) {
+      var window = Ext.create('Decshee.routines.member.Edit');
+      window.down('form').loadRecord(record);
+    }
+  }
+);
diff --git a/routines/member/Model.js b/routines/member/Model.js
new file mode 100644 (file)
index 0000000..eb47450
--- /dev/null
@@ -0,0 +1,7 @@
+Ext.define(
+  'Decshee.routines.member.Model',
+  {
+    extend: 'Ext.data.Model',
+    fields: ['name', 'email']
+  }
+);
\ No newline at end of file
diff --git a/routines/member/Root.js b/routines/member/Root.js
new file mode 100644 (file)
index 0000000..143d954
--- /dev/null
@@ -0,0 +1,26 @@
+Ext.define(
+  'Decshee.routines.member.Root',
+  {
+    extend: 'Ext.panel.Panel',
+    requires: [
+      'Decshee.routines.member.List'
+    ],
+    alias: 'widget.memberroot',
+    layout: 'fit',
+
+    initComponent : function() {
+      console.log('[START]Decshee.routines.member.Root.initComponent');
+      var me = this;
+      Ext.apply(
+        me,
+        {
+          items: [
+            Ext.create('Decshee.routines.member.List')
+          ]
+        }
+      );
+      this.callParent(arguments);
+      console.log('[ END ]Decshee.routines.member.Root.initComponent');
+    }
+  }
+);
diff --git a/routines/member/Store.js b/routines/member/Store.js
new file mode 100644 (file)
index 0000000..4c22696
--- /dev/null
@@ -0,0 +1,28 @@
+Ext.define(
+  'Decshee.routines.member.Store',
+  {
+    extend: 'Ext.data.Store',
+    requires: ['Decshee.routines.member.Model'],
+
+    model: 'Decshee.routines.member.Model',
+    autoLoad: true,
+
+    proxy: {
+      type: 'ajax',
+      api: {
+        read: 'routines/member/data.json',
+        update: 'routines/member/update.json'
+      },
+
+      reader: {
+        type: 'json',
+        root: 'members',
+        successProperty: 'success'
+      }
+    },
+
+    initComponent: function() {
+        Ext.require('Decshee.routines.member.Model');
+    }
+  }
+);
\ No newline at end of file
diff --git a/routines/member/data.json b/routines/member/data.json
new file mode 100644 (file)
index 0000000..ca118aa
--- /dev/null
@@ -0,0 +1,7 @@
+{
+  success: true,
+  members: [
+    {id: 1, name: 'Ed',    email: 'ed@sencha.com'},
+    {id: 2, name: 'Tommy', email: 'tommy@sencha.com'}
+  ]
+}
\ No newline at end of file
diff --git a/routines/member/update.json b/routines/member/update.json
new file mode 100644 (file)
index 0000000..7146d7e
--- /dev/null
@@ -0,0 +1 @@
+{ success: true }
\ No newline at end of file