Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
intranet-timesheet2-weekly
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
project-open
intranet-timesheet2-weekly
Commits
fb63d69c
Commit
fb63d69c
authored
Apr 03, 2021
by
Project Open
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Created a HourWeeklyProxy between panel and HoursStore.
parent
b9c62c43
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
189 additions
and
50 deletions
+189
-50
index.adp
www/index.adp
+21
-12
HourWeekly.js
www/js/HourWeekly.js
+11
-1
HourWeeklyController.js.adp
www/js/HourWeeklyController.js.adp
+36
-36
HourWeeklyProxy.js
www/js/HourWeeklyProxy.js
+108
-0
HourWeeklyStore.js
www/js/HourWeeklyStore.js
+13
-1
No files found.
www/index.adp
View file @
fb63d69c
...
...
@@ -32,6 +32,7 @@ Ext.require([
'PO.store.timesheet.TaskTreeStore',
'PO.tsweekly.HourWeeklyController',
'PO.tsweekly.HourWeekly',
'PO.tsweekly.HourWeeklyProxy',
'PO.tsweekly.HourWeeklyStore',
'PO.view.field.POComboTree'
]);
...
...
@@ -40,6 +41,7 @@ function launchTimesheetWeeklyLogging(){
// -----------------------------------------------------------------------
// Stores
var hourStore = Ext.StoreManager.get('hourStore');
var hourWeeklyStore = Ext.StoreManager.get('hourWeeklyStore');
var taskTreeStore = Ext.StoreManager.get('taskTreeStore');
var projectStore = Ext.StoreManager.get('projectMainStore');
...
...
@@ -75,7 +77,7 @@ function launchTimesheetWeeklyLogging(){
};
var hourGrid = Ext.create('Ext.grid.Panel', {
store: hourStore,
store: hour
Weekly
Store,
layout: 'fit',
region: 'center',
columnLines: true,
...
...
@@ -134,26 +136,30 @@ function launchTimesheetWeeklyLogging(){
},
editor: { xtype: 'pocombotree', store: taskTreeStore, queryMode: 'local', displayField: 'project_name', valueField: 'id'}
},
{text: "<div align=center>Mon<br>3/29/2021</div>", width: 65, align: "right", dataIndex: 'hours',
{text: "<div align=center>Mon<br>3/29/2021</div>", width: 65, align: "right", dataIndex: 'hours
_0
',
editor: { xtype: 'numberfield', minValue: 0}, summaryType: sumType, summaryRenderer: sumRenderer},
{text: "<div align=center>Tue<br>3/30/2021</div>", width: 65, align: "right", dataIndex: 'hours',
{text: "<div align=center>Tue<br>3/30/2021</div>", width: 65, align: "right", dataIndex: 'hours
_1
',
editor: { xtype: 'numberfield', minValue: 0}, summaryType: sumType, summaryRenderer: sumRenderer},
{text: "<div align=center>Wed<br>2/31/2021</div>", width: 65, align: "right", dataIndex: 'hours',
{text: "<div align=center>Wed<br>2/31/2021</div>", width: 65, align: "right", dataIndex: 'hours
_2
',
editor: { xtype: 'numberfield', minValue: 0}, summaryType: sumType, summaryRenderer: sumRenderer},
{text: "<div align=center>Thu<br>2/31/2021</div>", width: 65, align: "right", dataIndex: 'hours',
{text: "<div align=center>Thu<br>2/31/2021</div>", width: 65, align: "right", dataIndex: 'hours
_3
',
editor: { xtype: 'numberfield', minValue: 0}, summaryType: sumType, summaryRenderer: sumRenderer},
{text: "<div align=center>Fri<br>2/31/2021</div>", width: 65, align: "right", dataIndex: 'hours',
{text: "<div align=center>Fri<br>2/31/2021</div>", width: 65, align: "right", dataIndex: 'hours
_4
',
editor: { xtype: 'numberfield', minValue: 0}, summaryType: sumType, summaryRenderer: sumRenderer},
{text: "<div align=center>Sat<br>2/31/2021</div>", width: 65, align: "right", dataIndex: 'hours',
{text: "<div align=center>Sat<br>2/31/2021</div>", width: 65, align: "right", dataIndex: 'hours
_5
',
editor: { xtype: 'numberfield', minValue: 0}, summaryType: sumType, summaryRenderer: sumRenderer},
{text: "<div align=center>Sun<br>2/31/2021</div>", width: 65, align: "right", dataIndex: 'hours',
{text: "<div align=center>Sun<br>2/31/2021</div>", width: 65, align: "right", dataIndex: 'hours
_6
',
editor: { xtype: 'numberfield', minValue: 0}, summaryType: sumType, summaryRenderer: sumRenderer},
{ text: "Sum", width: 65, dataIndex: 'note', align: "center",
renderer: function(value, metaData, record, rowIndex, colIndex, store, view) {
var hoursString = record.get('hours');
var hoursFloat = parseFloat(hoursString)
if ("number" == typeof(hoursFloat)) return Math.round(700.0 * hoursFloat) / 100.0;
return "";
var sum = 0.0;
for (var i = 0; i < 7; i++) {
var hoursString = record.get('hours_'+i);
var hoursFloat = parseFloat(hoursString);
var type = typeof(hoursFloat);
if ("number" == type && !!hoursFloat) sum = sum + hoursFloat;
}
return Math.round(100.0 * sum) / 100.0;
},
summaryType: function(hourArray, dataIndex) {
var sum = 0;
...
...
@@ -208,6 +214,8 @@ function launchTimesheetWeeklyLogging(){
var hourController = Ext.create('PO.tsweekly.HourWeeklyController', {
'hourButtonPanel': hourButtonPanel,
'taskTreeStore': taskTreeStore,
'rowEditing': rowEditing,
'hourWeeklyStore': hourWeeklyStore,
'hourGrid': hourGrid
});
hourController.init(this).onLaunch(this);
...
...
@@ -236,6 +244,7 @@ Ext.onReady(function() {
var debug = PO.Utilities.getDebug('default');
var taskTreeStore = Ext.create('PO.store.timesheet.TaskTreeStore');
var hourStore = Ext.create('PO.store.timesheet.HourStore');
var hourWeeklyStore = Ext.create('PO.tsweekly.HourWeeklyStore');
var projectStore = Ext.create('PO.store.project.ProjectMainStore');
// Use a "store coodinator" in order to launchTimesheetWeeklyLogging() only
...
...
www/js/HourWeekly.js
View file @
fb63d69c
Ext
.
define
(
'PO.tsweekly.HourWeekly'
,
{
extend
:
'Ext.data.Model'
,
fields
:
[
...
...
@@ -15,6 +16,15 @@ Ext.define('PO.tsweekly.HourWeekly', {
'hours_4'
,
// How many hours were logged?
'hours_5'
,
// How many hours were logged?
'hours_6'
// How many hours were logged?
]
],
// proxy: { type: 'hourWeeklyProxy' }
/* proxy: {
type: 'hourWeeklyProxy',
reader: {
type: 'json',
root: 'users'
}
}
*/
});
www/js/HourWeeklyController.js.adp
View file @
fb63d69c
...
...
@@ -11,11 +11,13 @@ Ext.define('PO.tsweekly.HourWeeklyController', {
hourController: null,
hourGrid: null,
taskTreeStore: null,
rowEditing: null,
hourWeeklyStore: null,
// Setup the various listeners to receive events here
init: function() {
var me = this;
if (me.debug) { console.log('PO.tsweekly.HourWeeklyController
: init
'); }
if (me.debug) { console.log('PO.tsweekly.HourWeeklyController
.init: Starting
'); }
this.control({
'#buttonAddEntry': { click: this.onButtonAddEntry },
...
...
@@ -29,12 +31,13 @@ Ext.define('PO.tsweekly.HourWeeklyController', {
// Trying to crate a "change" event from the Project combo,
// but this didn't work. Now just hard-wiring...
var rowEditing = me.hourGrid.editingPlugin;
// ToDo
// Catch a global key strokes. This is used to abort entry with Esc.
// For some reaons this doesn't work on the level of the HourButtonPanel, so we go for the global "window"
Ext.EventManager.on(window, 'keydown', this.onWindowKeyDown, me);
if (me.debug) { console.log('PO.tsweekly.HourWeeklyController.init: Finished'); }
return this;
},
...
...
@@ -70,10 +73,12 @@ Ext.define('PO.tsweekly.HourWeeklyController', {
* fills in the end_time.
*/
onGridBeforeEdit: function(editor, context, eOpts) {
console.log('GanttButtonController.onGridBeforeEdit');
var me = this;
if (me.debug) console.log('HourWeeklyController.onGridBeforeEdit: Starting');
// console.log(context.record);
// Return true to indicate to the editor that it's OK to edit
if (me.debug) console.log('HourWeeklyController.onGridBeforeEdit: Finished');
return true;
},
...
...
@@ -81,7 +86,8 @@ Ext.define('PO.tsweekly.HourWeeklyController', {
* Gets called after finishing an edit using the "Update" button
*/
onGridEdit: function(editor, context) {
console.log('GanttButtonController.onGridEdit');
var me = this;
if (me.debug) console.log('HourWeeklyController.onGridEdit: Starting');
var rec = context.record;
var interval_date = rec.get('interval_date');
...
...
@@ -123,13 +129,14 @@ Ext.define('PO.tsweekly.HourWeeklyController', {
rec.save();
rec.commit();
if (me.debug) console.log('HourWeeklyController.onGridEdit: Finished');
},
// Esc (Escape) button pressed somewhere in the application window
onWindowKeyDown: function(e) {
var keyCode = e.getKey();
var keyCtrl = e.ctrlKey;
console.log('
GanttButton
Controller.onWindowKeyDown: code='+keyCode+', ctrl='+keyCtrl);
console.log('
HourWeekly
Controller.onWindowKeyDown: code='+keyCode+', ctrl='+keyCtrl);
// cancel hour logging with Esc key
if (27 == keyCode) {
...
...
@@ -140,61 +147,56 @@ Ext.define('PO.tsweekly.HourWeeklyController', {
// Click into the empty space below the grid entries in order to start creating a new entry
onGridContainerClick: function() {
console.log('GanttButtonController.GridContainerClick');
var buttonStartLogging = Ext.getCmp('buttonStartLogging');
var disabled = buttonStartLogging.disabled;
if (!disabled) {
this.onButtonStartLogging();
}
},
/*
* Start logging the time.
* Before calling this procedure, the user must have selected a single
* leaf in the task tree for logging hours.
*/
onButtonStartLogging: function() {
console.log('GanttButtonController.ButtonStartLogging');
var me = this;
if (me.debug) console.log('HourWeeklyController.GridContainerClick: Starting');
alert('xxx');
if (me.debug) console.log('HourWeeklyController.GridContainerClick: Finished');
},
/*
* Start logging the time, for entirely manual entries.
*/
onButtonAddEntry: function() {
console.log('GanttButtonController.ButtonManualLogging');
var me = this;
if (me.debug) console.log('HourWeeklyController.!!! ButtonManualLogging');
var buttonAddEntry = Ext.getCmp('buttonAddEntry');
var buttonDeleteEntry = Ext.getCmp('buttonDeleteEntry');
//
var buttonAddEntry = Ext.getCmp('buttonAddEntry');
//
var buttonDeleteEntry = Ext.getCmp('buttonDeleteEntry');
// buttonAddEntry.disable();
// buttonDeleteEntry.enable();
rowEditing.cancelEdit();
me.
rowEditing.cancelEdit();
var day = PO.Utilities.dateToPg(new Date());
var hour = new Ext.create('PO.model.timesheet.Hour', {
var hourWeekly = new Ext.create('PO.tsweekly.HourWeekly', {
project_id: null,
user_id: @current_user_id@,
day: day
});
hourStore.add(hour);
rowEditing.startEdit(hour, 0);
me.hourWeeklyStore.add(hourWeekly);
var proxy = me.hourWeeklyStore.getProxy();
hourWeekly.setProxy(proxy);
me.rowEditing.startEdit(hourWeekly, 0);
},
onButtonDeleteEntry: function() {
var me = this;
console.log('
GanttButton
Controller.ButtonDeleteLogging');
console.log('
HourWeekly
Controller.ButtonDeleteLogging');
var buttonAddEntry = Ext.getCmp('buttonAddEntry');
// var buttonDeleteEntry = Ext.getCmp('buttonDeleteEntry');
buttonAddEntry.enable();
// buttonDeleteEntry.enable();
rowEditing.cancelEdit();
me.
rowEditing.cancelEdit();
var records = hourGrid.getSelectionModel().getSelection();
// Not logging already - enable the "start" button
if (1 == records.length) { // Exactly one record enabled
var record = records[0];
hour
Store.remove(record);
me.hourWeekly
Store.remove(record);
record.destroy();
}
},
...
...
@@ -204,15 +206,13 @@ Ext.define('PO.tsweekly.HourWeeklyController', {
* Skip logging hours when changing the selection.
*/
onTreePanelSelectionChange: function(view, records) {
if (this.debug) { console.log('
GanttButton
Controller.onTreePanelSelectionChange'); }
if (this.debug) { console.log('
HourWeekly
Controller.onTreePanelSelectionChange'); }
var buttonStartLogging = Ext.getCmp('buttonStartLogging');
var buttonAddEntry = Ext.getCmp('buttonAddEntry');
// Not logging already - enable the "start" button
if (1 == records.length) { // Exactly one record enabled
} else { // Zero or two or more records enabled
buttonStartLogging.setDisabled(true);
buttonAddEntry.setDisabled(true);
}
},
...
...
@@ -222,7 +222,7 @@ Ext.define('PO.tsweekly.HourWeeklyController', {
* Enable or disable the "Delete" button
*/
onGridSelectionChange: function(view, records) {
if (this.debug) { console.log('
GanttButton
Controller.onGridSelectionChange'); }
if (this.debug) { console.log('
HourWeekly
Controller.onGridSelectionChange'); }
var buttonDeleteEntry = Ext.getCmp('buttonDeleteEntry');
buttonDeleteEntry.setDisabled(1 != records.length);
},
...
...
@@ -232,10 +232,10 @@ Ext.define('PO.tsweekly.HourWeeklyController', {
* Handle various key actions
*/
onCellKeyDown: function(table, htmlTd, cellIndex, record, htmlTr, rowIndex, e, eOpts) {
console.log('
GanttButton
Controller.onCellKeyDown');
console.log('
HourWeekly
Controller.onCellKeyDown');
var keyCode = e.getKey();
var keyCtrl = e.ctrlKey;
console.log('
GanttButton
Controller.onCellKeyDown: code='+keyCode+', ctrl='+keyCtrl);
console.log('
HourWeekly
Controller.onCellKeyDown: code='+keyCode+', ctrl='+keyCtrl);
}
});
www/js/HourWeeklyProxy.js
0 → 100644
View file @
fb63d69c
Ext
.
define
(
'PO.tsweekly.HourWeeklyProxy'
,
{
extend
:
'Ext.data.proxy.Client'
,
alias
:
'proxy.hourWeeklyProxy'
,
debug
:
true
,
constructor
:
function
(
config
)
{
this
.
callParent
(
arguments
);
},
/**
* Fake processing function to commit the records, set the current operation
* to successful and call the callback if provided. This function is shared
* by the create, update and destroy methods to perform the bare minimum
* processing required for the proxy to register a result from the action.
*/
updateOperation
:
function
(
operation
,
callback
,
scope
)
{
var
i
=
0
,
recs
=
operation
.
getRecords
(),
len
=
recs
.
length
;
for
(
i
;
i
<
len
;
i
++
)
{
recs
[
i
].
commit
();
}
operation
.
setCompleted
();
operation
.
setSuccessful
();
Ext
.
callback
(
callback
,
scope
||
this
,
[
operation
]);
},
//inherit docs
create
:
function
(
operation
,
callback
,
scope
)
{
var
me
=
this
;
if
(
me
.
debug
)
{
console
.
log
(
'HourWeeklyProxy.create: Started'
);
console
.
log
(
operation
);
}
this
.
updateOperation
.
apply
(
this
,
arguments
);
if
(
me
.
debug
)
console
.
log
(
'HourWeeklyProxy.create: Finished'
);
},
//inherit docs
read
:
function
(
operation
,
callback
,
scope
)
{
var
me
=
this
;
if
(
me
.
debug
)
{
console
.
log
(
'HourWeeklyProxy.read: Started'
);
console
.
log
(
operation
);
}
operation
.
setStarted
();
var
data
=
[
{
data
:
{
name
:
'File1'
,
thumbnail
:
'/piko/desktop/img/my_photos.png'
,
url
:
'/img/faces.jpg'
,
size
:
32000
,
metadata
:
{
type
:
'file'
,
width
:
64
,
height
:
64
}},
join
:
function
(
store
)
{
this
.
store
=
store
;
},
unjoin
:
function
(
store
)
{
this
.
store
=
store
;
}},
// { data: { name: 'File2', thumbnail: '/piko/desktop/img/my_photos.png', url: '/img/faces.jpg', size: 32000, metadata: { type: 'file', width: 64, height: 64 }}, join: function(store) { this.store = store; }},
];
operation
.
resultSet
=
Ext
.
create
(
'Ext.data.ResultSet'
,
{
records
:
data
,
total
:
data
.
length
,
loaded
:
true
});
operation
.
commitRecords
(
data
);
operation
.
setCompleted
();
operation
.
setSuccessful
();
if
(
typeof
callback
==
'function'
)
{
callback
.
call
(
scope
||
this
,
operation
);
}
if
(
me
.
debug
)
console
.
log
(
'HourWeeklyProxy.read: Finished'
);
},
//inherit docs
update
:
function
(
operation
,
callback
,
scope
)
{
var
me
=
this
;
if
(
me
.
debug
)
{
console
.
log
(
'HourWeeklyProxy.update: Started'
);
console
.
log
(
operation
);
}
this
.
updateOperation
.
apply
(
this
,
arguments
);
if
(
me
.
debug
)
console
.
log
(
'HourWeeklyProxy.update: Finished'
);
},
//inherit
destroy
:
function
(
operation
,
callback
,
scope
)
{
var
me
=
this
;
if
(
me
.
debug
)
{
console
.
log
(
'HourWeeklyProxy.destroy: Started'
);
console
.
log
(
operation
);
}
this
.
updateOperation
.
apply
(
this
,
arguments
);
if
(
me
.
debug
)
console
.
log
(
'HourWeeklyProxy.destroy: Finished'
);
},
clear
:
function
()
{
var
me
=
this
;
if
(
me
.
debug
)
{
console
.
log
(
'HourWeeklyProxy.clear: Started'
);
console
.
log
(
operation
);
}
this
.
updateOperation
.
apply
(
this
,
arguments
);
if
(
me
.
debug
)
console
.
log
(
'HourWeeklyProxy.clear: Finished'
);
}
});
www/js/HourWeeklyStore.js
View file @
fb63d69c
...
...
@@ -5,12 +5,24 @@
// All rights reserved. Please see
// https://www.project-open.com/license/ for details.
Ext
.
define
(
'PO.tsweekly.HourWeeklyStore'
,
{
extend
:
'Ext.data.Store'
,
model
:
'PO.tsweekly.HourWeekly'
,
storeId
:
'hourWeeklyStore'
,
autoDestroy
:
true
,
autoLoad
:
false
,
autoSync
:
false
autoSync
:
false
,
proxy
:
{
type
:
'hourWeeklyProxy'
}
/* data: hourWeeklyStoreJson,
var hourWeeklyStoreJson = {};
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'users'
}
}
*/
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment