Skip to content

Commit adb9c87

Browse files
committed
Merge branch '5.9' into 6.x
2 parents 25e312e + 0bc5f7e commit adb9c87

File tree

18 files changed

+136
-90
lines changed

18 files changed

+136
-90
lines changed

packages/craftcms-asset-bundles/bundles/cp/src/js/CustomizeSourcesModal.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,8 @@ Craft.CustomizeSourcesModal = Garnish.Modal.extend({
438438
},
439439

440440
addSource: function (sourceData, isNew) {
441-
const pageName = sourceData.page ?? this.selectedPage.name ?? '__DEFAULT__';
441+
const pageName =
442+
sourceData.page ?? this.selectedPage?.name ?? '__DEFAULT__';
442443
sourceData.page = pageName;
443444
const isHeading = sourceData.type === 'heading';
444445

@@ -465,7 +466,7 @@ Craft.CustomizeSourcesModal = Garnish.Modal.extend({
465466

466467
const $itemInput = $('<input/>', {
467468
type: 'hidden',
468-
name: 'sourceOrder[][key]',
469+
name: 'sourceOrder[]',
469470
value: sourceData.key,
470471
}).appendTo($item);
471472
$(
@@ -1083,9 +1084,13 @@ Craft.CustomizeSourcesModal.Page = Garnish.Base.extend(
10831084
const $sourceContainer = this.getSourceContainer(false);
10841085
if ($sourceContainer) {
10851086
if (closestPage) {
1086-
$sourceContainer
1087-
.children()
1088-
.appendTo(closestPage.getSourceContainer());
1087+
const $newSourceContainer = closestPage.getSourceContainer();
1088+
const $sources = $sourceContainer.children();
1089+
for (let i = 0; i < $sources.length; i++) {
1090+
const $source = $sources.eq(i).appendTo($newSourceContainer);
1091+
const source = $source.data('source');
1092+
source.$pageInput.val(closestPage.name);
1093+
}
10891094
}
10901095
$sourceContainer.remove();
10911096
}

packages/craftcms-vue/admintable/App.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,8 @@
498498
isEmpty: false,
499499
isLoading: true,
500500
searchClearTitle: Craft.escapeHtml(Craft.t('app', 'Clear')),
501-
searchTerm: '',
501+
searchTerm:
502+
new URL(window.location.href).searchParams.get('search') || '',
502503
selectAll: null,
503504
sortable: null,
504505
tableBodySelector: '.vuetable-body',
@@ -717,6 +718,14 @@
717718
}
718719
this.reload();
719720
}
721+
722+
const url = new URL(window.location.href);
723+
if (this.searchTerm) {
724+
url.searchParams.set('search', this.searchTerm);
725+
} else {
726+
url.searchParams.delete('search');
727+
}
728+
window.history.replaceState({}, '', url);
720729
}, 500),
721730
722731
resetSearch: function () {

resources/templates/_layouts/components/global-sidebar.twig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% macro action(item, isSelected, showIcon) %}
1+
{% macro action(item, isSubnav, isSelected, showIcon) %}
22
{% set showIcon = showIcon ?? true %}
33
{% set selected = item.sel ?? isSelected ?? false %}
44
{% set badgeCount = item.badgeCount ?? false %}
@@ -29,11 +29,11 @@
2929

3030
{{ item.label }}
3131

32-
{% if subnav %}
32+
{% if not isSubnav and subnav %}
3333
<craft-navigation slot="subnav">
3434
{% for subItem in subnav %}
3535
{% set isSelected = selectedSubnavItem is defined and selectedSubnavItem == subItemId and subItem.url in craft.app.request.fullPath -%}
36-
{{ _self.action(subItem, isSelected) }}
36+
{{ _self.action(subItem, true, isSelected) }}
3737
{% endfor %}
3838
</craft-navigation>
3939
{% endif %}
@@ -48,7 +48,7 @@
4848

4949
<craft-navigation class="global-sidebar__nav" label="{{ 'Primary' | t('app') }}">
5050
{% for item in craft.cp.nav() %}
51-
{{ _self.action(item) }}
51+
{{ _self.action(item, false) }}
5252
{% endfor %}
5353
</craft-navigation>
5454

resources/templates/_layouts/elementindex.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
iconAltText: 'Site'|t('app'),
3131
label: selectedSite.name|t('site'),
3232
menu: {
33-
items: siteMenuItems|length > 1 ? siteMenuItems : null,
33+
items: siteMenuItems,
3434
label: 'Select site'|t('app')
3535
}
3636
}) %}

src/Http/Controllers/FieldsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ private function cpScreenResponse(FieldInterface $field, ?Request $request = nul
500500
if (! $this->readOnly) {
501501
$response
502502
->action('fields/save-field')
503-
->redirectUrl('settings/fields')
503+
->redirectUrl(UrlHelper::cpReferralUrl() ?? 'settings/fields')
504504
->addAltAction(t('Save and continue editing'), [
505505
'redirect' => 'settings/fields/edit/{id}',
506506
'shortcut' => true,

src/Http/Controllers/Settings/EntryTypesController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44

55
namespace CraftCms\Cms\Http\Controllers\Settings;
66

7+
use Craft;
78
use craft\base\FieldLayoutElement;
89
use craft\elements\Entry;
910
use craft\fieldlayoutelements\entries\EntryTitleField;
1011
use craft\helpers\Cp;
12+
use craft\helpers\UrlHelper;
1113
use craft\models\FieldLayout;
1214
use CraftCms\Cms\Config\GeneralConfig;
1315
use CraftCms\Cms\Entry\Data\EntryType;
@@ -125,7 +127,7 @@ public function edit(EntryTypeModel $entryType): CpScreenResponse
125127
callback: function (CpScreenResponse $response) use ($entryTypeData) {
126128
$response
127129
->action('entry-types/save')
128-
->redirectUrl('settings/entry-types')
130+
->redirectUrl(UrlHelper::cpReferralUrl() ?? 'settings/entry-types')
129131
->addAltAction(t('Save and continue editing'), [
130132
'redirect' => 'settings/entry-types/{id}',
131133
'shortcut' => true,
@@ -293,7 +295,7 @@ public function renderOverrideSettings(Request $request): JsonResponse
293295
$entryType->description = $request->input('description', $entryType->description);
294296

295297
$namespace = Str::random(10);
296-
$view = \Craft::$app->getView();
298+
$view = Craft::$app->getView();
297299

298300
$html = $view->namespaceInputs(
299301
fn () => $view->renderTemplate('_includes/forms/entry-type-select/selection-settings.twig', [

src/Http/Controllers/Utilities/MigrationsController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use CraftCms\Cms\Utility\Utilities;
1010
use CraftCms\Cms\Utility\Utilities\Migrations;
1111
use Illuminate\Http\Request;
12-
use Illuminate\Support\Facades\Log;
1312
use Throwable;
1413

1514
use function CraftCms\Cms\cp_redirect;
@@ -30,7 +29,7 @@ public function __invoke(Request $request, Migrator $migrator)
3029
$migrator->track('content')->run();
3130
Flash::success(t('Applied new migrations successfully.'));
3231
} catch (Throwable $e) {
33-
Log::error($e);
32+
report($e);
3433

3534
Flash::fail(t('Couldn’t apply new migrations.'));
3635
}

yii2-adapter/legacy/controllers/ElementIndexSettingsController.php

Lines changed: 63 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -273,78 +273,86 @@ public function actionSaveCustomizeSourcesModalSettings(): Response
273273
if ($multiPage) {
274274
$sourcePages = $this->request->getBodyParam('sourcePages', []);
275275
$pageSettings = $this->request->getBodyParam('pageSettings', []);
276+
$sourcePageIndexes = [];
276277
}
277278

278279
// Normalize to the way it's stored in the DB
279-
foreach ($sourceOrder as $source) {
280-
if (isset($source['key'])) {
281-
$type = match (true) {
282-
str_starts_with($source['key'], 'custom:') => ElementSources::TYPE_CUSTOM,
283-
str_starts_with($source['key'], 'heading:') => ElementSources::TYPE_HEADING,
284-
default => ElementSources::TYPE_NATIVE,
285-
};
286-
287-
$isCustom = $type === ElementSources::TYPE_CUSTOM;
288-
$sourceConfig = [
289-
'type' => $type,
290-
'key' => $source['key'],
291-
];
292-
293-
if (isset($sourcePages[$source['key']])) {
294-
$sourceConfig['page'] = $sourcePages[$source['key']];
280+
foreach ($sourceOrder as $key) {
281+
$type = match (true) {
282+
str_starts_with($key, 'custom:') => ElementSources::TYPE_CUSTOM,
283+
str_starts_with($key, 'heading:') => ElementSources::TYPE_HEADING,
284+
default => ElementSources::TYPE_NATIVE,
285+
};
286+
287+
$isCustom = $type === ElementSources::TYPE_CUSTOM;
288+
$sourceConfig = [
289+
'type' => $type,
290+
'key' => $key,
291+
];
292+
293+
if (isset($sourcePages[$key])) {
294+
$sourceConfig['page'] = $sourcePages[$key];
295+
}
296+
297+
// Were new settings posted?
298+
if (isset($sourceSettings[$key])) {
299+
$postedSettings = $sourceSettings[$key];
300+
301+
if ($type !== ElementSources::TYPE_HEADING) {
302+
$sourceConfig['tableAttributes'] = array_values(array_filter($postedSettings['tableAttributes'] ?? [])) ?: '-';
295303
}
296304

297-
// Were new settings posted?
298-
if (isset($sourceSettings[$source['key']])) {
299-
$postedSettings = $sourceSettings[$source['key']];
305+
if (isset($postedSettings['defaultSort'])) {
306+
$sourceConfig['defaultSort'] = $postedSettings['defaultSort'];
307+
}
300308

301-
if ($type !== ElementSources::TYPE_HEADING) {
302-
$sourceConfig['tableAttributes'] = array_values(array_filter($postedSettings['tableAttributes'] ?? [])) ?: '-';
303-
}
309+
if (isset($postedSettings['defaultViewMode'])) {
310+
$sourceConfig['defaultViewMode'] = $postedSettings['defaultViewMode'];
311+
}
304312

305-
if (isset($postedSettings['defaultSort'])) {
306-
$sourceConfig['defaultSort'] = $postedSettings['defaultSort'];
307-
}
313+
if ($isCustom) {
314+
$sourceConfig += [
315+
'label' => $postedSettings['label'],
316+
'condition' => $conditionsService->createCondition($postedSettings['condition'])->getConfig(),
317+
];
308318

309-
if (isset($postedSettings['defaultViewMode'])) {
310-
$sourceConfig['defaultViewMode'] = $postedSettings['defaultViewMode'];
319+
if (isset($postedSettings['sites']) && $postedSettings['sites'] !== '*') {
320+
$sourceConfig['sites'] = is_array($postedSettings['sites']) ? $postedSettings['sites'] : false;
311321
}
312322

313-
if ($isCustom) {
314-
$sourceConfig += [
315-
'label' => $postedSettings['label'],
316-
'condition' => $conditionsService->createCondition($postedSettings['condition'])->getConfig(),
317-
];
318-
319-
if (isset($postedSettings['sites']) && $postedSettings['sites'] !== '*') {
320-
$sourceConfig['sites'] = is_array($postedSettings['sites']) ? $postedSettings['sites'] : false;
321-
}
322-
323-
if (isset($postedSettings['userGroups']) && $postedSettings['userGroups'] !== '*') {
324-
$sourceConfig['userGroups'] = is_array($postedSettings['userGroups']) ? $postedSettings['userGroups'] : false;
325-
}
326-
} elseif ($type === ElementSources::TYPE_HEADING) {
327-
$sourceConfig['heading'] = $postedSettings['heading'];
328-
} elseif (isset($postedSettings['enabled'])) {
329-
$sourceConfig['disabled'] = !$postedSettings['enabled'];
330-
if ($sourceConfig['disabled']) {
331-
$disabledSourceKeys[] = $source['key'];
332-
}
323+
if (isset($postedSettings['userGroups']) && $postedSettings['userGroups'] !== '*') {
324+
$sourceConfig['userGroups'] = is_array($postedSettings['userGroups']) ? $postedSettings['userGroups'] : false;
333325
}
334-
} elseif (isset($oldSourceConfigs[$source['key']])) {
335-
$sourceConfig += $oldSourceConfigs[$source['key']];
336-
if (!empty($sourceConfig['disabled'])) {
337-
$disabledSourceKeys[] = $source['key'];
326+
} elseif ($type === ElementSources::TYPE_HEADING) {
327+
$sourceConfig['heading'] = $postedSettings['heading'];
328+
} elseif (isset($postedSettings['enabled'])) {
329+
$sourceConfig['disabled'] = !$postedSettings['enabled'];
330+
if ($sourceConfig['disabled']) {
331+
$disabledSourceKeys[] = $key;
338332
}
339-
} elseif ($isCustom) {
340-
// Ignore it
341-
continue;
342333
}
334+
} elseif (isset($oldSourceConfigs[$key])) {
335+
$sourceConfig += $oldSourceConfigs[$key];
336+
if (!empty($sourceConfig['disabled'])) {
337+
$disabledSourceKeys[] = $key;
338+
}
339+
} elseif ($isCustom) {
340+
// Ignore it
341+
continue;
342+
}
343+
344+
$newSourceConfigs[] = $sourceConfig;
343345

344-
$newSourceConfigs[] = $sourceConfig;
346+
if ($multiPage) {
347+
$sourcePageIndexes[] = array_search($sourceConfig['page'], array_keys($pageSettings));
345348
}
346349
}
347350

351+
if ($multiPage) {
352+
/** @phpstan-ignore-next-line */
353+
array_multisort($sourcePageIndexes, SORT_NUMERIC, range(1, count($newSourceConfigs)), SORT_NUMERIC, $newSourceConfigs);
354+
}
355+
348356
$projectConfig->set(sprintf('%s.%s', ProjectConfig::PATH_ELEMENT_SOURCES, $elementType), $newSourceConfigs);
349357

350358
if ($multiPage) {

yii2-adapter/legacy/controllers/ElementIndexesController.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -849,10 +849,6 @@ protected function elementResponseData(bool $includeContainer, bool $includeActi
849849
*/
850850
protected function availableActions(): ?array
851851
{
852-
if ($this->request->isMobileBrowser()) {
853-
return null;
854-
}
855-
856852
$actions = $this->elementType::actions($this->sourceKey);
857853

858854
foreach ($actions as $i => $action) {

yii2-adapter/legacy/controllers/ElementsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ public function actionEdit(?ElementInterface $element, ?int $elementId = null):
364364
[$docTitle, $title] = $this->_editElementTitles($element);
365365
$enabledForSite = $element->getEnabledForSite();
366366
$hasRoute = $element->getRoute() !== null;
367-
$redirectUrl = $this->request->getValidatedQueryParam('returnUrl') ?? ElementHelper::postEditUrl($element);
367+
$redirectUrl = $this->request->getValidatedQueryParam('returnUrl') ?? UrlHelper::cpReferralUrl() ?? ElementHelper::postEditUrl($element);
368368

369369
// Site statuses
370370
if ($canEditMultipleSites) {

0 commit comments

Comments
 (0)