Merge pull request #3601 from moodlehq/MOBILE-4308
MOBILE-4308 core: Apply no filter to complex iconsmain
commit
7494f52c79
|
@ -258,5 +258,14 @@ export class AddonModResourceModuleHandlerService extends CoreModuleHandlerBase
|
|||
return AddonModResourceIndexComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
iconIsShape(module?: CoreCourseModuleData | undefined, modicon?: string | undefined): boolean | undefined {
|
||||
const iconUrl = module?.modicon ?? modicon;
|
||||
|
||||
return !iconUrl?.startsWith('assets/img/files/');
|
||||
}
|
||||
|
||||
}
|
||||
export const AddonModResourceModuleHandler = makeSingleton(AddonModResourceModuleHandlerService);
|
||||
|
|
|
@ -55,7 +55,7 @@ export class AddonModUrlModuleHandlerService extends CoreModuleHandlerBase imple
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
getData(module: CoreCourseModuleData): CoreCourseModuleHandlerData {
|
||||
async getData(module: CoreCourseModuleData): Promise<CoreCourseModuleHandlerData> {
|
||||
|
||||
/**
|
||||
* Open the URL.
|
||||
|
@ -109,11 +109,9 @@ export class AddonModUrlModuleHandlerService extends CoreModuleHandlerBase imple
|
|||
}],
|
||||
};
|
||||
|
||||
this.hideLinkButton(module).then((hideButton) => {
|
||||
if (!handlerData.buttons) {
|
||||
return;
|
||||
}
|
||||
const hideButton = await CoreUtils.ignoreErrors(this.hideLinkButton(module));
|
||||
|
||||
if (handlerData.buttons && hideButton !== undefined) {
|
||||
handlerData.buttons[0].hidden = hideButton;
|
||||
|
||||
if (module.contents && module.contents[0]) {
|
||||
|
@ -122,11 +120,7 @@ export class AddonModUrlModuleHandlerService extends CoreModuleHandlerBase imple
|
|||
// Calculate the icon to use.
|
||||
handlerData.icon = CoreCourse.getModuleIconSrc(module.modname, module.modicon, icon);
|
||||
}
|
||||
|
||||
return;
|
||||
}).catch(() => {
|
||||
// Ignore errors.
|
||||
});
|
||||
}
|
||||
|
||||
return handlerData;
|
||||
}
|
||||
|
@ -193,5 +187,14 @@ export class AddonModUrlModuleHandlerService extends CoreModuleHandlerBase imple
|
|||
return this.shouldOpenLink(module);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
iconIsShape(module?: CoreCourseModuleData | undefined, modicon?: string | undefined): boolean | undefined {
|
||||
const iconUrl = module?.modicon ?? modicon;
|
||||
|
||||
return !iconUrl?.startsWith('assets/img/files/');
|
||||
}
|
||||
|
||||
}
|
||||
export const AddonModUrlModuleHandler = makeSingleton(AddonModUrlModuleHandlerService);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { CoreConstants, ModPurpose } from '@/core/constants';
|
||||
import { Component, ElementRef, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChange } from '@angular/core';
|
||||
import { Component, ElementRef, Input, OnChanges, OnInit, SimpleChange } from '@angular/core';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate';
|
||||
import { CoreSites } from '@services/sites';
|
||||
|
@ -35,13 +35,11 @@ export class CoreModIconComponent implements OnInit, OnChanges {
|
|||
@Input() fallbackTranslation = ''; // Fallback translation string if cannot auto translate.
|
||||
@Input() componentId?: number; // Component Id for external icons.
|
||||
@Input() modicon?: string; // Module icon url or local url.
|
||||
@Input() noFilter?: boolean; // Whether to disable filters.
|
||||
@Input() showAlt = true; // Show alt otherwise it's only presentation icon.
|
||||
@Input() purpose: ModPurpose = ModPurpose.MOD_PURPOSE_OTHER; // Purpose of the module.
|
||||
|
||||
@Output() failedLoading = new EventEmitter<void>();
|
||||
|
||||
icon = '';
|
||||
noFilter = false;
|
||||
modNameTranslated = '';
|
||||
isLocalUrl = true;
|
||||
linkIconWithComponent = false;
|
||||
|
@ -81,22 +79,22 @@ export class CoreModIconComponent implements OnInit, OnChanges {
|
|||
}
|
||||
}
|
||||
|
||||
this.setIcon();
|
||||
await this.setIcon();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
ngOnChanges(changes: { [name: string]: SimpleChange }): void {
|
||||
async ngOnChanges(changes: { [name: string]: SimpleChange }): Promise<void> {
|
||||
if (changes && changes.modicon && changes.modicon.previousValue !== undefined) {
|
||||
this.setIcon();
|
||||
await this.setIcon();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set icon.
|
||||
*/
|
||||
setIcon(): void {
|
||||
async setIcon(): Promise<void> {
|
||||
this.icon = this.modicon || this.icon;
|
||||
this.isLocalUrl = this.icon.startsWith(assetsPath);
|
||||
|
||||
|
@ -108,6 +106,9 @@ export class CoreModIconComponent implements OnInit, OnChanges {
|
|||
!!this.componentId &&
|
||||
!this.isLocalUrl &&
|
||||
!this.icon.match('/theme/image.php/[^/]+/' + this.modname + '/[-0-9]*/');
|
||||
|
||||
const iconIsShape = await CoreCourseModuleDelegate.moduleIconIsShape(this.modname, this.icon);
|
||||
this.noFilter = iconIsShape === false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -126,8 +127,7 @@ export class CoreModIconComponent implements OnInit, OnChanges {
|
|||
}
|
||||
|
||||
this.icon = path + moduleName + '.svg';
|
||||
|
||||
this.failedLoading.emit();
|
||||
this.noFilter = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -48,8 +48,7 @@
|
|||
<img *ngIf="row.image && !row.itemmodule" [src]="row.image" slot="start" class="core-module-icon"
|
||||
[alt]="row.iconAlt" />
|
||||
<core-mod-icon *ngIf="row.image && row.itemmodule" [modicon]="row.image" slot="start"
|
||||
[modname]="row.itemmodule" [noFilter]="row.imageIsShape === false"
|
||||
(failedLoading)="failedLoadingRowImage(row)">
|
||||
[modname]="row.itemmodule">
|
||||
</core-mod-icon>
|
||||
<span [innerHTML]="row.gradeitem"></span>
|
||||
</th>
|
||||
|
|
|
@ -239,13 +239,4 @@ export class CoreGradesCoursePage implements AfterViewInit, OnDestroy {
|
|||
infiniteComplete && infiniteComplete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle row image failed loading.
|
||||
*
|
||||
* @param row Row data.
|
||||
*/
|
||||
failedLoadingRowImage(row: CoreGradesFormattedTableRow): void {
|
||||
delete row.imageIsShape;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -693,7 +693,6 @@ export class CoreGradesHelperProvider {
|
|||
row.itemmodule = modname;
|
||||
row.iconAlt = CoreCourse.translateModuleName(row.itemmodule) || '';
|
||||
row.image = await CoreCourseModuleDelegate.getModuleIconSrc(modname, modicon);
|
||||
row.imageIsShape = await CoreCourseModuleDelegate.moduleIconIsShape(modname, modicon);
|
||||
}
|
||||
} else {
|
||||
if (row.rowspan && row.rowspan > 1) {
|
||||
|
@ -806,7 +805,6 @@ export type CoreGradesFormattedRowCommonData = {
|
|||
rowclass?: string;
|
||||
itemtype?: string;
|
||||
image?: string;
|
||||
imageIsShape?: boolean;
|
||||
itemmodule?: string;
|
||||
iconAlt?: string;
|
||||
rowspan?: number;
|
||||
|
|
Loading…
Reference in New Issue