1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-08 07:47:00 +02:00
This commit is contained in:
Ryan Cramer
2024-04-05 13:00:26 -04:00
parent 6aa698343b
commit 7438ae90ca
3 changed files with 23 additions and 9 deletions

View File

@@ -866,18 +866,24 @@ abstract class FieldtypeMulti extends Fieldtype {
* *
*/ */
public function getLoadQueryAutojoin(Field $field, DatabaseQuerySelect $query) { public function getLoadQueryAutojoin(Field $field, DatabaseQuerySelect $query) {
$database = $this->wire()->database;
if($this->get('useOrderByCols')) { if($this->get('useOrderByCols')) {
// autojoin is not used if sorting or pagination is active // autojoin is not used if sorting or pagination is active
$orderByCols = $field->get('orderByCols'); $orderByCols = $field->get('orderByCols');
if(count($orderByCols) > 0) return null; if(count($orderByCols) > 0) return null;
} }
$table = $this->database->escapeTable($field->table); $table = $database->escapeTable($field->table);
$schema = $this->trimDatabaseSchema($this->getDatabaseSchema($field)); $schemaAll = $this->getDatabaseSchema($field);
$fieldName = $this->database->escapeCol($field->name); $schema = $this->trimDatabaseSchema($schemaAll);
$fieldName = $database->escapeCol($field->name);
$separator = self::multiValueSeparator; $separator = self::multiValueSeparator;
if($field->distinctAutojoin) $table = "DISTINCT $table"; $orderBy = '';
if($field->distinctAutojoin) {
if(isset($schemaAll['sort'])) $orderBy = "ORDER BY $table.sort";
$table = "DISTINCT $table";
}
foreach($schema as $key => $unused) { foreach($schema as $key => $unused) {
$query->select("GROUP_CONCAT($table.$key SEPARATOR '$separator') AS `{$fieldName}__$key`"); // QA $query->select("GROUP_CONCAT($table.$key $orderBy SEPARATOR '$separator') AS `{$fieldName}__$key`"); // QA
} }
return $query; return $query;
} }
@@ -1039,5 +1045,3 @@ abstract class FieldtypeMulti extends Fieldtype {
} }
} }

View File

@@ -241,7 +241,8 @@ var InputfieldPageAutocomplete = {
// items: '.InputfieldPageListSelectMultiple ol > li', // items: '.InputfieldPageListSelectMultiple ol > li',
axis: 'y', axis: 'y',
update: function(e, data) { update: function(e, data) {
InputfieldPageAutocomplete.rebuildInput($(this)); InputfieldPageAutocomplete.rebuildInput($(this));
InputfieldPageAutocomplete.triggerChange($ol)
$ol.trigger('sorted', [ data.item ]); $ol.trigger('sorted', [ data.item ]);
}, },
start: function(e, data) { start: function(e, data) {

View File

@@ -322,12 +322,21 @@ class InputfieldPageAutocomplete extends Inputfield implements InputfieldHasArra
$pps->setDisplayFormat($name, $this->labelFieldFormat, true); $pps->setDisplayFormat($name, $this->labelFieldFormat, true);
$queryStrings[] = "format_name=$name"; $queryStrings[] = "format_name=$name";
} }
// optional extra data set in session in case any hooks need it.
// how to retrieve when ProcessPageSearch is $this->process
// $name = $input->get->fieldName('format_name');
// $data = $process->getForSelector($name, true);
$data = array(
'page_id' => ($this->hasPage ? $this->hasPage->id : 0),
'field' => ($this->hasField ? $this->hasField->name : ''),
);
$queryStrings[] = 'get=' . urlencode($this->labelFieldName); $queryStrings[] = 'get=' . urlencode($this->labelFieldName);
// tell ProcessPageSearch to store this selector which we can tell it to use // tell ProcessPageSearch to store this selector which we can tell it to use
// by setting $_GET['for_selector_name'] = $name // by setting $_GET['for_selector_name'] = $name
$url = $pps->setForSelector($name, trim($selector, ', ')); $url = $pps->setForSelector($name, trim($selector, ', '), $data);
if(count($queryStrings)) $url .= '&' . implode('&', $queryStrings); if(count($queryStrings)) $url .= '&' . implode('&', $queryStrings);
// replace any pipes with encoded version // replace any pipes with encoded version