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