fix wrong repository properties

This commit is contained in:
Sebastian Sdorra
2011-09-04 18:34:11 +02:00
parent 8f744138e3
commit df636f606a
2 changed files with 44 additions and 8 deletions

View File

@@ -54,7 +54,7 @@ Sonia.repository.PropertiesFormPanel = Ext.extend(Sonia.repository.FormPanel, {
loadProperties: function(){
this.items.each(function(field){
if (field.property){
if (!Ext.isEmpty(field.property)){
this.properties.push({
'name': field.name,
'property': field.property
@@ -75,15 +75,31 @@ Sonia.repository.PropertiesFormPanel = Ext.extend(Sonia.repository.FormPanel, {
// create properties if they are empty
if (!item.properties){
item.properties = [];
} else {
var filtered = item.properties.filter(function(p){
var result = !Ext.isEmpty(p.key);
if ( result ){
for (var i in this.properties){
if ( p.key == this.properties[i].property ){
result = false;
break;
}
}
}
return result;
}, this);
item.properties = filtered;
}
// copy fields to properties
for ( var i in this.properties ){
var property = this.properties[i];
for ( var k in this.properties ){
var property = this.properties[k];
if (!Ext.isEmpty(property.name)){
item.properties.push({
key: property.property,
value: item[property.name]
});
}
delete item[property.name];
}
}

View File

@@ -40,7 +40,8 @@ Sonia.util.clone = function(obj) {
if (obj[i] && typeof obj[i] == "object") {
newObj[i] = Sonia.util.clone(obj[i]);
} else newObj[i] = obj[i]
} return newObj;
}
return newObj;
};
Sonia.util.parseInt = function(string, defaultValue){
@@ -71,3 +72,22 @@ Sonia.util.getStringFromArray = function(array){
return value;
}
if (!Array.prototype.filter) {
Array.prototype.filter = function(fn, scope){
var results = [],
i = 0,
ln = array.length;
for (; i < ln; i++) {
if (fn.call(scope, array[i], i, array)) {
results.push(array[i]);
}
}
return results;
}
}