MOBILE-4616 chore: Move ucFirst to CoreText
parent
d6007c2aae
commit
6303769f0c
|
@ -13,7 +13,7 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreCoordinates, CoreDom } from '@singletons/dom';
|
||||
import { CoreEventObserver } from '@singletons/events';
|
||||
import { CoreLogger } from '@singletons/logger';
|
||||
|
@ -267,7 +267,7 @@ export class AddonQtypeDdMarkerQuestion {
|
|||
}
|
||||
|
||||
// Check that a function to draw this shape exists.
|
||||
const drawFunc = 'drawShape' + CoreTextUtils.ucFirst(shape);
|
||||
const drawFunc = 'drawShape' + CoreText.capitalize(shape);
|
||||
if (!(this[drawFunc] instanceof Function)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import { CoreCourseModulePrefetchDelegate } from '../services/module-prefetch-de
|
|||
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
||||
import { CoreUrl } from '@singletons/url';
|
||||
import { CoreTime } from '@singletons/time';
|
||||
import { CoreText } from '@singletons/text';
|
||||
|
||||
/**
|
||||
* Result of a resource download.
|
||||
|
@ -232,7 +233,7 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy,
|
|||
const lastDownloaded =
|
||||
await CoreCourseHelper.getModulePackageLastDownloaded(this.module, this.component);
|
||||
|
||||
this.downloadTimeReadable = CoreTextUtils.ucFirst(lastDownloaded.downloadTimeReadable);
|
||||
this.downloadTimeReadable = CoreText.capitalize(lastDownloaded.downloadTimeReadable);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,7 +28,7 @@ import { CoreFilepool } from '@services/filepool';
|
|||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { ModalController, NgZone } from '@singletons';
|
||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||
|
@ -222,7 +222,7 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy {
|
|||
|
||||
if (this.canPrefetch) {
|
||||
if (moduleInfo.downloadTime && moduleInfo.downloadTime > 0) {
|
||||
this.downloadTimeReadable = CoreTextUtils.ucFirst(moduleInfo.downloadTimeReadable);
|
||||
this.downloadTimeReadable = CoreText.capitalize(moduleInfo.downloadTimeReadable);
|
||||
}
|
||||
this.prefetchLoading = moduleInfo.status === DownloadStatus.DOWNLOADING;
|
||||
this.prefetchDisabled = moduleInfo.status === DownloadStatus.DOWNLOADED;
|
||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
|
|||
import { FileEntry } from '@awesome-cordova-plugins/file/ngx';
|
||||
|
||||
import { CoreFile } from '@services/file';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { makeSingleton, Translate } from '@singletons';
|
||||
import { CoreLogger } from '@singletons/logger';
|
||||
import { CoreWSFile } from '@services/ws';
|
||||
|
@ -466,7 +466,7 @@ export class CoreMimetypeUtilsProvider {
|
|||
const value = attr[key];
|
||||
translateParams[key] = value;
|
||||
translateParams[key.toUpperCase()] = value.toUpperCase();
|
||||
translateParams[CoreTextUtils.ucFirst(key)] = CoreTextUtils.ucFirst(value);
|
||||
translateParams[CoreText.capitalize(key)] = CoreText.capitalize(value);
|
||||
}
|
||||
|
||||
// MIME types may include + symbol but this is not permitted in string ids.
|
||||
|
@ -486,7 +486,7 @@ export class CoreMimetypeUtilsProvider {
|
|||
}
|
||||
|
||||
if (capitalise) {
|
||||
result = CoreTextUtils.ucFirst(result);
|
||||
result = CoreText.capitalize(result);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -28,6 +28,7 @@ import { CorePath } from '@singletons/path';
|
|||
import { CorePlatform } from '@services/platform';
|
||||
import { ContextLevel } from '@/core/constants';
|
||||
import { CoreDom } from '@singletons/dom';
|
||||
import { CoreText } from '@singletons/text';
|
||||
|
||||
/**
|
||||
* Different type of errors the app can treat.
|
||||
|
@ -1007,9 +1008,10 @@ export class CoreTextUtilsProvider {
|
|||
*
|
||||
* @param text Text to treat.
|
||||
* @returns Treated text.
|
||||
* @deprecated since 4.5. Use CoreText.capitalize instead.
|
||||
*/
|
||||
ucFirst(text: string): string {
|
||||
return text.charAt(0).toUpperCase() + text.slice(1);
|
||||
return CoreText.capitalize(text);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -95,4 +95,14 @@ export class CoreText {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a string's first character uppercase.
|
||||
*
|
||||
* @param text Text to treat.
|
||||
* @returns Treated text.
|
||||
*/
|
||||
static capitalize(text: string): string {
|
||||
return text.charAt(0).toUpperCase() + text.slice(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue