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

Commit 8840eb54 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update RowHistoryData, the user can modify values.

parent c7327a48
......@@ -209,9 +209,10 @@ class CoreUi(object):
"widget": {
"xtype": "xrowhistorydata",
"bind": {
"historyData": "{record.HistoryData}"
"historyData": "{record.HistoryData}",
"historyId_events": "{record.HistoryId_events}"
},
"padding": "10 0 12 50"
"padding": "10 100 12 50"
}
}
......
......@@ -11,10 +11,10 @@
*/
Ext.define("Event.grid.RowHistoryData", {
extend: "Ext.grid.Panel",
extend: "Ext.grid.property.Grid",
alias: "widget.xrowhistorydata",
uses: "Ext.data.Store",
config: {
/**
* @cfg {Object}
* Contains the user data block which will be displayed in a grid:
......@@ -31,12 +31,28 @@ Ext.define("Event.grid.RowHistoryData", {
*/
historyData: null,
// Predefined configuration options
forceFit: true,
/**
* @cfg {Number}
* The identifier of the event
*
* This configuration has to be bind to the grid by the RowWidget plugin:
*
* historyId_events = "{record.HistoryId_events}"
*
*/
historyId_events: undefined,
// private properties for internationalization
textProperty: "property",
textValue: "value",
/**
* @cfg {Boolean}
* Activate the read only mode when it is true.
* In that case, the user cannot modify the value anymore.
*
*/
readOnly: false
},
// pivate property
eventStore: "eventsStore",
// jshint strict: false
......@@ -44,34 +60,35 @@ Ext.define("Event.grid.RowHistoryData", {
initComponent: function () {
var me = this;
me.callParent(arguments);
// the store for the grid
me.store = Ext.create("Ext.data.Store", {
fields: [
{name: "property", type: "string"},
{name: "value", type: "string"}
],
proxy: "memory"
});
// link to the event store
me.eventStore = Dbui.getStore(me.eventStore);
// the columns of the grid
me.columns =[{
dataIndex: "property",
flex: 0.5,
sortable: true,
text: me.textProperty
}, {
dataIndex: "value",
flex: 4,
sortable: true,
text: me.textValue
}];
// instantiate the base class
me.callParent(arguments);
// to deal with readonly mode at any time
me.on("beforeedit", me.onBeforeEdit, me);
// activate the two way binding
// the history.data field is updated when the user modifies a value
// in the property grid. Here we mimic the behaviour of a spreadsheet.
if (!me.readOnly) {
me.on("propertychange", me.onPropertyChange, me);
}
},
// private method requests by the component model of ExtJS
beforeDestroy: function () {
var me = this;
// hide the dirty flag when a cell is modified
me.getView().markDirty = false;
me.un("beforeedit", me.onBeforeEdit, me);
if (!me.readOnly) {
me.un("propertychange", me.onPropertyChange, me);
}
me.callParent(arguments);
},
// jshint strict: true
......@@ -80,8 +97,7 @@ Ext.define("Event.grid.RowHistoryData", {
* Setter for the historyData property.
* Method required by the binding model.
*
* @param {Object} value
* The object should has the following structure:
* @return {Object}
*
* {
* property1: val1,
......@@ -89,33 +105,64 @@ Ext.define("Event.grid.RowHistoryData", {
* }
*
*/
setHistoryData: function (value) {
getHistoryData: function () {
"use strict";
var me = this,
store = me.getStore(),
model = store.getProxy().getModel(),
records = [],
record;
value = {};
me.eventData = value;
me.getStore().each(function(record) {
value[record.get("name")] = record.get("value");
});
if (value) {
return value;
},
Ext.Object.each(value, function (prop, val) {
record = model.create();
record.set("property", prop);
record.set("value", val);
records.push(record);
});
/**
* Handler to activate / desactivate the readonly mode
*
*/
onBeforeEdit: function () {
store.loadData(records, false);
"use strict";
var me = this;
} else {
store.removeAll(true);
}
return !me.readOnly;
},
/**
* Handler to update the database
*
*/
onPropertyChange: function () {
"use strict";
var me = this;
me.publishState("historyData", me.getHistoryData());
},
/**
* Setter for the historyData property.
* Method required by the binding model.
*
* @param {Object} value
* The object should has the following structure:
*
* {
* property1: val1,
* property2: val2
* }
*
*/
setHistoryData: function (value) {
"use strict";
var me = this,
events = me.eventStore,
idEvent= me.historyId_events,
sourceConfig = Event.getHistoryDataConfig(events, idEvent);
me.getView().refresh();
me.setSource(value, sourceConfig);
}
});
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