-
Notifications
You must be signed in to change notification settings - Fork 0
/
books-admin.html
executable file
·160 lines (124 loc) · 3.16 KB
/
books-admin.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<html>
<head>
<title>Books</title>
<link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css" />
<style>
body{
background-color:#aeaeae;
}
#container{
background-color:#ccc;
}
</style>
<script src="extjs/adapter/ext/ext-base.js"></script>
<script src="extjs/ext-all-debug.js"></script>
<script>
Ext.BLANK_IMAGE_URL = 'extjs/resources/images/default/s.gif';
Ext.onReady(function () {
// a grid with an "add" button
// clicking "add" will trigger a "card" layout in a "window"
// each panel of the "card" layout will be a form
// each step of the card should validate before moving to the next step
// completing the card sequence will submit the data as a whole and add record to grid
// editing will re-initiate the card flow
// deleting will simply remove
// search
var bookForm = {
id: 'book-form',
xtype: 'form', // FormPanel
layout: 'form', // form layout
title : 'Book Form',
//html : 'Panel with <b>no</b> xtype specified',
frame: true,
items: [
{
xtype: 'fieldset',
defaultType: 'textfield',
items: [
{
fieldLabel: "Title",
name: 'title'
},
{
fieldLabel: "Author",
name: 'author'
}
]
}
],
buttons: [
{
text: 'Submit',
formBind: true,
handler: function(){
console.log("Submitting");
var formPanel = Ext.getCmp('book-form');
formPanel.el.mask('Please wait', 'x-mask-loading');
formPanel.getForm().submit({
url : 'books.php',
params: {
action: 'submit'
},
success : function(form, action) {
var formPanel = Ext.getCmp('book-form');
formPanel.el.unmask();
var result = action.result;
if (result.success) {
Ext.MessageBox.alert('Success',action.result.msg);
} else {
Ext.MessageBox.alert('Failure',action.result.msg);
}
},
failure : function(form, action) {
var formPanel = Ext.getCmp('book-form');
formPanel.el.unmask();
var result = action.result;
if (result.success) {
Ext.MessageBox.alert('Success',action.result.msg);
} else {
Ext.MessageBox.alert('Failure',action.result.msg);
}
}
});
}
},
{
text: 'Reset',
handler: function(btn, eventObj) {
Ext.getCmp('book-form').getForm().reset();
}
}
]
};
var myViewport = new Ext.Viewport({
id: 'myViewport',
layout: 'border',
items : [
{
id : 'panel1',
region: 'center',
title : 'Plain Panel',
html : 'Panel with an xtype specified',
frame: true
},
{
id : 'panel2',
region: 'west',
title : 'Plain Panel',
//html : 'Panel with an xtype specified',
width:400,
frame: true,
items: [
bookForm
]
}
]
});
myViewport.show();
});
</script>
</head>
<body>
<div id="container"></div>
</body>
</html>