This file contains hidden or 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
# Using a Promise | |
loadCompanies: -> | |
@companyService.loadCompanies().then( | |
success: ( records ) -> | |
# Do something with results | |
failure: ( error ) -> | |
# Do something with the error | |
).always( -> | |
# Do something whether the call succeeded or failed | |
) |
This file contains hidden or 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
# Common way of making async call via underlying Ext.Ajax call | |
loadCompanies: -> | |
@companyService.loadCompanies( | |
success: ( response ) -> | |
results = Ext.decode( response.responseText ) | |
# Do something with results | |
# Do something whether the call succeeded or failed | |
failure: ( response ) -> | |
# Do something with the error |
This file contains hidden or 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
# Common way of making async call via underlying Store | |
loadCompanies: -> | |
@companyService.loadCompanies( | |
callback: ( records, operation, success ) -> | |
if( success ) | |
# Do something with results | |
else | |
# Do something with the error | |
# Do something whether the call succeeded or failed |
This file contains hidden or 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
it "should allow setting the current company to be intercepted and altered", -> | |
store = Deft.ioc.Injector.resolve( "companyStore" ) | |
waitsFor( ( -> store.getCount() > 0 ), "Store data never loaded.", 2000 ) | |
runs( -> | |
grid = viewController.getCompanyGridPanel() | |
changedPrice = 12345.67 | |
spyOn( viewController, 'setCurrentCompany').andCallFake( ( company ) -> | |
originalFunction = @setCurrentCompany.originalValue |
This file contains hidden or 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
it "should allow getting the current company to be faked", -> | |
grid = viewController.getCompanyGridPanel() | |
spyOn( viewController, 'getCurrentCompany').andCallFake( -> | |
return "Fake Company" | |
) | |
expect( viewController.getCurrentCompany() ).toBe( "Fake Company" ) |
This file contains hidden or 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
it "should store the selected company as the current company", -> | |
store = Deft.ioc.Injector.resolve( "companyStore" ) | |
waitsFor( ( -> store.getCount() > 0 ), "Store data never loaded.", 2000 ) | |
runs( -> | |
grid = viewController.getCompanyGridPanel() | |
spyOn( viewController, 'setCurrentCompany').andCallThrough() | |
firstCompany = grid.store.getAt( 0 ) | |
grid.fireEvent( "selectionchange", {}, [ firstCompany ], 0 ) |
This file contains hidden or 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
it "should pass the selected company when setting the current company", -> | |
store = Deft.ioc.Injector.resolve( "companyStore" ) | |
waitsFor( ( -> store.getCount() > 0 ), "Store data never loaded.", 2000 ) | |
runs( -> | |
grid = viewController.getCompanyGridPanel() | |
spyOn( viewController, 'setCurrentCompany') | |
firstCompany = grid.store.getAt( 0 ) | |
grid.fireEvent( "selectionchange", {}, [ firstCompany ], 0 ) |
This file contains hidden or 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
it "should update the current company upon selection", -> | |
store = Deft.ioc.Injector.resolve( "companyStore" ) | |
waitsFor( ( -> store.getCount() > 0 ), "Store data never loaded.", 2000 ) | |
runs( -> | |
grid = viewController.getCompanyGridPanel() | |
spyOn( viewController, 'setCurrentCompany' ) | |
firstCompany = grid.store.getAt( 0 ) | |
grid.fireEvent( "selectionchange", {}, [ firstCompany ] ) |
This file contains hidden or 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
Ext.define( "JasmineExample.controller.MainController", | |
extend: "Deft.mvc.ViewController" | |
control: | |
companyGridPanel: | |
selectionchange: "onCompanySelected" | |
panel2: {} | |
config: |
This file contains hidden or 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 version by harley.333 | |
* Updated 5/6/2011 by taylorbarstow | |
* | |
* FOUND HERE: http://www.sencha.com/forum/showthread.php?53118-Multiple-Cells-Selection-Model | |
* | |
* @class Ext.ux.MultiCellSelectionModel | |
* @extends Ext.grid.AbstractSelectionModel | |
* Supports multiple selections and keyboard selection/navigation. | |
* @constructor |