MOBILE-2726 siteplugins: Let modules hide default menu options

main
dpalou 2018-11-13 08:16:38 +01:00
parent 76a753be58
commit c50d8bb81d
2 changed files with 19 additions and 6 deletions

View File

@ -1,11 +1,11 @@
<!-- Buttons to add to the header. --> <!-- Buttons to add to the header. -->
<core-navbar-buttons end> <core-navbar-buttons end>
<core-context-menu> <core-context-menu>
<core-context-menu-item *ngIf="externalUrl" [priority]="900" [content]="'core.openinbrowser' | translate" [href]="externalUrl" [iconAction]="'open'"></core-context-menu-item> <core-context-menu-item [hidden]="!displayOpenInBrowser || !externalUrl" [priority]="900" [content]="'core.openinbrowser' | translate" [href]="externalUrl" [iconAction]="'open'"></core-context-menu-item>
<core-context-menu-item *ngIf="description" [priority]="800" [content]="'core.moduleintro' | translate" (action)="expandDescription()" [iconAction]="'arrow-forward'"></core-context-menu-item> <core-context-menu-item [hidden]="!displayDescription || !description" [priority]="800" [content]="'core.moduleintro' | translate" (action)="expandDescription()" [iconAction]="'arrow-forward'"></core-context-menu-item>
<core-context-menu-item [priority]="700" [content]="'core.refresh' | translate" (action)="doRefresh(null, $event)" [iconAction]="refreshIcon" [closeOnClick]="false"></core-context-menu-item> <core-context-menu-item [hidden]="!displayRefresh" [priority]="700" [content]="'core.refresh' | translate" (action)="doRefresh(null, $event)" [iconAction]="refreshIcon" [closeOnClick]="false"></core-context-menu-item>
<core-context-menu-item *ngIf="prefetchStatusIcon" [priority]="600" [content]="prefetchText" (action)="prefetch()" [iconAction]="prefetchStatusIcon" [closeOnClick]="false"></core-context-menu-item> <core-context-menu-item [hidden]="!displayPrefetch || !prefetchStatusIcon" [priority]="600" [content]="prefetchText" (action)="prefetch()" [iconAction]="prefetchStatusIcon" [closeOnClick]="false"></core-context-menu-item>
<core-context-menu-item *ngIf="size" [priority]="500" [content]="size" [iconDescription]="'cube'" (action)="removeFiles()" [iconAction]="'trash'"></core-context-menu-item> <core-context-menu-item [hidden]="!displaySize || !size" [priority]="500" [content]="size" [iconDescription]="'cube'" (action)="removeFiles()" [iconAction]="'trash'"></core-context-menu-item>
</core-context-menu> </core-context-menu>
</core-navbar-buttons> </core-navbar-buttons>

View File

@ -15,6 +15,7 @@
import { Component, OnInit, OnDestroy, Input, ViewChild } from '@angular/core'; import { Component, OnInit, OnDestroy, Input, ViewChild } from '@angular/core';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { CoreTextUtilsProvider } from '@providers/utils/text'; import { CoreTextUtilsProvider } from '@providers/utils/text';
import { CoreUtilsProvider } from '@providers/utils/utils';
import { CoreSitePluginsProvider } from '../../providers/siteplugins'; import { CoreSitePluginsProvider } from '../../providers/siteplugins';
import { CoreCourseModuleMainComponent } from '@core/course/providers/module-delegate'; import { CoreCourseModuleMainComponent } from '@core/course/providers/module-delegate';
import { CoreCourseModulePrefetchDelegate } from '@core/course/providers/module-prefetch-delegate'; import { CoreCourseModulePrefetchDelegate } from '@core/course/providers/module-prefetch-delegate';
@ -46,6 +47,12 @@ export class CoreSitePluginsModuleIndexComponent implements OnInit, OnDestroy, C
prefetchStatusIcon: string; prefetchStatusIcon: string;
prefetchText: string; prefetchText: string;
size: string; size: string;
displayOpenInBrowser = true;
displayDescription = true;
displayRefresh = true;
displayPrefetch = true;
displaySize = true;
jsData: any; // Data to pass to the component. jsData: any; // Data to pass to the component.
protected isDestroyed = false; protected isDestroyed = false;
@ -53,7 +60,7 @@ export class CoreSitePluginsModuleIndexComponent implements OnInit, OnDestroy, C
constructor(protected sitePluginsProvider: CoreSitePluginsProvider, protected courseHelper: CoreCourseHelperProvider, constructor(protected sitePluginsProvider: CoreSitePluginsProvider, protected courseHelper: CoreCourseHelperProvider,
protected prefetchDelegate: CoreCourseModulePrefetchDelegate, protected textUtils: CoreTextUtilsProvider, protected prefetchDelegate: CoreCourseModulePrefetchDelegate, protected textUtils: CoreTextUtilsProvider,
protected translate: TranslateService) { } protected translate: TranslateService, protected utils: CoreUtilsProvider) { }
/** /**
* Component being initialized. * Component being initialized.
@ -75,6 +82,12 @@ export class CoreSitePluginsModuleIndexComponent implements OnInit, OnDestroy, C
module: this.module, module: this.module,
courseId: this.courseId courseId: this.courseId
}; };
this.displayOpenInBrowser = !this.utils.isFalseOrZero(handler.handlerSchema.displayopeninbrowser);
this.displayDescription = !this.utils.isFalseOrZero(handler.handlerSchema.displaydescription);
this.displayRefresh = !this.utils.isFalseOrZero(handler.handlerSchema.displayrefresh);
this.displayPrefetch = !this.utils.isFalseOrZero(handler.handlerSchema.displayprefetch);
this.displaySize = !this.utils.isFalseOrZero(handler.handlerSchema.displaysize);
} }
// Get the data for the context menu. // Get the data for the context menu.