Commit f32dd2cc authored by Dietmar Maurer's avatar Dietmar Maurer

correctly check for undefined values

and remove stale code (that code is not required because this is done by the reader).
parent 99a583a8
...@@ -6,24 +6,18 @@ Ext.define('PVE.grid.PendingObjectGrid', { ...@@ -6,24 +6,18 @@ Ext.define('PVE.grid.PendingObjectGrid', {
var me = this; var me = this;
var rec = me.store.getById(key); var rec = me.store.getById(key);
if (rec) { if (rec) {
if (pending && rec.data['pending']) { var value = (pending && Ext.isDefined(rec.data.pending) && (rec.data.pending !== '')) ?
return rec.data['pending']; rec.data.pending : rec.data.value;
}else if (rec.data.value) {
return rec.data.value; if (Ext.isDefined(value) && (value !== '')) {
}else { return value;
} else {
return defaultValue; return defaultValue;
} }
} }
return defaultValue; return defaultValue;
}, },
renderKey: function(key, metaData, record, rowIndex, colIndex, store) {
var me = this;
var rows = me.rows;
var rowdef = (rows && rows[key]) ? rows[key] : {};
return rowdef.header || key;
},
renderValue: function(value, metaData, record, rowIndex, colIndex, store) { renderValue: function(value, metaData, record, rowIndex, colIndex, store) {
var me = this; var me = this;
var rows = me.rows; var rows = me.rows;
...@@ -35,26 +29,27 @@ Ext.define('PVE.grid.PendingObjectGrid', { ...@@ -35,26 +29,27 @@ Ext.define('PVE.grid.PendingObjectGrid', {
var pending = ''; var pending = '';
if (renderer) { if (renderer) {
current = renderer(value, metaData, record, rowIndex, colIndex, store); current = renderer(value, metaData, record, rowIndex, colIndex, store, false);
if(record.data['pending'] || record.data['pending'] === 0 || rowdef.multiValues){ if (Ext.isDefined(record.data.pending) && (record.data.pending !== '')) {
pending = renderer(record.data['pending'], metaData, record, rowIndex, colIndex, store, 1); pending = renderer(record.data.pending, metaData, record, rowIndex, colIndex, store, true);
} }
if(pending == current) { if (pending == current) {
pending = undefined; pending = undefined;
} }
}else{ } else {
current = value; current = value;
pending = record.data['pending']; pending = record.data.pending;
} }
if(record.data['delete']){
if (record.data['delete']) {
pendingdelete = '<div style="text-decoration: line-through;">'+ current +'</div>'; pendingdelete = '<div style="text-decoration: line-through;">'+ current +'</div>';
} }
value = current; if (pending || pendingdelete) {
if(pending || pendingdelete){ return current + '<div style="color:red">' + pending + pendingdelete + '</div>';
value += '<div style="color:red">' + pending + pendingdelete + '</div>'; } else {
return current;
} }
return value;
}, },
initComponent : function() { initComponent : function() {
...@@ -81,17 +76,6 @@ Ext.define('PVE.grid.PendingObjectGrid', { ...@@ -81,17 +76,6 @@ Ext.define('PVE.grid.PendingObjectGrid', {
var store = Ext.create('PVE.data.DiffStore', { rstore: rstore }); var store = Ext.create('PVE.data.DiffStore', { rstore: rstore });
if (rows) {
Ext.Object.each(rows, function(key, rowdef) {
//fixme : add missing options from config file ?
if (Ext.isDefined(rowdef.defaultValue)) {
store.add({ key: key, value: rowdef.defaultValue, pending: undefined, delete: undefined });
} else if (rowdef.required) {
store.add({ key: key, value: undefined, pending: undefined, delete: undefined });
}
});
}
if (me.sorterFn) { if (me.sorterFn) {
store.sorters.add(new Ext.util.Sorter({ store.sorters.add(new Ext.util.Sorter({
sorterFn: me.sorterFn sorterFn: me.sorterFn
......
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