Commit 32cfe5fd authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Merge branch '17-context-menu' into 'master'

Resolve "Improve the context menu of the history table"

* Context menu of the history table exposes actions `close` and `split` on top of  the usual one.
* Closes #17

See merge request !25
parents 1e4c7313 2c1365b9
......@@ -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',
......
......@@ -37,14 +37,14 @@ is_dbui = (ctrl == "plugin_dbui") and \
if is_dbui:
dbui.Dbui.define_paths(
app_about="static/plugin_event/ABOUT.html",
app_css="static/plugin_event/resources/css/event.css",
app_css=None,
app_changelog="static/plugin_event/CHANGELOG",
app_db_schema="static/plugin_event/docs/database.png",
app_debug="static/plugin_event/src",
app_debug=None,
app_html_api="static/plugin_event/docs/api/index.html",
app_html_jsduck="static/plugin_event/docs/jsduck/index.html",
app_html_user="static/plugin_event/docs/user/index.html",
app_lg="static/plugin_event/locale/event-lang-fr.js",
app_lg=None,
app_license="static/plugin_event/LICENSE",
app_libmin="static/plugin_event/event-min.js",
app_pdf_api="static/plugin_event/docs/pdf/event_api.pdf",
......@@ -84,7 +84,6 @@ if ctrl == "plugin_dbui" and fnct in ("call", "dbui_conf"):
"events",
"fundings",
"graphs",
"history",
"lists",
"metrics1d",
"metrics2d",
......
......@@ -28,7 +28,7 @@ class Event(object):
dbui = PluginManager("dbui").dbui
dbui.plugins_paths["event"] = {
"css": "static/plugin_event/resources/css/event.css",
"debug": "static/plugin_event/event-debug.js",
"css": "static/plugin_event/resources/css/",
"debug": None,
"lg": "static/plugin_event/locale/event-lang-%s.js" % lg,
"libmin": "static/plugin_event/event-min.js"}
......@@ -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",
......
......@@ -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(){
......
......@@ -35,4 +35,26 @@ Ext.define("Event.locale.grid.HistoryFilter", {
textObject: "Objet",
textPeople: "Personne",
textPeriod: "Période"
});
\ No newline at end of file
});
Ext.define("Event.locale.grid.plugin.HistoryContextMenu", {
override: "Event.grid.plugin.HistoryContextMenu",
textClose: "Clore",
textCloseEvent: "Clore l'évènement...",
textDestroy: "Détruire",
textDuplicate: "Dupliquer",
textNew: "Nouveau",
textEnterNewDate: "Entrez une date de fin:",
textSplit: "Scinder en deux",
textSplitEvent: "Scinder en deux évènements...",
textSplitMsg: "Les opérations suivantes seront exécutées :<br><br>" +
"1. Clore l'évènement sélectionné.<br>" +
"2. Le dupliquer avec:" +
"<ul>" +
"<li>date de début = end de fin + 1 jour." +
"<li>pas de date de fin." +
"</ul>" +
"3. Editer l'évènement dupliqué.",
textUpdate: "Actualiser",
});
/*
* KDE 4.4.5 style oxygen
* Icon copy from /usr/share/icons/oxygen/16x16
*
*/
.xaction-event-close {
background-image: url(../icons/kde-oxygen/16x16/format-remove-node.png);
background-repeat: no-repeat;
}
.xaction-event-split {
background-image: url(../icons/kde-oxygen/16x16/format-break-node.png);
background-repeat: no-repeat;
}
/**
* 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",
uses: "Ext.window.MessageBox",
// private properties for internationalization
textClose: "Close",
textCloseEvent: "Close event...",
textDestroy: "Delete",
textDuplicate: "Duplicate",
textNew: "New",
textEnterNewDate: "Please enter a closing date:",
textSplit: "Split into two",
textSplitEvent: "Split into two events...",
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 + 1 day." +
"<li>no end date." +
"</ul>" +
"3. Edit the duplicated event.",
textUpdate: "Update",
// private short-cut
buttonOk: null,
dateField: null,
rowEditor: null,
splitMsg: null,
window: null,
// jshint strict: false
/**
* Initialize the plugin.
*
* @param {Dbui.grid.Panel} grid
*/
init: function (grid) {
var me = this,
rowEditor = grid.getPlugin("rowEditor"),
panelCfg, formCfg, window;
// protection
if (!rowEditor) {
throw new Error("no grid row editor !!!");
}
// the contextmenu menu
me.menu = {
items: [{
text: me.textNew,
handler: rowEditor.onAddRow,
iconCls: "xaction-create",
scope: rowEditor
}, "-", {
text: me.textSplit,
handler: me.onSplitEvent,
iconCls: "xaction-event-split",
scope: me
}, {
text: me.textClose,
handler: me.onCloseEvent,
iconCls: "xaction-event-close",
scope: me
}, "-", {
text: me.textDuplicate,
handler: rowEditor.onDuplicateRow,
iconCls: "xaction-duplicate",
scope: rowEditor
}, {
text: me.textUpdate,
handler: rowEditor.onEditRow,
iconCls: "xaction-update",
scope: rowEditor
}, "-", {
text: me.textDestroy,
handler: rowEditor.onDeleteRow,
iconCls: "xaction-destroy",
scope: rowEditor
}]
};
// 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: true,
altFormats: "",
fieldLabel: me.textEnterNewDate,
format: "Y-m-d",
labelAlign: "top",
name: "newEndDate",
padding: 5,
xtype: "datefield"
}],
buttons: [{
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);
},
// jshint strict: true
/**
* close the selected event by setting its end date.
*
*/
onCloseEvent: function () {
"use strict";
var me = this,
record = me.rowEditor.getSelected(),
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);
me.window.hide();
});
window.setTitle(me.textCloseEvent);
window.show();
},
/**
* 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,
rowEditor = me.rowEditor,
record = rowEditor.getSelected(),
endDate = record.get("HistoryEnd_date") || new Date(),
window = me.window;
me.splitMsg.show();
me.dateField.setValue(endDate);
me.buttonOk.setHandler(function () {
var newEndDate, newRecord, startDate;
// 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);
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();
});
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