fix: fix various typos

This commit is contained in:
Wieland Schöbl
2021-05-21 15:35:26 +02:00
parent 1d94dd5bf3
commit ad0dae46ff
16 changed files with 49 additions and 49 deletions

View File

@@ -80,9 +80,9 @@ export class DataFacetsProvider {
}
const combinedFacets: SCFacet[] = facets;
const combinedFacetsMap: {[key: string]: {[key: string]: number; }; } = this.facetsToMap(combinedFacets);
(items as any[]).forEach((item) => {
items.forEach((item) => {
aggregations.forEach((aggregation) => {
let fieldValues: string | string[] = item[aggregation.fieldName];
let fieldValues = item[aggregation.fieldName as keyof SCThing] as string | string[] | undefined;
if (typeof fieldValues === 'undefined') {
return;
}

View File

@@ -86,7 +86,7 @@ export class DataProvider {
}
/**
* Provides a saveable thing from the local database using the provided UID
* Provides a savable thing from the local database using the provided UID
*/
async get(uid: string, scope: DataScope.Local): Promise<SCSaveableThing<SCThings>>;
/**
@@ -148,10 +148,10 @@ export class DataProvider {
* Save a data item
*
* @param item Data item that needs to be saved
* @param [type] Saveable type (e.g. 'favorite'); if nothing is provided then type of the thing is used
* @param [type] Savable type (e.g. 'favorite'); if nothing is provided then type of the thing is used
*/
async put(item: SCThings, type?: SCThingType): Promise<SCSaveableThing<SCThings>> {
const saveableItem: SCSaveableThing<SCThings> = {
const savableItem: SCSaveableThing<SCThings> = {
data: item,
name: item.name,
origin: {
@@ -163,7 +163,7 @@ export class DataProvider {
};
// @TODO: Implementation for saving item into the backend (user's account)
return ( this.storageProvider.put<SCSaveableThing<SCThings>>(this.getDataKey(item.uid), saveableItem));
return ( this.storageProvider.put<SCSaveableThing<SCThings>>(this.getDataKey(item.uid), savableItem));
}
/**

View File

@@ -87,7 +87,7 @@ describe('DataDetailComponent', () => {
expect(comp).toBeDefined(),
);
it('should have apropriate title', async () => {
it('should have appropriate title', async () => {
const title: DebugElement | null = detailPage.query(By.directive(IonTitle));
expect(title).not.toBe(null);
expect(title!.nativeElement.textContent).toBe('Foo');

View File

@@ -43,14 +43,14 @@ export class SimpleCardComponent {
* TODO
*/
// tslint:disable-next-line:prefer-function-over-method
isString(data: any): data is string {
isString(data: unknown): data is string {
return typeof data === 'string';
}
/**
* TODO
*/
// tslint:disable-next-line:prefer-function-over-method
isThing(something: any): something is SCThing {
isThing(something: unknown): something is SCThing {
return isThing(something);
}
}

View File

@@ -17,12 +17,12 @@ import {Injectable} from '@angular/core';
import {HttpClientInterface, HttpClientRequest} from '@openstapps/api/lib/http-client-interface';
/**
* HttpClient that is based on angular's HttpClient (@TODO: move it to provider or independent package)
* HttpClient that is based on the Angular HttpClient (@TODO: move it to provider or independent package)
*/
@Injectable()
export class StAppsWebHttpClient implements HttpClientInterface {
/**
*
*
* @param http TODO
*/
constructor(private readonly http: HttpClient) {
@@ -39,7 +39,7 @@ export class StAppsWebHttpClient implements HttpClientInterface {
/**
* TODO
*/
[key: string]: any;
[key: string]: unknown;
/**
* TODO
*/
@@ -63,6 +63,7 @@ export class StAppsWebHttpClient implements HttpClientInterface {
requestConfig.method || 'GET', requestConfig.url.toString(), options)
.toPromise();
// tslint:disable-next-line:prefer-object-spread
return Object.assign(response, {statusCode: response.status, body: response.body || {}});
} catch (err) {
throw Error(err);

View File

@@ -55,7 +55,7 @@ export class PlaceMensaDetailComponent implements AfterViewInit {
startingDay: Moment;
constructor(private mensaService: PlaceMensaService, private changeDectectorRef: ChangeDetectorRef) {
constructor(private mensaService: PlaceMensaService, private changeDetectorRef: ChangeDetectorRef) {
// TODO: translation
this.startingDay = moment();
this.startingDay.hour(0);
@@ -76,7 +76,7 @@ export class PlaceMensaDetailComponent implements AfterViewInit {
break;
}
}
this.changeDectectorRef.detectChanges();
this.changeDetectorRef.detectChanges();
return out;
});

View File

@@ -20,9 +20,9 @@ import {
SCThingType,
SCTranslations,
} from '@openstapps/core';
import {Subscription} from 'rxjs';
import {ContextMenuService} from './context-menu.service';
import {FilterContext, SortContext, SortContextOption} from './context-type';
import {Subscription} from 'rxjs';
/**
* The context menu
@@ -64,16 +64,16 @@ export class ContextMenuComponent {
*/
sortOption: SortContext;
/**
* Core translator
*/
translator: SCThingTranslator;
/**
* Array of all Subscriptions
*/
subscriptions: Subscription[] = [];
/**
* Core translator
*/
translator: SCThingTranslator;
constructor(private translateService: TranslateService,
private readonly contextMenuService: ContextMenuService) {
@@ -94,15 +94,6 @@ export class ContextMenuComponent {
}));
}
/**
* Unsubscribe from Observables
*/
ngOnDestroy() {
for (let sub of this.subscriptions) {
sub.unsubscribe();
}
}
/**
* Sets selected filter options and updates listener
*/
@@ -126,6 +117,15 @@ export class ContextMenuComponent {
return this.translator.translatedPropertyValue(onlyForType, field, key);
}
/**
* Unsubscribe from Observables
*/
ngOnDestroy() {
for (const sub of this.subscriptions) {
sub.unsubscribe();
}
}
/**
* Resets filter options
*/

View File

@@ -58,7 +58,7 @@ export class NavigationComponent {
}
/**
* Loads menu entris from configProvider
* Loads menu entries from configProvider
*/
async loadMenuEntries() {
try {

View File

@@ -20,9 +20,9 @@ import {TranslateModule} from '@ngx-translate/core';
import {MomentModule} from 'ngx-moment';
import {DataModule} from '../data/data.module';
import {SettingsProvider} from '../settings/settings.provider';
import {NewsItemComponent} from './page/news-item.component';
import {NewsPageComponent} from './page/news-page.component';
import {SkeletonNewsItem} from './page/skeleton-news-item.component';
import {NewsItemComponent} from './page/news-item.component';
const newsRoutes: Routes = [
{path: 'news', component: NewsPageComponent},

View File

@@ -204,7 +204,7 @@ export class SettingsProvider {
/**
* Add an Setting to the Cache if not exist and set undefined value to defaultValue
* @param setting Setting with categories, defautlValue, name, input type and valid values
* @param setting Setting with categories, defaultValue, name, input type and valid values
*/
private addSetting(setting: SCSetting): void {
if (!this.categoryExists(setting.categories[0])) {
@@ -396,7 +396,7 @@ export class SettingsProvider {
}
/**
* Sets the order the given categories showup in the settings page
* Sets the order the given categories show up in the settings page
* @param categoryNames the order of the categories
*/
public setCategoriesOrder(categoryNames: string[]) {

View File

@@ -21,7 +21,6 @@ import {Storage} from '@ionic/storage';
@Injectable()
export class StorageProvider {
/**
*
* @param storage TODO
*/
constructor(private readonly storage: Storage) {
@@ -124,7 +123,7 @@ export class StorageProvider {
/**
* Puts a value of type T into the storage using provided key
*
* @param key Unique indentifier
* @param key Unique identifier
* @param value Resource to store under the key
*/
async put<T>(key: string, value: T): Promise<T> {

View File

@@ -77,13 +77,13 @@ export class StringSplitPipe implements PipeTransform {
pure: false, // required to update the value when the promise is resolved
})
export class NumberLocalizedPipe implements PipeTransform, OnDestroy {
decialPipe: DecimalPipe;
decimalPipe: DecimalPipe;
locale: string;
onLangChange: Subscription;
value: unknown;
constructor(private readonly translate: TranslateService) {
this.decialPipe = new DecimalPipe('de-DE');
this.decimalPipe = new DecimalPipe('de-DE');
this.locale = translate.currentLang;
}
@@ -124,6 +124,6 @@ export class NumberLocalizedPipe implements PipeTransform, OnDestroy {
updateValue(value: unknown, digitsInfo?: string | undefined): void {
// this.value = this.locale;
this.value = this.decialPipe.transform(value, digitsInfo,this.locale);
this.value = this.decimalPipe.transform(value, digitsInfo,this.locale);
}
}

View File

@@ -19,30 +19,30 @@ import {Injectable} from '@angular/core';
export abstract class ThingTranslateParser {
/**
* Gets a value from an object given a keypath
* paser.getValueFromKeyPath(anObject, 'property.subarray[42].etc');
* Gets a value from an object given a keyPath
* parser.getValueFromKeyPath(anObject, 'property.subarray[42].etc');
*/
abstract getValueFromKeyPath(instance: object, keypath: string): unknown;
abstract getValueFromKeyPath(instance: object, keyPath: string): unknown;
}
@Injectable()
export class ThingTranslateDefaultParser extends ThingTranslateParser {
getValueFromKeyPath(instance: object, keypath: string): unknown {
// keypath = aproperty[0].anotherproperty["arrayproperty"][42].finalproperty
let path = keypath.replace(/(?:\"|\')'"/gmi, '.');
getValueFromKeyPath(instance: object, keyPath: string): unknown {
// keyPath = aproperty[0].anotherproperty["arrayproperty"][42].finalproperty
let path = keyPath.replace(/(?:\"|\')'"/gmi, '.');
// path = aproperty[0].anotherproperty[.arrayproperty.][42].finalproperty
path = path.replace(/(?:\[|\])/gmi, '.');
// path = aproperty.0..anotherproperty..arrayproperty...42..finalproperty
path = path.replace(/\.{2,}/gmi, '.');
// path = aproperty.0.anotherproperty.arrayproperty.42.finalproperty
const keypathChain = keypath.split('.');
const keyPathChain = keyPath.split('.');
// tslint:disable-next-line: no-any
let property = instance as any;
for(const key of keypathChain) {
for(const key of keyPathChain) {
property = property[key] ?? undefined;
}