Skip to content

Commit

Permalink
Merge branch '2023.11' into 2024.11
Browse files Browse the repository at this point in the history
  • Loading branch information
gitlabci committed Jan 29, 2024
2 parents 4c4ae99 + 453ea01 commit b72b195
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
16 changes: 15 additions & 1 deletion tine20/Inventory/js/InventoryItemEditDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Tine.Inventory.InventoryItemEditDialog = Ext.extend(Tine.widgets.dialog.EditDial
windowHeight: 470,
windowWidth: 800,
displayNotes: true,
defaultRelationCombo: ['Addressbook', 'Contact'],

/**
* check validity of activ number field
Expand Down Expand Up @@ -288,5 +289,18 @@ Tine.Inventory.InventoryItemEditDialog = Ext.extend(Tine.widgets.dialog.EditDial
*/
isMultipleValid: function() {
return true;
}
},

/**
* creates the relations panel, if relations are defined
*/
initRelationsPanel: function() {
if (! this.hideRelationsPanel && this.recordClass && this.recordClass.hasField('relations')) {
// init relations panel before onRecordLoad
if (! this.relationsPanel) {
this.relationsPanel = new Tine.widgets.relation.GenericPickerGridPanel({ anchor: '100% 100%', editDialog: this, defaultCombo: this.defaultRelationCombo });
this.items.items.push(this.relationsPanel);
}
}
},
});
25 changes: 22 additions & 3 deletions tine20/Tinebase/js/widgets/relation/GenericPickerGridPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ Tine.widgets.relation.GenericPickerGridPanel = Ext.extend(Tine.widgets.grid.Pick
*/
hideRelatedDegree: true,

/**
* @cfg {Array|null}
* default/initial value, null for any
*/
defaultCombo: null,

/**
* @cfg {Number} pos
* position 200 = 100 + 100*3 -> means third one after app specific tabs
Expand Down Expand Up @@ -202,7 +208,14 @@ Tine.widgets.relation.GenericPickerGridPanel = Ext.extend(Tine.widgets.grid.Pick

this.store.on('add', this.onAdd, this);
},


onAfterRender: function () {
if (this.defaultCombo) {
this.showSearchCombo(this.defaultCombo[0], this.defaultCombo[1])
}
Tine.widgets.relation.GenericPickerGridPanel.superclass.onAfterRender.call(this)
},

/**
* is called from onApplyChanges of the edit dialog per save event
*
Expand Down Expand Up @@ -468,8 +481,15 @@ Tine.widgets.relation.GenericPickerGridPanel = Ext.extend(Tine.widgets.grid.Pick
var data = [];
var id = 0;

let defaultIndex = 0
Ext.each(this.possibleRelations, function(rel) {
data.push([id, rel.text, rel.relatedApp, rel.relatedModel]);
if (this.defaultCombo &&
rel.relatedApp === this.defaultCombo[0] &&
rel.relatedModel === this.defaultCombo[1] )
{
defaultIndex = id
}
id++;
}, this);

Expand All @@ -478,10 +498,9 @@ Tine.widgets.relation.GenericPickerGridPanel = Ext.extend(Tine.widgets.grid.Pick
fields: ['id', 'text', 'appName', 'modelName'],
data: data
}),

allowBlank: false,
forceSelection: true,
value: data.length > 0 ? data[0][0] : null,
value: data.length > 0 ? data[defaultIndex][0] : null,
displayField: 'text',
valueField: 'id',
idIndex: 0,
Expand Down

0 comments on commit b72b195

Please sign in to comment.