mirror of
https://github.com/humhub/humhub.git
synced 2025-04-21 23:52:04 +02:00
Fix/7483 basepicker use itemkey instead of guid (#7498)
* Fix #7483: BasePicker: when posting the form, use the itemKey value instead of the guid * Fix #7483: BasePicker: when posting the form, use the itemKey value instead of the guid * Restrict to id or guid * https://github.com/humhub/humhub/pull/7498#discussion_r2048892158
This commit is contained in:
parent
12d5df5b13
commit
fe5ddd3e15
@ -15,6 +15,7 @@ HumHub Changelog
|
||||
- Fix #7456: Fix setting manager backwards compatibility
|
||||
- Enh #7468: Remove deprecated widget `DataSaved`
|
||||
- Enh #7493: Add possibility to define content search order via module config
|
||||
- Fix #7483: `BasePicker`: when posting the form, use the `itemKey` value instead of the `guid`
|
||||
|
||||
1.17.3 (Unreleased)
|
||||
----------------------
|
||||
|
@ -119,7 +119,7 @@ abstract class BasePicker extends JsInputWidget
|
||||
|
||||
/**
|
||||
* The item key used as option value and loading items by attribute value.
|
||||
* e.g. id or guid.
|
||||
* Available values: `id` or `guid`
|
||||
*
|
||||
* @since v1.3 'id' by default
|
||||
*
|
||||
@ -408,6 +408,7 @@ abstract class BasePicker extends JsInputWidget
|
||||
|
||||
$result = [
|
||||
'add-options' => $this->addOptions,
|
||||
'item-key' => $this->itemKey,
|
||||
'picker-url' => $this->getUrl(),
|
||||
'picker-focus' => $this->focus,
|
||||
'maximum-selection-length' => $this->maxSelection,
|
||||
|
@ -241,7 +241,7 @@ humhub.module('ui.picker', function (module, require, $) {
|
||||
item.disabled = true;
|
||||
}
|
||||
// Compatibility with old picker implementation and data attributes
|
||||
item.id = item.guid || item.id || item['data-id'];
|
||||
item.id = item.id || item.guid || item['data-id'];
|
||||
item.text = item.text || item.title || item.displayName || item['data-text'];
|
||||
item.image = item.image || item['data-image'];
|
||||
item.new = false;
|
||||
@ -332,6 +332,10 @@ humhub.module('ui.picker', function (module, require, $) {
|
||||
};
|
||||
|
||||
Picker.prototype.prepareItem = function (item) {
|
||||
const itemKey = this.$.data('item-key');
|
||||
if (itemKey && itemKey !== 'id' && item.hasOwnProperty(itemKey)) {
|
||||
item.id = item[itemKey];
|
||||
}
|
||||
item.text = item.textValue || item.text || $(item.element).data('text');
|
||||
item.image = item.image || $(item.element).data('image');
|
||||
item.imageNode = this.getImageNode(item);
|
||||
|
Loading…
x
Reference in New Issue
Block a user