-/*!
- * Ext JS Library 3.2.2
- * Copyright(c) 2006-2010 Ext JS, Inc.
- * licensing@extjs.com
- * http://www.extjs.com/license
- */
-// Application instance for showing user-feedback messages.
-var App = new Ext.App({});
-
-// Create HttpProxy instance. Notice new configuration parameter "api" here instead of load. However, you can still use
-// the "url" paramater -- All CRUD requests will be directed to your single url instead.
-var proxy = new Ext.data.HttpProxy({
- api: {
- read : 'app.php/users/view',
- create : 'app.php/users/create',
- update: 'app.php/users/update',
- destroy: 'app.php/users/destroy'
+/*
+
+This file is part of Ext JS 4
+
+Copyright (c) 2011 Sencha Inc
+
+Contact: http://www.sencha.com/contact
+
+GNU General Public License Usage
+This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
+
+If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
+
+*/
+Ext.define('Writer.Form', {
+ extend: 'Ext.form.Panel',
+ alias: 'widget.writerform',
+
+ requires: ['Ext.form.field.Text'],
+
+ initComponent: function(){
+ this.addEvents('create');
+ Ext.apply(this, {
+ activeRecord: null,
+ iconCls: 'icon-user',
+ frame: true,
+ title: 'User -- All fields are required',
+ defaultType: 'textfield',
+ bodyPadding: 5,
+ fieldDefaults: {
+ anchor: '100%',
+ labelAlign: 'right'
+ },
+ items: [{
+ fieldLabel: 'Email',
+ name: 'email',
+ allowBlank: false,
+ vtype: 'email'
+ }, {
+ fieldLabel: 'First',
+ name: 'first',
+ allowBlank: false
+ }, {
+ fieldLabel: 'Last',
+ name: 'last',
+ allowBlank: false
+ }],
+ dockedItems: [{
+ xtype: 'toolbar',
+ dock: 'bottom',
+ ui: 'footer',
+ items: ['->', {
+ iconCls: 'icon-save',
+ itemId: 'save',
+ text: 'Save',
+ disabled: true,
+ scope: this,
+ handler: this.onSave
+ }, {
+ iconCls: 'icon-user-add',
+ text: 'Create',
+ scope: this,
+ handler: this.onCreate
+ }, {
+ iconCls: 'icon-reset',
+ text: 'Reset',
+ scope: this,
+ handler: this.onReset
+ }]
+ }]
+ });
+ this.callParent();
+ },
+
+ setActiveRecord: function(record){
+ this.activeRecord = record;
+ if (record) {
+ this.down('#save').enable();
+ this.getForm().loadRecord(record);
+ } else {
+ this.down('#save').disable();
+ this.getForm().reset();
+ }
+ },
+
+ onSave: function(){
+ var active = this.activeRecord,
+ form = this.getForm();
+
+ if (!active) {
+ return;
+ }
+ if (form.isValid()) {
+ form.updateRecord(active);
+ this.onReset();
+ }
+ },
+
+ onCreate: function(){
+ var form = this.getForm();
+
+ if (form.isValid()) {
+ this.fireEvent('create', this, form.getValues());
+ form.reset();
+ }
+
+ },
+
+ onReset: function(){
+ this.setActiveRecord(null);
+ this.getForm().reset();