Commit 0b5e16a6 authored by Frank Bergmann's avatar Frank Bergmann

- Sencha Timesheet TS:

  Added a Project timesheet view
parent 69016a56
Ext.define('PO.controller.ProjectNavigationController', {
extend: 'Ext.app.Controller',
xtype: 'projectNavigationController',
config: {
refs: {
projectNavigationView: 'projectNavigationView'
},
control: {
'projectNavigationView': {
initialize: 'onInitializeNavigationView'
},
'projectList': {
disclose: 'showDetail'
}
}
},
// Initialization of the Container - add a button
// The NavigationView itself doesn't seem to allow for this type of customization
onInitializeNavigationView: function(navView) {
var navBar = Ext.ComponentQuery.query('projectNavigationView')[0].getNavigationBar();
navBar.add({
xtype: 'button',
text: 'New Project',
align: 'right',
handler: function() {
console.log('ProjectListController: New Project button pressed');
navView.push({
xtype: 'projectDetail',
title: 'New Project'
});
}
});
},
// "Disclose" Event - somebody pressed on the -> button at the list
// Create a new instance of the projectDetail page and push on the top
// of the stack
showDetail: function(list, record) {
var view = this.getProjectNavigationView();
view.push({
xtype: 'projectTimesheet',
record: record
});
}
});
Ext.define('PO.view.ProjectDetail', {
extend: 'Ext.form.Panel',
xtype: 'projectDetail',
config: {
title: 'Project Detail',
layout: 'vbox',
items: [{
xtype: 'fieldset',
title: 'Edit Project',
items: [{
xtype: 'selectfield',
name: 'project_type_id',
label: 'Type',
options: [
{text: 'Address', value: '11500'},
{text: 'Email', value: '11502'},
{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',
name: 'project',
label: 'Project'
}, {
xtype: 'hiddenfield',
name: 'id'
}, {
xtype: 'hiddenfield',
name: 'project_status_id',
value: 11400
}, {
xtype: 'hiddenfield',
name: 'object_id',
label: 'Object ID',
value: 0 // Magic value: 0 is the ID of the "guest" object
}
]
}, {
xtype: 'button',
text: 'Save',
ui: 'confirm',
handler: function() {
console.log('ProjectDetail: Button "Save" pressed:');
// Save the form values to the record.
// The record was set by the ProjectNavigationController
var form = this.up('formpanel');
var values = form.getValues();
var rec = form.getRecord();
// Did we create a completely new project?
if (typeof rec === "undefined" || rec == null) {
rec = Ext.ModelManager.create(values, 'PO.model.Project');
}
// Save the model - generates PUT or POST to REST backend
rec.set(values);
rec.save();
// reload the store
var projectStore = Ext.data.StoreManager.lookup('ProjectStore');
projectStore.load();
// Return to the list of projects page
var navView = this.up('projectNavigationView');
navView.pop();
}
}
]
}
});
Ext.define('PO.view.ProjectEdit', {
extend: 'Ext.form.Panel',
xtype: 'projectEdit',
config: {
title: 'Project Edit',
layout: 'vbox',
items: [{
xtype: 'fieldset',
title: 'Edit Project',
items: [{
xtype: 'selectfield',
name: 'project_type_id',
label: 'Type',
options: [
{text: 'Address', value: '11500'},
{text: 'Email', value: '11502'},
{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',
name: 'project',
label: 'Project'
}, {
xtype: 'hiddenfield',
name: 'id'
}, {
xtype: 'hiddenfield',
name: 'project_status_id',
value: 11400
}, {
xtype: 'hiddenfield',
name: 'object_id',
label: 'Object ID',
value: 0 // Magic value: 0 is the ID of the "guest" object
}
]
}, {
xtype: 'button',
text: 'Save',
ui: 'confirm',
handler: function() {
console.log('ProjectEdit: Button "Save" pressed:');
// Save the form values to the record.
// The record was set by the ProjectNavigationController
var form = this.up('formpanel');
var values = form.getValues();
var rec = form.getRecord();
// Did we create a completely new project?
if (typeof rec === "undefined" || rec == null) {
rec = Ext.ModelManager.create(values, 'PO.model.Project');
}
// Save the model - generates PUT or POST to REST backend
rec.set(values);
rec.save();
// reload the store
var projectStore = Ext.data.StoreManager.lookup('ProjectStore');
projectStore.load();
// Return to the list of projects page
var navView = this.up('projectNavigationView');
navView.pop();
}
}
]
}
});
Ext.define('PO.view.ProjectNavigationView', {
extend: 'Ext.navigation.View',
xtype: 'projectNavigationView',
requires: [
'PO.view.ProjectList',
'PO.view.ProjectDetail'
],
config: {
title: 'Projects',
iconCls: 'star',
items: [{
xtype: 'projectList'
}]
}
});
/*
* ProjectTimesheet.js
* (c) 2013 ]project-open[
* Please see www.project-open.org/en/project_open_license for details
*
* Timesheet entry page for a single task, sub-project or main project.
* Allows the user to log a single timesheet entry.
*/
Ext.define('PO.view.ProjectTimesheet', {
extend: 'Ext.form.Panel',
xtype: 'projectTimesheet',
config: {
title: 'Project Timesheet',
layout: 'vbox',
items: [{
xtype: 'fieldset',
title: 'Information',
items: [{
xtype: 'selectfield',
name: 'project_type_id',
label: 'Type',
options: [
{text: 'Address', value: '11500'},
{text: 'Email', value: '11502'},
{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',
name: 'project',
label: 'Project'
}, {
xtype: 'hiddenfield',
name: 'id'
}, {
xtype: 'hiddenfield',
name: 'project_status_id',
value: 11400
}, {
xtype: 'hiddenfield',
name: 'object_id',
label: 'Object ID',
value: 0 // Magic value: 0 is the ID of the "guest" object
}
]
}, {
xtype: 'button',
text: 'Save',
ui: 'confirm',
handler: function() {
console.log('ProjectTimesheet: Button "Save" pressed:');
// Save the form values to the record.
// The record was set by the ProjectNavigationController
var form = this.up('formpanel');
var values = form.getValues();
var rec = form.getRecord();
// Did we create a completely new project?
if (typeof rec === "undefined" || rec == null) {
rec = Ext.ModelManager.create(values, 'PO.model.Project');
}
// Save the model - generates PUT or POST to REST backend
rec.set(values);
rec.save();
// reload the store
var projectStore = Ext.data.StoreManager.lookup('ProjectStore');
projectStore.load();
// Return to the list of projects page
var navView = this.up('projectNavigationView');
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