Commit 26040b8c authored by Frank Bergmann's avatar Frank Bergmann

- Sencha Touch:

  Creating new Notes now working except for REST interface
parent 681e70a5
......@@ -30,9 +30,7 @@ Ext.application({
],
controllers: [
'UserNavigationController',
'NoteNavigationController',
'NoteListController'
// 'NoteDetailController'
'NoteNavigationController'
],
// Main function: Load the various panels
......
Ext.define('PO.controller.NoteDetailController', {
extend: 'Ext.app.Controller',
xtype: 'noteDetailController',
config: {
refs: {
noteDetail: 'noteDetail'
},
control: {
'noteDetail': {
activate: 'onActivate'
}
}
},
onActivate: function(obj, rec) {
var form = this.getNoteDetail();
var data = form.getData();
console.log('NoteDetailController.onActivate: data=' + data);
form.setValues(data);
form.setRecord(rec);
}
});
Ext.define('PO.controller.NoteListController', {
extend: 'Ext.app.Controller',
xtype: 'noteListController',
config: {
refs: {
},
control: {
'noteList': {
activate: 'onActivate'
}
}
},
// Load the store on-demand in order to fix iPhone loading issue
onActivate: function() {
Ext.getStore('NoteStore').load();
}
});
......@@ -6,12 +6,35 @@ Ext.define('PO.controller.NoteNavigationController', {
noteNavigationView: 'noteNavigationView'
},
control: {
'noteNavigationView': {
activate: 'onActivateNavigationView'
},
'noteList': {
disclose: 'showDetail'
}
}
},
// Initialization of the Container - add a button
// The NavigationView itself doesn't seem to allow for this type of customization
onActivateNavigationView: function(navView) {
var navBar = Ext.ComponentQuery.query('noteNavigationView')[0].getNavigationBar();
navBar.add({
xtype: 'button',
text: 'New Note',
align: 'right',
handler: function() {
console.log('NoteListController: New Note button pressed');
navView.push({
xtype: 'noteDetail'
});
}
});
},
// "Disclose" Event - somebody pressed on the -> button at the list
// Create a new instance of the noteDetail page and push on the top
// of the stack
showDetail: function(list, record) {
var view = this.getNoteNavigationView();
view.push({
......@@ -20,5 +43,6 @@ Ext.define('PO.controller.NoteNavigationController', {
record: record
});
}
});
......@@ -3,7 +3,7 @@ Ext.define('PO.store.NoteStore', {
storeId: 'noteStore',
config: {
model: 'PO.model.Note',
autoLoad: false,
autoLoad: true,
sorters: 'last_name',
grouper: {
......
......@@ -40,11 +40,20 @@ Ext.define('PO.view.NoteDetail', {
text: 'Save',
ui: 'confirm',
handler: function() {
console.log('NoteDetail: Button "Save" pressed:');
// Save the form values to the record.
// The record was set by the NoteNavigationController
var form = this.up('formpanel');
var values = form.getValues();
var rec = form.getRecord();
rec.set(form.getValues());
// Did we create a completely new note?
if (typeof rec === "undefined" || rec == null) {
rec = Ext.ModelManager.create(values, 'PO.model.Note');
}
rec.set(values);
rec.save();
// Return to the list of notes page
......
......@@ -4,7 +4,6 @@ Ext.define('PO.view.NoteList', {
requires: ['PO.store.NoteStore'],
config: {
title: 'NoteList',
iconCls: 'star',
itemTpl: '<div class="contact2">{note}</div>',
......@@ -13,8 +12,6 @@ Ext.define('PO.view.NoteList', {
indexBar: true,
store: 'NoteStore',
onItemDisclosure: true
}
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment