commit
c1ddc04506
|
@ -1792,6 +1792,7 @@
|
||||||
"core.fileuploader.uploadingperc": "local_moodlemobileapp",
|
"core.fileuploader.uploadingperc": "local_moodlemobileapp",
|
||||||
"core.fileuploader.video": "local_moodlemobileapp",
|
"core.fileuploader.video": "local_moodlemobileapp",
|
||||||
"core.filter": "moodle",
|
"core.filter": "moodle",
|
||||||
|
"core.firstdayofweek": "langconfig",
|
||||||
"core.folder": "moodle",
|
"core.folder": "moodle",
|
||||||
"core.forcepasswordchangenotice": "moodle",
|
"core.forcepasswordchangenotice": "moodle",
|
||||||
"core.fulllistofcourses": "moodle",
|
"core.fulllistofcourses": "moodle",
|
||||||
|
|
|
@ -153,6 +153,9 @@ export class CoreConstants {
|
||||||
static readonly MOD_ARCHETYPE_ASSIGNMENT = 2; // Assignment module archetype.
|
static readonly MOD_ARCHETYPE_ASSIGNMENT = 2; // Assignment module archetype.
|
||||||
static readonly MOD_ARCHETYPE_SYSTEM = 3; // System (not user-addable) module archetype.
|
static readonly MOD_ARCHETYPE_SYSTEM = 3; // System (not user-addable) module archetype.
|
||||||
|
|
||||||
|
// Other constants.
|
||||||
|
static readonly CALENDAR_DEFAULT_STARTING_WEEKDAY = 1;
|
||||||
|
|
||||||
// Config & environment constants.
|
// Config & environment constants.
|
||||||
static readonly CONFIG = { ...envJson.config } as unknown as EnvironmentConfig; // Data parsed from config.json files.
|
static readonly CONFIG = { ...envJson.config } as unknown as EnvironmentConfig; // Data parsed from config.json files.
|
||||||
static readonly BUILD = envJson.build as unknown as EnvironmentBuild; // Build info.
|
static readonly BUILD = envJson.build as unknown as EnvironmentBuild; // Build info.
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
// (C) Copyright 2015 Moodle Pty Ltd.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
import { Directive, OnInit } from '@angular/core';
|
||||||
|
import { CoreLang } from '@services/lang';
|
||||||
|
import { CoreUser } from '@features/user/services/user';
|
||||||
|
import { IonDatetime } from '@ionic/angular';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Directive to automatically add language and starting week day to ion-datetime.
|
||||||
|
*/
|
||||||
|
@Directive({
|
||||||
|
selector: 'ion-datetime',
|
||||||
|
})
|
||||||
|
export class CoreIonDatetimeDirective implements OnInit {
|
||||||
|
|
||||||
|
constructor(protected datetime: IonDatetime) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.setLanguage();
|
||||||
|
this.setStartingWeekDay();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set language to use.
|
||||||
|
*/
|
||||||
|
protected async setLanguage(): Promise<void> {
|
||||||
|
if (this.datetime.locale) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const language = await CoreLang.getCurrentLanguage();
|
||||||
|
this.datetime.locale = language;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set starting week day.
|
||||||
|
*/
|
||||||
|
protected async setStartingWeekDay(): Promise<void> {
|
||||||
|
if (this.datetime.firstDayOfWeek || this.datetime.firstDayOfWeek === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const startingDay = await CoreUser.getStartingWeekDay();
|
||||||
|
this.datetime.firstDayOfWeek = startingDay;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -34,6 +34,7 @@ import { CoreCollapsibleFooterDirective } from './collapsible-footer';
|
||||||
import { CoreContentDirective } from './content';
|
import { CoreContentDirective } from './content';
|
||||||
import { CoreUpdateNonReactiveAttributesDirective } from './update-non-reactive-attributes';
|
import { CoreUpdateNonReactiveAttributesDirective } from './update-non-reactive-attributes';
|
||||||
import { CoreUserTourDirective } from './user-tour';
|
import { CoreUserTourDirective } from './user-tour';
|
||||||
|
import { CoreIonDatetimeDirective } from './datetime';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
|
@ -57,6 +58,7 @@ import { CoreUserTourDirective } from './user-tour';
|
||||||
CoreContentDirective,
|
CoreContentDirective,
|
||||||
CoreUpdateNonReactiveAttributesDirective,
|
CoreUpdateNonReactiveAttributesDirective,
|
||||||
CoreUserTourDirective,
|
CoreUserTourDirective,
|
||||||
|
CoreIonDatetimeDirective,
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
CoreAutoFocusDirective,
|
CoreAutoFocusDirective,
|
||||||
|
@ -79,6 +81,7 @@ import { CoreUserTourDirective } from './user-tour';
|
||||||
CoreContentDirective,
|
CoreContentDirective,
|
||||||
CoreUpdateNonReactiveAttributesDirective,
|
CoreUpdateNonReactiveAttributesDirective,
|
||||||
CoreUserTourDirective,
|
CoreUserTourDirective,
|
||||||
|
CoreIonDatetimeDirective,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class CoreDirectivesModule {}
|
export class CoreDirectivesModule {}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import { USERS_TABLE_NAME, CoreUserDBRecord } from './database/user';
|
||||||
import { CoreUserHelper } from './user-helper';
|
import { CoreUserHelper } from './user-helper';
|
||||||
import { CoreUrlUtils } from '@services/utils/url';
|
import { CoreUrlUtils } from '@services/utils/url';
|
||||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
|
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
|
||||||
|
import { CoreConstants } from '@/core/constants';
|
||||||
|
|
||||||
const ROOT_CACHE_KEY = 'mmUser:';
|
const ROOT_CACHE_KEY = 'mmUser:';
|
||||||
|
|
||||||
|
@ -285,6 +286,24 @@ export class CoreUserProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the starting week day based on the user preference.
|
||||||
|
*
|
||||||
|
* @returns Starting week day.
|
||||||
|
*/
|
||||||
|
async getStartingWeekDay(): Promise<number> {
|
||||||
|
const preference = await CoreUtils.ignoreErrors(this.getUserPreference('calendar_startwday'));
|
||||||
|
|
||||||
|
if (preference && !isNaN(Number(preference))) {
|
||||||
|
return Number(preference);
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultValue = Number(CoreSites.getCurrentSite()?.getStoredConfig('calendar_startwday') ??
|
||||||
|
Translate.instant('core.firstdayofweek'));
|
||||||
|
|
||||||
|
return !isNaN(defaultValue) ? defaultValue % 7 : CoreConstants.CALENDAR_DEFAULT_STARTING_WEEKDAY;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get cache key for a user WS call.
|
* Get cache key for a user WS call.
|
||||||
*
|
*
|
||||||
|
|
|
@ -131,6 +131,7 @@
|
||||||
"filenameexist": "File name already exists: {{$a}}",
|
"filenameexist": "File name already exists: {{$a}}",
|
||||||
"filenotfound": "File not found, sorry.",
|
"filenotfound": "File not found, sorry.",
|
||||||
"filter": "Filter",
|
"filter": "Filter",
|
||||||
|
"firstdayofweek": "1",
|
||||||
"folder": "Folder",
|
"folder": "Folder",
|
||||||
"forcepasswordchangenotice": "You must change your password to proceed.",
|
"forcepasswordchangenotice": "You must change your password to proceed.",
|
||||||
"fulllistofcourses": "All courses",
|
"fulllistofcourses": "All courses",
|
||||||
|
|
|
@ -208,7 +208,11 @@ export class CoreTimeUtilsProvider {
|
||||||
* @returns Formatted time.
|
* @returns Formatted time.
|
||||||
*/
|
*/
|
||||||
toDatetimeFormat(timestamp?: number): string {
|
toDatetimeFormat(timestamp?: number): string {
|
||||||
return moment(timestamp || Date.now()).toISOString();
|
const isoString = moment(timestamp || Date.now()).toISOString(true);
|
||||||
|
|
||||||
|
// Remove milliseconds and timezone for consistency with the values used by ion-datetime.
|
||||||
|
// ion-datetime no longer uses timezone, it always uses UTC.
|
||||||
|
return isoString.substring(0, isoString.indexOf('.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue