Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

Commit e828ab23 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update HistoryContextMenu in order to use Date field.

parent c5f2209e
......@@ -16,26 +16,26 @@ Ext.define("Event.grid.plugin.HistoryContextMenu", {
textCloseEvent: "Close event...",
textDestroy: "Delete",
textDuplicate: "Duplicate",
textEndBy: "The selected event ends by ",
textNeverEnd: "The selected event never ends. ",
textNew: "New",
textEnterNewDate: "Please enter a new date:",
textEnterNewDate: "Please enter a closing 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:" +
textSplitMsg: "The following operations will be performed:<br><br>" +
"1. Close the selected event.<br>" +
"2. Duplicate the selected event with:" +
"<ul>" +
"<li>start date = end date of the current event + 1 day." +
"<li>end date is not defined." +
"<li>start date = end date + 1 day." +
"<li>no end date." +
"</ul>" +
"<li>Edit the duplicated event in order to modify it." +
"</ol>",
"3. Edit the duplicated event.",
textUpdate: "Update",
// private short-cut
buttonOk: null,
dateField: null,
rowEditor: null,
splitMsg: null,
window: null,
// jshint strict: false
......@@ -47,16 +47,14 @@ Ext.define("Event.grid.plugin.HistoryContextMenu", {
init: function (grid) {
var me = this,
rowEditor = grid.getPlugin("rowEditor");
rowEditor = grid.getPlugin("rowEditor"),
panelCfg, formCfg, window;
// protection
if (!rowEditor) {
throw new Error("no grid row editor !!!");
}
// alias
me.rowEditor = rowEditor;
// the contextmenu menu
me.menu = {
items: [{
......@@ -90,6 +88,63 @@ Ext.define("Event.grid.plugin.HistoryContextMenu", {
}]
};
// instantiate the window for close and split actions
// It contains a panel for the split message and a form to
// retrieve the closing date
panelCfg = {
html: me.textSplitMsg,
itemId: "splitmsg",
padding: 5,
};
formCfg = {
items: [{
allowBlank: false,
altFormats: "",
fieldLabel: me.textEnterNewDate,
format: "Y-m-d",
labelAlign: "top",
name: "newEndDate",
padding: 5,
xtype: "datefield"
}],
buttons: [{
// Validation is not working ?
// formBind: true,
// disabled: true,
itemId: "closesplitaction",
text: "OK"
}, {
text: "Cancel",
handler: function () {
this.up("window").hide();
}
}]
};
window = Ext.create("Ext.window.Window", {
closeAction: "hide",
defaults: {
border: false,
frame: true,
layout: "fit"
},
items: [panelCfg, formCfg],
layout: "form",
modal: true,
padding: 0,
plain: true,
width: 300
});
// short-cuts
me.buttonOk = window.down("#closesplitaction");
me.dateField = window.down("datefield");
me.rowEditor = rowEditor;
me.splitMsg = window.down("#splitmsg");
me.window = window;
// initialise the base class
me.callParent(arguments);
},
......@@ -105,25 +160,22 @@ Ext.define("Event.grid.plugin.HistoryContextMenu", {
var me = this,
record = me.rowEditor.getSelected(),
endDate = record.get("HistoryEnd_date"),
msg = "";
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, newEndDate) {
if (buttonId === "ok") {
endDate = record.get("HistoryEnd_date") || new Date(),
window = me.window;
me.splitMsg.hide();
me.dateField.setValue(endDate);
me.buttonOk.setHandler(function () {
var newEndDate = me.dateField.getValue();
newEndDate =Ext.Date.format(newEndDate, "Y-m-d");
record.set("HistoryEnd_date", newEndDate);
}
},
null,
false,
endDate
);
me.window.hide();
});
window.setTitle(me.textCloseEvent);
window.show();
},
/**
......@@ -140,24 +192,20 @@ Ext.define("Event.grid.plugin.HistoryContextMenu", {
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;
endDate = record.get("HistoryEnd_date") || new Date(),
window = me.window;
Ext.Msg.prompt(
me.textSplitEvent,
msg,
function(buttonId, newEndDate) {
me.splitMsg.show();
me.dateField.setValue(endDate);
var newRecord, startDate;
me.buttonOk.setHandler(function () {
var newEndDate, newRecord, startDate;
if (buttonId === "cancel") {
return;
}
// close the current event
newEndDate = me.dateField.getValue();
newEndDate =Ext.Date.format(newEndDate, "Y-m-d");
record.set("HistoryEnd_date", newEndDate);
me.window.hide();
// duplicate record
startDate = new Date(newEndDate);
......@@ -171,13 +219,12 @@ Ext.define("Event.grid.plugin.HistoryContextMenu", {
// edit and insert the duplicated record below the current one
rowEditor.setCurrentIndex();
rowEditor.formPanel.setAction('duplicate', newRecord);
rowEditor.formPanel.setAction("duplicate", newRecord);
rowEditor.window.setTitle(rowEditor.duplicateTitle);
rowEditor.window.show();
},
null,
false,
endDate
);
});
window.setTitle(me.textSplitEvent);
window.show();
}
});
\ No newline at end of file
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