Commit 681e70a5 authored by Frank Bergmann's avatar Frank Bergmann

- Sencha Touch:

  Notes example now working with edit
parent 7ff7ea10
...@@ -8,13 +8,15 @@ Ext.application({ ...@@ -8,13 +8,15 @@ Ext.application({
], ],
models: [ models: [
'Category',
'Note', 'Note',
'User' 'User'
], ],
stores: [ stores: [
'NoteStore', 'NoteStore',
'UserStore', 'UserStore',
'ContactStore' 'ContactStore',
'CategoryNoteTypeStore'
], ],
views: [ views: [
'SplashPage', 'SplashPage',
...@@ -30,6 +32,7 @@ Ext.application({ ...@@ -30,6 +32,7 @@ Ext.application({
'UserNavigationController', 'UserNavigationController',
'NoteNavigationController', 'NoteNavigationController',
'NoteListController' 'NoteListController'
// 'NoteDetailController'
], ],
// Main function: Load the various panels // 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);
}
});
...@@ -13,12 +13,11 @@ Ext.define('PO.controller.NoteNavigationController', { ...@@ -13,12 +13,11 @@ Ext.define('PO.controller.NoteNavigationController', {
}, },
showDetail: function(list, record) { showDetail: function(list, record) {
console.log('disclose details');
var view = this.getNoteNavigationView(); var view = this.getNoteNavigationView();
view.push({ view.push({
xtype: 'noteDetail', xtype: 'noteDetail',
title: record.data.note, title: record.data.note,
data: record.data record: record
}); });
} }
}); });
......
Ext.define('PO.model.Category', {
extend: 'Ext.data.Model',
config: {
idProperty: 'category_id',
fields: [
{type: 'string', name: 'category_id'},
{type: 'string', name: 'tree_sortkey'},
{type: 'string', name: 'category'},
{type: 'string', name: 'aux_string1'},
{type: 'string', name: 'aux_string2'},
{type: 'string', name: 'category_type'},
{type: 'string', name: 'category_translated'},
{type: 'string', name: 'sort_order'},
{type: 'string', name: 'indent_class',
// Determine the indentation level for each element in the tree
convert: function(value, record) {
var category = record.get('category_translated');
var indent = (record.get('tree_sortkey').length / 8) - 1;
return 'extjs-indent-level-' + indent;
}
},
{type: 'string', name: 'tree_category_translated'}
],
proxy: {
type: 'rest',
url: '/intranet-rest/im_category',
appendId: true, // Append the object_id: ../im_ticket/<object_id>
timeout: 300000,
extraParams: {
format: 'json' // Tell the ]po[ REST to return JSON data.
},
reader: {
type: 'json', // Tell the Proxy Reader to parse JSON
rootProperty: 'data', // Where do the data start in the JSON file?
totalProperty: 'total' // Total number of tickets for pagination
}
}
}
});
Ext.define('PO.store.CategoryNoteTypeStore', {
extend: 'Ext.data.Store',
storeId: 'categoryNodeTypeStore',
config: {
model: 'PO.model.Category',
autoLoad: true,
sorters: [{
property: 'sort_order',
direction: 'ASC'
}, {
property: 'tree_sortkey',
direction: 'ASC'
}],
proxy: {
type: 'rest',
url: '/intranet-rest/im_category',
appendId: true,
extraParams: {
format: 'json',
category_type: '\'Intranet Notes Type\''
},
reader: {
type: 'json',
rootProperty: 'data'
}
}
}
});
...@@ -9,17 +9,30 @@ Ext.define('PO.view.NoteDetail', { ...@@ -9,17 +9,30 @@ Ext.define('PO.view.NoteDetail', {
title: 'Note Fields', title: 'Note Fields',
instructions: '(email address is optional)', instructions: '(email address is optional)',
items: [{ items: [{
xtype: 'textfield', xtype: 'selectfield',
name: 'first_names', name: 'note_type_id',
label: 'Name' label: 'Type',
}, { options: [
xtype: 'emailfield', {text: 'Address', value: '11500'},
name: 'email', {text: 'Email', value: '11502'},
label: 'Email' {text: 'Http', value: '11504'},
{text: 'Ftp', value: '11506'},
{text: 'Phone', value: '11508'},
{text: 'Fax', value: '11510'},
{text: 'Mobile', value: '11512'},
{text: 'Other', value: '11514'}
]
}, { }, {
xtype: 'textareafield', xtype: 'textareafield',
name: 'message', name: 'note',
label: 'Message' label: 'Note'
}, {
xtype: 'hiddenfield',
name: 'id'
}, {
xtype: 'hiddenfield',
name: 'object_id',
label: 'Object ID'
} }
] ]
}, { }, {
...@@ -27,21 +40,18 @@ Ext.define('PO.view.NoteDetail', { ...@@ -27,21 +40,18 @@ Ext.define('PO.view.NoteDetail', {
text: 'Save', text: 'Save',
ui: 'confirm', ui: 'confirm',
handler: function() { handler: function() {
// var form = Ext.getCmp('contactFormPanel').getValues(); // Save the form values to the record.
var form = this.up('formpanel'); // The record was set by the NoteNavigationController
form.submit({ var form = this.up('formpanel');
method: 'GET', var rec = form.getRecord();
url: 'http://www.project-open.net/intranet-crm-tracking/contact', rec.set(form.getValues());
success: function() { rec.save();
alert('form submitted successfully!');
}, // Return to the list of notes page
failure: function() { var navView = this.up('noteNavigationView');
alert('form submission failed'); navView.pop();
}
});
} }
} }
] ]
} }
}); });
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