From 0521fda729d1980dcb581d3de85fe0dee61f9184 Mon Sep 17 00:00:00 2001 From: Albert Gasset Date: Tue, 6 Aug 2019 14:38:31 +0200 Subject: [PATCH] MOBILE-3021 calendar: Display current month/day button before other buttons --- .../components/calendar/addon-calendar-calendar.html | 2 +- src/addon/calendar/pages/day/day.html | 6 +++--- src/components/navbar-buttons/navbar-buttons.ts | 5 ++++- src/providers/utils/dom.ts | 6 ++++-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/addon/calendar/components/calendar/addon-calendar-calendar.html b/src/addon/calendar/components/calendar/addon-calendar-calendar.html index 073811937..1bf31b5d0 100644 --- a/src/addon/calendar/components/calendar/addon-calendar-calendar.html +++ b/src/addon/calendar/components/calendar/addon-calendar-calendar.html @@ -1,6 +1,6 @@ - + diff --git a/src/addon/calendar/pages/day/day.html b/src/addon/calendar/pages/day/day.html index 083bdd315..cec0955ac 100644 --- a/src/addon/calendar/pages/day/day.html +++ b/src/addon/calendar/pages/day/day.html @@ -2,12 +2,12 @@ {{ 'addon.calendar.calendarevents' | translate }} - + diff --git a/src/components/navbar-buttons/navbar-buttons.ts b/src/components/navbar-buttons/navbar-buttons.ts index 7f4ae239b..c38931322 100644 --- a/src/components/navbar-buttons/navbar-buttons.ts +++ b/src/components/navbar-buttons/navbar-buttons.ts @@ -25,6 +25,8 @@ import { CoreContextMenuComponent } from '../context-menu/context-menu'; * If this component indicates a position (start/end), the buttons will only be added if the header has some buttons in that * position. If no start/end is specified, then the buttons will be added to the first found in the header. * + * If this component has a "prepend" attribute, the buttons will be added before other existing buttons in the header. + * * You can use the [hidden] input to hide all the inner buttons if a certain condition is met. * * IMPORTANT: Do not use *ngIf in the buttons inside this component, it can cause problems. Please use [hidden] instead. @@ -92,7 +94,8 @@ export class CoreNavBarButtonsComponent implements OnInit, OnDestroy { if (buttonsContainer) { this.mergeContextMenus(buttonsContainer); - this.movedChildren = this.domUtils.moveChildren(this.element, buttonsContainer); + const prepend = this.element.hasAttribute('prepend'); + this.movedChildren = this.domUtils.moveChildren(this.element, buttonsContainer, prepend); this.showHideAllElements(); } else { diff --git a/src/providers/utils/dom.ts b/src/providers/utils/dom.ts index d67c7fb90..e0a99c94c 100644 --- a/src/providers/utils/dom.ts +++ b/src/providers/utils/dom.ts @@ -795,16 +795,18 @@ export class CoreDomUtilsProvider { * * @param {HTMLElement} oldParent The old parent. * @param {HTMLElement} newParent The new parent. + * @param {boolean} [prepend] If true, adds the children to the beginning of the new parent. * @return {Node[]} List of moved children. */ - moveChildren(oldParent: HTMLElement, newParent: HTMLElement): Node[] { + moveChildren(oldParent: HTMLElement, newParent: HTMLElement, prepend?: boolean): Node[] { const movedChildren: Node[] = []; + const referenceNode = prepend ? newParent.firstChild : null; while (oldParent.childNodes.length > 0) { const child = oldParent.childNodes[0]; movedChildren.push(child); - newParent.appendChild(child); + newParent.insertBefore(child, referenceNode); } return movedChildren;