Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
tev
plugin_event
Commits
8840eb54
Commit
8840eb54
authored
Apr 20, 2017
by
LE GAC Renaud
Browse files
Update RowHistoryData, the user can modify values.
parent
c7327a48
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
118 additions
and
70 deletions
+118
-70
modules/plugin_event/ui_core.py
modules/plugin_event/ui_core.py
+3
-2
static/plugin_event/src/grid/RowHistoryData.js
static/plugin_event/src/grid/RowHistoryData.js
+115
-68
No files found.
modules/plugin_event/ui_core.py
View file @
8840eb54
...
...
@@ -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
10
0 12 50"
}
}
...
...
static/plugin_event/src/grid/RowHistoryData.js
View file @
8840eb54
...
...
@@ -11,70 +11,136 @@
*/
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:
*
* {
* property1: val1,
* property2: val2
* }
*
* This configuration has to be bind to the grid by the RowWidget plugin:
*
* historyData = "{record.HistoryData}"
*
*/
historyData
:
null
,
/**
* @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
,
/**
* @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
// private method requests by the component model of ExtJS
initComponent
:
function
()
{
var
me
=
this
;
me
.
callParent
(
arguments
);
// link to the event store
me
.
eventStore
=
Dbui
.
getStore
(
me
.
eventStore
);
// 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
;
me
.
un
(
"
beforeedit
"
,
me
.
onBeforeEdit
,
me
);
if
(
!
me
.
readOnly
)
{
me
.
un
(
"
propertychange
"
,
me
.
onPropertyChange
,
me
);
}
me
.
callParent
(
arguments
);
},
// jshint strict: true
/**
* @cfg {Object}
* Contains the user data block which will be displayed in a grid:
* Setter for the historyData property.
* Method required by the binding model.
*
* @return {Object}
*
* {
* property1: val1,
* property2: val2
* }
*
* This configuration has to be bind to the grid by the RowWidget plugin:
*
* historyData = "{record.HistoryData}"
* }
*
*/
h
istoryData
:
null
,
getH
istoryData
:
function
()
{
// Predefined configuration options
forceFit
:
true
,
"
use strict
"
;
var
me
=
this
,
value
=
{};
// private properties for internationalization
textProperty
:
"
property
"
,
textValue
:
"
value
"
,
me
.
getStore
().
each
(
function
(
record
)
{
value
[
record
.
get
(
"
name
"
)]
=
record
.
get
(
"
value
"
);
});
// jshint strict: false
return
value
;
},
// private method requests by the component model of ExtJS
initComponent
:
function
()
{
/**
* Handler to activate / desactivate the readonly mode
*
*/
onBeforeEdit
:
function
()
{
"
use strict
"
;
var
me
=
this
;
// the store for the grid
me
.
store
=
Ext
.
create
(
"
Ext.data.Store
"
,
{
fields
:
[
{
name
:
"
property
"
,
type
:
"
string
"
},
{
name
:
"
value
"
,
type
:
"
string
"
}
],
proxy
:
"
memory
"
});
return
!
me
.
readOnly
;
},
// 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
);
/**
* Handler to update the database
*
*/
onPropertyChange
:
function
()
{
// hide the dirty flag when a cell is modified
me
.
getView
().
markDirty
=
false
;
},
"
use strict
"
;
var
me
=
this
;
// jshint strict: true
me
.
publishState
(
"
historyData
"
,
me
.
getHistoryData
());
},
/**
* Setter for the historyData property.
...
...
@@ -92,30 +158,11 @@ Ext.define("Event.grid.RowHistoryData", {
setHistoryData
:
function
(
value
)
{
"
use strict
"
;
var
me
=
this
,
store
=
me
.
getStore
(),
model
=
store
.
getProxy
().
getModel
(),
records
=
[],
record
;
me
.
eventData
=
value
;
if
(
value
)
{
Ext
.
Object
.
each
(
value
,
function
(
prop
,
val
)
{
record
=
model
.
create
();
record
.
set
(
"
property
"
,
prop
);
record
.
set
(
"
value
"
,
val
);
records
.
push
(
record
);
});
store
.
loadData
(
records
,
false
);
}
else
{
store
.
removeAll
(
true
);
}
events
=
me
.
eventStore
,
idEvent
=
me
.
historyId_events
,
sourceConfig
=
Event
.
getHistoryDataConfig
(
events
,
idEvent
);
me
.
g
et
View
().
refresh
(
);
me
.
s
et
Source
(
value
,
sourceConfig
);
}
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment