refactor: replace TSLint with ESLint

This commit is contained in:
Wieland Schöbl
2021-06-30 13:53:44 +02:00
committed by Jovan Krunić
parent 67fb4a43c9
commit d696215d08
147 changed files with 5471 additions and 2704 deletions

View File

@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Component} from '@angular/core';
import {Component, OnDestroy} from '@angular/core';
import {LangChangeEvent, TranslateService} from '@ngx-translate/core';
import {
SCLanguage,
@@ -37,8 +37,7 @@ import {FilterContext, SortContext, SortContextOption} from './context-type';
selector: 'stapps-context',
templateUrl: 'context-menu.html',
})
export class ContextMenuComponent {
export class ContextMenuComponent implements OnDestroy {
/**
* Amount of filter options shown on compact view
*/
@@ -74,24 +73,26 @@ export class ContextMenuComponent {
*/
translator: SCThingTranslator;
constructor(private translateService: TranslateService,
private readonly contextMenuService: ContextMenuService) {
this.language = this.translateService.currentLang as keyof SCTranslations<SCLanguage>;
constructor(
private translateService: TranslateService,
private readonly contextMenuService: ContextMenuService,
) {
this.language = this.translateService
.currentLang as keyof SCTranslations<SCLanguage>;
this.translator = new SCThingTranslator(this.language);
this.subscriptions.push(this.translateService.onLangChange.subscribe((event: LangChangeEvent) => {
this.language = event.lang as keyof SCTranslations<SCLanguage>;
this.translator = new SCThingTranslator(this.language);
}));
this.subscriptions.push(this.contextMenuService.filterContextChanged$.subscribe((filterContext) => {
this.filterOption = filterContext;
}));
this.subscriptions.push(this.contextMenuService.sortOptions.subscribe((sortContext) => {
this.sortOption = sortContext;
}));
this.subscriptions.push(
this.translateService.onLangChange.subscribe((event: LangChangeEvent) => {
this.language = event.lang as keyof SCTranslations<SCLanguage>;
this.translator = new SCThingTranslator(this.language);
}),
this.contextMenuService.filterContextChanged$.subscribe(filterContext => {
this.filterOption = filterContext;
}),
this.contextMenuService.sortOptions.subscribe(sortContext => {
this.sortOption = sortContext;
}),
);
}
/**
@@ -99,21 +100,31 @@ export class ContextMenuComponent {
*/
filterChanged = () => {
this.contextMenuService.contextFilterChanged(this.filterOption);
}
};
/**
* Returns translated property name
*/
getTranslatedPropertyName(property: string, onlyForType?: SCThingType): string {
return (this.translator
// tslint:disable-next-line:no-any
.translatedPropertyNames(onlyForType ?? SCThingType.AcademicEvent) as any)[property];
getTranslatedPropertyName(
property: string,
onlyForType?: SCThingType,
): string {
return (
this.translator.translatedPropertyNames(
onlyForType ?? SCThingType.AcademicEvent,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
) as any
)[property];
}
/**
* Returns translated property value
*/
getTranslatedPropertyValue(onlyForType: SCThingType, field: string, key?: string): string | undefined {
getTranslatedPropertyValue(
onlyForType: SCThingType,
field: string,
key?: string,
): string | undefined {
return this.translator.translatedPropertyValue(onlyForType, field, key);
}
@@ -130,11 +141,13 @@ export class ContextMenuComponent {
* Resets filter options
*/
resetFilter = (option: FilterContext) => {
option.options.forEach((filterFacet) => filterFacet.buckets.forEach((filterBucket) => {
filterBucket.checked = false;
}));
for (const filterFacet of option.options)
for (const filterBucket of filterFacet.buckets) {
filterBucket.checked = false;
}
this.contextMenuService.contextFilterChanged(this.filterOption);
}
};
/**
* Updates selected sort option and updates listener
@@ -151,5 +164,5 @@ export class ContextMenuComponent {
}
}
this.contextMenuService.contextSortChanged(option);
}
};
}