Commit 8be4d8cf authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Create the new contextmenu for the history table.

parent 1e4c7313
......@@ -102,11 +102,13 @@
'end': 'fin',
'End': 'Fin',
'End Date': 'Date de fin',
'End_Date': 'Date de fin',
'enter a number between %(min)g and %(max)g': 'enter a number between %(min)g and %(max)g',
'Enter a number between %(min)g and %(max)g': 'Enter a number between %(min)g and %(max)g',
'enter a value': 'enter a value',
'Enter an integer between %(min)g and %(max)g': 'Enter an integer between %(min)g and %(max)g',
'enter an integer between %(min)g and %(max)g': 'enter an integer between %(min)g and %(max)g',
'Enter date as %(format)s': 'Enter date as %(format)s',
'enter date as %(format)s': 'enter date as %(format)s',
"Entries are sorted according to the value of these fields. It can be any field of the history table including those of the foreign tables, the individual property of the history.data dictionary, or 'year'. Descending order is obtained by using the '~field' construct.": "Les élémnents sont ordonnés selon les valeurs de ces champs. Ce sont les champs de la table historique en incluant tous les champs des tables étrangères, les clés du dictionaire history.data , ou 'year'. Un tri décroissant est obtenu en utilisant la synstaxe '~field'.",
'Error': 'Error',
......
......@@ -84,7 +84,6 @@ if ctrl == "plugin_dbui" and fnct in ("call", "dbui_conf"):
"events",
"fundings",
"graphs",
"history",
"lists",
"metrics1d",
"metrics2d",
......
......@@ -202,7 +202,11 @@ class CoreUi(object):
# Grid
#
mdf = gridModifier("history")
mdf.configure(plugins=["pGridPaging"])
mdf.configure(plugins=["pGridRowEditorConfirmDelete",
"pGridRowEditorDblClick",
"pHistoryContextMenu",
"pGridToolbar",
"pGridPaging"])
mdf.hide_columns("data",
"id_domains",
......
/**
* The plugin instantiating the context menu for the history table.
* It allows to create, close, duplicate, destroy, split and update events.
*
* It mainly uses the RowEditor of the grid.
*
*/
Ext.define("Event.grid.plugin.HistoryContextMenu", {
extend: "Dbui.grid.plugin.ContextMenu",
alias: "plugin.pHistoryContextMenu",
// private properties for internationalization
textClose: "Close",
textCloseEvent: "Close event...",
textDestroy: "Delete",
textDuplicate: "Duplicate",
textEndBy: "The selected event ends by ",
textNeverEnd: "The selected event never ends. ",
textNew: "New",
textEnterNewValue: "Please enter a new value:",
textSplit: "Split",
textUpdate: "Update",
rowEditor: null,
// jshint strict: false
/**
* Initialize the plugin.
*
* @param {Dbui.grid.Panel} grid
*/
init: function (grid) {
var me = this,
rowEditor = grid.getPlugin("rowEditor");
// protection
if (!rowEditor) {
throw new Error("no grid row editor !!!");
}
// alias
me.rowEditor = rowEditor;
// the contextmenu menu
me.menu = {
items: [{
text: me.textNew,
iconCls: "xaction-create",
handler: rowEditor.onAddRow,
scope: rowEditor
}, "-", {
text: me.textSplit,
handler: me.onSplitEvent,
scope: me
}, {
text: me.textClose,
handler: me.onCloseEvent,
scope: me
}, "-", {
text: me.textDuplicate,
iconCls: "xaction-duplicate",
handler: rowEditor.onDuplicateRow,
scope: rowEditor
}, {
text: me.textUpdate,
iconCls: "xaction-update",
handler: rowEditor.onEditRow,
scope: rowEditor
}, "-", {
text: me.textDestroy,
iconCls: "xaction-destroy",
handler: rowEditor.onDeleteRow,
scope: rowEditor
}]
};
// initialise the base class
me.callParent(arguments);
},
// jshint strict: true
/**
* Close the selected event.
*
*/
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");
// ask for a new value and update the record
msg = (endDate ? me.textEndBy + endDate + "." : me.textNeverEnd);
msg += "<br>" + me.textEnterNewValue;
Ext.Msg.prompt(
me.textCloseEvent,
msg,
function(buttonId, value) {
if (buttonId === "ok") {
record.set("HistoryEnd_date", value);
}
},
null,
false,
endDate
);
},
onSplitEvent: function () {
"use strict";
var me = this;
}
});
\ 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