Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sencha-core
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
sencha-core
Commits
38087271
Commit
38087271
authored
Apr 01, 2014
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Gantt Editor:
First Timeline functionality working
parent
0d7ac188
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
425 deletions
+108
-425
GanttButtonController.js
www/controller/gantt/GanttButtonController.js
+30
-1
GanttDrawComponent.js
www/view/gantt/GanttDrawComponent.js
+66
-9
GanttTimeline.js
www/view/gantt/GanttTimeline.js
+12
-415
No files found.
www/controller/gantt/GanttButtonController.js
View file @
38087271
...
@@ -20,7 +20,7 @@ Ext.define('PO.controller.gantt.GanttButtonController', {
...
@@ -20,7 +20,7 @@ Ext.define('PO.controller.gantt.GanttButtonController', {
'ganttButtonController'
:
null
,
'ganttButtonController'
:
null
,
'ganttTreePanel'
:
null
,
'ganttTreePanel'
:
null
,
'ganttDrawComponent'
:
null
,
'ganttDrawComponent'
:
null
,
'ganttTimeline'
:
null
,
// x3 time axis
refs
:
[
refs
:
[
{
ref
:
'ganttTreePanel'
,
selector
:
'#ganttTreePanel'
}
{
ref
:
'ganttTreePanel'
,
selector
:
'#ganttTreePanel'
}
...
@@ -55,6 +55,11 @@ Ext.define('PO.controller.gantt.GanttButtonController', {
...
@@ -55,6 +55,11 @@ Ext.define('PO.controller.gantt.GanttButtonController', {
// Listen to special keys
// Listen to special keys
me
.
ganttTreePanel
.
on
(
'cellkeydown'
,
this
.
onCellKeyDown
,
me
.
ganttTreePanel
);
me
.
ganttTreePanel
.
on
(
'cellkeydown'
,
this
.
onCellKeyDown
,
me
.
ganttTreePanel
);
me
.
ganttTreePanel
.
on
(
'beforecellkeydown'
,
this
.
onBeforeCellKeyDown
,
me
.
ganttTreePanel
);
me
.
ganttTreePanel
.
on
(
'beforecellkeydown'
,
this
.
onBeforeCellKeyDown
,
me
.
ganttTreePanel
);
// Deal with mouse move events from both surfaces
me
.
ganttTimeline
.
on
(
'move'
,
this
.
onTimelineMove
,
me
);
me
.
ganttDrawComponent
.
on
(
'move'
,
this
.
onDrawComponentMove
,
me
);
return
this
;
return
this
;
},
},
...
@@ -66,6 +71,30 @@ Ext.define('PO.controller.gantt.GanttButtonController', {
...
@@ -66,6 +71,30 @@ Ext.define('PO.controller.gantt.GanttButtonController', {
console
.
log
(
'ButtonSave'
);
console
.
log
(
'ButtonSave'
);
},
},
/**
* The user is drag-and-dropping the Timeline around.
* Now update the main DrawComponent accordingly.
*/
onTimelineMove
:
function
(
dist
)
{
// console.log('GanttButtonController.onTimelineMove: dist='+dist);
this
.
ganttDrawComponent
.
translate
(
dist
*
3
);
// Move the DrawComponent multiplied
// ToDo: There are still some break when switching between the surfaces
// this.ganttDrawComponent.dndBase[0] = -dist;
},
/**
* The user is drag-and-dropping the main DrawComponent around.
* Now move the Timeline accordingly.
*/
onDrawComponentMove
:
function
(
dist
)
{
console
.
log
(
'GanttButtonController.onDrawComponentMove: dist='
+
dist
);
this
.
ganttTimeline
.
translate
(
dist
/
3.0
);
// Move the Timeline by a fraction
// ToDo: There are still some break when switching between the surfaces
// this.ganttTimeline.dndBase[0] = -dist;
},
/**
/**
* Control the enabled/disabled status of the (-) (Delete) button
* Control the enabled/disabled status of the (-) (Delete) button
*/
*/
...
...
www/view/gantt/GanttDrawComponent.js
View file @
38087271
...
@@ -47,7 +47,7 @@ Ext.define('PO.view.gantt.GanttDrawComponent', {
...
@@ -47,7 +47,7 @@ Ext.define('PO.view.gantt.GanttDrawComponent', {
dndStartRawCoordinates
:
null
,
// Raw mouse coordinates when starting to drag
dndStartRawCoordinates
:
null
,
// Raw mouse coordinates when starting to drag
dndTranslate
:
null
,
dndTranslate
:
null
,
barHeight
:
15
,
barHeight
:
0
,
barStartHash
:
{},
// Hash array from object_ids -> Start/end point
barStartHash
:
{},
// Hash array from object_ids -> Start/end point
barEndHash
:
{},
// Hash array from object_ids -> Start/end point
barEndHash
:
{},
// Hash array from object_ids -> Start/end point
taskModelHash
:
{},
taskModelHash
:
{},
...
@@ -65,11 +65,11 @@ Ext.define('PO.view.gantt.GanttDrawComponent', {
...
@@ -65,11 +65,11 @@ Ext.define('PO.view.gantt.GanttDrawComponent', {
me
.
axisHeight
=
20
;
me
.
axisHeight
=
20
;
me
.
dndBase
=
null
;
// Drag-and-drop starting point
me
.
dndBase
=
null
;
// Drag-and-drop starting point
me
.
dndBaseObject
=
null
;
me
.
dndBaseObject
=
null
;
me
.
dndTranslate
=
[
0
,
0
];
// Default translate of the surface
me
.
dndTranslate
=
[
0
,
0
];
// Default translate of the surface
me
.
dndStartRawCoordinates
=
null
;
me
.
dndStartRawCoordinates
=
null
;
me
.
barHeight
=
15
;
me
.
barHeight
=
15
;
me
.
barStartHash
=
{};
// Hash array from object_ids -> Start/end point
me
.
barStartHash
=
{};
// Hash array from object_ids -> Start/end point
me
.
barEndHash
=
{};
// Hash array from object_ids -> Start/end point
me
.
barEndHash
=
{};
// Hash array from object_ids -> Start/end point
me
.
taskModelHash
=
{};
me
.
taskModelHash
=
{};
...
@@ -87,7 +87,7 @@ Ext.define('PO.view.gantt.GanttDrawComponent', {
...
@@ -87,7 +87,7 @@ Ext.define('PO.view.gantt.GanttDrawComponent', {
'scope'
:
this
'scope'
:
this
});;
});;
// Drag & Drop on the "surface"
// Drag & Drop on the "surface"
me
.
on
({
me
.
on
({
'mousedown'
:
me
.
onMouseDown
,
'mousedown'
:
me
.
onMouseDown
,
'mouseup'
:
me
.
onMouseUp
,
'mouseup'
:
me
.
onMouseUp
,
...
@@ -96,7 +96,7 @@ Ext.define('PO.view.gantt.GanttDrawComponent', {
...
@@ -96,7 +96,7 @@ Ext.define('PO.view.gantt.GanttDrawComponent', {
'scope'
:
this
'scope'
:
this
});
});
// Drag & Drop on the TreePanel - moving tasks
// Drag & Drop on the TreePanel - moving tasks
var
ganttTreeView
=
me
.
ganttTreePanel
.
getView
();
var
ganttTreeView
=
me
.
ganttTreePanel
.
getView
();
ganttTreeView
.
on
({
ganttTreeView
.
on
({
'drop'
:
me
.
onTreeViewDrop
,
'drop'
:
me
.
onTreeViewDrop
,
...
@@ -121,6 +121,8 @@ Ext.define('PO.view.gantt.GanttDrawComponent', {
...
@@ -121,6 +121,8 @@ Ext.define('PO.view.gantt.GanttDrawComponent', {
me
.
axisStartDate
=
me
.
prevMonth
(
new
Date
(
me
.
axisStartTime
));
me
.
axisStartDate
=
me
.
prevMonth
(
new
Date
(
me
.
axisStartTime
));
me
.
axisEndDate
=
me
.
nextMonth
(
new
Date
(
me
.
axisEndTime
));
me
.
axisEndDate
=
me
.
nextMonth
(
new
Date
(
me
.
axisEndTime
));
this
.
addEvents
(
'move'
);
},
},
/**
/**
...
@@ -311,9 +313,14 @@ Ext.define('PO.view.gantt.GanttDrawComponent', {
...
@@ -311,9 +313,14 @@ Ext.define('PO.view.gantt.GanttDrawComponent', {
if
(
me
.
dndBase
!=
null
)
{
// Only if we are dragging
if
(
me
.
dndBase
!=
null
)
{
// Only if we are dragging
var
point
=
e
.
getXY
();
var
point
=
e
.
getXY
();
var
translateDist
=
point
[
0
]
-
me
.
dndBase
[
0
]
// console.log('PO.class.GanttDrawComponent.onMouseMove: '+point);
// console.log('PO.class.GanttDrawComponent.onMouseMove: '+point);
me
.
translate
(
point
[
0
]
-
me
.
dndBase
[
0
]);
// Move the entire surface around
me
.
translate
(
translateDist
);
// Fire event in order to notify listerns about the move
this
.
fireEvent
(
'move'
,
translateDist
);
}
}
},
},
...
@@ -516,6 +523,14 @@ Ext.define('PO.view.gantt.GanttDrawComponent', {
...
@@ -516,6 +523,14 @@ Ext.define('PO.view.gantt.GanttDrawComponent', {
var
count
=
0
;
var
count
=
0
;
var
y
=
0
;
var
y
=
0
;
// Yearly Axis
var
yearTime
=
365.0
*
24
*
3600
*
1000
;
var
axisUnits
=
(
me
.
axisEndTime
-
me
.
axisStartTime
)
/
yearTime
;
if
(
axisUnits
>
3
&&
axisUnits
<
50
)
{
me
.
drawAxisYear
(
y
);
y
=
y
+
me
.
axisHeight
;
}
// Quarterly Axis
// Quarterly Axis
var
quarterTime
=
90.0
*
24
*
3600
*
1000
;
var
quarterTime
=
90.0
*
24
*
3600
*
1000
;
var
axisUnits
=
(
me
.
axisEndTime
-
me
.
axisStartTime
)
/
quarterTime
;
var
axisUnits
=
(
me
.
axisEndTime
-
me
.
axisStartTime
)
/
quarterTime
;
...
@@ -542,6 +557,40 @@ Ext.define('PO.view.gantt.GanttDrawComponent', {
...
@@ -542,6 +557,40 @@ Ext.define('PO.view.gantt.GanttDrawComponent', {
},
},
/**
* Draw a horizontal axis from start until end date
*/
drawAxisYear
:
function
(
y
)
{
var
me
=
this
;
var
count
=
0
;
// Advance to first day of the next year
var
axisStartYear
=
me
.
nextYear
(
new
Date
(
me
.
axisStartTime
));
var
x
=
me
.
date2x
(
axisStartYear
);
while
(
x
<
me
.
axisEndX
&&
count
<
200
)
{
var
line
=
me
.
surface
.
add
({
type
:
'path'
,
stroke
:
'#444'
,
'shape-rendering'
:
'crispy-edges'
,
'stroke-width'
:
0.5
,
path
:
'M '
+
x
+
' '
+
y
+
' v '
+
me
.
axisHeight
,
}).
show
(
true
);
var
text
=
axisStartYear
.
getFullYear
();
var
textSprite
=
me
.
surface
.
add
({
type
:
'text'
,
text
:
''
+
text
,
x
:
x
+
2
,
y
:
y
+
6
,
font
:
'12px tahoma'
}).
show
(
true
);
axisStartYear
=
me
.
nextYear
(
axisStartYear
);
x
=
me
.
date2x
(
axisStartYear
);
count
++
;
}
},
/**
/**
* Draw a horizontal monthly axis
* Draw a horizontal monthly axis
*/
*/
...
@@ -557,10 +606,8 @@ Ext.define('PO.view.gantt.GanttDrawComponent', {
...
@@ -557,10 +606,8 @@ Ext.define('PO.view.gantt.GanttDrawComponent', {
type
:
'path'
,
type
:
'path'
,
stroke
:
'#444'
,
stroke
:
'#444'
,
fill
:
'none'
,
fill
:
'none'
,
'shape-rendering'
:
'crispy-edges'
,
'shape-rendering'
:
'crispy-edges'
,
'stroke-width'
:
0.5
,
'stroke-width'
:
0.5
,
path
:
'M '
+
x
+
' '
+
y
+
' v '
+
me
.
axisHeight
path
:
'M '
+
x
+
' '
+
y
+
' v '
+
me
.
axisHeight
});
});
...
@@ -568,7 +615,7 @@ Ext.define('PO.view.gantt.GanttDrawComponent', {
...
@@ -568,7 +615,7 @@ Ext.define('PO.view.gantt.GanttDrawComponent', {
line
.
show
(
true
);
line
.
show
(
true
);
var
quarter
=
Math
.
floor
(
axisStartQuarter
.
getMonth
()
/
3
)
+
1
;
var
quarter
=
Math
.
floor
(
axisStartQuarter
.
getMonth
()
/
3
)
+
1
;
var
text
=
(
''
+
axisStartQuarter
.
get
Year
()).
substring
(
1
,
4
)
+
'Q'
+
quarter
;
var
text
=
(
''
+
axisStartQuarter
.
get
FullYear
()).
substring
(
2
,
4
)
+
'Q'
+
quarter
;
var
textSprite
=
me
.
surface
.
add
({
var
textSprite
=
me
.
surface
.
add
({
type
:
'text'
,
type
:
'text'
,
text
:
text
,
text
:
text
,
...
@@ -791,9 +838,19 @@ Ext.define('PO.view.gantt.GanttDrawComponent', {
...
@@ -791,9 +838,19 @@ Ext.define('PO.view.gantt.GanttDrawComponent', {
result
=
new
Date
(
date
.
getFullYear
(),
date
.
getMonth
()
+
3
,
1
);
result
=
new
Date
(
date
.
getFullYear
(),
date
.
getMonth
()
+
3
,
1
);
}
}
return
result
;
return
result
;
},
/**
* Advance a date to the 1st of january of the next year
*/
nextYear
:
function
(
date
)
{
var
result
;
result
=
new
Date
(
date
.
getFullYear
()
+
1
,
0
,
1
);
return
result
;
}
}
});
});
www/view/gantt/GanttTimeline.js
View file @
38087271
This diff is collapsed.
Click to expand it.
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