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