MOBILE-3021 calendar: Display current month/day button before other buttons

main
Albert Gasset 2019-08-06 14:38:31 +02:00
parent 949467a11b
commit 0521fda729
4 changed files with 12 additions and 7 deletions

View File

@ -1,6 +1,6 @@
<!-- Add buttons to the nav bar. -->
<core-navbar-buttons end>
<core-navbar-buttons end prepend>
<button [hidden]="!canNavigate || isCurrentMonth || !displayNavButtons" ion-button icon-only clear (click)="goToCurrentMonth()">
<core-icon name="fa-calendar-times-o"></core-icon>
</button>

View File

@ -2,12 +2,12 @@
<ion-navbar core-back-button>
<ion-title>{{ 'addon.calendar.calendarevents' | translate }}</ion-title>
<ion-buttons end>
<button *ngIf="courses && courses.length" ion-button icon-only (click)="openCourseFilter($event)" [attr.aria-label]="'core.courses.filter' | translate">
<ion-icon name="funnel"></ion-icon>
</button>
<button *ngIf="!isCurrentDay" ion-button icon-only clear (click)="goToCurrentDay()">
<core-icon name="fa-calendar-times-o"></core-icon>
</button>
<button *ngIf="courses && courses.length" ion-button icon-only (click)="openCourseFilter($event)" [attr.aria-label]="'core.courses.filter' | translate">
<ion-icon name="funnel"></ion-icon>
</button>
<core-context-menu>
<core-context-menu-item [hidden]="!loaded || !hasOffline || !isOnline" [priority]="400" [content]="'core.settings.synchronizenow' | translate" (action)="doRefresh(null, $event, true)" [iconAction]="syncIcon" [closeOnClick]="false"></core-context-menu-item>
</core-context-menu>

View File

@ -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 <ion-buttons> 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 {

View File

@ -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;