Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
tev
plugin_event
Commits
c10ffc6e
Commit
c10ffc6e
authored
Dec 17, 2016
by
LE GAC Renaud
Browse files
Add the split action.
parent
8be4d8cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
14 deletions
+75
-14
static/app.js
static/app.js
+1
-0
static/plugin_event/src/grid/plugin/HistoryContextMenu.js
static/plugin_event/src/grid/plugin/HistoryContextMenu.js
+74
-14
No files found.
static/app.js
View file @
c10ffc6e
...
...
@@ -28,6 +28,7 @@ Ext.require('Event.form.field.UserData');
Ext
.
require
(
'
Event.form.field.UserDataMultiDefault
'
);
Ext
.
require
(
'
Event.form.plugin.UserDataConsistency
'
);
Ext
.
require
(
'
Event.grid.HistoryFilter
'
);
Ext
.
require
(
'
Event.grid.plugin.HistoryContextMenu
'
);
Ext
.
onReady
(
function
(){
...
...
static/plugin_event/src/grid/plugin/HistoryContextMenu.js
View file @
c10ffc6e
...
...
@@ -9,6 +9,7 @@ Ext.define("Event.grid.plugin.HistoryContextMenu", {
extend
:
"
Dbui.grid.plugin.ContextMenu
"
,
alias
:
"
plugin.pHistoryContextMenu
"
,
uses
:
"
Ext.window.MessageBox
"
,
// private properties for internationalization
textClose
:
"
Close
"
,
...
...
@@ -18,10 +19,22 @@ Ext.define("Event.grid.plugin.HistoryContextMenu", {
textEndBy
:
"
The selected event ends by
"
,
textNeverEnd
:
"
The selected event never ends.
"
,
textNew
:
"
New
"
,
textEnterNewValue
:
"
Please enter a new value:
"
,
textSplit
:
"
Split
"
,
textEnterNewDate
:
"
Please enter a new date:
"
,
textSplit
:
"
Split into two
"
,
textSplitEvent
:
"
Split into two events...
"
,
textSplitMsg
:
"
The following operation will be performed:
"
+
"
<ol>
"
+
"
<li>Close the selected event.
"
+
"
<li>Duplicate the selected event with:
"
+
"
<ul>
"
+
"
<li>start date = end date of the current event + 1 day.
"
+
"
<li>end date is not defined.
"
+
"
</ul>
"
+
"
<li>Edit the duplicated event in order to modify it.
"
+
"
</ol>
"
,
textUpdate
:
"
Update
"
,
// private short-cut
rowEditor
:
null
,
// jshint strict: false
...
...
@@ -83,29 +96,28 @@ Ext.define("Event.grid.plugin.HistoryContextMenu", {
// jshint strict: true
/**
*
C
lose the selected event.
*
c
lose the selected event
by setting its end date
.
*
*/
onCloseEvent
:
function
()
{
"
use strict
"
;
var
me
=
this
,
endDate
,
msg
,
record
;
// get the selected record and its end date
record
=
me
.
rowEditor
.
getSelected
();
endDate
=
record
.
get
(
"
HistoryEnd_date
"
);
var
me
=
this
,
record
=
me
.
rowEditor
.
getSelected
(),
endDate
=
record
.
get
(
"
HistoryEnd_date
"
),
msg
=
""
;
// ask for a new value and update the record
msg
=
(
endDate
?
me
.
textEndBy
+
endDate
+
"
.
"
:
me
.
textNeverEnd
);
msg
+=
"
<br>
"
+
me
.
textEnterNewValue
;
msg
+=
(
endDate
?
me
.
textEndBy
+
endDate
+
"
.
"
:
me
.
textNeverEnd
);
msg
+=
"
<br>
"
+
me
.
textEnterNewDate
;
// ask for a new end date and update the record
Ext
.
Msg
.
prompt
(
me
.
textCloseEvent
,
msg
,
function
(
buttonId
,
valu
e
)
{
function
(
buttonId
,
newEndDat
e
)
{
if
(
buttonId
===
"
ok
"
)
{
record
.
set
(
"
HistoryEnd_date
"
,
valu
e
);
record
.
set
(
"
HistoryEnd_date
"
,
newEndDat
e
);
}
},
null
,
...
...
@@ -114,10 +126,58 @@ Ext.define("Event.grid.plugin.HistoryContextMenu", {
);
},
/**
* Split the select event. It consists of several step:
* - set the end date of the current event;
* - duplicate the current event by setting its start date equal
* to the end date of the current event plus one day;
* - edit the duplicated record in order to modify it.
*
*/
onSplitEvent
:
function
()
{
"
use strict
"
;
var
me
=
this
;
var
me
=
this
,
rowEditor
=
me
.
rowEditor
,
record
=
rowEditor
.
getSelected
(),
endDate
=
record
.
get
(
"
HistoryEnd_date
"
),
msg
=
me
.
textSplitMsg
;
msg
+=
(
endDate
?
me
.
textEndBy
+
endDate
+
"
.
"
:
me
.
textNeverEnd
);
msg
+=
"
<br>
"
+
me
.
textEnterNewDate
;
Ext
.
Msg
.
prompt
(
me
.
textSplitEvent
,
msg
,
function
(
buttonId
,
newEndDate
)
{
var
newRecord
,
startDate
;
if
(
buttonId
===
"
cancel
"
)
{
return
;
}
// close the current event
record
.
set
(
"
HistoryEnd_date
"
,
newEndDate
);
// duplicate record
startDate
=
new
Date
(
newEndDate
);
startDate
=
Ext
.
Date
.
add
(
startDate
,
Ext
.
Date
.
DAY
,
1
);
startDate
=
Ext
.
Date
.
format
(
startDate
,
"
Y-m-d
"
);
newRecord
=
record
.
copy
();
newRecord
.
set
(
"
HistoryId
"
,
null
,
{
dirty
:
false
});
newRecord
.
set
(
"
HistoryStart_date
"
,
startDate
,
{
dirty
:
false
});
newRecord
.
set
(
"
HistoryEnd_date
"
,
null
,
{
dirty
:
false
});
// edit and insert the duplicated record below the current one
rowEditor
.
setCurrentIndex
();
rowEditor
.
formPanel
.
setAction
(
'
duplicate
'
,
newRecord
);
rowEditor
.
window
.
setTitle
(
rowEditor
.
duplicateTitle
);
rowEditor
.
window
.
show
();
},
null
,
false
,
endDate
);
}
});
\ No newline at end of file
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