Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup model, store and views for users model.
- Loading branch information
Showing
6 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
App.models.User = Ext.regModel('User', { | ||
fields: [ | ||
{ | ||
name: 'id', | ||
type: 'int' | ||
}, { | ||
name: 'name', | ||
type: 'string' | ||
}, { | ||
name: 'email', | ||
type: 'string' | ||
} | ||
], | ||
|
||
validations: [ | ||
{ | ||
type: 'presence', | ||
name: 'name' | ||
}, { | ||
type: 'format', | ||
name: 'email', | ||
matcher: /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, | ||
message: 'must be a valid email' | ||
} | ||
], | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
App.stores.users = new Ext.data.Store({ | ||
model: 'User', | ||
autoLoad: true, | ||
proxy: { | ||
type: 'localstorage', | ||
id: 'sencha-users' | ||
} | ||
}); | ||
|
||
// temporary data, for use until full CRUD is implemented | ||
App.stores.users.proxy.clear(); | ||
App.stores.users.add({ name: 'Drew Neil', email: 'drew.neil@example.com' }); | ||
App.stores.users.add({ name: 'James Pearce', email: 'james.pearce@example.com' }); | ||
App.stores.users.add({ name: 'Ed Spencer', email: 'ed.spencer@example.com' }); | ||
App.stores.users.add({ name: 'Tommy Mainz', email: 'tommy.mainz@example.com' }); | ||
App.stores.users.sync(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
App.views.UsersForm = Ext.extend(Ext.form.FormPanel, { | ||
initComponent: function(){ | ||
Ext.apply(this, { | ||
html: 'user form' | ||
}); | ||
|
||
App.views.UsersForm.superclass.initComponent.call(this); | ||
} | ||
}); | ||
|
||
Ext.reg('App.views.UsersForm', App.views.UsersForm); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
App.views.UsersList = Ext.extend(Ext.Panel, { | ||
initComponent: function(){ | ||
Ext.apply(this, { | ||
html: 'placeholder', | ||
layout: 'fit', | ||
|
||
dockedItems: [ | ||
{ | ||
dock: 'top', | ||
xtype: 'toolbar', | ||
title: 'Users', | ||
items: [] | ||
} | ||
], | ||
items: [ | ||
{ | ||
xtype: 'list', | ||
itemTpl: '{name}', | ||
store: App.stores.users, | ||
emptyText: '<div class="emptytext">There are no users in the system at the moment.</div>', | ||
} | ||
] | ||
}); | ||
|
||
App.views.UsersList.superclass.initComponent.call(this); | ||
} | ||
}); | ||
|
||
Ext.reg('App.views.UsersList', App.views.UsersList); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
App.views.Viewport = Ext.extend(Ext.Panel, { | ||
fullscreen: true, | ||
layout: 'card', | ||
|
||
initComponent: function() { | ||
Ext.apply(this, { | ||
items: [ | ||
{ xtype: 'App.views.UsersList' }, | ||
{ xtype: 'App.views.UsersForm' }, | ||
] | ||
}); | ||
App.views.Viewport.superclass.initComponent.apply(this, arguments); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters