fastui 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/MIT-LICENSE +20 -0
- data/README.md +53 -0
- data/Rakefile +40 -0
- data/app/assets/images/fastui/application/application.png +0 -0
- data/app/assets/images/fastui/application/application_add.png +0 -0
- data/app/assets/images/fastui/application/application_cascade.png +0 -0
- data/app/assets/images/fastui/application/application_delete.png +0 -0
- data/app/assets/images/fastui/application/application_double.png +0 -0
- data/app/assets/images/fastui/application/application_edit.png +0 -0
- data/app/assets/images/fastui/application/application_error.png +0 -0
- data/app/assets/images/fastui/application/application_form.png +0 -0
- data/app/assets/images/fastui/application/application_form_add.png +0 -0
- data/app/assets/images/fastui/application/application_form_delete.png +0 -0
- data/app/assets/images/fastui/application/application_form_edit.png +0 -0
- data/app/assets/images/fastui/application/application_form_magnify.png +0 -0
- data/app/assets/images/fastui/application/application_get.png +0 -0
- data/app/assets/images/fastui/application/application_go.png +0 -0
- data/app/assets/images/fastui/application/application_home.png +0 -0
- data/app/assets/images/fastui/application/application_key.png +0 -0
- data/app/assets/images/fastui/application/application_lightning.png +0 -0
- data/app/assets/images/fastui/application/application_link.png +0 -0
- data/app/assets/images/fastui/application/application_osx.png +0 -0
- data/app/assets/images/fastui/application/application_osx_terminal.png +0 -0
- data/app/assets/images/fastui/application/application_put.png +0 -0
- data/app/assets/images/fastui/application/application_side_boxes.png +0 -0
- data/app/assets/images/fastui/application/application_side_contract.png +0 -0
- data/app/assets/images/fastui/application/application_side_expand.png +0 -0
- data/app/assets/images/fastui/application/application_side_list.png +0 -0
- data/app/assets/images/fastui/application/application_side_tree.png +0 -0
- data/app/assets/images/fastui/application/application_split.png +0 -0
- data/app/assets/images/fastui/application/application_tile_horizontal.png +0 -0
- data/app/assets/images/fastui/application/application_tile_vertical.png +0 -0
- data/app/assets/images/fastui/application/application_view_columns.png +0 -0
- data/app/assets/images/fastui/application/application_view_detail.png +0 -0
- data/app/assets/images/fastui/application/application_view_gallery.png +0 -0
- data/app/assets/images/fastui/application/application_view_icons.png +0 -0
- data/app/assets/images/fastui/application/application_view_list.png +0 -0
- data/app/assets/images/fastui/application/application_view_tile.png +0 -0
- data/app/assets/images/fastui/application/application_xp.png +0 -0
- data/app/assets/images/fastui/application/application_xp_terminal.png +0 -0
- data/app/assets/images/fastui/arrow/accept.png +0 -0
- data/app/assets/images/fastui/arrow/add.png +0 -0
- data/app/assets/images/fastui/arrow/arrow_branch.png +0 -0
- data/app/assets/images/fastui/arrow/arrow_divide.png +0 -0
- data/app/assets/images/fastui/arrow/arrow_down.png +0 -0
- data/app/assets/images/fastui/arrow/arrow_in.png +0 -0
- data/app/assets/images/fastui/arrow/arrow_inout.png +0 -0
- data/app/assets/images/fastui/arrow/arrow_join.png +0 -0
- data/app/assets/images/fastui/arrow/arrow_left.png +0 -0
- data/app/assets/images/fastui/arrow/arrow_merge.png +0 -0
- data/app/assets/images/fastui/arrow/arrow_out.png +0 -0
- data/app/assets/images/fastui/arrow/arrow_redo.png +0 -0
- data/app/assets/images/fastui/arrow/arrow_refresh.png +0 -0
- data/app/assets/images/fastui/arrow/arrow_refresh_small.png +0 -0
- data/app/assets/images/fastui/arrow/arrow_rotate_anticlockwise.png +0 -0
- data/app/assets/images/fastui/arrow/arrow_rotate_clockwise.png +0 -0
- data/app/assets/images/fastui/arrow/arrow_switch.png +0 -0
- data/app/assets/images/fastui/arrow/arrow_turn_left.png +0 -0
- data/app/assets/images/fastui/arrow/arrow_turn_right.png +0 -0
- data/app/assets/images/fastui/arrow/arrow_undo.png +0 -0
- data/app/assets/images/fastui/arrow/arrow_up.png +0 -0
- data/app/assets/images/fastui/arrow/cross.png +0 -0
- data/app/assets/images/fastui/cross.png +0 -0
- data/app/assets/images/fastui/key_go.png +0 -0
- data/app/assets/images/fastui/list1211.png +0 -0
- data/app/assets/images/fastui/loading.gif +0 -0
- data/app/assets/images/fastui/lock.png +0 -0
- data/app/assets/images/fastui/locked.png +0 -0
- data/app/assets/images/fastui/table/help.png +0 -0
- data/app/assets/images/fastui/table/table.png +0 -0
- data/app/assets/images/fastui/table/table_add.png +0 -0
- data/app/assets/images/fastui/table/table_delete.png +0 -0
- data/app/assets/images/fastui/table/table_edit.png +0 -0
- data/app/assets/images/fastui/table/table_save.png +0 -0
- data/app/assets/images/fastui/upload.png +0 -0
- data/app/assets/javascripts/fastui/app/Ctx.js +33 -0
- data/app/assets/javascripts/fastui/app/Env.js +38 -0
- data/app/assets/javascripts/fastui/app/Evaluator.js +6 -0
- data/app/assets/javascripts/fastui/app/inflection.js +656 -0
- data/app/assets/javascripts/fastui/app/store/MListMgr.js +34 -0
- data/app/assets/javascripts/fastui/app/store/MWindowMgr.js +27 -0
- data/app/assets/javascripts/fastui/app/view/FormFactory.js +11 -0
- data/app/assets/javascripts/fastui/app/view/Rest.js +40 -0
- data/app/assets/javascripts/fastui/app/view/VCommentForm.js +53 -0
- data/app/assets/javascripts/fastui/app/view/VCriteria.js +25 -0
- data/app/assets/javascripts/fastui/app/view/VCustomForm.js +34 -0
- data/app/assets/javascripts/fastui/app/view/VCustomTab.js +266 -0
- data/app/assets/javascripts/fastui/app/view/VForm.js +117 -0
- data/app/assets/javascripts/fastui/app/view/VGrid.js +172 -0
- data/app/assets/javascripts/fastui/app/view/VHelpWindow.js +21 -0
- data/app/assets/javascripts/fastui/app/view/VLoginForm.js +101 -0
- data/app/assets/javascripts/fastui/app/view/VLoginWindow.js +73 -0
- data/app/assets/javascripts/fastui/app/view/VMenu.js +75 -0
- data/app/assets/javascripts/fastui/app/view/VSearchWindow.js +102 -0
- data/app/assets/javascripts/fastui/app/view/VTab.js +293 -0
- data/app/assets/javascripts/fastui/app/view/VToolbar.js +23 -0
- data/app/assets/javascripts/fastui/app/view/VTreeGrid.js +158 -0
- data/app/assets/javascripts/fastui/app/view/VVWindow.js +72 -0
- data/app/assets/javascripts/fastui/app/view/VWindow.js +52 -0
- data/app/assets/javascripts/fastui/app/view/Viewport.js +54 -0
- data/app/assets/javascripts/fastui/app/view/vfield/VCheckBox.js +19 -0
- data/app/assets/javascripts/fastui/app/view/vfield/VCheckboxGroup.js +19 -0
- data/app/assets/javascripts/fastui/app/view/vfield/VDate.js +19 -0
- data/app/assets/javascripts/fastui/app/view/vfield/VFieldFactory.js +77 -0
- data/app/assets/javascripts/fastui/app/view/vfield/VFile.js +22 -0
- data/app/assets/javascripts/fastui/app/view/vfield/VHtmlEditor.js +19 -0
- data/app/assets/javascripts/fastui/app/view/vfield/VLongComboBox.js +19 -0
- data/app/assets/javascripts/fastui/app/view/vfield/VLookup.js +45 -0
- data/app/assets/javascripts/fastui/app/view/vfield/VMultipleChoice.js +46 -0
- data/app/assets/javascripts/fastui/app/view/vfield/VNumber.js +18 -0
- data/app/assets/javascripts/fastui/app/view/vfield/VSexSelect.js +30 -0
- data/app/assets/javascripts/fastui/app/view/vfield/VSingleChoice.js +35 -0
- data/app/assets/javascripts/fastui/app/view/vfield/VText.js +17 -0
- data/app/assets/javascripts/fastui/app/view/vfield/VTextArea.js +19 -0
- data/app/assets/javascripts/fastui/app/view/vfield/VTree.js +17 -0
- data/app/assets/javascripts/fastui/app/view/vfield/VYesOrNo.js +30 -0
- data/app/assets/javascripts/fastui/application.js +18 -0
- data/app/assets/javascripts/fastui/data/mwindows.json +7 -0
- data/app/assets/javascripts/fastui/data/updateMWindows.json +4 -0
- data/app/assets/javascripts/fastui/extjs4/locale/ext-lang-zh_CN.js +304 -0
- data/app/assets/javascripts/fastui/fastui.js +23 -0
- data/app/assets/stylesheets/fastui/admin.css +95 -0
- data/app/assets/stylesheets/fastui/application.css +14 -0
- data/app/controllers/fastui/admin_controller.rb +9 -0
- data/app/controllers/fastui/application_controller.rb +19 -0
- data/app/controllers/fastui/m_list_items_controller.rb +64 -0
- data/app/controllers/fastui/m_lists_controller.rb +58 -0
- data/app/controllers/fastui/m_menu_items_controller.rb +69 -0
- data/app/controllers/fastui/m_menus_controller.rb +58 -0
- data/app/controllers/fastui/m_orgs_controller.rb +62 -0
- data/app/controllers/fastui/m_people_controller.rb +89 -0
- data/app/controllers/fastui/m_roles_controller.rb +61 -0
- data/app/controllers/fastui/m_views_controller.rb +18 -0
- data/app/controllers/fastui/sessions_controller.rb +42 -0
- data/app/helpers/fastui/admin_helper.rb +4 -0
- data/app/helpers/fastui/application_helper.rb +4 -0
- data/app/models/fastui/acl.rb +21 -0
- data/app/models/fastui/ctx.rb +15 -0
- data/app/models/fastui/env.rb +16 -0
- data/app/models/fastui/m_acl_entry.rb +5 -0
- data/app/models/fastui/m_list.rb +6 -0
- data/app/models/fastui/m_list_item.rb +8 -0
- data/app/models/fastui/m_menu.rb +10 -0
- data/app/models/fastui/m_menu_item.rb +11 -0
- data/app/models/fastui/m_object.rb +41 -0
- data/app/models/fastui/m_org.rb +16 -0
- data/app/models/fastui/m_person.rb +21 -0
- data/app/models/fastui/m_relationship.rb +9 -0
- data/app/models/fastui/m_role.rb +11 -0
- data/app/models/fastui/user_authenticator.rb +18 -0
- data/app/views/fastui/admin/index.html.erb +2 -0
- data/app/views/layouts/fastui/application.html.erb +22 -0
- data/config/routes.rb +19 -0
- data/db/migrate/20121017013727_create_fastui_m_menu_items.rb +28 -0
- data/db/migrate/20121017014112_create_fastui_m_menus.rb +20 -0
- data/db/migrate/20121017024943_create_fastui_m_orgs.rb +26 -0
- data/db/migrate/20121017025014_create_fastui_m_people.rb +24 -0
- data/db/migrate/20121204021053_create_fastui_m_roles.rb +22 -0
- data/db/migrate/20121204061207_create_fastui_m_relationships.rb +25 -0
- data/db/migrate/20121211062955_create_fastui_m_lists.rb +23 -0
- data/db/migrate/20121211074436_create_fastui_m_list_items.rb +21 -0
- data/db/migrate/20121217020606_create_fastui_m_acl_entries.rb +22 -0
- data/lib/fastui/engine.rb +8 -0
- data/lib/fastui/m_model.rb +26 -0
- data/lib/fastui/tab.rb +26 -0
- data/lib/fastui/version.rb +3 -0
- data/lib/fastui/view.rb +32 -0
- data/lib/fastui/window.rb +43 -0
- data/lib/fastui.rb +8 -0
- data/lib/generators/fastui/USAGE +21 -0
- data/lib/generators/fastui/install_generator.rb +31 -0
- data/lib/generators/fastui/templates/fastui_config.erb +77 -0
- data/lib/tasks/create_sys_data.rake +11 -0
- data/lib/tasks/fastui_tasks.rake +707 -0
- data/lib/tasks/loading_data.rake +28 -0
- metadata +276 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
Ext.define('FastUI.store.MWindowMgr', {
|
2
|
+
singleton: true,
|
3
|
+
_windows_: {},
|
4
|
+
request:function(id, callback){
|
5
|
+
var me = this;
|
6
|
+
Ext.Ajax.request({
|
7
|
+
url: '/fastui/m_views/'+id+'.json',
|
8
|
+
//async: true,
|
9
|
+
success: function(response, opts) {
|
10
|
+
var obj = Ext.decode(response.responseText);
|
11
|
+
me._windows_[id] = obj;
|
12
|
+
callback.call(this, obj);
|
13
|
+
},
|
14
|
+
failure: function(response, opts) {
|
15
|
+
|
16
|
+
}
|
17
|
+
});
|
18
|
+
},
|
19
|
+
load:function(id,callback){
|
20
|
+
var win = this._windows_[id];
|
21
|
+
if (win){
|
22
|
+
callback.call(this, win);
|
23
|
+
}else{
|
24
|
+
this.request(id,callback);
|
25
|
+
}
|
26
|
+
}
|
27
|
+
});
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Ext.define('FastUI.view.FormFactory', {
|
2
|
+
singleton: true,
|
3
|
+
|
4
|
+
createForm: function (form_kind, tab) {
|
5
|
+
if (form_kind == '') {
|
6
|
+
return Ext.create('FastUI.view.VForm', {tab: tab});
|
7
|
+
} else {
|
8
|
+
return Ext.create('FastUI.view.' + this.form_kind, {tab: tab});
|
9
|
+
}
|
10
|
+
}
|
11
|
+
});
|
@@ -0,0 +1,40 @@
|
|
1
|
+
Ext.define('FastUI.view.Rest', {
|
2
|
+
constructor:function (entity_class) {
|
3
|
+
this.entity_class = entity_class;
|
4
|
+
this.ext = '.json';
|
5
|
+
this.path = this.entity_class.underscore().pluralize();
|
6
|
+
},
|
7
|
+
getClassName:function(){
|
8
|
+
return this.entity_class.demodulize();
|
9
|
+
},
|
10
|
+
getTableName:function(){
|
11
|
+
return this.getClassName().underscore();
|
12
|
+
},
|
13
|
+
getKey:function(){
|
14
|
+
return this.getTableName() + '_id';
|
15
|
+
},
|
16
|
+
getTitle:function(){
|
17
|
+
return this.getTableName() + '_title';
|
18
|
+
},
|
19
|
+
newPath:function(){
|
20
|
+
return this.path + "/new" + this.ext;
|
21
|
+
},
|
22
|
+
editPath:function(id){
|
23
|
+
return this.path + "/" + id + "/edit"+ this.ext;
|
24
|
+
},
|
25
|
+
showPath:function(id){
|
26
|
+
return this.path + "/" + id + this.ext;
|
27
|
+
},
|
28
|
+
updatePath:function(id){
|
29
|
+
return this.path + "/" + id + this.ext;
|
30
|
+
},
|
31
|
+
createPath:function(){
|
32
|
+
return this.path + this.ext;
|
33
|
+
},
|
34
|
+
indexPath:function(){
|
35
|
+
return this.path + this.ext;
|
36
|
+
},
|
37
|
+
deletePath:function(id){
|
38
|
+
return this.path + "/" + id + this.ext;
|
39
|
+
}
|
40
|
+
});
|
@@ -0,0 +1,53 @@
|
|
1
|
+
Ext.define('FastUI.view.VComment', {
|
2
|
+
extend: 'Ext.form.Panel',
|
3
|
+
title: 'Comment Form ',
|
4
|
+
bodyPadding: 5,
|
5
|
+
layout: 'anchor',
|
6
|
+
fieldDefaults: {
|
7
|
+
labelAlign: 'left',
|
8
|
+
labelWidth: 90,
|
9
|
+
anchor: '60%'
|
10
|
+
},
|
11
|
+
defaultType: 'textfield',
|
12
|
+
border: true,
|
13
|
+
items: [
|
14
|
+
{
|
15
|
+
xtype: 'textfield',
|
16
|
+
name: 'm_comment[title]',
|
17
|
+
fieldLabel: '名称'
|
18
|
+
},
|
19
|
+
{
|
20
|
+
xtype: 'textareafield',
|
21
|
+
name: 'm_comment[note]',
|
22
|
+
fieldLabel: '描述'
|
23
|
+
},
|
24
|
+
{
|
25
|
+
xtype: 'textfield',
|
26
|
+
name: 'm_comment[guide]',
|
27
|
+
fieldLabel: '指导'
|
28
|
+
},
|
29
|
+
{
|
30
|
+
xtype: 'numberfield',
|
31
|
+
name: 'm_comment[total]',
|
32
|
+
fieldLabel: '总分'
|
33
|
+
},
|
34
|
+
{
|
35
|
+
xtype: 'textareafield',
|
36
|
+
name: 'm_comment[memo]',
|
37
|
+
fieldLabel: '备注'
|
38
|
+
}
|
39
|
+
],
|
40
|
+
initComponent: function () {
|
41
|
+
this.callParent();
|
42
|
+
},
|
43
|
+
addCriterion: function(){
|
44
|
+
|
45
|
+
}
|
46
|
+
});
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Ext.define('FastUI.view.VCriteria', {
|
2
|
+
extend: 'Ext.container.Container',
|
3
|
+
width: 400,
|
4
|
+
renderTo:{},
|
5
|
+
layout:'anchor',
|
6
|
+
defaults: {
|
7
|
+
labelAlign: 'left',
|
8
|
+
labelWidth: 90,
|
9
|
+
anchor: '60%'
|
10
|
+
},
|
11
|
+
items: [{
|
12
|
+
xtype: 'textfield',
|
13
|
+
name: 'm_comment[criteria][0][note]',
|
14
|
+
fieldLabel: '标准'
|
15
|
+
}
|
16
|
+
],
|
17
|
+
initComponent: function () {
|
18
|
+
console.log();
|
19
|
+
this.callParent();
|
20
|
+
}
|
21
|
+
|
22
|
+
});
|
23
|
+
|
24
|
+
|
25
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
Ext.define('FastUI.view.VCustomForm', {
|
2
|
+
extend:'Ext.form.Panel',
|
3
|
+
requires: ['FastUI.view.vfield.VFieldFactory'],
|
4
|
+
tab:{},
|
5
|
+
title:'Simple Form',
|
6
|
+
bodyPadding:5,
|
7
|
+
layout:'anchor',
|
8
|
+
fieldDefaults: {
|
9
|
+
labelAlign: 'left',
|
10
|
+
labelWidth: 90,
|
11
|
+
anchor: '60%'
|
12
|
+
},
|
13
|
+
defaultType:'textfield',
|
14
|
+
border:true,
|
15
|
+
initComponent:function () {
|
16
|
+
this.title = this.getValue('title');
|
17
|
+
this.items = this.getFFields();
|
18
|
+
this.callParent();
|
19
|
+
},
|
20
|
+
getValue:function(key){
|
21
|
+
return this.tab.valueObject[key];
|
22
|
+
},
|
23
|
+
getMEntity:function(){
|
24
|
+
return this.tab.valueObject.m_entity;
|
25
|
+
},
|
26
|
+
getFFields:function () {
|
27
|
+
var fields = [];
|
28
|
+
Ext.each(this.getValue('m_fields'), function (field) {
|
29
|
+
fields.push(FastUI.view.vfield.VFieldFactory.buildField(field,this.tab.winCtx, this.tab.winId,this.tab.rest));
|
30
|
+
}, this);
|
31
|
+
return fields;
|
32
|
+
}
|
33
|
+
|
34
|
+
});
|
@@ -0,0 +1,266 @@
|
|
1
|
+
Ext.define('FastUI.view.VCustomTab', {
|
2
|
+
extend: 'Ext.Panel',
|
3
|
+
alias: 'widget.vcustomtab',
|
4
|
+
valueObject: {},
|
5
|
+
winId: 0,
|
6
|
+
winCtx: {},
|
7
|
+
layout: "card",
|
8
|
+
border: true,
|
9
|
+
initComponent: function () {
|
10
|
+
this.id = 'tab-' + this.getValue('id');
|
11
|
+
this.grid_kind = this.getValue('grid_kind');
|
12
|
+
this.title = this.getValue('level') + this.getValue('title');
|
13
|
+
this.rest = Ext.create('FastUI.view.Rest', this.getMEntity().name);
|
14
|
+
this.tbar = Ext.create('Ext.toolbar.Toolbar', {
|
15
|
+
id: this.id + 'tbar',
|
16
|
+
defaults: {
|
17
|
+
scale: 'small' //scale: 'large'
|
18
|
+
},
|
19
|
+
items: [
|
20
|
+
{
|
21
|
+
id: this.id + 'new',
|
22
|
+
text: '新建',
|
23
|
+
iconCls: 'fastui-btn-new',
|
24
|
+
handler: function () {
|
25
|
+
this.cmdCreate();
|
26
|
+
this.getBtn('save').enable();
|
27
|
+
this.getBtn('edit').disable();
|
28
|
+
},
|
29
|
+
scope: this
|
30
|
+
},
|
31
|
+
{
|
32
|
+
id: this.id + 'edit',
|
33
|
+
text: '编辑',
|
34
|
+
disabled: true,
|
35
|
+
iconCls: 'fastui-btn-edit',
|
36
|
+
handler: function () {
|
37
|
+
this.cmdEdit();
|
38
|
+
this.getBtn('save').enable();
|
39
|
+
this.getBtn('new').disable();
|
40
|
+
},
|
41
|
+
scope: this
|
42
|
+
},
|
43
|
+
{
|
44
|
+
id: this.id + 'list',
|
45
|
+
text: '列表',
|
46
|
+
iconCls: 'fastui-btn-list',
|
47
|
+
handler: function () {
|
48
|
+
this.cmdList();
|
49
|
+
this.getBtn('save').disable();
|
50
|
+
this.getBtn('new').enable();
|
51
|
+
},
|
52
|
+
scope: this
|
53
|
+
},
|
54
|
+
{
|
55
|
+
id: this.id + 'save',
|
56
|
+
text: '保存',
|
57
|
+
disabled: true,
|
58
|
+
iconCls: 'fastui-btn-save',
|
59
|
+
handler: function () {
|
60
|
+
this.cmdSave();
|
61
|
+
this.getBtn('save').disable();
|
62
|
+
},
|
63
|
+
scope: this
|
64
|
+
},
|
65
|
+
{
|
66
|
+
id: this.id + 'del',
|
67
|
+
text: '删除',
|
68
|
+
disabled: true,
|
69
|
+
iconCls: 'fastui-btn-del',
|
70
|
+
handler: function () {
|
71
|
+
this.cmdDelete();
|
72
|
+
this.getBtn('edit').disable();
|
73
|
+
},
|
74
|
+
scope: this
|
75
|
+
},
|
76
|
+
{
|
77
|
+
id: this.id + 'help',
|
78
|
+
text: '帮助',
|
79
|
+
iconCls: 'fastui-btn-help',
|
80
|
+
handler: function () {
|
81
|
+
this.cmdHelp();
|
82
|
+
},
|
83
|
+
scope: this
|
84
|
+
}
|
85
|
+
]
|
86
|
+
});
|
87
|
+
FastUI.Env.setTabCtx(FastUI.Env.getWinCtx('winNo','win_id'),'tabNo','tab_id',this.id);
|
88
|
+
this.callParent();
|
89
|
+
},
|
90
|
+
getBtn: function (name) {
|
91
|
+
return this.getDockedComponent(this.id + 'tbar').items.get(this.id + name);
|
92
|
+
},
|
93
|
+
getValue: function (key) {
|
94
|
+
return this.valueObject[key];
|
95
|
+
},
|
96
|
+
getMEntity: function () {
|
97
|
+
return this.valueObject.m_entity;
|
98
|
+
},
|
99
|
+
listeners: {
|
100
|
+
activate: function (tab, opts) {
|
101
|
+
this.cmdList();
|
102
|
+
}
|
103
|
+
},
|
104
|
+
getParams: function () {
|
105
|
+
var p = {};
|
106
|
+
var tab = Ext.getCmp('tab-' + this.getValue('included_tab_id'));
|
107
|
+
if (tab) {
|
108
|
+
//p[tab.rest.getKey()] = tab.getSelectedId();
|
109
|
+
p[tab.rest.getKey()] = this.winCtx.getWinCtx(this.winId, tab.rest.getKey());
|
110
|
+
}
|
111
|
+
return p;
|
112
|
+
},
|
113
|
+
getVGrid: function () {
|
114
|
+
if (!this.vgrid) {
|
115
|
+
if (this.grid_kind == 'treegrid') {
|
116
|
+
this.vgrid = Ext.create('FastUI.view.VTreeGrid', {tab: this});
|
117
|
+
} else {
|
118
|
+
this.vgrid = Ext.create('FastUI.view.VGrid', {tab: this});
|
119
|
+
}
|
120
|
+
this.add(this.vgrid);
|
121
|
+
}
|
122
|
+
return this.vgrid;
|
123
|
+
},
|
124
|
+
getSelectedId: function () {
|
125
|
+
return this.getVGrid().selectedId();
|
126
|
+
},
|
127
|
+
cmdList: function () {
|
128
|
+
var grid = this.getVGrid();
|
129
|
+
var store = grid.getStore();
|
130
|
+
|
131
|
+
// var params1 = store.getProxy().extraParams;
|
132
|
+
// var params2 = this.getParams();
|
133
|
+
// if (Ext.encode(params1) !== Ext.encode(params2)) {
|
134
|
+
// //alert(Ext.encode(params1) + Ext.encode(params2));
|
135
|
+
// store.getProxy().extraParams = params2;
|
136
|
+
// store.reload();
|
137
|
+
// }
|
138
|
+
|
139
|
+
var id = grid.selectedId();
|
140
|
+
store.getProxy().extraParams = this.getParams();
|
141
|
+
store.reload({
|
142
|
+
callback: function (records, operation, success) {
|
143
|
+
if (this.grid_kind == 'treegrid') {
|
144
|
+
this.getBtn('edit').enable();
|
145
|
+
} else {
|
146
|
+
var rowIndex = store.find('id', id); //where 'id': the id field of your model, record.getId() is the method automatically created by Extjs. You can replace 'id' with your unique field.. And 'this' is your store.
|
147
|
+
if (rowIndex > -1) {
|
148
|
+
this.vgrid.getView().select(rowIndex);
|
149
|
+
this.getBtn('edit').enable();
|
150
|
+
}
|
151
|
+
}
|
152
|
+
},
|
153
|
+
scope: this
|
154
|
+
});
|
155
|
+
this.getLayout().setActiveItem(this.vgrid.id);
|
156
|
+
},
|
157
|
+
getForm: function () {
|
158
|
+
if (!this.vform) {
|
159
|
+
this.vform = Ext.create('FastUI.view.VCustomForm', {tab: this});
|
160
|
+
this.add(this.vform);
|
161
|
+
}
|
162
|
+
return this.vform.getForm();
|
163
|
+
},
|
164
|
+
cmdCreate: function () {
|
165
|
+
var form = this.getForm();
|
166
|
+
form.url = this.rest.createPath();
|
167
|
+
form.method = 'POST';
|
168
|
+
form.reset();
|
169
|
+
var temp = {};
|
170
|
+
var logic = "";
|
171
|
+
Ext.each(this.getValue('m_fields'), function (mfield) {
|
172
|
+
if (mfield.default_logic.length > 0) {
|
173
|
+
logic = this.winCtx.parseCtx(this.winId, mfield.default_logic);
|
174
|
+
temp[this.rest.getTableName() + '[' + mfield.m_property.name + ']'] = Ext.decode(logic);
|
175
|
+
}
|
176
|
+
}, this);
|
177
|
+
form.setValues(temp);
|
178
|
+
this.getLayout().setActiveItem(this.vform.id);
|
179
|
+
},
|
180
|
+
cmdEdit: function () {
|
181
|
+
var id = this.getVGrid().selectedId();
|
182
|
+
var form = this.getForm();
|
183
|
+
form.url = this.rest.updatePath(id);
|
184
|
+
form.method = 'PUT';
|
185
|
+
|
186
|
+
Ext.Ajax.request({
|
187
|
+
url: this.rest.editPath(id),
|
188
|
+
success: function (response) {
|
189
|
+
var data = Ext.decode(response.responseText);
|
190
|
+
var k, o = {};
|
191
|
+
for (k in data) {
|
192
|
+
if (k.match(/_id$/)) {
|
193
|
+
var attr = data[k.replace('_id', '')];
|
194
|
+
var title = data[k];
|
195
|
+
if (attr && attr.title) {
|
196
|
+
title = attr.title
|
197
|
+
}
|
198
|
+
o[this.rest.getTableName() + '[' + k + ']'] = {id: data[k], title: title};
|
199
|
+
} else if (k.match(/_ids$/)) {
|
200
|
+
o[this.rest.getTableName() + '[' + k + '][]'] = data[k];
|
201
|
+
}
|
202
|
+
else {
|
203
|
+
o[this.rest.getTableName() + '[' + k + ']'] = data[k];
|
204
|
+
}
|
205
|
+
}
|
206
|
+
// alert(Ext.encode(o));
|
207
|
+
form.setValues(o);
|
208
|
+
}, scope: this
|
209
|
+
});
|
210
|
+
this.getLayout().setActiveItem(this.vform.id);
|
211
|
+
},
|
212
|
+
cmdDelete: function () {
|
213
|
+
var id = this.getVGrid().selectedId();
|
214
|
+
Ext.MessageBox.confirm('提示', '确定要删除此记录吗?', function (btn) {
|
215
|
+
if (btn == 'yes') {
|
216
|
+
Ext.Ajax.request({
|
217
|
+
url: this.rest.deletePath(id),
|
218
|
+
method: 'DELETE',
|
219
|
+
success: function () {
|
220
|
+
this.cmdList();
|
221
|
+
Ext.MessageBox.alert("提示", "操作成功!")
|
222
|
+
},
|
223
|
+
failure: function () {
|
224
|
+
Ext.MessageBox.alert("提示", "操作失败!")
|
225
|
+
},
|
226
|
+
scope: this
|
227
|
+
});
|
228
|
+
}
|
229
|
+
}, this)
|
230
|
+
|
231
|
+
},
|
232
|
+
cmdHelp: function () {
|
233
|
+
var helpWindow = Ext.create('FastUI.view.VHelpWindow', {html: this.getValue('help')});
|
234
|
+
helpWindow.show();
|
235
|
+
},
|
236
|
+
cmdSave: function () {
|
237
|
+
if (this.vform) {
|
238
|
+
var form = this.getForm();
|
239
|
+
if (form.isValid()) {
|
240
|
+
this.constructAjaxRequest({
|
241
|
+
url: form.url,
|
242
|
+
method: form.method,
|
243
|
+
params: form.getValues(false, false, false),
|
244
|
+
success: function () {
|
245
|
+
this.cmdList();
|
246
|
+
Ext.MessageBox.alert("提示", "操作成功!")
|
247
|
+
},
|
248
|
+
failure: function () {
|
249
|
+
Ext.MessageBox.alert("提示", "操作失败!")
|
250
|
+
},
|
251
|
+
scope: this
|
252
|
+
})
|
253
|
+
}
|
254
|
+
}
|
255
|
+
},
|
256
|
+
constructAjaxRequest: function (options) {
|
257
|
+
return Ext.Ajax.request({
|
258
|
+
url: options.url,
|
259
|
+
method: options.method,
|
260
|
+
params: options.params,
|
261
|
+
success: options.success,
|
262
|
+
failure: options.failure,
|
263
|
+
scope: options.scope
|
264
|
+
});
|
265
|
+
}
|
266
|
+
});
|
@@ -0,0 +1,117 @@
|
|
1
|
+
Ext.define('FastUI.view.VForm', {
|
2
|
+
extend:'Ext.form.Panel',
|
3
|
+
requires: ['FastUI.view.vfield.VFieldFactory'],
|
4
|
+
tab:{},
|
5
|
+
title:'Simple Form',
|
6
|
+
bodyPadding:5,
|
7
|
+
layout:'anchor',
|
8
|
+
fieldDefaults: {
|
9
|
+
labelAlign: 'left',
|
10
|
+
labelWidth: 90,
|
11
|
+
anchor: '60%'
|
12
|
+
},
|
13
|
+
defaultType:'textfield',
|
14
|
+
border:false,
|
15
|
+
initComponent:function () {
|
16
|
+
this.title = this.getValue('title');
|
17
|
+
this.items = this.getFFields();
|
18
|
+
this.rest = Ext.create('FastUI.view.Rest', this.getMEntity());
|
19
|
+
this.callParent();
|
20
|
+
},
|
21
|
+
getValue:function(key){
|
22
|
+
return this.tab.valueObject[key];
|
23
|
+
},
|
24
|
+
getMEntity:function(){
|
25
|
+
return this.tab.valueObject.entity;
|
26
|
+
},
|
27
|
+
getFFields:function () {
|
28
|
+
var fields = [];
|
29
|
+
Ext.each(this.getValue('members'), function (member) {
|
30
|
+
member.readonly = member.readonly || false;
|
31
|
+
member.display = member.display || 'all';
|
32
|
+
if (member.display == 'all' || member.display == 'form'){
|
33
|
+
fields.push(FastUI.view.vfield.VFieldFactory.buildField(member,this.tab.winCtx, this.tab.winId,this.tab.rest));
|
34
|
+
}
|
35
|
+
}, this);
|
36
|
+
return fields;
|
37
|
+
},
|
38
|
+
cmdCreate: function () {
|
39
|
+
var form = this.getForm();
|
40
|
+
form.url = this.rest.createPath();
|
41
|
+
form.method = 'POST';
|
42
|
+
form.reset();
|
43
|
+
this.setAutoFields(form); // 有数据时要进行测试
|
44
|
+
},
|
45
|
+
setAutoFields: function (form) {
|
46
|
+
var temp = {};
|
47
|
+
var logic = "";
|
48
|
+
Ext.each(this.getValue('m_fields'), function (mfield) {
|
49
|
+
if (mfield.default_logic && mfield.default_logic.length > 0) {
|
50
|
+
logic = this.winCtx.parseCtx(this.winId, mfield.default_logic);
|
51
|
+
temp[this.rest.getTableName() + '[' + mfield.m_property.name + ']'] = Ext.decode(logic);
|
52
|
+
}
|
53
|
+
}, this);
|
54
|
+
form.setValues(temp);
|
55
|
+
},
|
56
|
+
cmdEdit: function () {
|
57
|
+
var id = this.tab.getVGrid().selectedId();
|
58
|
+
var form = this.getForm();
|
59
|
+
form.url = this.rest.updatePath(id);
|
60
|
+
form.method = 'PUT';
|
61
|
+
this.setEditValues(id, form);
|
62
|
+
},
|
63
|
+
setEditValues: function (id, form) {
|
64
|
+
Ext.Ajax.request({
|
65
|
+
url: this.rest.editPath(id),
|
66
|
+
success: function (response) {
|
67
|
+
var data = Ext.decode(response.responseText);
|
68
|
+
var k, o = {};
|
69
|
+
for (k in data) {
|
70
|
+
if (k.match(/_id$/)) {
|
71
|
+
var attr = data[k.replace('_id', '')];
|
72
|
+
var title = data[k];
|
73
|
+
if (attr && attr.title) {
|
74
|
+
title = attr.title
|
75
|
+
}
|
76
|
+
o[this.rest.getTableName() + '[' + k + ']'] = {id: data[k], title: title};
|
77
|
+
} else if (k.match(/_ids$/)) {
|
78
|
+
o[this.rest.getTableName() + '[' + k + '][]'] = data[k];
|
79
|
+
}
|
80
|
+
else {
|
81
|
+
o[this.rest.getTableName() + '[' + k + ']'] = data[k];
|
82
|
+
}
|
83
|
+
}
|
84
|
+
// alert(Ext.encode(o));
|
85
|
+
form.setValues(o);
|
86
|
+
}, scope: this
|
87
|
+
});
|
88
|
+
},
|
89
|
+
cmdSave: function () {
|
90
|
+
var form = this.getForm();
|
91
|
+
if (form.isValid()) {
|
92
|
+
this.constructAjaxRequest({
|
93
|
+
url: form.url,
|
94
|
+
method: form.method,
|
95
|
+
params: form.getValues(false, false, false),
|
96
|
+
success: function () {
|
97
|
+
Ext.MessageBox.alert("提示", "操作成功!")
|
98
|
+
},
|
99
|
+
failure: function () {
|
100
|
+
Ext.MessageBox.alert("提示", "操作失败!")
|
101
|
+
},
|
102
|
+
scope: this
|
103
|
+
});
|
104
|
+
}
|
105
|
+
},
|
106
|
+
constructAjaxRequest: function (options) {
|
107
|
+
return Ext.Ajax.request({
|
108
|
+
url: options.url,
|
109
|
+
method: options.method,
|
110
|
+
params: options.params,
|
111
|
+
success: options.success,
|
112
|
+
failure: options.failure,
|
113
|
+
scope: options.scope
|
114
|
+
});
|
115
|
+
}
|
116
|
+
|
117
|
+
});
|