Skip to content

Commit

Permalink
V8: Accessibility Changes For umbEditorHeader Directive (#6315)
Browse files Browse the repository at this point in the history
* Umb editor control contains a11y support for the media section

* Started work to align to the settings section

* A11Y Amends for umbraco header directive specifically to support document type

* Fixed error when creating a new user

* This change makes sure that if a relationship type is edited, followed by a create, the title of the page is reset, a seperate PR will address the a11y requirements for this controller

* Umbraco Header directive now uses "create" rather than create item

* Made the ediorFor property more generic

* Made the ediorFor property more generic
Umbraco Header directive now uses "create" rather than create item

* Edit and create template now aligns to the more a11y header directive

* Added support for a11y name and title on settings->scripts

* Added support for a11y name and title on settings->stylesheets

* Added support for a11y name and title on settings->partial views

* Added support for a11y name and title on settings->partial view macros

* Added support for a11y name and title when editing members

* Added support for a11y name and title when editing member groups

* Updated to ignore package-lock

* Added support for a11y name and title when editing media types

* Added the ability to prevent the title being set via the umbeditorheader directive, currently for use when the content editor is editing media via a content page

* No longer sets the page title by default

* No longer sets the page title by default

* Added support for a11y name and title when editing members

* Added support for a11y name and title when editing dictionary items

* Removed bug where by screen reader was reading "blank" when the name-locked value was set to true or there was no message/ name to display

* Fixing redering issues following refactor

* Don't ignore package-lock.json

* Merged languages

* Fix up merge errors
  • Loading branch information
RachBreeze authored and emmaburstow committed Oct 30, 2019
1 parent e906704 commit 1bac814
Show file tree
Hide file tree
Showing 29 changed files with 2,423 additions and 2,254 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,22 +195,55 @@ Use this directive to construct a header inside the main editor window.
@param {string=} icon Show and edit the content icon. Opens an overlay to change the icon.
@param {boolean=} hideIcon Set to <code>true</code> to hide icon.
@param {string=} alias show and edit the content alias.
@param {boolean=} aliasLocked Set to <code>true</code> to lock the alias.
@param {boolean=} hideAlias Set to <code>true</code> to hide alias.
@param {string=} description Add a description to the content.
@param {boolean=} hideDescription Set to <code>true</code> to hide description.
@param {boolean=} setpagetitle If true the page title will be set to reflect the type of data the header is working with
@param {string=} editorfor The localization to use to aid accessibility on the edit and create screen
**/

(function () {
'use strict';

function EditorHeaderDirective(editorService) {
function EditorHeaderDirective(editorService, localizationService, editorState) {

function link(scope, $injector) {

function link(scope) {
scope.vm = {};
scope.vm.dropdownOpen = false;
scope.vm.currentVariant = "";
scope.loading = true;
scope.accessibility = {};
scope.accessibility.a11yMessage = "";
scope.accessibility.a11yName = "";
scope.accessibility.a11yMessageVisible = false;
scope.accessibility.a11yNameVisible = false;

// need to call localizationService service outside of routine to set a11y due to promise requirements
if (editorState.current) {
//to do make work for user create/edit
// to do make it work for user group create/ edit
// to make it work for language edit/create
scope.isNew = editorState.current.id === 0 ||
editorState.current.id === "0" ||
editorState.current.id === -1 ||
editorState.current.id === 0 ||
editorState.current.id === "-1";

var localizeVars = [
scope.isNew ? "placeholders_a11yCreateItem" : "placeholders_a11yEdit",
"placeholders_a11yName",
scope.isNew ? "general_new" : "general_edit"
];

if (scope.editorfor) {
localizeVars.push(scope.editorfor);
}
localizationService.localizeMany(localizeVars).then(function (data) {
setAccessibilityForEditor(data);
scope.loading = false;
});
}

scope.goBack = function () {
if (scope.onBack) {
Expand Down Expand Up @@ -247,6 +280,57 @@ Use this directive to construct a header inside the main editor window.
editorService.iconPicker(iconPicker);
};

function setAccessibilityForEditor(data) {

if (editorState.current) {
if (scope.nameLocked) {
scope.accessibility.a11yName = scope.name;
SetPageTitle(scope.name);
} else {

scope.accessibility.a11yMessage = data[0];
scope.accessibility.a11yName = data[1];
var title = data[2] + ":";
if (!scope.isNew) {
scope.accessibility.a11yMessage += " " + scope.name;
title += " " + scope.name;
} else {
var name = "";
if (editorState.current.contentTypeName) {
name = editorState.current.contentTypeName;
} else if (scope.editorfor) {
name = data[3];
}
if (name !== "") {
scope.accessibility.a11yMessage += " " + name;
scope.accessibility.a11yName = name + " " + scope.accessibility.a11yName;
title += " " + name;
}
}
if (title !== data[2] + ":") {
SetPageTitle(title);
}

}
scope.accessibility.a11yMessageVisible = !isEmptyOrSpaces(scope.accessibility.a11yMessage);
scope.accessibility.a11yNameVisible = !isEmptyOrSpaces(scope.accessibility.a11yName);
}

}

function isEmptyOrSpaces(str) {
return str === null || str===undefined || str.trim ==='';
}

function SetPageTitle(title) {
var setTitle = false;
if (scope.setpagetitle !== undefined) {
setTitle = scope.setpagetitle;
}
if (setTitle) {
scope.$emit("$changeTitle", title);
}
}
}

var directive = {
Expand All @@ -262,7 +346,6 @@ Use this directive to construct a header inside the main editor window.
icon: "=",
hideIcon: "@",
alias: "=",
aliasLocked: "<",
hideAlias: "=",
description: "=",
hideDescription: "@",
Expand All @@ -271,7 +354,9 @@ Use this directive to construct a header inside the main editor window.
onSelectNavigationItem: "&?",
key: "=",
onBack: "&?",
showBackButton: "<?"
showBackButton: "<?",
editorfor: "=",
setpagetitle:"="
},
link: link
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div data-element="editor-header" class="umb-editor-header" ng-class="{'-split-view-active': splitViewOpen === true}">

<div class="flex items-center" style="height: 100%;">
<umb-loader ng-show="loading"></umb-loader>
<div class="flex items-center" style="height: 100%;" ng-hide="loading">

<div ng-if="showBackButton === true && splitViewOpen !== true" style="margin-right: 15px;">
<button type="button" class="umb-editor-header__back" ng-click="goBack()" prevent-default>
Expand All @@ -22,11 +22,18 @@
</ng-form>

<div id="nameField" class="umb-editor-header__name-and-description" style="flex: 1 1 auto;">
<div>
<p tabindex="0" class="sr-only" ng-show="accessibility.a11yMessageVisible">
{{accessibility.a11yMessage}}
</p>
</div>
<div class="umb-editor-header__name-wrapper" ng-show="!nameLocked || !hideAlias">
<label for="headerName" class="sr-only" ng-show="accessibility.a11yNameVisible">{{accessibility.a11yName}}</label>
<ng-form name="headerNameForm">
<input data-element="editor-name-field"
no-password-manager
type="text"
id="headerName"
class="umb-editor-header__name-input"
localize="placeholder"
placeholder="@placeholders_entername"
Expand All @@ -38,7 +45,10 @@
focus-on-filled="true"
val-server-field="Name"
required
autocomplete="off" />
aria-required="true"
aria-invalid="{{contentForm.headerNameForm.headerName.$invalid ? true : false}}"
autocomplete="off"
maxlength="255"/>
</ng-form>

<umb-generate-alias data-element="editor-alias"
Expand All @@ -62,7 +72,7 @@
localize="placeholder"
placeholder="@placeholders_enterDescription"
ng-if="!hideDescription && !descriptionLocked"
ng-model="$parent.description" />
ng-model="$parent.description"/>

<div class="umb-panel-header-locked-description" ng-if="descriptionLocked">{{ description }}</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ function DictionaryEditController($scope, $routeParams, $location, dictionaryRes

//setup scope vars
vm.nameDirty = false;
vm.header = {};
vm.header.editorfor = "template_insertDictionaryItem";
vm.header.setPageTitle = true;

vm.page = {};
vm.page.loading = false;
vm.page.nameLocked = false;
Expand Down
4 changes: 3 additions & 1 deletion src/Umbraco.Web.UI.Client/src/views/dictionary/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
hide-description="true"
hide-alias="true"
on-back="vm.back()"
show-back-button="vm.showBackButton">
show-back-button="vm.showBackButton"
editorfor="vm.header.editorfor"
setpagetitle="vm.header.setPageTitle">
</umb-editor-header>

<umb-editor-container class="form-horizontal">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@

vm.currentNode = null;
vm.contentType = {};
vm.header = {};
vm.header.editorfor = "content_documentType";
vm.header.setPageTitle = true;
vm.labels = {};
vm.submitButtonKey = "buttons_save";
vm.generateModelsKey = "buttons_saveAndGenerateModels";
Expand All @@ -33,7 +36,7 @@
vm.page.loading = false;
vm.page.saveButtonState = "init";
vm.page.navigation = [];

var labelKeys = [
"general_design",
"general_listView",
Expand Down
4 changes: 3 additions & 1 deletion src/Umbraco.Web.UI.Client/src/views/documenttypes/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
key="vm.contentType.key"
description="vm.contentType.description"
navigation="vm.page.navigation"
icon="vm.contentType.icon">
icon="vm.contentType.icon"
editorfor="vm.header.editorfor"
setpagetitle="vm.header.setPageTitle">
</umb-editor-header>

<umb-editor-container class="editors-document-type-container">
Expand Down
3 changes: 2 additions & 1 deletion src/Umbraco.Web.UI.Client/src/views/media/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
navigation="content.apps"
on-select-navigation-item="appChanged(item)"
show-back-button="showBack()"
on-back="onBack()">
on-back="onBack()"
setpagetitle="header.setPageTitle">
</umb-editor-header>

<umb-editor-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ function mediaEditController($scope, $routeParams, $q, appState, mediaResource,
//setup scope vars
$scope.currentSection = appState.getSectionState("currentSection");
$scope.currentNode = null; //the editors affiliated node

$scope.header = {};
$scope.header.setPageTitle = $scope.currentSection ==="media";
$scope.page = {};
$scope.page.loading = false;
$scope.page.menu = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
vm.close = close;

vm.currentNode = null;
vm.header = {};
vm.header.editorfor = "content_mediatype";
vm.header.setPageTitle = true;
vm.contentType = {};
vm.page = {};
vm.page.loading = false;
Expand Down
4 changes: 3 additions & 1 deletion src/Umbraco.Web.UI.Client/src/views/mediatypes/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
key="vm.contentType.key"
description="vm.contentType.description"
navigation="vm.page.navigation"
icon="vm.contentType.icon">
icon="vm.contentType.icon"
editorfor="vm.header.editorfor"
setpagetitle="vm.header.setPageTitle">
</umb-editor-header>

<umb-editor-container class="editors-document-type-container">
Expand Down
4 changes: 3 additions & 1 deletion src/Umbraco.Web.UI.Client/src/views/member/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
hide-description="true"
hide-alias="true"
show-back-button="showBack()"
on-back="onBack()">
on-back="onBack()"
editorfor="header.editorfor"
setpagetitle="header.setPageTitle">
</umb-editor-header>

<umb-editor-container class="form-horizontal">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ function MemberEditController($scope, $routeParams, $location, appState, memberR
var listName = infiniteMode ? $scope.model.listname : $routeParams.listName;
var docType = infiniteMode ? $scope.model.doctype : $routeParams.doctype;

$scope.header = {};
$scope.header.editorfor = "visuallyHiddenTexts_newMember";
$scope.header.setPageTitle = true;

//setup scope vars
$scope.page = {};
$scope.page.loading = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ function MemberGroupsEditController($scope, $routeParams, appState, navigationSe
//setup scope vars
$scope.page = {};
$scope.page.loading = false;
$scope.header = {};
$scope.header.editorfor = "content_membergroup";
$scope.header.setPageTitle = true;
$scope.page.menu = {};
$scope.page.menu.currentSection = appState.getSectionState("currentSection");
$scope.page.menu.currentNode = null;
Expand Down
4 changes: 3 additions & 1 deletion src/Umbraco.Web.UI.Client/src/views/membergroups/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
name-locked="page.nameLocked"
hide-icon="true"
hide-description="true"
hide-alias="true">
hide-alias="true"
editorfor="header.editorfor"
setpagetitle="header.setPageTitle">
</umb-editor-header>

<umb-editor-container class="form-horizontal">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
var vm = this;

vm.save = save;

vm.editorfor = "visuallyHiddenTexts_newMember";
vm.header = {};
vm.header.editorfor = "content_membergroup";
vm.header.setPageTitle = true;
vm.currentNode = null;
vm.contentType = {};
vm.page = {};
Expand Down
4 changes: 3 additions & 1 deletion src/Umbraco.Web.UI.Client/src/views/membertypes/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
alias="vm.contentType.alias"
description="vm.contentType.description"
navigation="vm.page.navigation"
icon="vm.contentType.icon">
icon="vm.contentType.icon"
editorfor="vm.header.editorfor"
setpagetitle="vm.header.setPageTitle">
</umb-editor-header>

<umb-editor-container class="editors-document-type-container">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

var vm = this;

vm.header = {};
vm.header.editorfor = "visuallyHiddenTexts_newPartialViewMacro";
vm.header.setPageTitle = true;
vm.page = {};
vm.page.loading = true;
vm.partialViewMacroFile = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
hide-alias="true"
description="vm.partialViewMacro.virtualPath"
description-locked="true"
hide-icon="true">
hide-icon="true"
editorfor="vm.header.editorfor"
setpagetitle="vm.header.setPageTitle">
</umb-editor-header>

<umb-editor-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

vm.close = close;

vm.header = {};
vm.header.editorfor = "visuallyHiddenTexts_newPartialView";
vm.header.setPageTitle = true;

vm.page = {};
vm.page.loading = true;
vm.partialView = {};
Expand Down
4 changes: 3 additions & 1 deletion src/Umbraco.Web.UI.Client/src/views/partialviews/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
hide-alias="true"
description="vm.partialView.virtualPath"
description-locked="true"
hide-icon="true">
hide-icon="true"
editorfor="vm.header.editorfor"
setpagetitle="vm.header.setPageTitle">
</umb-editor-header>

<umb-editor-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function RelationTypeCreateController($scope, $location, relationTypeResource, n
init();

function init() {
$scope.$emit("$changeTitle", "");
relationTypeResource.getRelationObjectTypes().then(function(data) {
vm.objectTypes = data;
},
Expand Down
Loading

0 comments on commit 1bac814

Please sign in to comment.