Commit 345c3600 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Merge branch '12-filter-history.data' into 'master'

12 filter history.data

* Add the widget `HistoryGridFilter`.
* Close #12

See merge request !20
parents f4e7dc7c 0d076d0b
......@@ -193,6 +193,7 @@
'is equal to': 'égal à',
'Is Over': 'Is Over',
'Javascript API': 'Javascript API',
'key': 'clé',
'Labels': 'Etiquettes',
'Last Name': 'Nom de famille',
'Last name': 'Nom de famille',
......@@ -382,6 +383,7 @@
'User ID': 'User ID',
'users': 'users',
'Usual': 'Habituel',
'value': 'valeur',
'Value already in database or empty': 'Value already in database or empty',
'value already in database or empty': 'value already in database or empty',
'Verify Password': 'Verify Password',
......
......@@ -17,7 +17,7 @@ plugins = PluginManager()
plugins.dbui.app_css = 'static/my.css'
plugins.dbui.app_debug = 'static/src'
plugins.dbui.app_libmin = 'static/track_events-min.js'
plugins.dbui.app_lg = 'static/locale/myapp-lang-fr.js'
plugins.dbui.app_lg = 'static/track_events/locale/myapp-lang-fr.js'
plugins.dbui.app_script = 'static/app.js'
# plugins.dbui.app_script_dir = None
......
......@@ -84,7 +84,17 @@ gridModifier.append_filter(('id_object_categories', '==', T('is equal to')))
gridModifier.append_filter(('start_date', '>=', T('greater or equal to')))
gridModifier.append_filter(('end_date', '<=', T('less or equal to')))
gridModifier.configure_filters(plugins=['pFormToolTip'], width=300)
gridModifier.append_filter(
('data', 'like', 'key(s) is(are) equal to value(s). The jocker is %'),
fieldLabel=T('Data'),
header=[T("key"), T("value")],
numColumns=2,
numRows=3,
xtype='xtablefield')
gridModifier.configure_filters(plugins=['pFormToolTip'],
width=300,
xtype='xhistorygridfilter')
#-------------------------------------------------------------------------------
#
......
......@@ -5,6 +5,7 @@ HEAD
- New syntax for grid column configuration property: renderer and
summaryRenderer.
- Redesing the JavaScript class UserDataMultiDefault.
- Add the widget HistoryGridFilter.
0.6.0 (Oct 2016)
- Require plugin_dbui 0.9.0 or higher.
......
......@@ -27,6 +27,7 @@ Ext.require('Ext.tip.QuickTipManager');
Ext.require('TrackEvents.form.field.UserData');
Ext.require('TrackEvents.form.field.UserDataMultiDefault');
Ext.require('TrackEvents.form.plugin.UserDataConsistency');
Ext.require('TrackEvents.grid.HistoryFilter');
Ext.onReady(function(){
......
......@@ -3,7 +3,7 @@
*
*/
Ext.define('TrackEvents.locale.form.field.UserData', {
Ext.define("TrackEvents.locale.form.field.UserData", {
override : "TrackEvents.form.field.UserData",
textAddMenu: "ajouter",
textAddTitle: "Entrer une nouvelle propriété",
......@@ -20,9 +20,19 @@ Ext.define('TrackEvents.locale.form.field.UserData', {
textValue: "valeur"
});
Ext.define('TrackEvents.locale.form.plugin.UserDataConsistency', {
override : "TrackEvents.form.plugin.UserDataConsistency",
textError : "Erreur en mettant à jour l'historique...",
textInfo : "Information...",
Ext.define("TrackEvents.locale.form.plugin.UserDataConsistency", {
override: "TrackEvents.form.plugin.UserDataConsistency",
textError: "Erreur en mettant à jour l'historique...",
textInfo: "Information...",
textUpdate: "Mise à jour de l'historique..."
});
Ext.define("TrackEvents.locale.grid.HistoryFilter", {
override: "TrackEvents.grid.HistoryFilter",
textEventData: "Donnée d'un évènement",
textFunding: "Financement" ,
textMetadata: "Métadonnée",
textObject: "Objet",
textPeople: "Personne",
textPeriod: "Période"
});
\ No newline at end of file
/**
* The filter dedicated to the history grid.
*
* Custom layout based on accordeon
* Handle the data filter based on the Table widget
*
*
*/
Ext.define('TrackEvents.grid.HistoryFilter', {
extend: 'Dbui.grid.Filter',
alias: 'widget.xhistorygridfilter',
// private properties for internationalization
textEventData: "Event data",
textFunding: "Funding" ,
textMetadata: "Metadata",
textObject: "Object",
textPeople: "People",
textPeriod: "Period",
// jshint strict: false
// private method requests by the component model of ExtJS
// Apply a accordeon layout
initComponent: function () {
var me = this,
eventdata = [],
funding = [],
metadata = [],
object = [],
period = [],
people = [];
// the arcordeon layout
me.layout = {
type: 'accordion',
titleCollapse: true
};
me.defaults = {
frame: true
};
// collect fields for each sub-panel
// metadata, people, object, eventdata, period, funding
me.items.forEach(function (field) {
switch (field.name) {
case "[history.id_events]":
case "[history.id_domains]":
case "[history.id_teams]":
case "[history.id_projects]":
metadata.push(field);
break;
case "[people.last_name]":
case "[history.id_people_categories]":
people.push(field);
break;
case "[objects.reference]":
case "[history.id_object_categories]":
object.push(field);
break;
case "[history.data]":
field.fieldLabel = undefined;
eventdata.push(field);
break;
case "[history.start_date]":
case "[history.end_date]":
period.push(field);
break;
case "[history.id_fundings]":
field.fieldLabel = undefined;
funding.push(field);
break;
}
});
// create the new item structure by adding sub-panel
me.items = [{
title: me.textMetadata,
items: metadata
}, {
title: me.textPeople,
items: people
}, {
title: me.textObject,
items: object
}, {
title: me.textEventData,
items: eventdata,
layout: 'fit'
}, {
title: me.textPeriod,
items: period
}, {
title: me.textFunding,
items: funding,
layout: 'fit'
}];
// initialise the base class
me.callParent(arguments);
},
/**
* Build the value to be used by the filter.
* Superseede the method of the base class to handle the data filter
* which is based on the Dbui.form.field.Table widget.
*
* @param {Ext.form.Field} field
*/
getFilterValue: function (field) {
var me = this,
toJSON = Dbui.grid.Filter.valueToJSON,
table, value;
// standard case
if (field.xtype !== 'xtablefield') {
return me.callParent(arguments);
}
// table case
// Value is like [[key1, value2], [key2], [key3, value3]]
table = field.getValue();
value = "";
table.forEach(function (row) {
var s;
if (row.lentgh === 1) {
s = '"' + row[0] +'"';
} else {
s = '"' + row[0] +'": ' + toJSON(row[1]);
}
value += (value.length > 0 ? '%' + s : s);
});
// the database is filtered by the LIKE operator, add joker %
value = (value[0] === "%" ? value : "%" + value);
value = (value[value.length-1] === "%" ? value : value + "%");
return value;
}
// jshint strict: true
});
\ 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