Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to source navigation and element index UI, user-related document titles #14946

Merged
merged 15 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
- The accessible name of “Select site” buttons is now translated to the current language.
- Improved the accessibility of two-step verification steps on the control panel login screen. ([#15145](https://github.com/craftcms/cms/pull/15145))
- Improved the accessibility of global nav items with subnavs. ([#15006](https://github.com/craftcms/cms/issues/15006))
- The secondary nav is now kept open during source selection for mobile viewports, preventing focus from being dropped. ([#14946](https://github.com/craftcms/cms/pull/14946))
- User edit screens’ document titles have been updated to describe the page purpose. ([#14946](https://github.com/craftcms/cms/pull/14946))

### Administration
- Added the `--format` option to the `db/backup` and `db/restore` commands for PostgreSQL installs. ([#14931](https://github.com/craftcms/cms/pull/14931))
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
- Matrix fields in cards view and Addresses fields now show which nested entries/addresses contain validation errors. ([#15161](https://github.com/craftcms/cms/issues/15161))
- Improved the accessibility of two-step verification steps on the control panel login screen. ([#15145](https://github.com/craftcms/cms/pull/15145))
- Improved the accessibility of global nav items with subnavs. ([#15006](https://github.com/craftcms/cms/issues/15006))
- The secondary nav is now kept open during source selection for mobile viewports, preventing focus from being dropped. ([#14946](https://github.com/craftcms/cms/pull/14946))
- User edit screens’ document titles have been updated to describe the page purpose. ([#14946](https://github.com/craftcms/cms/pull/14946))
- Fixed an error that could occur if a Local filesystem wasn’t configured with a base path.
- Fixed a bug where some entries could be missing content after upgrading to Craft 5. ([#15150](https://github.com/craftcms/cms/issues/15150))
- Fixed a bug where it wasn’t always possible to add new entries to Matrix fields in inline-editable blocks view, if the field’s Max Entries setting had been reached before page load. ([#15158](https://github.com/craftcms/cms/issues/15158))
Expand Down
10 changes: 9 additions & 1 deletion src/controllers/EditUserTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,19 @@ protected function asEditUserScreen(User $user, string $screen): Response
throw new ForbiddenHttpException('User not authorized to perform this action.');
}

$pageName = $screens[$screen]["label"];
$response = $this->asCpScreen();
if ($user->getIsCurrent()) {
$response->title(Craft::t('app', 'My Account'));
$response->docTitle($pageName);
} else {
$response->title($user->getUiLabel());
$username = $user->getUiLabel();
$extendedTitle = Craft::t('app', 'User {page}', [
'page' => $pageName,
]);
$docTitle = "$username - $extendedTitle";
$response->title($username);
$response->docTitle($docTitle);
}

$navItems = [];
Expand Down
2 changes: 1 addition & 1 deletion src/templates/_layouts/cp.twig
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ history.replaceState(undefined, undefined, window.location.href.match(/^[^#]*/)[
aria-controls="sidebar-container"
aria-expanded="false"
>
<span id="content-heading"></span>
{{ 'Show sidebar'|t('app') }}
</button>
</div>
<div id="sidebar-container">
Expand Down
1 change: 1 addition & 0 deletions src/translations/en/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -1791,6 +1791,7 @@
'User Group' => 'User Group',
'User Groups' => 'User Groups',
'User Permissions' => 'User Permissions',
'User {page}' => 'User {page}',
'User Photo Location' => 'User Photo Location',
'User Photo Volume' => 'User Photo Volume',
'User Photos' => 'User Photos',
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/css/cp.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/css/cp.css.map

Large diffs are not rendered by default.

25 changes: 16 additions & 9 deletions src/web/assets/cp/src/css/_cp.scss
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,21 @@ li.breadcrumb-toggle-wrapper {
}
}

#content-heading {
font-size: 0.875rem;
font-weight: normal;

&:before {
content: '/';
display: inline-block;
margin-inline: 0.5rem;
}

@media only screen and (min-width: $minHorizontalUiWidth) {
display: none;
}
}

#toolbar {
flex: 1;
align-items: flex-start;
Expand Down Expand Up @@ -1320,8 +1335,7 @@ li.breadcrumb-toggle-wrapper {
// Rearrange #main-content to flow vertically at < 999
@media only screen and (max-width: $minHorizontalUiWidth - calc(1rem/16)) {
#header {
display: flex;
flex-wrap: wrap;
display: block;

.flex:not(#toolbar) {
margin-top: 10px;
Expand All @@ -1330,19 +1344,12 @@ li.breadcrumb-toggle-wrapper {

#toolbar {
flex-wrap: wrap !important;
order: 3;
width: 100%;
flex: auto;

& > * {
margin-top: 10px !important;
}
}

#action-buttons {
order: 2;
}

body.fixed-header #header .flex:first-child {
margin-top: 0;
}
Expand Down
19 changes: 18 additions & 1 deletion src/web/assets/cp/src/js/BaseElementIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,9 @@ Craft.BaseElementIndex = Garnish.Base.extend(
}
this.afterSetInitialSource(queryParams);
}

// Set visible source name on small/zoomed screens
this.updateMainHeading();
},

afterInit: function () {
Expand Down Expand Up @@ -772,6 +775,20 @@ Craft.BaseElementIndex = Garnish.Base.extend(
}
},

updateMainHeading: function () {
let $contentHeading = $('#content-heading');

if (!$contentHeading.length) {
$contentHeading = $('<span>', {
id: 'content-heading',
});

$contentHeading.appendTo('.screen-title');
}

$contentHeading.text(this.getSourceLabel());
},

deinitSource: function ($source) {
this.sourceNav.removeItems($source);
this.deinitSourceToggle($source);
Expand Down Expand Up @@ -2162,7 +2179,7 @@ Craft.BaseElementIndex = Garnish.Base.extend(
this.setInstanceState('selectedSource', this.sourceKey);
this.sourceNav.selectItem($source);

Craft.cp.updateContentHeading();
this.updateMainHeading();

if (this.searching) {
// Clear the search value without causing it to update elements
Expand Down
13 changes: 1 addition & 12 deletions src/web/assets/cp/src/js/CP.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Craft.CP = Garnish.Base.extend(

this.isMobile = Garnish.isMobileBrowser();

this.updateContentHeading();
//this.updateContentHeading();

// Swap any instruction text with info icons
let $allInstructions = this.$details.find(
Expand Down Expand Up @@ -497,17 +497,6 @@ Craft.CP = Garnish.Base.extend(
Craft.submitForm(this.$primaryForm, options);
},

updateSidebarMenuLabel: function () {
this.updateContentHeading();
},

updateContentHeading: function () {
const $item = this.$sidebar.find('a.sel:first');
const $label = $item.children('.label');
$('#content-heading').text($label.length ? $label.text() : $item.text());
Garnish.$bod.removeClass('showing-sidebar');
},

toggleNav: function () {
const isExpanded = this.navIsExpanded();

Expand Down