commit
98ebbd329e
|
@ -0,0 +1,71 @@
|
|||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const srcPath = path.join(__dirname, '..', 'src')
|
||||
|
||||
function findFiles(dirPath) {
|
||||
const result = []
|
||||
const entries = fs.readdirSync(dirPath, {withFileTypes: true})
|
||||
|
||||
entries.forEach((entry) => {
|
||||
const entryPath = path.join(dirPath, entry.name)
|
||||
if (entry.isFile() && entry.name.endsWith('.ts')) {
|
||||
result.push(entryPath)
|
||||
} else if (entry.isDirectory()) {
|
||||
result.push(...findFiles(entryPath))
|
||||
}
|
||||
})
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
findFiles(srcPath).forEach((file) => {
|
||||
let src = fs.readFileSync(file, 'utf-8')
|
||||
|
||||
// Fix wrong use of @type instead of @return.
|
||||
src = src.replace(/(\n +\* \@param [^\n]*\n +\* )\@type /g, (match, p1) => p1 + '@return ')
|
||||
|
||||
// Remove square brackets and default values from @param lines.
|
||||
src = src.replace(/(\n +\* @param +\{[^\n]+\} +)\[(\w+)[^\]\n]*\]/g, (match, p1, p2) => p1 + p2)
|
||||
|
||||
// Remove types from @param and @return lines.
|
||||
src = src.replace(/(\n +\* \@(?:param|returns?) *)([a-zA-Z0-9_]+ *)?(\{[^\n]*)/g, (match, p1, p2, p3) => {
|
||||
p2 = p2 || ''
|
||||
let brackets = 1;
|
||||
let end = 0;
|
||||
for (let i = 1; brackets > 0 && i < p3.length; i++) {
|
||||
if (p3[i] == '{') {
|
||||
brackets++
|
||||
} else if (p3[i] == '}') {
|
||||
brackets--
|
||||
end = i + 1
|
||||
}
|
||||
}
|
||||
p1 = p1.trimEnd().replace('@returns', '@return')
|
||||
p2 = p2.trim()
|
||||
p3 = p3.slice(end).trim().replace(/^([a-zA-Z0-9_]+) +/, '$1 ')
|
||||
if (!p2 && !p3) return ''
|
||||
return p1 + ' ' + p2 + (p2 && p3 ? ' ' + p3 : p3)
|
||||
})
|
||||
|
||||
// Remove @type lines.
|
||||
src = src.replace(/\n +\* \@type .*\n/g, '\n')
|
||||
|
||||
// Remove consecutive empty doc lines.
|
||||
src = src.replace(/\n *\* *(\n *\*\/? *\n)/g, (match, p1) => p1)
|
||||
|
||||
// Remove empty docs.
|
||||
src = src.replace(/\n *\/\*\*[ \n\*]+\*\/ *\n/g, '\n')
|
||||
|
||||
// Fix indentation.
|
||||
src = src.replace(/(\n +\* +(?:@param \w+|@return) )([^\n]*)((?:\n +\* +[^@\n][^\n]+)+)/g, (match, p1, p2, p3) => {
|
||||
const indent = p1.length
|
||||
p3 = p3.replace(/(\n +\*)( +)([^\n]+)/g, (match, p1, p2, p3) => {
|
||||
p2 = new Array(Math.max(0, indent - p1.length + 1)).join(' ')
|
||||
return p1 + p2 + p3
|
||||
})
|
||||
return p1 + p2 + p3
|
||||
})
|
||||
|
||||
fs.writeFileSync(file, src)
|
||||
})
|
|
@ -65,7 +65,7 @@ export class AddonBadgesIssuedBadgePage {
|
|||
/**
|
||||
* Fetch the issued badge required for the view.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
fetchIssuedBadge(): Promise<any> {
|
||||
const promises = [];
|
||||
|
@ -101,7 +101,7 @@ export class AddonBadgesIssuedBadgePage {
|
|||
/**
|
||||
* Refresh the badges.
|
||||
*
|
||||
* @param {any} refresher Refresher.
|
||||
* @param refresher Refresher.
|
||||
*/
|
||||
refreshBadges(refresher: any): void {
|
||||
this.badgesProvider.invalidateUserBadges(this.courseId, this.userId).finally(() => {
|
||||
|
|
|
@ -64,7 +64,7 @@ export class AddonBadgesUserBadgesPage {
|
|||
/**
|
||||
* Fetch all the badges required for the view.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
fetchBadges(): Promise<any> {
|
||||
this.currentTime = this.timeUtils.timestamp();
|
||||
|
@ -79,7 +79,7 @@ export class AddonBadgesUserBadgesPage {
|
|||
/**
|
||||
* Refresh the badges.
|
||||
*
|
||||
* @param {any} refresher Refresher.
|
||||
* @param refresher Refresher.
|
||||
*/
|
||||
refreshBadges(refresher: any): void {
|
||||
this.badgesProvider.invalidateUserBadges(this.courseId, this.userId).finally(() => {
|
||||
|
@ -92,7 +92,7 @@ export class AddonBadgesUserBadgesPage {
|
|||
/**
|
||||
* Navigate to a particular badge.
|
||||
*
|
||||
* @param {string} badgeHash Badge to load.
|
||||
* @param badgeHash Badge to load.
|
||||
*/
|
||||
loadIssuedBadge(badgeHash: string): void {
|
||||
this.badgeHash = badgeHash;
|
||||
|
|
|
@ -33,11 +33,11 @@ export class AddonBadgesBadgeLinkHandler extends CoreContentLinksHandlerBase {
|
|||
/**
|
||||
* Get the list of actions for a link (url).
|
||||
*
|
||||
* @param {string[]} siteIds List of sites the URL belongs to.
|
||||
* @param {string} url The URL to treat.
|
||||
* @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param {number} [courseId] Course ID related to the URL. Optional but recommended.
|
||||
* @return {CoreContentLinksAction[]|Promise<CoreContentLinksAction[]>} List of (or promise resolved with list of) actions.
|
||||
* @param siteIds List of sites the URL belongs to.
|
||||
* @param url The URL to treat.
|
||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||
* @return List of (or promise resolved with list of) actions.
|
||||
*/
|
||||
getActions(siteIds: string[], url: string, params: any, courseId?: number):
|
||||
CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> {
|
||||
|
@ -53,11 +53,11 @@ export class AddonBadgesBadgeLinkHandler extends CoreContentLinksHandlerBase {
|
|||
* Check if the handler is enabled for a certain site (site + user) and a URL.
|
||||
* If not defined, defaults to true.
|
||||
*
|
||||
* @param {string} siteId The site ID.
|
||||
* @param {string} url The URL to treat.
|
||||
* @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param {number} [courseId] Course ID related to the URL. Optional but recommended.
|
||||
* @return {boolean|Promise<boolean>} Whether the handler is enabled for the URL and site.
|
||||
* @param siteId The site ID.
|
||||
* @param url The URL to treat.
|
||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||
* @return Whether the handler is enabled for the URL and site.
|
||||
*/
|
||||
isEnabled(siteId: string, url: string, params: any, courseId?: number): boolean | Promise<boolean> {
|
||||
|
||||
|
|
|
@ -35,8 +35,8 @@ export class AddonBadgesProvider {
|
|||
* This method is called quite often and thus should only perform a quick
|
||||
* check, we should not be calling WS from here.
|
||||
*
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<boolean>} Promise resolved with true if enabled, false otherwise.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with true if enabled, false otherwise.
|
||||
*/
|
||||
isPluginEnabled(siteId?: string): Promise<boolean> {
|
||||
|
||||
|
@ -54,9 +54,9 @@ export class AddonBadgesProvider {
|
|||
/**
|
||||
* Get the cache key for the get badges call.
|
||||
*
|
||||
* @param {number} courseId ID of the course to get the badges from.
|
||||
* @param {number} userId ID of the user to get the badges from.
|
||||
* @return {string} Cache key.
|
||||
* @param courseId ID of the course to get the badges from.
|
||||
* @param userId ID of the user to get the badges from.
|
||||
* @return Cache key.
|
||||
*/
|
||||
protected getBadgesCacheKey(courseId: number, userId: number): string {
|
||||
return this.ROOT_CACHE_KEY + 'badges:' + courseId + ':' + userId;
|
||||
|
@ -65,10 +65,10 @@ export class AddonBadgesProvider {
|
|||
/**
|
||||
* Get issued badges for a certain user in a course.
|
||||
*
|
||||
* @param {number} courseId ID of the course to get the badges from.
|
||||
* @param {number} userId ID of the user to get the badges from.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>}Promise to be resolved when the badges are retrieved.
|
||||
* @param courseId ID of the course to get the badges from.
|
||||
* @param userId ID of the user to get the badges from.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise to be resolved when the badges are retrieved.
|
||||
*/
|
||||
getUserBadges(courseId: number, userId: number, siteId?: string): Promise<any> {
|
||||
|
||||
|
@ -98,10 +98,10 @@ export class AddonBadgesProvider {
|
|||
/**
|
||||
* Invalidate get badges WS call.
|
||||
*
|
||||
* @param {number} courseId Course ID.
|
||||
* @param {number} userId ID of the user to get the badges from.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved when data is invalidated.
|
||||
* @param courseId Course ID.
|
||||
* @param userId ID of the user to get the badges from.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved when data is invalidated.
|
||||
*/
|
||||
invalidateUserBadges(courseId: number, userId: number, siteId?: string): Promise<any> {
|
||||
|
||||
|
|
|
@ -34,11 +34,11 @@ export class AddonBadgesMyBadgesLinkHandler extends CoreContentLinksHandlerBase
|
|||
/**
|
||||
* Get the list of actions for a link (url).
|
||||
*
|
||||
* @param {string[]} siteIds List of sites the URL belongs to.
|
||||
* @param {string} url The URL to treat.
|
||||
* @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param {number} [courseId] Course ID related to the URL. Optional but recommended.
|
||||
* @return {CoreContentLinksAction[]|Promise<CoreContentLinksAction[]>} List of (or promise resolved with list of) actions.
|
||||
* @param siteIds List of sites the URL belongs to.
|
||||
* @param url The URL to treat.
|
||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||
* @return List of (or promise resolved with list of) actions.
|
||||
*/
|
||||
getActions(siteIds: string[], url: string, params: any, courseId?: number):
|
||||
CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> {
|
||||
|
@ -54,11 +54,11 @@ export class AddonBadgesMyBadgesLinkHandler extends CoreContentLinksHandlerBase
|
|||
* Check if the handler is enabled for a certain site (site + user) and a URL.
|
||||
* If not defined, defaults to true.
|
||||
*
|
||||
* @param {string} siteId The site ID.
|
||||
* @param {string} url The URL to treat.
|
||||
* @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param {number} [courseId] Course ID related to the URL. Optional but recommended.
|
||||
* @return {boolean|Promise<boolean>} Whether the handler is enabled for the URL and site.
|
||||
* @param siteId The site ID.
|
||||
* @param url The URL to treat.
|
||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||
* @return Whether the handler is enabled for the URL and site.
|
||||
*/
|
||||
isEnabled(siteId: string, url: string, params: any, courseId?: number): boolean | Promise<boolean> {
|
||||
|
||||
|
|
|
@ -33,8 +33,8 @@ export class AddonBadgesPushClickHandler implements CorePushNotificationsClickHa
|
|||
/**
|
||||
* Check if a notification click is handled by this handler.
|
||||
*
|
||||
* @param {any} notification The notification to check.
|
||||
* @return {boolean} Whether the notification click is handled by this handler
|
||||
* @param notification The notification to check.
|
||||
* @return Whether the notification click is handled by this handler
|
||||
*/
|
||||
handles(notification: any): boolean | Promise<boolean> {
|
||||
const data = notification.customdata || {};
|
||||
|
@ -50,8 +50,8 @@ export class AddonBadgesPushClickHandler implements CorePushNotificationsClickHa
|
|||
/**
|
||||
* Handle the notification click.
|
||||
*
|
||||
* @param {any} notification The notification to check.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param notification The notification to check.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
handleClick(notification: any): Promise<any> {
|
||||
const data = notification.customdata || {};
|
||||
|
|
|
@ -30,7 +30,7 @@ export class AddonBadgesUserHandler implements CoreUserProfileHandler {
|
|||
/**
|
||||
* Check if handler is enabled.
|
||||
*
|
||||
* @return {Promise<boolean>} Always enabled.
|
||||
* @return Always enabled.
|
||||
*/
|
||||
isEnabled(): Promise<boolean> {
|
||||
return this.badgesProvider.isPluginEnabled();
|
||||
|
@ -39,11 +39,11 @@ export class AddonBadgesUserHandler implements CoreUserProfileHandler {
|
|||
/**
|
||||
* Check if handler is enabled for this user in this context.
|
||||
*
|
||||
* @param {any} user User to check.
|
||||
* @param {number} courseId Course ID.
|
||||
* @param {any} [navOptions] Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
|
||||
* @param {any} [admOptions] Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
|
||||
* @return {boolean} True if enabled, false otherwise.
|
||||
* @param user User to check.
|
||||
* @param courseId Course ID.
|
||||
* @param navOptions Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
|
||||
* @param admOptions Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
|
||||
* @return True if enabled, false otherwise.
|
||||
*/
|
||||
isEnabledForUser(user: any, courseId: number, navOptions?: any, admOptions?: any): boolean {
|
||||
|
||||
|
@ -58,7 +58,7 @@ export class AddonBadgesUserHandler implements CoreUserProfileHandler {
|
|||
/**
|
||||
* Returns the data needed to render the handler.
|
||||
*
|
||||
* @return {CoreUserProfileHandlerData} Data needed to render the handler.
|
||||
* @return Data needed to render the handler.
|
||||
*/
|
||||
getDisplayData(user: any, courseId: number): CoreUserProfileHandlerData {
|
||||
return {
|
||||
|
|
|
@ -52,7 +52,7 @@ export class AddonBlockActivityModulesComponent extends CoreBlockBaseComponent i
|
|||
/**
|
||||
* Perform the invalidate content function.
|
||||
*
|
||||
* @return {Promise<any>} Resolved when done.
|
||||
* @return Resolved when done.
|
||||
*/
|
||||
protected invalidateContent(): Promise<any> {
|
||||
return this.courseProvider.invalidateSections(this.instanceId);
|
||||
|
@ -61,7 +61,7 @@ export class AddonBlockActivityModulesComponent extends CoreBlockBaseComponent i
|
|||
/**
|
||||
* Fetch the data to render the block.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected fetchContent(): Promise<any> {
|
||||
return this.courseProvider.getSections(this.instanceId, false, true).then((sections) => {
|
||||
|
|
|
@ -32,11 +32,11 @@ export class AddonBlockActivityModulesHandler extends CoreBlockBaseHandler {
|
|||
/**
|
||||
* Returns the data needed to render the block.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @param {any} block The block to render.
|
||||
* @param {string} contextLevel The context where the block will be used.
|
||||
* @param {number} instanceId The instance ID associated with the context level.
|
||||
* @return {CoreBlockHandlerData|Promise<CoreBlockHandlerData>} Data or promise resolved with the data.
|
||||
* @param injector Injector.
|
||||
* @param block The block to render.
|
||||
* @param contextLevel The context where the block will be used.
|
||||
* @param instanceId The instance ID associated with the context level.
|
||||
* @return Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
|
||||
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
|
||||
|
|
|
@ -33,11 +33,11 @@ export class AddonBlockBadgesHandler extends CoreBlockBaseHandler {
|
|||
/**
|
||||
* Returns the data needed to render the block.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @param {any} block The block to render.
|
||||
* @param {string} contextLevel The context where the block will be used.
|
||||
* @param {number} instanceId The instance ID associated with the context level.
|
||||
* @return {CoreBlockHandlerData|Promise<CoreBlockHandlerData>} Data or promise resolved with the data.
|
||||
* @param injector Injector.
|
||||
* @param block The block to render.
|
||||
* @param contextLevel The context where the block will be used.
|
||||
* @param instanceId The instance ID associated with the context level.
|
||||
* @return Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
|
||||
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
|
||||
|
|
|
@ -33,11 +33,11 @@ export class AddonBlockBlogMenuHandler extends CoreBlockBaseHandler {
|
|||
/**
|
||||
* Returns the data needed to render the block.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @param {any} block The block to render.
|
||||
* @param {string} contextLevel The context where the block will be used.
|
||||
* @param {number} instanceId The instance ID associated with the context level.
|
||||
* @return {CoreBlockHandlerData|Promise<CoreBlockHandlerData>} Data or promise resolved with the data.
|
||||
* @param injector Injector.
|
||||
* @param block The block to render.
|
||||
* @param contextLevel The context where the block will be used.
|
||||
* @param instanceId The instance ID associated with the context level.
|
||||
* @return Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
|
||||
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
|
||||
|
|
|
@ -33,11 +33,11 @@ export class AddonBlockBlogRecentHandler extends CoreBlockBaseHandler {
|
|||
/**
|
||||
* Returns the data needed to render the block.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @param {any} block The block to render.
|
||||
* @param {string} contextLevel The context where the block will be used.
|
||||
* @param {number} instanceId The instance ID associated with the context level.
|
||||
* @return {CoreBlockHandlerData|Promise<CoreBlockHandlerData>} Data or promise resolved with the data.
|
||||
* @param injector Injector.
|
||||
* @param block The block to render.
|
||||
* @param contextLevel The context where the block will be used.
|
||||
* @param instanceId The instance ID associated with the context level.
|
||||
* @return Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
|
||||
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
|
||||
|
|
|
@ -33,11 +33,11 @@ export class AddonBlockBlogTagsHandler extends CoreBlockBaseHandler {
|
|||
/**
|
||||
* Returns the data needed to render the block.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @param {any} block The block to render.
|
||||
* @param {string} contextLevel The context where the block will be used.
|
||||
* @param {number} instanceId The instance ID associated with the context level.
|
||||
* @return {CoreBlockHandlerData|Promise<CoreBlockHandlerData>} Data or promise resolved with the data.
|
||||
* @param injector Injector.
|
||||
* @param block The block to render.
|
||||
* @param contextLevel The context where the block will be used.
|
||||
* @param instanceId The instance ID associated with the context level.
|
||||
* @return Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
|
||||
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
|
||||
|
|
|
@ -33,11 +33,11 @@ export class AddonBlockCalendarMonthHandler extends CoreBlockBaseHandler {
|
|||
/**
|
||||
* Returns the data needed to render the block.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @param {any} block The block to render.
|
||||
* @param {string} contextLevel The context where the block will be used.
|
||||
* @param {number} instanceId The instance ID associated with the context level.
|
||||
* @return {CoreBlockHandlerData|Promise<CoreBlockHandlerData>} Data or promise resolved with the data.
|
||||
* @param injector Injector.
|
||||
* @param block The block to render.
|
||||
* @param contextLevel The context where the block will be used.
|
||||
* @param instanceId The instance ID associated with the context level.
|
||||
* @return Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
|
||||
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
|
||||
|
|
|
@ -33,11 +33,11 @@ export class AddonBlockCalendarUpcomingHandler extends CoreBlockBaseHandler {
|
|||
/**
|
||||
* Returns the data needed to render the block.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @param {any} block The block to render.
|
||||
* @param {string} contextLevel The context where the block will be used.
|
||||
* @param {number} instanceId The instance ID associated with the context level.
|
||||
* @return {CoreBlockHandlerData|Promise<CoreBlockHandlerData>} Data or promise resolved with the data.
|
||||
* @param injector Injector.
|
||||
* @param block The block to render.
|
||||
* @param contextLevel The context where the block will be used.
|
||||
* @param instanceId The instance ID associated with the context level.
|
||||
* @return Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
|
||||
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
|
||||
|
|
|
@ -32,11 +32,11 @@ export class AddonBlockCommentsHandler extends CoreBlockBaseHandler {
|
|||
/**
|
||||
* Returns the data needed to render the block.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @param {any} block The block to render.
|
||||
* @param {string} contextLevel The context where the block will be used.
|
||||
* @param {number} instanceId The instance ID associated with the context level.
|
||||
* @return {CoreBlockHandlerData|Promise<CoreBlockHandlerData>} Data or promise resolved with the data.
|
||||
* @param injector Injector.
|
||||
* @param block The block to render.
|
||||
* @param contextLevel The context where the block will be used.
|
||||
* @param instanceId The instance ID associated with the context level.
|
||||
* @return Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
|
||||
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
|
||||
|
|
|
@ -32,11 +32,11 @@ export class AddonBlockCompletionStatusHandler extends CoreBlockBaseHandler {
|
|||
/**
|
||||
* Returns the data needed to render the block.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @param {any} block The block to render.
|
||||
* @param {string} contextLevel The context where the block will be used.
|
||||
* @param {number} instanceId The instance ID associated with the context level.
|
||||
* @return {CoreBlockHandlerData|Promise<CoreBlockHandlerData>} Data or promise resolved with the data.
|
||||
* @param injector Injector.
|
||||
* @param block The block to render.
|
||||
* @param contextLevel The context where the block will be used.
|
||||
* @param instanceId The instance ID associated with the context level.
|
||||
* @return Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
|
||||
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
|
||||
|
|
|
@ -32,11 +32,11 @@ export class AddonBlockGlossaryRandomHandler extends CoreBlockBaseHandler {
|
|||
/**
|
||||
* Returns the data needed to render the block.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @param {any} block The block to render.
|
||||
* @param {string} contextLevel The context where the block will be used.
|
||||
* @param {number} instanceId The instance ID associated with the context level.
|
||||
* @return {CoreBlockHandlerData|Promise<CoreBlockHandlerData>} Data or promise resolved with the data.
|
||||
* @param injector Injector.
|
||||
* @param block The block to render.
|
||||
* @param contextLevel The context where the block will be used.
|
||||
* @param instanceId The instance ID associated with the context level.
|
||||
* @return Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
|
||||
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
|
||||
|
|
|
@ -32,11 +32,11 @@ export class AddonBlockHtmlHandler extends CoreBlockBaseHandler {
|
|||
/**
|
||||
* Returns the data needed to render the block.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @param {any} block The block to render.
|
||||
* @param {string} contextLevel The context where the block will be used.
|
||||
* @param {number} instanceId The instance ID associated with the context level.
|
||||
* @return {CoreBlockHandlerData|Promise<CoreBlockHandlerData>} Data or promise resolved with the data.
|
||||
* @param injector Injector.
|
||||
* @param block The block to render.
|
||||
* @param contextLevel The context where the block will be used.
|
||||
* @param instanceId The instance ID associated with the context level.
|
||||
* @return Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
|
||||
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
|
||||
|
|
|
@ -32,11 +32,11 @@ export class AddonBlockLearningPlansHandler extends CoreBlockBaseHandler {
|
|||
/**
|
||||
* Returns the data needed to render the block.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @param {any} block The block to render.
|
||||
* @param {string} contextLevel The context where the block will be used.
|
||||
* @param {number} instanceId The instance ID associated with the context level.
|
||||
* @return {CoreBlockHandlerData|Promise<CoreBlockHandlerData>} Data or promise resolved with the data.
|
||||
* @param injector Injector.
|
||||
* @param block The block to render.
|
||||
* @param contextLevel The context where the block will be used.
|
||||
* @param instanceId The instance ID associated with the context level.
|
||||
* @return Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
|
||||
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
|
||||
|
|
|
@ -133,7 +133,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
|
|||
/**
|
||||
* Perform the invalidate content function.
|
||||
*
|
||||
* @return {Promise<any>} Resolved when done.
|
||||
* @return Resolved when done.
|
||||
*/
|
||||
protected invalidateContent(): Promise<any> {
|
||||
const promises = [];
|
||||
|
@ -161,7 +161,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
|
|||
/**
|
||||
* Fetch the courses for my overview.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected fetchContent(): Promise<any> {
|
||||
return this.coursesHelper.getUserCoursesWithOptions(this.sort).then((courses) => {
|
||||
|
@ -197,7 +197,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
|
|||
/**
|
||||
* The filter has changed.
|
||||
*
|
||||
* @param {any} Received Event.
|
||||
* @param Received Event.
|
||||
*/
|
||||
filterChanged(event: any): void {
|
||||
const newValue = event.target.value && event.target.value.trim().toLowerCase();
|
||||
|
@ -239,7 +239,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
|
|||
/**
|
||||
* Prefetch all the shown courses.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
prefetchCourses(): Promise<any> {
|
||||
const selected = this.selectedFilter,
|
||||
|
@ -264,7 +264,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
|
|||
/**
|
||||
* Init courses filters.
|
||||
*
|
||||
* @param {any[]} courses Courses to filter.
|
||||
* @param courses Courses to filter.
|
||||
*/
|
||||
initCourseFilters(courses: any[]): void {
|
||||
if (this.showSortFilter) {
|
||||
|
@ -319,7 +319,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
|
|||
/**
|
||||
* The selected courses sort filter have changed.
|
||||
*
|
||||
* @param {string} sort New sorting.
|
||||
* @param sort New sorting.
|
||||
*/
|
||||
switchSort(sort: string): void {
|
||||
this.sort = sort;
|
||||
|
@ -344,7 +344,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
|
|||
/**
|
||||
* If switch button that enables the filter input is shown or not.
|
||||
*
|
||||
* @return {boolean} If switch button that enables the filter input is shown or not.
|
||||
* @return If switch button that enables the filter input is shown or not.
|
||||
*/
|
||||
showFilterSwitchButton(): boolean {
|
||||
return this.loaded && this.courses['all'] && this.courses['all'].length > 5;
|
||||
|
|
|
@ -34,7 +34,7 @@ export class AddonBlockMyOverviewHandler extends CoreBlockBaseHandler {
|
|||
/**
|
||||
* Check if the handler is enabled on a site level.
|
||||
*
|
||||
* @return {boolean} Whether or not the handler is enabled on a site level.
|
||||
* @return Whether or not the handler is enabled on a site level.
|
||||
*/
|
||||
isEnabled(): boolean | Promise<boolean> {
|
||||
return this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan('3.6') ||
|
||||
|
@ -44,11 +44,11 @@ export class AddonBlockMyOverviewHandler extends CoreBlockBaseHandler {
|
|||
/**
|
||||
* Returns the data needed to render the block.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @param {any} block The block to render.
|
||||
* @param {string} contextLevel The context where the block will be used.
|
||||
* @param {number} instanceId The instance ID associated with the context level.
|
||||
* @return {CoreBlockHandlerData|Promise<CoreBlockHandlerData>} Data or promise resolved with the data.
|
||||
* @param injector Injector.
|
||||
* @param block The block to render.
|
||||
* @param contextLevel The context where the block will be used.
|
||||
* @param instanceId The instance ID associated with the context level.
|
||||
* @return Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
|
||||
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
|
||||
|
|
|
@ -32,11 +32,11 @@ export class AddonBlockNewsItemsHandler extends CoreBlockBaseHandler {
|
|||
/**
|
||||
* Returns the data needed to render the block.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @param {any} block The block to render.
|
||||
* @param {string} contextLevel The context where the block will be used.
|
||||
* @param {number} instanceId The instance ID associated with the context level.
|
||||
* @return {CoreBlockHandlerData|Promise<CoreBlockHandlerData>} Data or promise resolved with the data.
|
||||
* @param injector Injector.
|
||||
* @param block The block to render.
|
||||
* @param contextLevel The context where the block will be used.
|
||||
* @param instanceId The instance ID associated with the context level.
|
||||
* @return Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
|
||||
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
|
||||
|
|
|
@ -32,11 +32,11 @@ export class AddonBlockOnlineUsersHandler extends CoreBlockBaseHandler {
|
|||
/**
|
||||
* Returns the data needed to render the block.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @param {any} block The block to render.
|
||||
* @param {string} contextLevel The context where the block will be used.
|
||||
* @param {number} instanceId The instance ID associated with the context level.
|
||||
* @return {CoreBlockHandlerData|Promise<CoreBlockHandlerData>} Data or promise resolved with the data.
|
||||
* @param injector Injector.
|
||||
* @param block The block to render.
|
||||
* @param contextLevel The context where the block will be used.
|
||||
* @param instanceId The instance ID associated with the context level.
|
||||
* @return Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
|
||||
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
|
||||
|
|
|
@ -32,11 +32,11 @@ export class AddonBlockPrivateFilesHandler extends CoreBlockBaseHandler {
|
|||
/**
|
||||
* Returns the data needed to render the block.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @param {any} block The block to render.
|
||||
* @param {string} contextLevel The context where the block will be used.
|
||||
* @param {number} instanceId The instance ID associated with the context level.
|
||||
* @return {CoreBlockHandlerData|Promise<CoreBlockHandlerData>} Data or promise resolved with the data.
|
||||
* @param injector Injector.
|
||||
* @param block The block to render.
|
||||
* @param contextLevel The context where the block will be used.
|
||||
* @param instanceId The instance ID associated with the context level.
|
||||
* @return Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
|
||||
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
|
||||
|
|
|
@ -33,11 +33,11 @@ export class AddonBlockRecentActivityHandler extends CoreBlockBaseHandler {
|
|||
/**
|
||||
* Returns the data needed to render the block.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @param {any} block The block to render.
|
||||
* @param {string} contextLevel The context where the block will be used.
|
||||
* @param {number} instanceId The instance ID associated with the context level.
|
||||
* @return {CoreBlockHandlerData|Promise<CoreBlockHandlerData>} Data or promise resolved with the data.
|
||||
* @param injector Injector.
|
||||
* @param block The block to render.
|
||||
* @param contextLevel The context where the block will be used.
|
||||
* @param instanceId The instance ID associated with the context level.
|
||||
* @return Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
|
||||
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
|
||||
|
|
|
@ -79,7 +79,7 @@ export class AddonBlockRecentlyAccessedCoursesComponent extends CoreBlockBaseCom
|
|||
/**
|
||||
* Perform the invalidate content function.
|
||||
*
|
||||
* @return {Promise<any>} Resolved when done.
|
||||
* @return Resolved when done.
|
||||
*/
|
||||
protected invalidateContent(): Promise<any> {
|
||||
const promises = [];
|
||||
|
@ -104,7 +104,7 @@ export class AddonBlockRecentlyAccessedCoursesComponent extends CoreBlockBaseCom
|
|||
/**
|
||||
* Fetch the courses for recent courses.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected fetchContent(): Promise<any> {
|
||||
return this.coursesHelper.getUserCoursesWithOptions('lastaccess', 10).then((courses) => {
|
||||
|
@ -133,7 +133,7 @@ export class AddonBlockRecentlyAccessedCoursesComponent extends CoreBlockBaseCom
|
|||
/**
|
||||
* Prefetch all the shown courses.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
prefetchCourses(): Promise<any> {
|
||||
const initialIcon = this.prefetchCoursesData.icon;
|
||||
|
|
|
@ -32,11 +32,11 @@ export class AddonBlockRecentlyAccessedCoursesHandler extends CoreBlockBaseHandl
|
|||
/**
|
||||
* Returns the data needed to render the block.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @param {any} block The block to render.
|
||||
* @param {string} contextLevel The context where the block will be used.
|
||||
* @param {number} instanceId The instance ID associated with the context level.
|
||||
* @return {CoreBlockHandlerData|Promise<CoreBlockHandlerData>} Data or promise resolved with the data.
|
||||
* @param injector Injector.
|
||||
* @param block The block to render.
|
||||
* @param contextLevel The context where the block will be used.
|
||||
* @param instanceId The instance ID associated with the context level.
|
||||
* @return Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
|
||||
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
|
||||
|
|
|
@ -50,7 +50,7 @@ export class AddonBlockRecentlyAccessedItemsComponent extends CoreBlockBaseCompo
|
|||
/**
|
||||
* Perform the invalidate content function.
|
||||
*
|
||||
* @return {Promise<any>} Resolved when done.
|
||||
* @return Resolved when done.
|
||||
*/
|
||||
protected invalidateContent(): Promise<any> {
|
||||
return this.recentItemsProvider.invalidateRecentItems();
|
||||
|
@ -59,7 +59,7 @@ export class AddonBlockRecentlyAccessedItemsComponent extends CoreBlockBaseCompo
|
|||
/**
|
||||
* Fetch the data to render the block.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected fetchContent(): Promise<any> {
|
||||
return this.recentItemsProvider.getRecentItems().then((items) => {
|
||||
|
@ -70,8 +70,8 @@ export class AddonBlockRecentlyAccessedItemsComponent extends CoreBlockBaseCompo
|
|||
/**
|
||||
* Event clicked.
|
||||
*
|
||||
* @param {Event} e Click event.
|
||||
* @param {any} item Activity item info.
|
||||
* @param e Click event.
|
||||
* @param item Activity item info.
|
||||
*/
|
||||
action(e: Event, item: any): void {
|
||||
e.preventDefault();
|
||||
|
|
|
@ -32,11 +32,11 @@ export class AddonBlockRecentlyAccessedItemsHandler extends CoreBlockBaseHandler
|
|||
/**
|
||||
* Returns the data needed to render the block.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @param {any} block The block to render.
|
||||
* @param {string} contextLevel The context where the block will be used.
|
||||
* @param {number} instanceId The instance ID associated with the context level.
|
||||
* @return {CoreBlockHandlerData|Promise<CoreBlockHandlerData>} Data or promise resolved with the data.
|
||||
* @param injector Injector.
|
||||
* @param block The block to render.
|
||||
* @param contextLevel The context where the block will be used.
|
||||
* @param instanceId The instance ID associated with the context level.
|
||||
* @return Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
|
||||
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
|
||||
|
|
|
@ -30,7 +30,7 @@ export class AddonBlockRecentlyAccessedItemsProvider {
|
|||
/**
|
||||
* Get cache key for get last accessed items value WS call.
|
||||
*
|
||||
* @return {string} Cache key.
|
||||
* @return Cache key.
|
||||
*/
|
||||
protected getRecentItemsCacheKey(): string {
|
||||
return this.ROOT_CACHE_KEY + ':recentitems';
|
||||
|
@ -39,8 +39,8 @@ export class AddonBlockRecentlyAccessedItemsProvider {
|
|||
/**
|
||||
* Get last accessed items.
|
||||
*
|
||||
* @param {string} [siteId] Site ID. If not defined, use current site.
|
||||
* @return {Promise<any[]>} Promise resolved when the info is retrieved.
|
||||
* @param siteId Site ID. If not defined, use current site.
|
||||
* @return Promise resolved when the info is retrieved.
|
||||
*/
|
||||
getRecentItems(siteId?: string): Promise<any[]> {
|
||||
|
||||
|
@ -63,8 +63,8 @@ export class AddonBlockRecentlyAccessedItemsProvider {
|
|||
/**
|
||||
* Invalidates get last accessed items WS call.
|
||||
*
|
||||
* @param {string} [siteId] Site ID to invalidate. If not defined, use current site.
|
||||
* @return {Promise<any>} Promise resolved when the data is invalidated.
|
||||
* @param siteId Site ID to invalidate. If not defined, use current site.
|
||||
* @return Promise resolved when the data is invalidated.
|
||||
*/
|
||||
invalidateRecentItems(siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
|
|
@ -33,11 +33,11 @@ export class AddonBlockRssClientHandler extends CoreBlockBaseHandler {
|
|||
/**
|
||||
* Returns the data needed to render the block.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @param {any} block The block to render.
|
||||
* @param {string} contextLevel The context where the block will be used.
|
||||
* @param {number} instanceId The instance ID associated with the context level.
|
||||
* @return {CoreBlockHandlerData|Promise<CoreBlockHandlerData>} Data or promise resolved with the data.
|
||||
* @param injector Injector.
|
||||
* @param block The block to render.
|
||||
* @param contextLevel The context where the block will be used.
|
||||
* @param instanceId The instance ID associated with the context level.
|
||||
* @return Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
|
||||
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
|
||||
|
|
|
@ -32,11 +32,11 @@ export class AddonBlockSelfCompletionHandler extends CoreBlockBaseHandler {
|
|||
/**
|
||||
* Returns the data needed to render the block.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @param {any} block The block to render.
|
||||
* @param {string} contextLevel The context where the block will be used.
|
||||
* @param {number} instanceId The instance ID associated with the context level.
|
||||
* @return {CoreBlockHandlerData|Promise<CoreBlockHandlerData>} Data or promise resolved with the data.
|
||||
* @param injector Injector.
|
||||
* @param block The block to render.
|
||||
* @param contextLevel The context where the block will be used.
|
||||
* @param instanceId The instance ID associated with the context level.
|
||||
* @return Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
|
||||
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
|
||||
|
|
|
@ -54,7 +54,7 @@ export class AddonBlockSiteMainMenuComponent extends CoreBlockBaseComponent impl
|
|||
/**
|
||||
* Perform the invalidate content function.
|
||||
*
|
||||
* @return {Promise<any>} Resolved when done.
|
||||
* @return Resolved when done.
|
||||
*/
|
||||
protected invalidateContent(): Promise<any> {
|
||||
const promises = [];
|
||||
|
@ -73,7 +73,7 @@ export class AddonBlockSiteMainMenuComponent extends CoreBlockBaseComponent impl
|
|||
/**
|
||||
* Fetch the data to render the block.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected fetchContent(): Promise<any> {
|
||||
return this.courseProvider.getSections(this.siteHomeId, false, true).then((sections) => {
|
||||
|
|
|
@ -32,11 +32,11 @@ export class AddonBlockSiteMainMenuHandler extends CoreBlockBaseHandler {
|
|||
/**
|
||||
* Returns the data needed to render the block.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @param {any} block The block to render.
|
||||
* @param {string} contextLevel The context where the block will be used.
|
||||
* @param {number} instanceId The instance ID associated with the context level.
|
||||
* @return {CoreBlockHandlerData|Promise<CoreBlockHandlerData>} Data or promise resolved with the data.
|
||||
* @param injector Injector.
|
||||
* @param block The block to render.
|
||||
* @param contextLevel The context where the block will be used.
|
||||
* @param instanceId The instance ID associated with the context level.
|
||||
* @return Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
|
||||
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
|
||||
|
|
|
@ -79,7 +79,7 @@ export class AddonBlockStarredCoursesComponent extends CoreBlockBaseComponent im
|
|||
/**
|
||||
* Perform the invalidate content function.
|
||||
*
|
||||
* @return {Promise<any>} Resolved when done.
|
||||
* @return Resolved when done.
|
||||
*/
|
||||
protected invalidateContent(): Promise<any> {
|
||||
const promises = [];
|
||||
|
@ -104,7 +104,7 @@ export class AddonBlockStarredCoursesComponent extends CoreBlockBaseComponent im
|
|||
/**
|
||||
* Fetch the courses.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected fetchContent(): Promise<any> {
|
||||
return this.coursesHelper.getUserCoursesWithOptions('timemodified', 0, 'isfavourite').then((courses) => {
|
||||
|
@ -133,7 +133,7 @@ export class AddonBlockStarredCoursesComponent extends CoreBlockBaseComponent im
|
|||
/**
|
||||
* Prefetch all the shown courses.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
prefetchCourses(): Promise<any> {
|
||||
const initialIcon = this.prefetchCoursesData.icon;
|
||||
|
|
|
@ -32,11 +32,11 @@ export class AddonBlockStarredCoursesHandler extends CoreBlockBaseHandler {
|
|||
/**
|
||||
* Returns the data needed to render the block.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @param {any} block The block to render.
|
||||
* @param {string} contextLevel The context where the block will be used.
|
||||
* @param {number} instanceId The instance ID associated with the context level.
|
||||
* @return {CoreBlockHandlerData|Promise<CoreBlockHandlerData>} Data or promise resolved with the data.
|
||||
* @param injector Injector.
|
||||
* @param block The block to render.
|
||||
* @param contextLevel The context where the block will be used.
|
||||
* @param instanceId The instance ID associated with the context level.
|
||||
* @return Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
|
||||
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
|
||||
|
|
|
@ -33,11 +33,11 @@ export class AddonBlockTagsHandler extends CoreBlockBaseHandler {
|
|||
/**
|
||||
* Returns the data needed to render the block.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @param {any} block The block to render.
|
||||
* @param {string} contextLevel The context where the block will be used.
|
||||
* @param {number} instanceId The instance ID associated with the context level.
|
||||
* @return {CoreBlockHandlerData|Promise<CoreBlockHandlerData>} Data or promise resolved with the data.
|
||||
* @param injector Injector.
|
||||
* @param block The block to render.
|
||||
* @param contextLevel The context where the block will be used.
|
||||
* @param instanceId The instance ID associated with the context level.
|
||||
* @return Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
|
||||
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
|
||||
|
|
|
@ -89,9 +89,9 @@ export class AddonBlockTimelineEventsComponent implements OnChanges {
|
|||
/**
|
||||
* Filter the events by time.
|
||||
*
|
||||
* @param {number} start Number of days to start getting events from today. E.g. -1 will get events from yesterday.
|
||||
* @param {number} [end] Number of days after the start.
|
||||
* @return {any[]} Filtered events.
|
||||
* @param start Number of days to start getting events from today. E.g. -1 will get events from yesterday.
|
||||
* @param end Number of days after the start.
|
||||
* @return Filtered events.
|
||||
*/
|
||||
protected filterEventsByTime(start: number, end?: number): any[] {
|
||||
start = moment().add(start, 'days').startOf('day').unix();
|
||||
|
@ -121,8 +121,8 @@ export class AddonBlockTimelineEventsComponent implements OnChanges {
|
|||
/**
|
||||
* Action clicked.
|
||||
*
|
||||
* @param {Event} e Click event.
|
||||
* @param {string} url Url of the action.
|
||||
* @param e Click event.
|
||||
* @param url Url of the action.
|
||||
*/
|
||||
action(e: Event, url: string): void {
|
||||
e.preventDefault();
|
||||
|
|
|
@ -75,7 +75,7 @@ export class AddonBlockTimelineComponent extends CoreBlockBaseComponent implemen
|
|||
/**
|
||||
* Perform the invalidate content function.
|
||||
*
|
||||
* @return {Promise<any>} Resolved when done.
|
||||
* @return Resolved when done.
|
||||
*/
|
||||
protected invalidateContent(): Promise<any> {
|
||||
const promises = [];
|
||||
|
@ -94,7 +94,7 @@ export class AddonBlockTimelineComponent extends CoreBlockBaseComponent implemen
|
|||
/**
|
||||
* Fetch the courses for my overview.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected fetchContent(): Promise<any> {
|
||||
if (this.sort == 'sortbydates') {
|
||||
|
@ -120,8 +120,8 @@ export class AddonBlockTimelineComponent extends CoreBlockBaseComponent implemen
|
|||
/**
|
||||
* Load more events.
|
||||
*
|
||||
* @param {any} course Course.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param course Course.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
loadMoreCourse(course: any): Promise<any> {
|
||||
return this.timelineProvider.getActionEventsByCourse(course.id, course.canLoadMore).then((courseEvents) => {
|
||||
|
@ -135,8 +135,8 @@ export class AddonBlockTimelineComponent extends CoreBlockBaseComponent implemen
|
|||
/**
|
||||
* Fetch the timeline.
|
||||
*
|
||||
* @param {number} [afterEventId] The last event id.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param afterEventId The last event id.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected fetchMyOverviewTimeline(afterEventId?: number): Promise<any> {
|
||||
return this.timelineProvider.getActionEventsByTimesort(afterEventId).then((events) => {
|
||||
|
@ -148,7 +148,7 @@ export class AddonBlockTimelineComponent extends CoreBlockBaseComponent implemen
|
|||
/**
|
||||
* Fetch the timeline by courses.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected fetchMyOverviewTimelineByCourses(): Promise<any> {
|
||||
return this.coursesHelper.getUserCoursesWithOptions().then((courses) => {
|
||||
|
@ -210,7 +210,7 @@ export class AddonBlockTimelineComponent extends CoreBlockBaseComponent implemen
|
|||
/**
|
||||
* Change timeline sort being viewed.
|
||||
*
|
||||
* @param {string} sort New sorting.
|
||||
* @param sort New sorting.
|
||||
*/
|
||||
switchSort(sort: string): void {
|
||||
this.sort = sort;
|
||||
|
|
|
@ -37,7 +37,7 @@ export class AddonBlockTimelineHandler extends CoreBlockBaseHandler {
|
|||
/**
|
||||
* Check if the handler is enabled on a site level.
|
||||
*
|
||||
* @return {boolean} Whether or not the handler is enabled on a site level.
|
||||
* @return Whether or not the handler is enabled on a site level.
|
||||
*/
|
||||
isEnabled(): boolean | Promise<boolean> {
|
||||
return this.timelineProvider.isAvailable().then((enabled) => {
|
||||
|
@ -49,11 +49,11 @@ export class AddonBlockTimelineHandler extends CoreBlockBaseHandler {
|
|||
/**
|
||||
* Returns the data needed to render the block.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @param {any} block The block to render.
|
||||
* @param {string} contextLevel The context where the block will be used.
|
||||
* @param {number} instanceId The instance ID associated with the context level.
|
||||
* @return {CoreBlockHandlerData|Promise<CoreBlockHandlerData>} Data or promise resolved with the data.
|
||||
* @param injector Injector.
|
||||
* @param block The block to render.
|
||||
* @param contextLevel The context where the block will be used.
|
||||
* @param instanceId The instance ID associated with the context level.
|
||||
* @return Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
|
||||
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
|
||||
|
|
|
@ -32,10 +32,10 @@ export class AddonBlockTimelineProvider {
|
|||
/**
|
||||
* Get calendar action events for the given course.
|
||||
*
|
||||
* @param {number} courseId Only events in this course.
|
||||
* @param {number} [afterEventId] The last seen event id.
|
||||
* @param {string} [siteId] Site ID. If not defined, use current site.
|
||||
* @return {Promise<{events: any[], canLoadMore: number}>} Promise resolved when the info is retrieved.
|
||||
* @param courseId Only events in this course.
|
||||
* @param afterEventId The last seen event id.
|
||||
* @param siteId Site ID. If not defined, use current site.
|
||||
* @return Promise resolved when the info is retrieved.
|
||||
*/
|
||||
getActionEventsByCourse(courseId: number, afterEventId?: number, siteId?: string):
|
||||
Promise<{ events: any[], canLoadMore: number }> {
|
||||
|
@ -68,8 +68,8 @@ export class AddonBlockTimelineProvider {
|
|||
/**
|
||||
* Get cache key for get calendar action events for the given course value WS call.
|
||||
*
|
||||
* @param {number} courseId Only events in this course.
|
||||
* @return {string} Cache key.
|
||||
* @param courseId Only events in this course.
|
||||
* @return Cache key.
|
||||
*/
|
||||
protected getActionEventsByCourseCacheKey(courseId: number): string {
|
||||
return this.getActionEventsByCoursesCacheKey() + ':' + courseId;
|
||||
|
@ -78,9 +78,9 @@ export class AddonBlockTimelineProvider {
|
|||
/**
|
||||
* Get calendar action events for a given list of courses.
|
||||
*
|
||||
* @param {number[]} courseIds Course IDs.
|
||||
* @param {string} [siteId] Site ID. If not defined, use current site.
|
||||
* @return {Promise<{[s: string]: {events: any[], canLoadMore: number}}>} Promise resolved when the info is retrieved.
|
||||
* @param courseIds Course IDs.
|
||||
* @param siteId Site ID. If not defined, use current site.
|
||||
* @return Promise resolved when the info is retrieved.
|
||||
*/
|
||||
getActionEventsByCourses(courseIds: number[], siteId?: string): Promise<{ [s: string]:
|
||||
{ events: any[], canLoadMore: number } }> {
|
||||
|
@ -114,7 +114,7 @@ export class AddonBlockTimelineProvider {
|
|||
/**
|
||||
* Get cache key for get calendar action events for a given list of courses value WS call.
|
||||
*
|
||||
* @return {string} Cache key.
|
||||
* @return Cache key.
|
||||
*/
|
||||
protected getActionEventsByCoursesCacheKey(): string {
|
||||
return this.ROOT_CACHE_KEY + 'bycourse';
|
||||
|
@ -123,9 +123,9 @@ export class AddonBlockTimelineProvider {
|
|||
/**
|
||||
* Get calendar action events based on the timesort value.
|
||||
*
|
||||
* @param {number} [afterEventId] The last seen event id.
|
||||
* @param {string} [siteId] Site ID. If not defined, use current site.
|
||||
* @return {Promise<{events: any[], canLoadMore: number}>} Promise resolved when the info is retrieved.
|
||||
* @param afterEventId The last seen event id.
|
||||
* @param siteId Site ID. If not defined, use current site.
|
||||
* @return Promise resolved when the info is retrieved.
|
||||
*/
|
||||
getActionEventsByTimesort(afterEventId: number, siteId?: string): Promise<{ events: any[], canLoadMore: number }> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -167,7 +167,7 @@ export class AddonBlockTimelineProvider {
|
|||
/**
|
||||
* Get prefix cache key for calendar action events based on the timesort value WS calls.
|
||||
*
|
||||
* @return {string} Cache key.
|
||||
* @return Cache key.
|
||||
*/
|
||||
protected getActionEventsByTimesortPrefixCacheKey(): string {
|
||||
return this.ROOT_CACHE_KEY + 'bytimesort:';
|
||||
|
@ -176,9 +176,9 @@ export class AddonBlockTimelineProvider {
|
|||
/**
|
||||
* Get cache key for get calendar action events based on the timesort value WS call.
|
||||
*
|
||||
* @param {number} [afterEventId] The last seen event id.
|
||||
* @param {number} [limit] Limit num of the call.
|
||||
* @return {string} Cache key.
|
||||
* @param afterEventId The last seen event id.
|
||||
* @param limit Limit num of the call.
|
||||
* @return Cache key.
|
||||
*/
|
||||
protected getActionEventsByTimesortCacheKey(afterEventId?: number, limit?: number): string {
|
||||
afterEventId = afterEventId || 0;
|
||||
|
@ -190,8 +190,8 @@ export class AddonBlockTimelineProvider {
|
|||
/**
|
||||
* Invalidates get calendar action events for a given list of courses WS call.
|
||||
*
|
||||
* @param {string} [siteId] Site ID to invalidate. If not defined, use current site.
|
||||
* @return {Promise<any>} Promise resolved when the data is invalidated.
|
||||
* @param siteId Site ID to invalidate. If not defined, use current site.
|
||||
* @return Promise resolved when the data is invalidated.
|
||||
*/
|
||||
invalidateActionEventsByCourses(siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -202,8 +202,8 @@ export class AddonBlockTimelineProvider {
|
|||
/**
|
||||
* Invalidates get calendar action events based on the timesort value WS call.
|
||||
*
|
||||
* @param {string} [siteId] Site ID to invalidate. If not defined, use current site.
|
||||
* @return {Promise<any>} Promise resolved when the data is invalidated.
|
||||
* @param siteId Site ID to invalidate. If not defined, use current site.
|
||||
* @return Promise resolved when the data is invalidated.
|
||||
*/
|
||||
invalidateActionEventsByTimesort(siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -214,8 +214,8 @@ export class AddonBlockTimelineProvider {
|
|||
/**
|
||||
* Returns whether or not My Overview is available for a certain site.
|
||||
*
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<boolean>} Promise resolved with true if available, resolved with false or rejected otherwise.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with true if available, resolved with false or rejected otherwise.
|
||||
*/
|
||||
isAvailable(siteId?: string): Promise<boolean> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -232,9 +232,9 @@ export class AddonBlockTimelineProvider {
|
|||
/**
|
||||
* Handles course events, filtering and treating if more can be loaded.
|
||||
*
|
||||
* @param {any} course Object containing response course events info.
|
||||
* @param {number} timeFrom Current time to filter events from.
|
||||
* @return {{events: any[], canLoadMore: number}} Object with course events and last loaded event id if more can be loaded.
|
||||
* @param course Object containing response course events info.
|
||||
* @param timeFrom Current time to filter events from.
|
||||
* @return Object with course events and last loaded event id if more can be loaded.
|
||||
*/
|
||||
protected treatCourseEvents(course: any, timeFrom: number): { events: any[], canLoadMore: number } {
|
||||
const canLoadMore: number =
|
||||
|
|
|
@ -104,8 +104,8 @@ export class AddonBlogEntriesComponent implements OnInit {
|
|||
/**
|
||||
* Fetch blog entries.
|
||||
*
|
||||
* @param {boolean} [refresh] Empty events array first.
|
||||
* @return {Promise<any>} Promise with the entries.
|
||||
* @param refresh Empty events array first.
|
||||
* @return Promise with the entries.
|
||||
*/
|
||||
private fetchEntries(refresh: boolean = false): Promise<any> {
|
||||
this.loadMoreError = false;
|
||||
|
@ -174,7 +174,7 @@ export class AddonBlogEntriesComponent implements OnInit {
|
|||
/**
|
||||
* Toggle between showing only my entries or not.
|
||||
*
|
||||
* @param {boolean} enabled If true, filter my entries. False otherwise.
|
||||
* @param enabled If true, filter my entries. False otherwise.
|
||||
*/
|
||||
onlyMyEntriesToggleChanged(enabled: boolean): void {
|
||||
if (enabled) {
|
||||
|
@ -198,8 +198,8 @@ export class AddonBlogEntriesComponent implements OnInit {
|
|||
/**
|
||||
* Function to load more entries.
|
||||
*
|
||||
* @param {any} [infiniteComplete] Infinite scroll complete function. Only used from core-infinite-loading.
|
||||
* @return {Promise<any>} Resolved when done.
|
||||
* @param infiniteComplete Infinite scroll complete function. Only used from core-infinite-loading.
|
||||
* @return Resolved when done.
|
||||
*/
|
||||
loadMore(infiniteComplete?: any): Promise<any> {
|
||||
return this.fetchEntries().finally(() => {
|
||||
|
@ -210,7 +210,7 @@ export class AddonBlogEntriesComponent implements OnInit {
|
|||
/**
|
||||
* Refresh blog entries on PTR.
|
||||
*
|
||||
* @param {any} refresher Refresher instance.
|
||||
* @param refresher Refresher instance.
|
||||
*/
|
||||
refresh(refresher?: any): void {
|
||||
const promises = this.entries.map((entry) => {
|
||||
|
|
|
@ -40,8 +40,8 @@ export class AddonBlogProvider {
|
|||
* This method is called quite often and thus should only perform a quick
|
||||
* check, we should not be calling WS from here.
|
||||
*
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<boolean>} Promise resolved with true if enabled, resolved with false or rejected otherwise.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with true if enabled, resolved with false or rejected otherwise.
|
||||
*/
|
||||
isPluginEnabled(siteId?: string): Promise<boolean> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -53,8 +53,8 @@ export class AddonBlogProvider {
|
|||
/**
|
||||
* Get the cache key for the blog entries.
|
||||
*
|
||||
* @param {any} [filter] Filter to apply on search.
|
||||
* @return {string} Cache key.
|
||||
* @param filter Filter to apply on search.
|
||||
* @return Cache key.
|
||||
*/
|
||||
getEntriesCacheKey(filter: any = {}): string {
|
||||
return this.ROOT_CACHE_KEY + this.utils.sortAndStringify(filter);
|
||||
|
@ -63,10 +63,10 @@ export class AddonBlogProvider {
|
|||
/**
|
||||
* Get blog entries.
|
||||
*
|
||||
* @param {any} [filter] Filter to apply on search.
|
||||
* @param {any} [page=0] Page of the blog entries to fetch.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise to be resolved when the entries are retrieved.
|
||||
* @param filter Filter to apply on search.
|
||||
* @param page Page of the blog entries to fetch.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise to be resolved when the entries are retrieved.
|
||||
*/
|
||||
getEntries(filter: any = {}, page: number = 0, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -88,9 +88,9 @@ export class AddonBlogProvider {
|
|||
/**
|
||||
* Invalidate blog entries WS call.
|
||||
*
|
||||
* @param {any} [filter] Filter to apply on search
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved when data is invalidated.
|
||||
* @param filter Filter to apply on search
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved when data is invalidated.
|
||||
*/
|
||||
invalidateEntries(filter: any = {}, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -101,9 +101,9 @@ export class AddonBlogProvider {
|
|||
/**
|
||||
* Trigger the blog_entries_viewed event.
|
||||
*
|
||||
* @param {any} [filter] Filter to apply on search.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise to be resolved when done.
|
||||
* @param filter Filter to apply on search.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise to be resolved when done.
|
||||
*/
|
||||
logView(filter: any = {}, siteId?: string): Promise<any> {
|
||||
this.pushNotificationsProvider.logViewListEvent('blog', 'core_blog_view_entries', filter, siteId);
|
||||
|
|
|
@ -37,10 +37,10 @@ export class AddonBlogCourseOptionHandler implements CoreCourseOptionsHandler {
|
|||
/**
|
||||
* Should invalidate the data to determine if the handler is enabled for a certain course.
|
||||
*
|
||||
* @param {number} courseId The course ID.
|
||||
* @param {any} [navOptions] Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
|
||||
* @param {any} [admOptions] Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param courseId The course ID.
|
||||
* @param navOptions Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
|
||||
* @param admOptions Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
invalidateEnabledForCourse(courseId: number, navOptions?: any, admOptions?: any): Promise<any> {
|
||||
return this.courseProvider.invalidateCourseBlocks(courseId);
|
||||
|
@ -49,7 +49,7 @@ export class AddonBlogCourseOptionHandler implements CoreCourseOptionsHandler {
|
|||
/**
|
||||
* Check if the handler is enabled on a site level.
|
||||
*
|
||||
* @return {boolean} Whether or not the handler is enabled on a site level.
|
||||
* @return Whether or not the handler is enabled on a site level.
|
||||
*/
|
||||
isEnabled(): boolean | Promise<boolean> {
|
||||
return this.blogProvider.isPluginEnabled();
|
||||
|
@ -58,11 +58,11 @@ export class AddonBlogCourseOptionHandler implements CoreCourseOptionsHandler {
|
|||
/**
|
||||
* Whether or not the handler is enabled for a certain course.
|
||||
*
|
||||
* @param {number} courseId The course ID.
|
||||
* @param {any} accessData Access type and data. Default, guest, ...
|
||||
* @param {any} [navOptions] Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
|
||||
* @param {any} [admOptions] Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
|
||||
* @return {boolean|Promise<boolean>} True or promise resolved with true if enabled.
|
||||
* @param courseId The course ID.
|
||||
* @param accessData Access type and data. Default, guest, ...
|
||||
* @param navOptions Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
|
||||
* @param admOptions Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
|
||||
* @return True or promise resolved with true if enabled.
|
||||
*/
|
||||
isEnabledForCourse(courseId: number, accessData: any, navOptions?: any, admOptions?: any): boolean | Promise<boolean> {
|
||||
return this.courseHelper.hasABlockNamed(courseId, 'blog_menu').then((enabled) => {
|
||||
|
@ -77,9 +77,9 @@ export class AddonBlogCourseOptionHandler implements CoreCourseOptionsHandler {
|
|||
/**
|
||||
* Returns the data needed to render the handler.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @param {number} course The course.
|
||||
* @return {CoreCourseOptionsHandlerData|Promise<CoreCourseOptionsHandlerData>} Data or promise resolved with the data.
|
||||
* @param injector Injector.
|
||||
* @param course The course.
|
||||
* @return Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, course: any): CoreCourseOptionsHandlerData | Promise<CoreCourseOptionsHandlerData> {
|
||||
return {
|
||||
|
@ -92,8 +92,8 @@ export class AddonBlogCourseOptionHandler implements CoreCourseOptionsHandler {
|
|||
/**
|
||||
* Called when a course is downloaded. It should prefetch all the data to be able to see the addon in offline.
|
||||
*
|
||||
* @param {any} course The course.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param course The course.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
prefetch(course: any): Promise<any> {
|
||||
const siteId = this.sitesProvider.getCurrentSiteId();
|
||||
|
|
|
@ -34,11 +34,11 @@ export class AddonBlogIndexLinkHandler extends CoreContentLinksHandlerBase {
|
|||
/**
|
||||
* Get the list of actions for a link (url).
|
||||
*
|
||||
* @param {string[]} siteIds List of sites the URL belongs to.
|
||||
* @param {string} url The URL to treat.
|
||||
* @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param {number} [courseId] Course ID related to the URL. Optional but recommended.
|
||||
* @return {CoreContentLinksAction[]|Promise<CoreContentLinksAction[]>} List of (or promise resolved with list of) actions.
|
||||
* @param siteIds List of sites the URL belongs to.
|
||||
* @param url The URL to treat.
|
||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||
* @return List of (or promise resolved with list of) actions.
|
||||
*/
|
||||
getActions(siteIds: string[], url: string, params: any, courseId?: number):
|
||||
CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> {
|
||||
|
@ -62,11 +62,11 @@ export class AddonBlogIndexLinkHandler extends CoreContentLinksHandlerBase {
|
|||
* Check if the handler is enabled for a certain site (site + user) and a URL.
|
||||
* If not defined, defaults to true.
|
||||
*
|
||||
* @param {string} siteId The site ID.
|
||||
* @param {string} url The URL to treat.
|
||||
* @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param {number} [courseId] Course ID related to the URL. Optional but recommended.
|
||||
* @return {boolean|Promise<boolean>} Whether the handler is enabled for the URL and site.
|
||||
* @param siteId The site ID.
|
||||
* @param url The URL to treat.
|
||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||
* @return Whether the handler is enabled for the URL and site.
|
||||
*/
|
||||
isEnabled(siteId: string, url: string, params: any, courseId?: number): boolean | Promise<boolean> {
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ export class AddonBlogMainMenuHandler implements CoreMainMenuHandler {
|
|||
/**
|
||||
* Check if the handler is enabled on a site level.
|
||||
*
|
||||
* @return {boolean} Whether or not the handler is enabled on a site level.
|
||||
* @return Whether or not the handler is enabled on a site level.
|
||||
*/
|
||||
isEnabled(): boolean | Promise<boolean> {
|
||||
return this.blogProvider.isPluginEnabled();
|
||||
|
@ -38,7 +38,7 @@ export class AddonBlogMainMenuHandler implements CoreMainMenuHandler {
|
|||
/**
|
||||
* Returns the data needed to render the handler.
|
||||
*
|
||||
* @return {CoreMainMenuHandlerData} Data needed to render the handler.
|
||||
* @return Data needed to render the handler.
|
||||
*/
|
||||
getDisplayData(): CoreMainMenuHandlerData {
|
||||
return {
|
||||
|
|
|
@ -30,7 +30,7 @@ export class AddonBlogTagAreaHandler implements CoreTagAreaHandler {
|
|||
|
||||
/**
|
||||
* Whether or not the handler is enabled on a site level.
|
||||
* @return {boolean|Promise<boolean>} Whether or not the handler is enabled on a site level.
|
||||
* @return Whether or not the handler is enabled on a site level.
|
||||
*/
|
||||
isEnabled(): boolean | Promise<boolean> {
|
||||
return this.blogProvider.isPluginEnabled();
|
||||
|
@ -39,8 +39,8 @@ export class AddonBlogTagAreaHandler implements CoreTagAreaHandler {
|
|||
/**
|
||||
* Parses the rendered content of a tag index and returns the items.
|
||||
*
|
||||
* @param {string} content Rendered content.
|
||||
* @return {any[]|Promise<any[]>} Area items (or promise resolved with the items).
|
||||
* @param content Rendered content.
|
||||
* @return Area items (or promise resolved with the items).
|
||||
*/
|
||||
parseContent(content: string): any[] | Promise<any[]> {
|
||||
return this.tagHelper.parseFeedContent(content);
|
||||
|
@ -49,8 +49,8 @@ export class AddonBlogTagAreaHandler implements CoreTagAreaHandler {
|
|||
/**
|
||||
* Get the component to use to display items.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @return {any|Promise<any>} The component (or promise resolved with component) to use, undefined if not found.
|
||||
* @param injector Injector.
|
||||
* @return The component (or promise resolved with component) to use, undefined if not found.
|
||||
*/
|
||||
getComponent(injector: Injector): any | Promise<any> {
|
||||
return CoreTagFeedComponent;
|
||||
|
|
|
@ -31,7 +31,7 @@ export class AddonBlogUserHandler implements CoreUserProfileHandler {
|
|||
|
||||
/**
|
||||
* Whether or not the handler is enabled on a site level.
|
||||
* @return {boolean|Promise<boolean>} Whether or not the handler is enabled on a site level.
|
||||
* @return Whether or not the handler is enabled on a site level.
|
||||
*/
|
||||
isEnabled(): boolean | Promise<boolean> {
|
||||
return this.blogProvider.isPluginEnabled();
|
||||
|
@ -40,11 +40,11 @@ export class AddonBlogUserHandler implements CoreUserProfileHandler {
|
|||
/**
|
||||
* Check if handler is enabled for this user in this context.
|
||||
*
|
||||
* @param {any} user User to check.
|
||||
* @param {number} courseId Course ID.
|
||||
* @param {any} [navOptions] Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
|
||||
* @param {any} [admOptions] Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
|
||||
* @return {boolean|Promise<boolean>} Promise resolved with true if enabled, resolved with false otherwise.
|
||||
* @param user User to check.
|
||||
* @param courseId Course ID.
|
||||
* @param navOptions Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
|
||||
* @param admOptions Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
|
||||
* @return Promise resolved with true if enabled, resolved with false otherwise.
|
||||
*/
|
||||
isEnabledForUser(user: any, courseId: number, navOptions?: any, admOptions?: any): boolean | Promise<boolean> {
|
||||
return true;
|
||||
|
@ -53,7 +53,7 @@ export class AddonBlogUserHandler implements CoreUserProfileHandler {
|
|||
/**
|
||||
* Returns the data needed to render the handler.
|
||||
*
|
||||
* @return {CoreUserProfileHandlerData} Data needed to render the handler.
|
||||
* @return Data needed to render the handler.
|
||||
*/
|
||||
getDisplayData(user: any, courseId: number): CoreUserProfileHandlerData {
|
||||
return {
|
||||
|
|
|
@ -134,8 +134,8 @@ export class AddonCalendarCalendarComponent implements OnInit, OnChanges, OnDest
|
|||
/**
|
||||
* Fetch contacts.
|
||||
*
|
||||
* @param {boolean} [refresh=false] True if we are refreshing events.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param refresh True if we are refreshing events.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
fetchData(refresh: boolean = false): Promise<any> {
|
||||
const promises = [];
|
||||
|
@ -184,7 +184,7 @@ export class AddonCalendarCalendarComponent implements OnInit, OnChanges, OnDest
|
|||
/**
|
||||
* Fetch the events for current month.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
fetchEvents(): Promise<any> {
|
||||
// Don't pass courseId and categoryId, we'll filter them locally.
|
||||
|
@ -238,7 +238,7 @@ export class AddonCalendarCalendarComponent implements OnInit, OnChanges, OnDest
|
|||
/**
|
||||
* Load categories to be able to filter events.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected loadCategories(): Promise<any> {
|
||||
if (this.categoriesRetrieved) {
|
||||
|
@ -285,8 +285,8 @@ export class AddonCalendarCalendarComponent implements OnInit, OnChanges, OnDest
|
|||
/**
|
||||
* Refresh events.
|
||||
*
|
||||
* @param {boolean} [afterChange] Whether the refresh is done after an event has changed or has been synced.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param afterChange Whether the refresh is done after an event has changed or has been synced.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
refreshData(afterChange?: boolean): Promise<any> {
|
||||
const promises = [];
|
||||
|
@ -340,8 +340,8 @@ export class AddonCalendarCalendarComponent implements OnInit, OnChanges, OnDest
|
|||
/**
|
||||
* An event was clicked.
|
||||
*
|
||||
* @param {any} calendarEvent Calendar event..
|
||||
* @param {MouseEvent} event Mouse event.
|
||||
* @param calendarEvent Calendar event..
|
||||
* @param event Mouse event.
|
||||
*/
|
||||
eventClicked(calendarEvent: any, event: MouseEvent): void {
|
||||
this.onEventClicked.emit(calendarEvent.id);
|
||||
|
@ -351,7 +351,7 @@ export class AddonCalendarCalendarComponent implements OnInit, OnChanges, OnDest
|
|||
/**
|
||||
* A day was clicked.
|
||||
*
|
||||
* @param {number} day Day.
|
||||
* @param day Day.
|
||||
*/
|
||||
dayClicked(day: number): void {
|
||||
this.onDayClicked.emit({day: day, month: this.month, year: this.year});
|
||||
|
@ -461,7 +461,7 @@ export class AddonCalendarCalendarComponent implements OnInit, OnChanges, OnDest
|
|||
/**
|
||||
* Sort events by timestart.
|
||||
*
|
||||
* @param {any[]} events List to sort.
|
||||
* @param events List to sort.
|
||||
*/
|
||||
protected sortEvents(events: any[]): any[] {
|
||||
return events.sort((a, b) => {
|
||||
|
@ -476,7 +476,7 @@ export class AddonCalendarCalendarComponent implements OnInit, OnChanges, OnDest
|
|||
/**
|
||||
* Undelete a certain event.
|
||||
*
|
||||
* @param {number} eventId Event ID.
|
||||
* @param eventId Event ID.
|
||||
*/
|
||||
protected undeleteEvent(eventId: number): void {
|
||||
if (!this.weeks) {
|
||||
|
@ -498,8 +498,8 @@ export class AddonCalendarCalendarComponent implements OnInit, OnChanges, OnDest
|
|||
|
||||
/**
|
||||
* Returns if the event is in the past or not.
|
||||
* @param {any} event Event object.
|
||||
* @return {boolean} True if it's in the past.
|
||||
* @param event Event object.
|
||||
* @return True if it's in the past.
|
||||
*/
|
||||
isEventPast(event: any): boolean {
|
||||
return (event.timestart + event.timeduration) < this.currentTime;
|
||||
|
|
|
@ -106,8 +106,8 @@ export class AddonCalendarUpcomingEventsComponent implements OnInit, OnChanges,
|
|||
/**
|
||||
* Fetch data.
|
||||
*
|
||||
* @param {boolean} [refresh=false] True if we are refreshing events.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param refresh True if we are refreshing events.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
fetchData(refresh: boolean = false): Promise<any> {
|
||||
const promises = [];
|
||||
|
@ -151,7 +151,7 @@ export class AddonCalendarUpcomingEventsComponent implements OnInit, OnChanges,
|
|||
/**
|
||||
* Fetch upcoming events.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
fetchEvents(): Promise<any> {
|
||||
// Don't pass courseId and categoryId, we'll filter them locally.
|
||||
|
@ -185,7 +185,7 @@ export class AddonCalendarUpcomingEventsComponent implements OnInit, OnChanges,
|
|||
/**
|
||||
* Load categories to be able to filter events.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected loadCategories(): Promise<any> {
|
||||
if (this.categoriesRetrieved) {
|
||||
|
@ -225,8 +225,8 @@ export class AddonCalendarUpcomingEventsComponent implements OnInit, OnChanges,
|
|||
/**
|
||||
* Refresh events.
|
||||
*
|
||||
* @param {boolean} [afterChange] Whether the refresh is done after an event has changed or has been synced.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param afterChange Whether the refresh is done after an event has changed or has been synced.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
refreshData(afterChange?: boolean): Promise<any> {
|
||||
const promises = [];
|
||||
|
@ -249,7 +249,7 @@ export class AddonCalendarUpcomingEventsComponent implements OnInit, OnChanges,
|
|||
/**
|
||||
* An event was clicked.
|
||||
*
|
||||
* @param {any} event Event.
|
||||
* @param event Event.
|
||||
*/
|
||||
eventClicked(event: any): void {
|
||||
this.onEventClicked.emit(event.id);
|
||||
|
@ -258,7 +258,7 @@ export class AddonCalendarUpcomingEventsComponent implements OnInit, OnChanges,
|
|||
/**
|
||||
* Merge online events with the offline events of that period.
|
||||
*
|
||||
* @return {any[]} Merged events.
|
||||
* @return Merged events.
|
||||
*/
|
||||
protected mergeEvents(): any[] {
|
||||
if (!this.offlineEvents.length && !this.deletedEvents.length) {
|
||||
|
@ -302,7 +302,7 @@ export class AddonCalendarUpcomingEventsComponent implements OnInit, OnChanges,
|
|||
/**
|
||||
* Sort events by timestart.
|
||||
*
|
||||
* @param {any[]} events List to sort.
|
||||
* @param events List to sort.
|
||||
*/
|
||||
protected sortEvents(events: any[]): any[] {
|
||||
return events.sort((a, b) => {
|
||||
|
@ -317,7 +317,7 @@ export class AddonCalendarUpcomingEventsComponent implements OnInit, OnChanges,
|
|||
/**
|
||||
* Undelete a certain event.
|
||||
*
|
||||
* @param {number} eventId Event ID.
|
||||
* @param eventId Event ID.
|
||||
*/
|
||||
protected undeleteEvent(eventId: number): void {
|
||||
const event = this.onlineEvents.find((event) => {
|
||||
|
|
|
@ -208,9 +208,9 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
|
|||
/**
|
||||
* Fetch all the data required for the view.
|
||||
*
|
||||
* @param {boolean} [sync] Whether it should try to synchronize offline events.
|
||||
* @param {boolean} [showErrors] Whether to show sync errors to the user.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param sync Whether it should try to synchronize offline events.
|
||||
* @param showErrors Whether to show sync errors to the user.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
fetchData(sync?: boolean, showErrors?: boolean): Promise<any> {
|
||||
|
||||
|
@ -280,7 +280,7 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
|
|||
/**
|
||||
* Fetch the events for current day.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
fetchEvents(): Promise<any> {
|
||||
// Don't pass courseId and categoryId, we'll filter them locally.
|
||||
|
@ -328,7 +328,7 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
|
|||
/**
|
||||
* Merge online events with the offline events of that period.
|
||||
*
|
||||
* @return {any[]} Merged events.
|
||||
* @return Merged events.
|
||||
*/
|
||||
protected mergeEvents(): any[] {
|
||||
this.hasOffline = false;
|
||||
|
@ -389,7 +389,7 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
|
|||
/**
|
||||
* Sort events by timestart.
|
||||
*
|
||||
* @param {any[]} events List to sort.
|
||||
* @param events List to sort.
|
||||
*/
|
||||
protected sortEvents(events: any[]): any[] {
|
||||
return events.sort((a, b) => {
|
||||
|
@ -404,10 +404,10 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
|
|||
/**
|
||||
* Refresh the data.
|
||||
*
|
||||
* @param {any} [refresher] Refresher.
|
||||
* @param {Function} [done] Function to call when done.
|
||||
* @param {boolean} [showErrors] Whether to show sync errors to the user.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param refresher Refresher.
|
||||
* @param done Function to call when done.
|
||||
* @param showErrors Whether to show sync errors to the user.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
doRefresh(refresher?: any, done?: () => void, showErrors?: boolean): Promise<any> {
|
||||
if (this.loaded) {
|
||||
|
@ -423,10 +423,10 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
|
|||
/**
|
||||
* Refresh the data.
|
||||
*
|
||||
* @param {boolean} [sync] Whether it should try to synchronize offline events.
|
||||
* @param {boolean} [showErrors] Whether to show sync errors to the user.
|
||||
* @param {boolean} [afterChange] Whether the refresh is done after an event has changed or has been synced.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param sync Whether it should try to synchronize offline events.
|
||||
* @param showErrors Whether to show sync errors to the user.
|
||||
* @param afterChange Whether the refresh is done after an event has changed or has been synced.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
refreshData(sync?: boolean, showErrors?: boolean, afterChange?: boolean): Promise<any> {
|
||||
this.syncIcon = 'spinner';
|
||||
|
@ -449,7 +449,7 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
|
|||
/**
|
||||
* Load categories to be able to filter events.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected loadCategories(): Promise<any> {
|
||||
return this.coursesProvider.getCategories(0, true).then((cats) => {
|
||||
|
@ -467,8 +467,8 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
|
|||
/**
|
||||
* Try to synchronize offline events.
|
||||
*
|
||||
* @param {boolean} [showErrors] Whether to show sync errors to the user.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param showErrors Whether to show sync errors to the user.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected sync(showErrors?: boolean): Promise<any> {
|
||||
return this.calendarSync.syncEvents().then((result) => {
|
||||
|
@ -495,7 +495,7 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
|
|||
/**
|
||||
* Navigate to a particular event.
|
||||
*
|
||||
* @param {number} eventId Event to load.
|
||||
* @param eventId Event to load.
|
||||
*/
|
||||
gotoEvent(eventId: number): void {
|
||||
if (eventId < 0) {
|
||||
|
@ -511,7 +511,7 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
|
|||
/**
|
||||
* Show the context menu.
|
||||
*
|
||||
* @param {MouseEvent} event Event.
|
||||
* @param event Event.
|
||||
*/
|
||||
openCourseFilter(event: MouseEvent): void {
|
||||
this.coursesHelper.selectCourse(event, this.courses, this.courseId).then((result) => {
|
||||
|
@ -532,7 +532,7 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
|
|||
/**
|
||||
* Open page to create/edit an event.
|
||||
*
|
||||
* @param {number} [eventId] Event ID to edit.
|
||||
* @param eventId Event ID to edit.
|
||||
*/
|
||||
openEdit(eventId?: number): void {
|
||||
const params: any = {};
|
||||
|
@ -658,9 +658,9 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
|
|||
/**
|
||||
* Find an event and mark it as deleted.
|
||||
*
|
||||
* @param {number} eventId Event ID.
|
||||
* @param {boolean} deleted Whether to mark it as deleted or not.
|
||||
* @return {boolean} Whether the event was found.
|
||||
* @param eventId Event ID.
|
||||
* @param deleted Whether to mark it as deleted or not.
|
||||
* @return Whether the event was found.
|
||||
*/
|
||||
protected markAsDeleted(eventId: number, deleted: boolean): boolean {
|
||||
const event = this.onlineEvents.find((event) => {
|
||||
|
@ -678,8 +678,8 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
|
|||
|
||||
/**
|
||||
* Returns if the event is in the past or not.
|
||||
* @param {any} event Event object.
|
||||
* @return {boolean} True if it's in the past.
|
||||
* @param event Event object.
|
||||
* @return True if it's in the past.
|
||||
*/
|
||||
isEventPast(event: any): boolean {
|
||||
return (event.timestart + event.timeduration) < this.currentTime;
|
||||
|
|
|
@ -148,8 +148,8 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy {
|
|||
/**
|
||||
* Fetch the data needed to render the form.
|
||||
*
|
||||
* @param {boolean} [refresh] Whether it's refreshing data.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param refresh Whether it's refreshing data.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected fetchData(refresh?: boolean): Promise<any> {
|
||||
let accessInfo;
|
||||
|
@ -289,9 +289,9 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy {
|
|||
/**
|
||||
* Load an event data into the form.
|
||||
*
|
||||
* @param {any} event Event data.
|
||||
* @param {boolean} isOffline Whether the data is from offline or not.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param event Event data.
|
||||
* @param isOffline Whether the data is from offline or not.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected loadEventData(event: any, isOffline: boolean): Promise<any> {
|
||||
const courseId = event.course ? event.course.id : event.courseid;
|
||||
|
@ -344,7 +344,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy {
|
|||
/**
|
||||
* Pull to refresh.
|
||||
*
|
||||
* @param {any} refresher Refresher.
|
||||
* @param refresher Refresher.
|
||||
*/
|
||||
refreshData(refresher: any): void {
|
||||
const promises = [
|
||||
|
@ -375,7 +375,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy {
|
|||
/**
|
||||
* A course was selected, get its groups.
|
||||
*
|
||||
* @param {number} courseId Course ID.
|
||||
* @param courseId Course ID.
|
||||
*/
|
||||
groupCourseSelected(courseId: number): void {
|
||||
if (!courseId) {
|
||||
|
@ -396,8 +396,8 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy {
|
|||
/**
|
||||
* Load groups of a certain course.
|
||||
*
|
||||
* @param {number} courseId Course ID.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param courseId Course ID.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected loadGroups(courseId: number): Promise<any> {
|
||||
this.loadingGroups = true;
|
||||
|
@ -515,7 +515,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy {
|
|||
/**
|
||||
* Convenience function to update or return to event list depending on device.
|
||||
*
|
||||
* @param {number} [event] Event.
|
||||
* @param event Event.
|
||||
*/
|
||||
protected returnToList(event?: any): void {
|
||||
// Unblock the sync because the view will be destroyed and the sync process could be triggered before ngOnDestroy.
|
||||
|
@ -568,7 +568,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy {
|
|||
/**
|
||||
* Check if we can leave the page or not.
|
||||
*
|
||||
* @return {boolean|Promise<void>} Resolved if we can leave it, rejected if not.
|
||||
* @return Resolved if we can leave it, rejected if not.
|
||||
*/
|
||||
ionViewCanLeave(): boolean | Promise<void> {
|
||||
|
||||
|
|
|
@ -144,9 +144,9 @@ export class AddonCalendarEventPage implements OnDestroy {
|
|||
/**
|
||||
* Fetches the event and updates the view.
|
||||
*
|
||||
* @param {boolean} [sync] Whether it should try to synchronize offline events.
|
||||
* @param {boolean} [showErrors] Whether to show sync errors to the user.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param sync Whether it should try to synchronize offline events.
|
||||
* @param showErrors Whether to show sync errors to the user.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
fetchEvent(sync?: boolean, showErrors?: boolean): Promise<any> {
|
||||
const currentSite = this.sitesProvider.getCurrentSite(),
|
||||
|
@ -312,7 +312,7 @@ export class AddonCalendarEventPage implements OnDestroy {
|
|||
/**
|
||||
* Add a reminder for this event.
|
||||
*
|
||||
* @param {Event} e Click event.
|
||||
* @param e Click event.
|
||||
*/
|
||||
addNotificationTime(e: Event): void {
|
||||
e.preventDefault();
|
||||
|
@ -342,8 +342,8 @@ export class AddonCalendarEventPage implements OnDestroy {
|
|||
/**
|
||||
* Cancel the selected notification.
|
||||
*
|
||||
* @param {number} id Reminder ID.
|
||||
* @param {Event} e Click event.
|
||||
* @param id Reminder ID.
|
||||
* @param e Click event.
|
||||
*/
|
||||
cancelNotification(id: number, e: Event): void {
|
||||
e.preventDefault();
|
||||
|
@ -359,10 +359,10 @@ export class AddonCalendarEventPage implements OnDestroy {
|
|||
/**
|
||||
* Refresh the data.
|
||||
*
|
||||
* @param {any} [refresher] Refresher.
|
||||
* @param {Function} [done] Function to call when done.
|
||||
* @param {boolean} [showErrors] Whether to show sync errors to the user.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param refresher Refresher.
|
||||
* @param done Function to call when done.
|
||||
* @param showErrors Whether to show sync errors to the user.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
doRefresh(refresher?: any, done?: () => void, showErrors?: boolean): Promise<any> {
|
||||
if (this.eventLoaded) {
|
||||
|
@ -378,9 +378,9 @@ export class AddonCalendarEventPage implements OnDestroy {
|
|||
/**
|
||||
* Refresh the event.
|
||||
*
|
||||
* @param {boolean} [sync] Whether it should try to synchronize offline events.
|
||||
* @param {boolean} [showErrors] Whether to show sync errors to the user.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param sync Whether it should try to synchronize offline events.
|
||||
* @param showErrors Whether to show sync errors to the user.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
refreshEvent(sync?: boolean, showErrors?: boolean): Promise<any> {
|
||||
this.syncIcon = 'spinner';
|
||||
|
@ -511,8 +511,8 @@ export class AddonCalendarEventPage implements OnDestroy {
|
|||
/**
|
||||
* Check the result of an automatic sync or a manual sync not done by this page.
|
||||
*
|
||||
* @param {boolean} isManual Whether it's a manual sync.
|
||||
* @param {any} data Sync result.
|
||||
* @param isManual Whether it's a manual sync.
|
||||
* @param data Sync result.
|
||||
*/
|
||||
protected checkSyncResult(isManual: boolean, data: any): void {
|
||||
if (!data) {
|
||||
|
|
|
@ -164,9 +164,9 @@ export class AddonCalendarIndexPage implements OnInit, OnDestroy {
|
|||
/**
|
||||
* Fetch all the data required for the view.
|
||||
*
|
||||
* @param {boolean} [sync] Whether it should try to synchronize offline events.
|
||||
* @param {boolean} [showErrors] Whether to show sync errors to the user.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param sync Whether it should try to synchronize offline events.
|
||||
* @param showErrors Whether to show sync errors to the user.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
fetchData(sync?: boolean, showErrors?: boolean): Promise<any> {
|
||||
|
||||
|
@ -230,10 +230,10 @@ export class AddonCalendarIndexPage implements OnInit, OnDestroy {
|
|||
/**
|
||||
* Refresh the data.
|
||||
*
|
||||
* @param {any} [refresher] Refresher.
|
||||
* @param {Function} [done] Function to call when done.
|
||||
* @param {boolean} [showErrors] Whether to show sync errors to the user.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param refresher Refresher.
|
||||
* @param done Function to call when done.
|
||||
* @param showErrors Whether to show sync errors to the user.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
doRefresh(refresher?: any, done?: () => void, showErrors?: boolean): Promise<any> {
|
||||
if (this.loaded) {
|
||||
|
@ -249,10 +249,10 @@ export class AddonCalendarIndexPage implements OnInit, OnDestroy {
|
|||
/**
|
||||
* Refresh the data.
|
||||
*
|
||||
* @param {boolean} [sync] Whether it should try to synchronize offline events.
|
||||
* @param {boolean} [showErrors] Whether to show sync errors to the user.
|
||||
* @param {boolean} [afterChange] Whether the refresh is done after an event has changed or has been synced.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param sync Whether it should try to synchronize offline events.
|
||||
* @param showErrors Whether to show sync errors to the user.
|
||||
* @param afterChange Whether the refresh is done after an event has changed or has been synced.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
refreshData(sync?: boolean, showErrors?: boolean, afterChange?: boolean): Promise<any> {
|
||||
this.syncIcon = 'spinner';
|
||||
|
@ -276,7 +276,7 @@ export class AddonCalendarIndexPage implements OnInit, OnDestroy {
|
|||
/**
|
||||
* Navigate to a particular event.
|
||||
*
|
||||
* @param {number} eventId Event to load.
|
||||
* @param eventId Event to load.
|
||||
*/
|
||||
gotoEvent(eventId: number): void {
|
||||
if (eventId < 0) {
|
||||
|
@ -292,7 +292,7 @@ export class AddonCalendarIndexPage implements OnInit, OnDestroy {
|
|||
/**
|
||||
* View a certain day.
|
||||
*
|
||||
* @param {any} data Data with the year, month and day.
|
||||
* @param data Data with the year, month and day.
|
||||
*/
|
||||
gotoDay(data: any): void {
|
||||
const params: any = {
|
||||
|
@ -311,7 +311,7 @@ export class AddonCalendarIndexPage implements OnInit, OnDestroy {
|
|||
/**
|
||||
* Show the context menu.
|
||||
*
|
||||
* @param {MouseEvent} event Event.
|
||||
* @param event Event.
|
||||
*/
|
||||
openCourseFilter(event: MouseEvent): void {
|
||||
this.coursesHelper.selectCourse(event, this.courses, this.courseId).then((result) => {
|
||||
|
@ -330,7 +330,7 @@ export class AddonCalendarIndexPage implements OnInit, OnDestroy {
|
|||
/**
|
||||
* Open page to create/edit an event.
|
||||
*
|
||||
* @param {number} [eventId] Event ID to edit.
|
||||
* @param eventId Event ID to edit.
|
||||
*/
|
||||
openEdit(eventId?: number): void {
|
||||
const params: any = {};
|
||||
|
|
|
@ -233,10 +233,10 @@ export class AddonCalendarListPage implements OnDestroy {
|
|||
/**
|
||||
* Fetch all the data required for the view.
|
||||
*
|
||||
* @param {boolean} [refresh] Empty events array first.
|
||||
* @param {boolean} [sync] Whether it should try to synchronize offline events.
|
||||
* @param {boolean} [showErrors] Whether to show sync errors to the user.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param refresh Empty events array first.
|
||||
* @param sync Whether it should try to synchronize offline events.
|
||||
* @param showErrors Whether to show sync errors to the user.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
fetchData(refresh?: boolean, sync?: boolean, showErrors?: boolean): Promise<any> {
|
||||
this.initialTime = this.timeUtils.timestamp();
|
||||
|
@ -314,8 +314,8 @@ export class AddonCalendarListPage implements OnDestroy {
|
|||
/**
|
||||
* Fetches the events and updates the view.
|
||||
*
|
||||
* @param {boolean} [refresh] Empty events array first.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param refresh Empty events array first.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
fetchEvents(refresh?: boolean): Promise<any> {
|
||||
this.loadMoreError = false;
|
||||
|
@ -388,8 +388,8 @@ export class AddonCalendarListPage implements OnDestroy {
|
|||
/**
|
||||
* Function to load more events.
|
||||
*
|
||||
* @param {any} [infiniteComplete] Infinite scroll complete function. Only used from core-infinite-loading.
|
||||
* @return {Promise<any>} Resolved when done.
|
||||
* @param infiniteComplete Infinite scroll complete function. Only used from core-infinite-loading.
|
||||
* @return Resolved when done.
|
||||
*/
|
||||
loadMoreEvents(infiniteComplete?: any): Promise<any> {
|
||||
return this.fetchEvents().finally(() => {
|
||||
|
@ -400,7 +400,7 @@ export class AddonCalendarListPage implements OnDestroy {
|
|||
/**
|
||||
* Get filtered events.
|
||||
*
|
||||
* @return {any[]} Filtered events.
|
||||
* @return Filtered events.
|
||||
*/
|
||||
protected getFilteredEvents(): any[] {
|
||||
if (!this.courseId) {
|
||||
|
@ -415,8 +415,8 @@ export class AddonCalendarListPage implements OnDestroy {
|
|||
|
||||
/**
|
||||
* Returns if the current state should load categories or not.
|
||||
* @param {any[]} events Events to parse.
|
||||
* @return {boolean} True if categories should be loaded.
|
||||
* @param events Events to parse.
|
||||
* @return True if categories should be loaded.
|
||||
*/
|
||||
protected shouldLoadCategories(events: any[]): boolean {
|
||||
if (this.categoriesRetrieved || this.getCategories) {
|
||||
|
@ -433,7 +433,7 @@ export class AddonCalendarListPage implements OnDestroy {
|
|||
/**
|
||||
* Load categories to be able to filter events.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected loadCategories(): Promise<any> {
|
||||
return this.coursesProvider.getCategories(0, true).then((cats) => {
|
||||
|
@ -451,8 +451,8 @@ export class AddonCalendarListPage implements OnDestroy {
|
|||
/**
|
||||
* Merge a period of online events with the offline events of that period.
|
||||
*
|
||||
* @param {any[]} onlineEvents Online events.
|
||||
* @return {any[]} Merged events.
|
||||
* @param onlineEvents Online events.
|
||||
* @return Merged events.
|
||||
*/
|
||||
protected mergeEvents(onlineEvents: any[]): any[] {
|
||||
if (!this.offlineEvents.length && !this.deletedEvents.length) {
|
||||
|
@ -501,7 +501,7 @@ export class AddonCalendarListPage implements OnDestroy {
|
|||
/**
|
||||
* Sort events by timestart.
|
||||
*
|
||||
* @param {any[]} events List to sort.
|
||||
* @param events List to sort.
|
||||
*/
|
||||
protected sortEvents(events: any[]): any[] {
|
||||
return events.sort((a, b) => {
|
||||
|
@ -516,10 +516,10 @@ export class AddonCalendarListPage implements OnDestroy {
|
|||
/**
|
||||
* Refresh the data.
|
||||
*
|
||||
* @param {any} [refresher] Refresher.
|
||||
* @param {Function} [done] Function to call when done.
|
||||
* @param {boolean} [showErrors] Whether to show sync errors to the user.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param refresher Refresher.
|
||||
* @param done Function to call when done.
|
||||
* @param showErrors Whether to show sync errors to the user.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
doRefresh(refresher?: any, done?: () => void, showErrors?: boolean): Promise<any> {
|
||||
if (this.eventsLoaded) {
|
||||
|
@ -535,9 +535,9 @@ export class AddonCalendarListPage implements OnDestroy {
|
|||
/**
|
||||
* Refresh the events.
|
||||
*
|
||||
* @param {boolean} [sync] Whether it should try to synchronize offline events.
|
||||
* @param {boolean} [showErrors] Whether to show sync errors to the user.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param sync Whether it should try to synchronize offline events.
|
||||
* @param showErrors Whether to show sync errors to the user.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
refreshEvents(sync?: boolean, showErrors?: boolean): Promise<any> {
|
||||
this.syncIcon = 'spinner';
|
||||
|
@ -561,9 +561,9 @@ export class AddonCalendarListPage implements OnDestroy {
|
|||
* Check date should be shown on event list for the current event.
|
||||
* If date has changed from previous to current event it should be shown.
|
||||
*
|
||||
* @param {any} event Current event where to show the date.
|
||||
* @param {any} [prevEvent] Previous event where to compare the date with.
|
||||
* @return {boolean} If date has changed and should be shown.
|
||||
* @param event Current event where to show the date.
|
||||
* @param prevEvent Previous event where to compare the date with.
|
||||
* @return If date has changed and should be shown.
|
||||
*/
|
||||
protected showDate(event: any, prevEvent?: any): boolean {
|
||||
if (!prevEvent) {
|
||||
|
@ -578,8 +578,8 @@ export class AddonCalendarListPage implements OnDestroy {
|
|||
/**
|
||||
* Check if event ends the same date or not.
|
||||
*
|
||||
* @param {any} event Event info.
|
||||
* @return {boolean} If date has changed and should be shown.
|
||||
* @param event Event info.
|
||||
* @return If date has changed and should be shown.
|
||||
*/
|
||||
protected endsSameDay(event: any): boolean {
|
||||
if (!event.timeduration) {
|
||||
|
@ -594,7 +594,7 @@ export class AddonCalendarListPage implements OnDestroy {
|
|||
/**
|
||||
* Show the context menu.
|
||||
*
|
||||
* @param {MouseEvent} event Event.
|
||||
* @param event Event.
|
||||
*/
|
||||
openCourseFilter(event: MouseEvent): void {
|
||||
this.coursesHelper.selectCourse(event, this.courses, this.courseId).then((result) => {
|
||||
|
@ -617,7 +617,7 @@ export class AddonCalendarListPage implements OnDestroy {
|
|||
/**
|
||||
* Open page to create/edit an event.
|
||||
*
|
||||
* @param {number} [eventId] Event ID to edit.
|
||||
* @param eventId Event ID to edit.
|
||||
*/
|
||||
openEdit(eventId?: number): void {
|
||||
this.eventId = undefined;
|
||||
|
@ -644,7 +644,7 @@ export class AddonCalendarListPage implements OnDestroy {
|
|||
/**
|
||||
* Navigate to a particular event.
|
||||
*
|
||||
* @param {number} eventId Event to load.
|
||||
* @param eventId Event to load.
|
||||
*/
|
||||
gotoEvent(eventId: number): void {
|
||||
this.eventId = eventId;
|
||||
|
@ -662,8 +662,8 @@ export class AddonCalendarListPage implements OnDestroy {
|
|||
/**
|
||||
* Find an event and mark it as deleted.
|
||||
*
|
||||
* @param {number} eventId Event ID.
|
||||
* @param {boolean} deleted Whether to mark it as deleted or not.
|
||||
* @param eventId Event ID.
|
||||
* @param deleted Whether to mark it as deleted or not.
|
||||
*/
|
||||
protected markAsDeleted(eventId: number, deleted: boolean): void {
|
||||
const event = this.onlineEvents.find((event) => {
|
||||
|
|
|
@ -45,7 +45,7 @@ export class AddonCalendarSettingsPage {
|
|||
/**
|
||||
* Update default time.
|
||||
*
|
||||
* @param {number} newTime New time.
|
||||
* @param newTime New time.
|
||||
*/
|
||||
updateDefaultTime(newTime: number): void {
|
||||
this.calendarProvider.setDefaultNotificationTime(newTime);
|
||||
|
|
|
@ -148,9 +148,9 @@ export class AddonCalendarOfflineProvider {
|
|||
/**
|
||||
* Delete an offline event.
|
||||
*
|
||||
* @param {number} eventId Event ID.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved if deleted, rejected if failure.
|
||||
* @param eventId Event ID.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved if deleted, rejected if failure.
|
||||
*/
|
||||
deleteEvent(eventId: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -165,8 +165,8 @@ export class AddonCalendarOfflineProvider {
|
|||
/**
|
||||
* Get the IDs of all the events created/edited/deleted in offline.
|
||||
*
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<number[]>} Promise resolved with the IDs.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with the IDs.
|
||||
*/
|
||||
getAllEventsIds(siteId?: string): Promise<number[]> {
|
||||
const promises = [];
|
||||
|
@ -182,8 +182,8 @@ export class AddonCalendarOfflineProvider {
|
|||
/**
|
||||
* Get all the events deleted in offline.
|
||||
*
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any[]>} Promise resolved with all the events deleted in offline.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with all the events deleted in offline.
|
||||
*/
|
||||
getAllDeletedEvents(siteId?: string): Promise<any[]> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -194,8 +194,8 @@ export class AddonCalendarOfflineProvider {
|
|||
/**
|
||||
* Get the IDs of all the events deleted in offline.
|
||||
*
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<number[]>} Promise resolved with the IDs of all the events deleted in offline.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with the IDs of all the events deleted in offline.
|
||||
*/
|
||||
getAllDeletedEventsIds(siteId?: string): Promise<number[]> {
|
||||
return this.getAllDeletedEvents(siteId).then((events) => {
|
||||
|
@ -208,8 +208,8 @@ export class AddonCalendarOfflineProvider {
|
|||
/**
|
||||
* Get all the events created/edited in offline.
|
||||
*
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any[]>} Promise resolved with events.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with events.
|
||||
*/
|
||||
getAllEditedEvents(siteId?: string): Promise<any[]> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -220,8 +220,8 @@ export class AddonCalendarOfflineProvider {
|
|||
/**
|
||||
* Get the IDs of all the events created/edited in offline.
|
||||
*
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<number[]>} Promise resolved with events IDs.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with events IDs.
|
||||
*/
|
||||
getAllEditedEventsIds(siteId?: string): Promise<number[]> {
|
||||
return this.getAllEditedEvents(siteId).then((events) => {
|
||||
|
@ -234,9 +234,9 @@ export class AddonCalendarOfflineProvider {
|
|||
/**
|
||||
* Get an event deleted in offline.
|
||||
*
|
||||
* @param {number} eventId Event ID.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved with the deleted event.
|
||||
* @param eventId Event ID.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with the deleted event.
|
||||
*/
|
||||
getDeletedEvent(eventId: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -251,9 +251,9 @@ export class AddonCalendarOfflineProvider {
|
|||
/**
|
||||
* Get an offline event.
|
||||
*
|
||||
* @param {number} eventId Event ID.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved with the event.
|
||||
* @param eventId Event ID.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with the event.
|
||||
*/
|
||||
getEvent(eventId: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -268,8 +268,8 @@ export class AddonCalendarOfflineProvider {
|
|||
/**
|
||||
* Check if there are offline events to send.
|
||||
*
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<boolean>} Promise resolved with boolean: true if has offline events, false otherwise.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with boolean: true if has offline events, false otherwise.
|
||||
*/
|
||||
hasEditedEvents(siteId?: string): Promise<boolean> {
|
||||
return this.getAllEditedEvents(siteId).then((events) => {
|
||||
|
@ -283,8 +283,8 @@ export class AddonCalendarOfflineProvider {
|
|||
/**
|
||||
* Check whether there's offline data for a site.
|
||||
*
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<boolean>} Promise resolved with boolean: true if has offline data, false otherwise.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with boolean: true if has offline data, false otherwise.
|
||||
*/
|
||||
hasOfflineData(siteId?: string): Promise<boolean> {
|
||||
return this.getAllEventsIds(siteId).then((ids) => {
|
||||
|
@ -295,9 +295,9 @@ export class AddonCalendarOfflineProvider {
|
|||
/**
|
||||
* Check if an event is deleted.
|
||||
*
|
||||
* @param {number} eventId Event ID.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<boolean>} Promise resolved with boolean: whether the event is deleted.
|
||||
* @param eventId Event ID.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with boolean: whether the event is deleted.
|
||||
*/
|
||||
isEventDeleted(eventId: number, siteId?: string): Promise<boolean> {
|
||||
return this.getDeletedEvent(eventId, siteId).then((event) => {
|
||||
|
@ -310,11 +310,11 @@ export class AddonCalendarOfflineProvider {
|
|||
/**
|
||||
* Mark an event as deleted.
|
||||
*
|
||||
* @param {number} eventId Event ID to delete.
|
||||
* @param {number} name Name of the event to delete.
|
||||
* @param {boolean} [deleteAll] If it's a repeated event. whether to delete all events of the series.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param eventId Event ID to delete.
|
||||
* @param name Name of the event to delete.
|
||||
* @param deleteAll If it's a repeated event. whether to delete all events of the series.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
markDeleted(eventId: number, name: string, deleteAll?: boolean, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -332,11 +332,11 @@ export class AddonCalendarOfflineProvider {
|
|||
/**
|
||||
* Offline version for adding a new discussion to a forum.
|
||||
*
|
||||
* @param {number} eventId Event ID. If it's a new event, set it to undefined/null.
|
||||
* @param {any} data Event data.
|
||||
* @param {number} [timeCreated] The time the event was created. If not defined, current time.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved with the stored event.
|
||||
* @param eventId Event ID. If it's a new event, set it to undefined/null.
|
||||
* @param data Event data.
|
||||
* @param timeCreated The time the event was created. If not defined, current time.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with the stored event.
|
||||
*/
|
||||
saveEvent(eventId: number, data: any, timeCreated?: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -373,9 +373,9 @@ export class AddonCalendarOfflineProvider {
|
|||
/**
|
||||
* Unmark an event as deleted.
|
||||
*
|
||||
* @param {number} eventId Event ID.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved if deleted, rejected if failure.
|
||||
* @param eventId Event ID.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved if deleted, rejected if failure.
|
||||
*/
|
||||
unmarkDeleted(eventId: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
|
|
@ -59,9 +59,9 @@ export class AddonCalendarSyncProvider extends CoreSyncBaseProvider {
|
|||
/**
|
||||
* Try to synchronize all events in a certain site or in all sites.
|
||||
*
|
||||
* @param {string} [siteId] Site ID to sync. If not defined, sync all sites.
|
||||
* @param {boolean} [force] Wether to force sync not depending on last execution.
|
||||
* @return {Promise<any>} Promise resolved if sync is successful, rejected if sync fails.
|
||||
* @param siteId Site ID to sync. If not defined, sync all sites.
|
||||
* @param force Wether to force sync not depending on last execution.
|
||||
* @return Promise resolved if sync is successful, rejected if sync fails.
|
||||
*/
|
||||
syncAllEvents(siteId?: string, force?: boolean): Promise<any> {
|
||||
return this.syncOnSites('all calendar events', this.syncAllEventsFunc.bind(this), [force], siteId);
|
||||
|
@ -70,9 +70,9 @@ export class AddonCalendarSyncProvider extends CoreSyncBaseProvider {
|
|||
/**
|
||||
* Sync all events on a site.
|
||||
*
|
||||
* @param {string} siteId Site ID to sync.
|
||||
* @param {boolean} [force] Wether to force sync not depending on last execution.
|
||||
* @return {Promise<any>} Promise resolved if sync is successful, rejected if sync fails.
|
||||
* @param siteId Site ID to sync.
|
||||
* @param force Wether to force sync not depending on last execution.
|
||||
* @return Promise resolved if sync is successful, rejected if sync fails.
|
||||
*/
|
||||
protected syncAllEventsFunc(siteId: string, force?: boolean): Promise<any> {
|
||||
|
||||
|
@ -93,8 +93,8 @@ export class AddonCalendarSyncProvider extends CoreSyncBaseProvider {
|
|||
/**
|
||||
* Sync a site events only if a certain time has passed since the last time.
|
||||
*
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved when the events are synced or if it doesn't need to be synced.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved when the events are synced or if it doesn't need to be synced.
|
||||
*/
|
||||
syncEventsIfNeeded(siteId?: string): Promise<any> {
|
||||
siteId = siteId || this.sitesProvider.getCurrentSiteId();
|
||||
|
@ -109,8 +109,8 @@ export class AddonCalendarSyncProvider extends CoreSyncBaseProvider {
|
|||
/**
|
||||
* Synchronize all offline events of a certain site.
|
||||
*
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved if sync is successful, rejected otherwise.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved if sync is successful, rejected otherwise.
|
||||
*/
|
||||
syncEvents(siteId?: string): Promise<any> {
|
||||
siteId = siteId || this.sitesProvider.getCurrentSiteId();
|
||||
|
@ -182,10 +182,10 @@ export class AddonCalendarSyncProvider extends CoreSyncBaseProvider {
|
|||
/**
|
||||
* Synchronize an offline event.
|
||||
*
|
||||
* @param {number} eventId The event ID to sync.
|
||||
* @param {any} result Object where to store the result of the sync.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved if sync is successful, rejected otherwise.
|
||||
* @param eventId The event ID to sync.
|
||||
* @param result Object where to store the result of the sync.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved if sync is successful, rejected otherwise.
|
||||
*/
|
||||
protected syncOfflineEvent(eventId: number, result: any, siteId?: string): Promise<any> {
|
||||
|
||||
|
|
|
@ -335,8 +335,8 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Check if a certain site allows deleting events.
|
||||
*
|
||||
* @param {string} [siteId] Site Id. If not defined, use current site.
|
||||
* @return {Promise<boolean>} Promise resolved with true if can delete.
|
||||
* @param siteId Site Id. If not defined, use current site.
|
||||
* @return Promise resolved with true if can delete.
|
||||
* @since 3.3
|
||||
*/
|
||||
canDeleteEvents(siteId?: string): Promise<boolean> {
|
||||
|
@ -350,8 +350,8 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Check if a certain site allows deleting events.
|
||||
*
|
||||
* @param {CoreSite} [site] Site. If not defined, use current site.
|
||||
* @return {boolean} Whether events can be deleted.
|
||||
* @param site Site. If not defined, use current site.
|
||||
* @return Whether events can be deleted.
|
||||
* @since 3.3
|
||||
*/
|
||||
canDeleteEventsInSite(site?: CoreSite): boolean {
|
||||
|
@ -363,8 +363,8 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Check if a certain site allows creating and editing events.
|
||||
*
|
||||
* @param {string} [siteId] Site Id. If not defined, use current site.
|
||||
* @return {Promise<boolean>} Promise resolved with true if can create/edit.
|
||||
* @param siteId Site Id. If not defined, use current site.
|
||||
* @return Promise resolved with true if can create/edit.
|
||||
* @since 3.7.1
|
||||
*/
|
||||
canEditEvents(siteId?: string): Promise<boolean> {
|
||||
|
@ -378,8 +378,8 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Check if a certain site allows creating and editing events.
|
||||
*
|
||||
* @param {CoreSite} [site] Site. If not defined, use current site.
|
||||
* @return {boolean} Whether events can be created and edited.
|
||||
* @param site Site. If not defined, use current site.
|
||||
* @return Whether events can be created and edited.
|
||||
* @since 3.7.1
|
||||
*/
|
||||
canEditEventsInSite(site?: CoreSite): boolean {
|
||||
|
@ -392,8 +392,8 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Check if a certain site allows viewing events in monthly view.
|
||||
*
|
||||
* @param {string} [siteId] Site Id. If not defined, use current site.
|
||||
* @return {Promise<boolean>} Promise resolved with true if monthly view is supported.
|
||||
* @param siteId Site Id. If not defined, use current site.
|
||||
* @return Promise resolved with true if monthly view is supported.
|
||||
* @since 3.4
|
||||
*/
|
||||
canViewMonth(siteId?: string): Promise<boolean> {
|
||||
|
@ -407,8 +407,8 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Check if a certain site allows viewing events in monthly view.
|
||||
*
|
||||
* @param {CoreSite} [site] Site. If not defined, use current site.
|
||||
* @return {boolean} Whether monthly view is supported.
|
||||
* @param site Site. If not defined, use current site.
|
||||
* @return Whether monthly view is supported.
|
||||
* @since 3.4
|
||||
*/
|
||||
canViewMonthInSite(site?: CoreSite): boolean {
|
||||
|
@ -420,8 +420,8 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Removes expired events from local DB.
|
||||
*
|
||||
* @param {string} [siteId] ID of the site the event belongs to. If not defined, use current site.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param siteId ID of the site the event belongs to. If not defined, use current site.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
cleanExpiredEvents(siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -442,12 +442,12 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Delete an event.
|
||||
*
|
||||
* @param {number} eventId Event ID to delete.
|
||||
* @param {string} name Name of the event to delete.
|
||||
* @param {boolean} [deleteAll] If it's a repeated event. whether to delete all events of the series.
|
||||
* @param {boolean} [forceOffline] True to always save it in offline.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param eventId Event ID to delete.
|
||||
* @param name Name of the event to delete.
|
||||
* @param deleteAll If it's a repeated event. whether to delete all events of the series.
|
||||
* @param forceOffline True to always save it in offline.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
deleteEvent(eventId: number, name: string, deleteAll?: boolean, forceOffline?: boolean, siteId?: string): Promise<boolean> {
|
||||
|
||||
|
@ -484,10 +484,10 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Delete an event. It will fail if offline or cannot connect.
|
||||
*
|
||||
* @param {number} eventId Event ID to delete.
|
||||
* @param {boolean} [deleteAll] If it's a repeated event. whether to delete all events of the series.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param eventId Event ID to delete.
|
||||
* @param deleteAll If it's a repeated event. whether to delete all events of the series.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
deleteEventOnline(eventId: number, deleteAll?: boolean, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -511,9 +511,9 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Delete a locally stored event cancelling all the reminders and notifications.
|
||||
*
|
||||
* @param {number} eventId Event ID.
|
||||
* @param {string} [siteId] ID of the site the event belongs to. If not defined, use current site.
|
||||
* @return {Promise<any>} Resolved when done.
|
||||
* @param eventId Event ID.
|
||||
* @param siteId ID of the site the event belongs to. If not defined, use current site.
|
||||
* @return Resolved when done.
|
||||
*/
|
||||
protected deleteLocalEvent(eventId: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -538,8 +538,8 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Check if event ends the same day or not.
|
||||
*
|
||||
* @param {any} event Event info.
|
||||
* @return {boolean} If the .
|
||||
* @param event Event info.
|
||||
* @return If the .
|
||||
*/
|
||||
endsSameDay(event: any): boolean {
|
||||
if (!event.timeduration) {
|
||||
|
@ -554,13 +554,13 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Format event time. Similar to calendar_format_event_time.
|
||||
*
|
||||
* @param {any} event Event to format.
|
||||
* @param {string} format Calendar time format (from getCalendarTimeFormat).
|
||||
* @param {boolean} [useCommonWords=true] Whether to use common words like "Today", "Yesterday", etc.
|
||||
* @param {number} [seenDay] Timestamp of day currently seen. If set, the function will not add links to this day.
|
||||
* @param {number} [showTime=0] Determine the show time GMT timestamp.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<string>} Promise resolved with the formatted event time.
|
||||
* @param event Event to format.
|
||||
* @param format Calendar time format (from getCalendarTimeFormat).
|
||||
* @param useCommonWords Whether to use common words like "Today", "Yesterday", etc.
|
||||
* @param seenDay Timestamp of day currently seen. If set, the function will not add links to this day.
|
||||
* @param showTime Determine the show time GMT timestamp.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with the formatted event time.
|
||||
*/
|
||||
formatEventTime(event: any, format: string, useCommonWords: boolean = true, seenDay?: number, showTime: number = 0,
|
||||
siteId?: string): Promise<string> {
|
||||
|
@ -630,9 +630,9 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get access information for a calendar (either course calendar or site calendar).
|
||||
*
|
||||
* @param {number} [courseId] Course ID. If not defined, site calendar.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved with object with access information.
|
||||
* @param courseId Course ID. If not defined, site calendar.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with object with access information.
|
||||
* @since 3.7
|
||||
*/
|
||||
getAccessInformation(courseId?: number, siteId?: string): Promise<any> {
|
||||
|
@ -653,8 +653,8 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get cache key for calendar access information WS calls.
|
||||
*
|
||||
* @param {number} [courseId] Course ID.
|
||||
* @return {string} Cache key.
|
||||
* @param courseId Course ID.
|
||||
* @return Cache key.
|
||||
*/
|
||||
protected getAccessInformationCacheKey(courseId?: number): string {
|
||||
return this.ROOT_CACHE_KEY + 'accessInformation:' + (courseId || 0);
|
||||
|
@ -663,8 +663,8 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get all calendar events from local Db.
|
||||
*
|
||||
* @param {string} [siteId] ID of the site the event belongs to. If not defined, use current site.
|
||||
* @return {Promise<any[]>} Promise resolved with all the events.
|
||||
* @param siteId ID of the site the event belongs to. If not defined, use current site.
|
||||
* @return Promise resolved with all the events.
|
||||
*/
|
||||
getAllEventsFromLocalDb(siteId?: string): Promise<any[]> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -675,9 +675,9 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get the type of events a user can create (either course calendar or site calendar).
|
||||
*
|
||||
* @param {number} [courseId] Course ID. If not defined, site calendar.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved with an object indicating the types.
|
||||
* @param courseId Course ID. If not defined, site calendar.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with an object indicating the types.
|
||||
* @since 3.7
|
||||
*/
|
||||
getAllowedEventTypes(courseId?: number, siteId?: string): Promise<any> {
|
||||
|
@ -709,8 +709,8 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get cache key for calendar allowed event types WS calls.
|
||||
*
|
||||
* @param {number} [courseId] Course ID.
|
||||
* @return {string} Cache key.
|
||||
* @param courseId Course ID.
|
||||
* @return Cache key.
|
||||
*/
|
||||
protected getAllowedEventTypesCacheKey(courseId?: number): string {
|
||||
return this.ROOT_CACHE_KEY + 'allowedEventTypes:' + (courseId || 0);
|
||||
|
@ -719,8 +719,8 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get the "look ahead" for a certain user.
|
||||
*
|
||||
* @param {string} [siteId] ID of the site. If not defined, use current site.
|
||||
* @return {Promise<number>} Promise resolved with the look ahead (number of days).
|
||||
* @param siteId ID of the site. If not defined, use current site.
|
||||
* @return Promise resolved with the look ahead (number of days).
|
||||
*/
|
||||
getCalendarLookAhead(siteId?: string): Promise<number> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -739,8 +739,8 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get the time format to use in calendar.
|
||||
*
|
||||
* @param {string} [siteId] ID of the site. If not defined, use current site.
|
||||
* @return {Promise<string>} Promise resolved with the format.
|
||||
* @param siteId ID of the site. If not defined, use current site.
|
||||
* @return Promise resolved with the format.
|
||||
*/
|
||||
getCalendarTimeFormat(siteId?: string): Promise<string> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -766,9 +766,9 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Return the representation day. Equivalent to Moodle's calendar_day_representation.
|
||||
*
|
||||
* @param {number} time Timestamp to get the day from.
|
||||
* @param {boolean} [useCommonWords=true] Whether to use common words like "Today", "Yesterday", etc.
|
||||
* @return {string} The formatted date/time.
|
||||
* @param time Timestamp to get the day from.
|
||||
* @param useCommonWords Whether to use common words like "Today", "Yesterday", etc.
|
||||
* @return The formatted date/time.
|
||||
*/
|
||||
getDayRepresentation(time: number, useCommonWords: boolean = true): string {
|
||||
|
||||
|
@ -797,8 +797,8 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get the configured default notification time.
|
||||
*
|
||||
* @param {string} [siteId] ID of the site. If not defined, use current site.
|
||||
* @return {Promise<number>} Promise resolved with the default time.
|
||||
* @param siteId ID of the site. If not defined, use current site.
|
||||
* @return Promise resolved with the default time.
|
||||
*/
|
||||
getDefaultNotificationTime(siteId?: string): Promise<number> {
|
||||
siteId = siteId || this.sitesProvider.getCurrentSiteId();
|
||||
|
@ -811,10 +811,10 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get a calendar event. If the server request fails and data is not cached, try to get it from local DB.
|
||||
*
|
||||
* @param {number} id Event ID.
|
||||
* @param {boolean} [refresh] True when we should update the event data.
|
||||
* @param {string} [siteId] ID of the site. If not defined, use current site.
|
||||
* @return {Promise<any>} Promise resolved when the event data is retrieved.
|
||||
* @param id Event ID.
|
||||
* @param refresh True when we should update the event data.
|
||||
* @param siteId ID of the site. If not defined, use current site.
|
||||
* @return Promise resolved when the event data is retrieved.
|
||||
*/
|
||||
getEvent(id: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -848,10 +848,10 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get a calendar event by ID. This function returns more data than getEvent, but it isn't available in all Moodles.
|
||||
*
|
||||
* @param {number} id Event ID.
|
||||
* @param {boolean} [refresh] True when we should update the event data.
|
||||
* @param {string} [siteId] ID of the site. If not defined, use current site.
|
||||
* @return {Promise<any>} Promise resolved when the event data is retrieved.
|
||||
* @param id Event ID.
|
||||
* @param refresh True when we should update the event data.
|
||||
* @param siteId ID of the site. If not defined, use current site.
|
||||
* @return Promise resolved when the event data is retrieved.
|
||||
* @since 3.4
|
||||
*/
|
||||
getEventById(id: number, siteId?: string): Promise<any> {
|
||||
|
@ -877,8 +877,8 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get cache key for a single event WS call.
|
||||
*
|
||||
* @param {number} id Event ID.
|
||||
* @return {string} Cache key.
|
||||
* @param id Event ID.
|
||||
* @return Cache key.
|
||||
*/
|
||||
protected getEventCacheKey(id: number): string {
|
||||
return this.ROOT_CACHE_KEY + 'events:' + id;
|
||||
|
@ -887,9 +887,9 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get a calendar event from local Db.
|
||||
*
|
||||
* @param {number} id Event ID.
|
||||
* @param {string} [siteId] ID of the site the event belongs to. If not defined, use current site.
|
||||
* @return {Promise<any>} Promise resolved when the event data is retrieved.
|
||||
* @param id Event ID.
|
||||
* @param siteId ID of the site the event belongs to. If not defined, use current site.
|
||||
* @return Promise resolved when the event data is retrieved.
|
||||
*/
|
||||
getEventFromLocalDb(id: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -913,10 +913,10 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Adds an event reminder and schedule a new notification.
|
||||
*
|
||||
* @param {any} event Event to update its notification time.
|
||||
* @param {number} time New notification setting timestamp.
|
||||
* @param {string} [siteId] ID of the site the event belongs to. If not defined, use current site.
|
||||
* @return {Promise<any>} Promise resolved when the notification is updated.
|
||||
* @param event Event to update its notification time.
|
||||
* @param time New notification setting timestamp.
|
||||
* @param siteId ID of the site the event belongs to. If not defined, use current site.
|
||||
* @return Promise resolved when the notification is updated.
|
||||
*/
|
||||
addEventReminder(event: any, time: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -935,8 +935,8 @@ export class AddonCalendarProvider {
|
|||
* Return the normalised event type.
|
||||
* Activity events are normalised to be course events.
|
||||
*
|
||||
* @param {any} event The event to get its type.
|
||||
* @return {string} Event type.
|
||||
* @param event The event to get its type.
|
||||
* @return Event type.
|
||||
*/
|
||||
getEventType(event: any): string {
|
||||
if (event.modulename) {
|
||||
|
@ -949,9 +949,9 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Remove an event reminder and cancel the notification.
|
||||
*
|
||||
* @param {number} id Reminder ID.
|
||||
* @param {string} [siteId] ID of the site the event belongs to. If not defined, use current site.
|
||||
* @return {Promise<any>} Promise resolved when the notification is updated.
|
||||
* @param id Reminder ID.
|
||||
* @param siteId ID of the site the event belongs to. If not defined, use current site.
|
||||
* @return Promise resolved when the notification is updated.
|
||||
*/
|
||||
deleteEventReminder(id: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -966,14 +966,14 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get calendar events for a certain day.
|
||||
*
|
||||
* @param {number} year Year to get.
|
||||
* @param {number} month Month to get.
|
||||
* @param {number} day Day to get.
|
||||
* @param {number} [courseId] Course to get.
|
||||
* @param {number} [categoryId] Category to get.
|
||||
* @param {boolean} [ignoreCache] True if it should ignore cached data (it will always fail in offline or server down).
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved with the response.
|
||||
* @param year Year to get.
|
||||
* @param month Month to get.
|
||||
* @param day Day to get.
|
||||
* @param courseId Course to get.
|
||||
* @param categoryId Category to get.
|
||||
* @param ignoreCache True if it should ignore cached data (it will always fail in offline or server down).
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with the response.
|
||||
*/
|
||||
getDayEvents(year: number, month: number, day: number, courseId?: number, categoryId?: number, ignoreCache?: boolean,
|
||||
siteId?: string): Promise<any> {
|
||||
|
@ -1014,7 +1014,7 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get prefix cache key for day events WS calls.
|
||||
*
|
||||
* @return {string} Prefix Cache key.
|
||||
* @return Prefix Cache key.
|
||||
*/
|
||||
protected getDayEventsPrefixCacheKey(): string {
|
||||
return this.ROOT_CACHE_KEY + 'day:';
|
||||
|
@ -1023,10 +1023,10 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get prefix cache key for a certain day for day events WS calls.
|
||||
*
|
||||
* @param {number} year Year to get.
|
||||
* @param {number} month Month to get.
|
||||
* @param {number} day Day to get.
|
||||
* @return {string} Prefix Cache key.
|
||||
* @param year Year to get.
|
||||
* @param month Month to get.
|
||||
* @param day Day to get.
|
||||
* @return Prefix Cache key.
|
||||
*/
|
||||
protected getDayEventsDayPrefixCacheKey(year: number, month: number, day: number): string {
|
||||
return this.getDayEventsPrefixCacheKey() + year + ':' + month + ':' + day + ':';
|
||||
|
@ -1035,12 +1035,12 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get cache key for day events WS calls.
|
||||
*
|
||||
* @param {number} year Year to get.
|
||||
* @param {number} month Month to get.
|
||||
* @param {number} day Day to get.
|
||||
* @param {number} [courseId] Course to get.
|
||||
* @param {number} [categoryId] Category to get.
|
||||
* @return {string} Cache key.
|
||||
* @param year Year to get.
|
||||
* @param month Month to get.
|
||||
* @param day Day to get.
|
||||
* @param courseId Course to get.
|
||||
* @param categoryId Category to get.
|
||||
* @return Cache key.
|
||||
*/
|
||||
protected getDayEventsCacheKey(year: number, month: number, day: number, courseId?: number, categoryId?: number): string {
|
||||
return this.getDayEventsDayPrefixCacheKey(year, month, day) + (courseId ? courseId : '') + ':' +
|
||||
|
@ -1050,9 +1050,9 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get a calendar reminders from local Db.
|
||||
*
|
||||
* @param {number} id Event ID.
|
||||
* @param {string} [siteId] ID of the site the event belongs to. If not defined, use current site.
|
||||
* @return {Promise<any>} Promise resolved when the event data is retrieved.
|
||||
* @param id Event ID.
|
||||
* @param siteId ID of the site the event belongs to. If not defined, use current site.
|
||||
* @return Promise resolved when the event data is retrieved.
|
||||
*/
|
||||
getEventReminders(id: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -1067,11 +1067,11 @@ export class AddonCalendarProvider {
|
|||
* E.g. using provider.getEventsList(undefined, 30, 30) is going to get the events starting after 30 days from now
|
||||
* and ending before 60 days from now.
|
||||
*
|
||||
* @param {number} [initialTime] Timestamp when the first fetch was done. If not defined, current time.
|
||||
* @param {number} [daysToStart=0] Number of days from now to start getting events.
|
||||
* @param {number} [daysInterval=30] Number of days between timestart and timeend.
|
||||
* @param {string} [siteId] Site to get the events from. If not defined, use current site.
|
||||
* @return {Promise<any[]>} Promise to be resolved when the participants are retrieved.
|
||||
* @param initialTime Timestamp when the first fetch was done. If not defined, current time.
|
||||
* @param daysToStart Number of days from now to start getting events.
|
||||
* @param daysInterval Number of days between timestart and timeend.
|
||||
* @param siteId Site to get the events from. If not defined, use current site.
|
||||
* @return Promise to be resolved when the participants are retrieved.
|
||||
*/
|
||||
getEventsList(initialTime?: number, daysToStart: number = 0, daysInterval: number = AddonCalendarProvider.DAYS_INTERVAL,
|
||||
siteId?: string): Promise<any[]> {
|
||||
|
@ -1137,7 +1137,7 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get prefix cache key for events list WS calls.
|
||||
*
|
||||
* @return {string} Prefix Cache key.
|
||||
* @return Prefix Cache key.
|
||||
*/
|
||||
protected getEventsListPrefixCacheKey(): string {
|
||||
return this.ROOT_CACHE_KEY + 'events:';
|
||||
|
@ -1146,9 +1146,9 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get cache key for events list WS calls.
|
||||
*
|
||||
* @param {number} daysToStart Number of days from now to start getting events.
|
||||
* @param {number} daysInterval Number of days between timestart and timeend.
|
||||
* @return {string} Cache key.
|
||||
* @param daysToStart Number of days from now to start getting events.
|
||||
* @param daysInterval Number of days between timestart and timeend.
|
||||
* @return Cache key.
|
||||
*/
|
||||
protected getEventsListCacheKey(daysToStart: number, daysInterval: number): string {
|
||||
return this.getEventsListPrefixCacheKey() + daysToStart + ':' + daysInterval;
|
||||
|
@ -1157,9 +1157,9 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get calendar events from local Db that have the same repeatid.
|
||||
*
|
||||
* @param {number} [repeatId] Repeat Id of the event.
|
||||
* @param {string} [siteId] ID of the site the event belongs to. If not defined, use current site.
|
||||
* @return {Promise<any[]>} Promise resolved with all the events.
|
||||
* @param repeatId Repeat Id of the event.
|
||||
* @param siteId ID of the site the event belongs to. If not defined, use current site.
|
||||
* @return Promise resolved with all the events.
|
||||
*/
|
||||
getLocalEventsByRepeatIdFromLocalDb(repeatId: number, siteId?: string): Promise<any[]> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -1169,13 +1169,13 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get monthly calendar events.
|
||||
*
|
||||
* @param {number} year Year to get.
|
||||
* @param {number} month Month to get.
|
||||
* @param {number} [courseId] Course to get.
|
||||
* @param {number} [categoryId] Category to get.
|
||||
* @param {boolean} [ignoreCache] True if it should ignore cached data (it will always fail in offline or server down).
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved with the response.
|
||||
* @param year Year to get.
|
||||
* @param month Month to get.
|
||||
* @param courseId Course to get.
|
||||
* @param categoryId Category to get.
|
||||
* @param ignoreCache True if it should ignore cached data (it will always fail in offline or server down).
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with the response.
|
||||
*/
|
||||
getMonthlyEvents(year: number, month: number, courseId?: number, categoryId?: number, ignoreCache?: boolean, siteId?: string)
|
||||
: Promise<any> {
|
||||
|
@ -1230,7 +1230,7 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get prefix cache key for monthly events WS calls.
|
||||
*
|
||||
* @return {string} Prefix Cache key.
|
||||
* @return Prefix Cache key.
|
||||
*/
|
||||
protected getMonthlyEventsPrefixCacheKey(): string {
|
||||
return this.ROOT_CACHE_KEY + 'monthly:';
|
||||
|
@ -1239,9 +1239,9 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get prefix cache key for a certain month for monthly events WS calls.
|
||||
*
|
||||
* @param {number} year Year to get.
|
||||
* @param {number} month Month to get.
|
||||
* @return {string} Prefix Cache key.
|
||||
* @param year Year to get.
|
||||
* @param month Month to get.
|
||||
* @return Prefix Cache key.
|
||||
*/
|
||||
protected getMonthlyEventsMonthPrefixCacheKey(year: number, month: number): string {
|
||||
return this.getMonthlyEventsPrefixCacheKey() + year + ':' + month + ':';
|
||||
|
@ -1250,11 +1250,11 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get cache key for monthly events WS calls.
|
||||
*
|
||||
* @param {number} year Year to get.
|
||||
* @param {number} month Month to get.
|
||||
* @param {number} [courseId] Course to get.
|
||||
* @param {number} [categoryId] Category to get.
|
||||
* @return {string} Cache key.
|
||||
* @param year Year to get.
|
||||
* @param month Month to get.
|
||||
* @param courseId Course to get.
|
||||
* @param categoryId Category to get.
|
||||
* @return Cache key.
|
||||
*/
|
||||
protected getMonthlyEventsCacheKey(year: number, month: number, courseId?: number, categoryId?: number): string {
|
||||
return this.getMonthlyEventsMonthPrefixCacheKey(year, month) + (courseId ? courseId : '') + ':' +
|
||||
|
@ -1264,11 +1264,11 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get upcoming calendar events.
|
||||
*
|
||||
* @param {number} [courseId] Course to get.
|
||||
* @param {number} [categoryId] Category to get.
|
||||
* @param {boolean} [ignoreCache] True if it should ignore cached data (it will always fail in offline or server down).
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved with the response.
|
||||
* @param courseId Course to get.
|
||||
* @param categoryId Category to get.
|
||||
* @param ignoreCache True if it should ignore cached data (it will always fail in offline or server down).
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with the response.
|
||||
*/
|
||||
getUpcomingEvents(courseId?: number, categoryId?: number, ignoreCache?: boolean, siteId?: string): Promise<any> {
|
||||
|
||||
|
@ -1304,7 +1304,7 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get prefix cache key for upcoming events WS calls.
|
||||
*
|
||||
* @return {string} Prefix Cache key.
|
||||
* @return Prefix Cache key.
|
||||
*/
|
||||
protected getUpcomingEventsPrefixCacheKey(): string {
|
||||
return this.ROOT_CACHE_KEY + 'upcoming:';
|
||||
|
@ -1313,9 +1313,9 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get cache key for upcoming events WS calls.
|
||||
*
|
||||
* @param {number} [courseId] Course to get.
|
||||
* @param {number} [categoryId] Category to get.
|
||||
* @return {string} Cache key.
|
||||
* @param courseId Course to get.
|
||||
* @param categoryId Category to get.
|
||||
* @return Cache key.
|
||||
*/
|
||||
protected getUpcomingEventsCacheKey(courseId?: number, categoryId?: number): string {
|
||||
return this.getUpcomingEventsPrefixCacheKey() + (courseId ? courseId : '') + ':' + (categoryId ? categoryId : '');
|
||||
|
@ -1324,11 +1324,11 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get URL to view a calendar.
|
||||
*
|
||||
* @param {string} view The view to load: 'month', 'day', 'upcoming', etc.
|
||||
* @param {number} [time] Time to load. If not defined, current time.
|
||||
* @param {string} [courseId] Course to load. If not defined, all courses.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<string>} Promise resolved with the URL.x
|
||||
* @param view The view to load: 'month', 'day', 'upcoming', etc.
|
||||
* @param time Time to load. If not defined, current time.
|
||||
* @param courseId Course to load. If not defined, all courses.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with the URL.x
|
||||
*/
|
||||
getViewUrl(view: string, time?: number, courseId?: string, siteId?: string): Promise<string> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -1349,8 +1349,8 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Get the week days, already ordered according to a specified starting day.
|
||||
*
|
||||
* @param {number} [startingDay=0] Starting day. 0=Sunday, 1=Monday, ...
|
||||
* @return {any[]} Week days.
|
||||
* @param startingDay Starting day. 0=Sunday, 1=Monday, ...
|
||||
* @return Week days.
|
||||
*/
|
||||
getWeekDays(startingDay?: number): any[] {
|
||||
startingDay = startingDay || 0;
|
||||
|
@ -1361,9 +1361,9 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Invalidates access information.
|
||||
*
|
||||
* @param {number} [courseId] Course ID. If not defined, site calendar.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved when the data is invalidated.
|
||||
* @param courseId Course ID. If not defined, site calendar.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved when the data is invalidated.
|
||||
*/
|
||||
invalidateAccessInformation(courseId?: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -1374,9 +1374,9 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Invalidates allowed event types.
|
||||
*
|
||||
* @param {number} [courseId] Course ID. If not defined, site calendar.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved when the data is invalidated.
|
||||
* @param courseId Course ID. If not defined, site calendar.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved when the data is invalidated.
|
||||
*/
|
||||
invalidateAllowedEventTypes(courseId?: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -1387,8 +1387,8 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Invalidates day events for all days.
|
||||
*
|
||||
* @param {string} [siteId] Site Id. If not defined, use current site.
|
||||
* @return {Promise<any>} Promise resolved when the data is invalidated.
|
||||
* @param siteId Site Id. If not defined, use current site.
|
||||
* @return Promise resolved when the data is invalidated.
|
||||
*/
|
||||
invalidateAllDayEvents(siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -1399,10 +1399,10 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Invalidates day events for a certain day.
|
||||
*
|
||||
* @param {number} year Year.
|
||||
* @param {number} month Month.
|
||||
* @param {number} day Day.
|
||||
* @return {Promise<any>} Promise resolved when the data is invalidated.
|
||||
* @param year Year.
|
||||
* @param month Month.
|
||||
* @param day Day.
|
||||
* @return Promise resolved when the data is invalidated.
|
||||
*/
|
||||
invalidateDayEvents(year: number, month: number, day: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -1413,8 +1413,8 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Invalidates events list and all the single events and related info.
|
||||
*
|
||||
* @param {string} [siteId] Site Id. If not defined, use current site.
|
||||
* @return {Promise<any[]>} Promise resolved when the list is invalidated.
|
||||
* @param siteId Site Id. If not defined, use current site.
|
||||
* @return Promise resolved when the list is invalidated.
|
||||
*/
|
||||
invalidateEventsList(siteId?: string): Promise<any[]> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -1433,9 +1433,9 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Invalidates a single event.
|
||||
*
|
||||
* @param {number} eventId List of courses or course ids.
|
||||
* @param {string} [siteId] Site Id. If not defined, use current site.
|
||||
* @return {Promise<any>} Promise resolved when the list is invalidated.
|
||||
* @param eventId List of courses or course ids.
|
||||
* @param siteId Site Id. If not defined, use current site.
|
||||
* @return Promise resolved when the list is invalidated.
|
||||
*/
|
||||
invalidateEvent(eventId: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -1446,8 +1446,8 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Invalidates monthly events for all months.
|
||||
*
|
||||
* @param {string} [siteId] Site Id. If not defined, use current site.
|
||||
* @return {Promise<any>} Promise resolved when the data is invalidated.
|
||||
* @param siteId Site Id. If not defined, use current site.
|
||||
* @return Promise resolved when the data is invalidated.
|
||||
*/
|
||||
invalidateAllMonthlyEvents(siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -1458,9 +1458,9 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Invalidates monthly events for a certain months.
|
||||
*
|
||||
* @param {number} year Year.
|
||||
* @param {number} month Month.
|
||||
* @return {Promise<any>} Promise resolved when the data is invalidated.
|
||||
* @param year Year.
|
||||
* @param month Month.
|
||||
* @return Promise resolved when the data is invalidated.
|
||||
*/
|
||||
invalidateMonthlyEvents(year: number, month: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -1471,8 +1471,8 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Invalidates upcoming events for all courses and categories.
|
||||
*
|
||||
* @param {string} [siteId] Site Id. If not defined, use current site.
|
||||
* @return {Promise<any>} Promise resolved when the data is invalidated.
|
||||
* @param siteId Site Id. If not defined, use current site.
|
||||
* @return Promise resolved when the data is invalidated.
|
||||
*/
|
||||
invalidateAllUpcomingEvents(siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -1483,10 +1483,10 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Invalidates upcoming events for a certain course or category.
|
||||
*
|
||||
* @param {number} [courseId] Course ID.
|
||||
* @param {number} [categoryId] Category ID.
|
||||
* @param {string} [siteId] Site Id. If not defined, use current site.
|
||||
* @return {Promise<any>} Promise resolved when the data is invalidated.
|
||||
* @param courseId Course ID.
|
||||
* @param categoryId Category ID.
|
||||
* @param siteId Site Id. If not defined, use current site.
|
||||
* @return Promise resolved when the data is invalidated.
|
||||
*/
|
||||
invalidateUpcomingEvents(courseId?: number, categoryId?: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -1497,8 +1497,8 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Invalidates look ahead setting.
|
||||
*
|
||||
* @param {string} [siteId] Site Id. If not defined, use current site.
|
||||
* @return {Promise<any>} Promise resolved when the data is invalidated.
|
||||
* @param siteId Site Id. If not defined, use current site.
|
||||
* @return Promise resolved when the data is invalidated.
|
||||
*/
|
||||
invalidateLookAhead(siteId?: string): Promise<any> {
|
||||
return this.userProvider.invalidateUserPreference('calendar_lookahead', siteId);
|
||||
|
@ -1507,8 +1507,8 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Invalidates time format setting.
|
||||
*
|
||||
* @param {string} [siteId] Site Id. If not defined, use current site.
|
||||
* @return {Promise<any>} Promise resolved when the data is invalidated.
|
||||
* @param siteId Site Id. If not defined, use current site.
|
||||
* @return Promise resolved when the data is invalidated.
|
||||
*/
|
||||
invalidateTimeFormat(siteId?: string): Promise<any> {
|
||||
return this.userProvider.invalidateUserPreference('calendar_timeformat', siteId);
|
||||
|
@ -1517,8 +1517,8 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Check if Calendar is disabled in a certain site.
|
||||
*
|
||||
* @param {CoreSite} [site] Site. If not defined, use current site.
|
||||
* @return {boolean} Whether it's disabled.
|
||||
* @param site Site. If not defined, use current site.
|
||||
* @return Whether it's disabled.
|
||||
*/
|
||||
isCalendarDisabledInSite(site?: CoreSite): boolean {
|
||||
site = site || this.sitesProvider.getCurrentSite();
|
||||
|
@ -1529,8 +1529,8 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Check if Calendar is disabled in a certain site.
|
||||
*
|
||||
* @param {string} [siteId] Site Id. If not defined, use current site.
|
||||
* @return {Promise<boolean>} Promise resolved with true if disabled, rejected or resolved with false otherwise.
|
||||
* @param siteId Site Id. If not defined, use current site.
|
||||
* @return Promise resolved with true if disabled, rejected or resolved with false otherwise.
|
||||
*/
|
||||
isDisabled(siteId?: string): Promise<boolean> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -1541,8 +1541,8 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Check if the get event by ID WS is available.
|
||||
*
|
||||
* @param {string} [siteId] Site Id. If not defined, use current site.
|
||||
* @return {Promise<boolean>} Promise resolved with true if available.
|
||||
* @param siteId Site Id. If not defined, use current site.
|
||||
* @return Promise resolved with true if available.
|
||||
* @since 3.4
|
||||
*/
|
||||
isGetEventByIdAvailable(siteId?: string): Promise<boolean> {
|
||||
|
@ -1556,8 +1556,8 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Check if the get event by ID WS is available in a certain site.
|
||||
*
|
||||
* @param {CoreSite} [site] Site. If not defined, use current site.
|
||||
* @return {boolean} Whether it's available.
|
||||
* @param site Site. If not defined, use current site.
|
||||
* @return Whether it's available.
|
||||
* @since 3.4
|
||||
*/
|
||||
isGetEventByIdAvailableInSite(site?: CoreSite): boolean {
|
||||
|
@ -1571,7 +1571,7 @@ export class AddonCalendarProvider {
|
|||
* If an event notification time is 0, cancel its scheduled notification (if any).
|
||||
* If local notification plugin is not enabled, resolve the promise.
|
||||
*
|
||||
* @return {Promise} Promise resolved when all the notifications have been scheduled.
|
||||
* @return Promise resolved when all the notifications have been scheduled.
|
||||
*/
|
||||
scheduleAllSitesEventsNotifications(): Promise<any[]> {
|
||||
const notificationsEnabled = this.localNotificationsProvider.isAvailable();
|
||||
|
@ -1603,10 +1603,10 @@ export class AddonCalendarProvider {
|
|||
* Schedules an event notification. If time is 0, cancel scheduled notification if any.
|
||||
* If local notification plugin is not enabled, resolve the promise.
|
||||
*
|
||||
* @param {any} event Event to schedule.
|
||||
* @param {number} time Notification setting time (in minutes). E.g. 10 means "notificate 10 minutes before start".
|
||||
* @param {string} [siteId] Site ID the event belongs to. If not defined, use current site.
|
||||
* @return {Promise<void>} Promise resolved when the notification is scheduled.
|
||||
* @param event Event to schedule.
|
||||
* @param time Notification setting time (in minutes). E.g. 10 means "notificate 10 minutes before start".
|
||||
* @param siteId Site ID the event belongs to. If not defined, use current site.
|
||||
* @return Promise resolved when the notification is scheduled.
|
||||
*/
|
||||
protected scheduleEventNotification(event: any, reminderId: number, time: number, siteId?: string): Promise<void> {
|
||||
if (this.localNotificationsProvider.isAvailable()) {
|
||||
|
@ -1668,9 +1668,9 @@ export class AddonCalendarProvider {
|
|||
* If an event notification time is 0, cancel its scheduled notification (if any).
|
||||
* If local notification plugin is not enabled, resolve the promise.
|
||||
*
|
||||
* @param {any[]} events Events to schedule.
|
||||
* @param {string} [siteId] ID of the site the events belong to. If not defined, use current site.
|
||||
* @return {Promise<any[]>} Promise resolved when all the notifications have been scheduled.
|
||||
* @param events Events to schedule.
|
||||
* @param siteId ID of the site the events belong to. If not defined, use current site.
|
||||
* @return Promise resolved when all the notifications have been scheduled.
|
||||
*/
|
||||
scheduleEventsNotifications(events: any[], siteId?: string): Promise<any[]> {
|
||||
|
||||
|
@ -1699,9 +1699,9 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Set the default notification time.
|
||||
*
|
||||
* @param {number} time New default time.
|
||||
* @param {string} [siteId] ID of the site. If not defined, use current site.
|
||||
* @return {Promise<any[]>} Promise resolved when stored.
|
||||
* @param time New default time.
|
||||
* @param siteId ID of the site. If not defined, use current site.
|
||||
* @return Promise resolved when stored.
|
||||
*/
|
||||
setDefaultNotificationTime(time: number, siteId?: string): Promise<any[]> {
|
||||
siteId = siteId || this.sitesProvider.getCurrentSiteId();
|
||||
|
@ -1714,9 +1714,9 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Store an event in local DB as it is.
|
||||
*
|
||||
* @param {any} event Event to store.
|
||||
* @param {string} [siteId] ID of the site the event belongs to. If not defined, use current site.
|
||||
* @return {Promise<any>} Promise resolved when stored.
|
||||
* @param event Event to store.
|
||||
* @param siteId ID of the site the event belongs to. If not defined, use current site.
|
||||
* @return Promise resolved when stored.
|
||||
*/
|
||||
storeEventInLocalDb(event: any, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -1780,9 +1780,9 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Store events in local DB.
|
||||
*
|
||||
* @param {any[]} events Events to store.
|
||||
* @param {string} [siteId] ID of the site the event belongs to. If not defined, use current site.
|
||||
* @return {Promise<any[]>} Promise resolved when the events are stored.
|
||||
* @param events Events to store.
|
||||
* @param siteId ID of the site the event belongs to. If not defined, use current site.
|
||||
* @return Promise resolved when the events are stored.
|
||||
*/
|
||||
protected storeEventsInLocalDB(events: any[], siteId?: string): Promise<any[]> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -1798,13 +1798,13 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Submit a calendar event.
|
||||
*
|
||||
* @param {number} eventId ID of the event. If undefined/null, create a new event.
|
||||
* @param {any} formData Form data.
|
||||
* @param {number} [timeCreated] The time the event was created. Only if modifying a new offline event.
|
||||
* @param {boolean} [forceOffline] True to always save it in offline.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<{sent: boolean, event: any}>} Promise resolved with the event and a boolean indicating if data was
|
||||
* sent to server or stored in offline.
|
||||
* @param eventId ID of the event. If undefined/null, create a new event.
|
||||
* @param formData Form data.
|
||||
* @param timeCreated The time the event was created. Only if modifying a new offline event.
|
||||
* @param forceOffline True to always save it in offline.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with the event and a boolean indicating if data was
|
||||
* sent to server or stored in offline.
|
||||
*/
|
||||
submitEvent(eventId: number, formData: any, timeCreated?: number, forceOffline?: boolean, siteId?: string):
|
||||
Promise<{sent: boolean, event: any}> {
|
||||
|
@ -1842,10 +1842,10 @@ export class AddonCalendarProvider {
|
|||
/**
|
||||
* Submit an event, either to create it or to edit it. It will fail if offline or cannot connect.
|
||||
*
|
||||
* @param {number} eventId ID of the event. If undefined/null, create a new event.
|
||||
* @param {any} formData Form data.
|
||||
* @param {string} [siteId] Site ID. If not provided, current site.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param eventId ID of the event. If undefined/null, create a new event.
|
||||
* @param formData Form data.
|
||||
* @param siteId Site ID. If not provided, current site.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
submitEventOnline(eventId: number, formData: any, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
|
|
@ -49,8 +49,8 @@ export class AddonCalendarHelperProvider {
|
|||
/**
|
||||
* Calculate some day data based on a list of events for that day.
|
||||
*
|
||||
* @param {any} day Day.
|
||||
* @param {any[]} events Events.
|
||||
* @param day Day.
|
||||
* @param events Events.
|
||||
*/
|
||||
calculateDayData(day: any, events: any[]): void {
|
||||
day.hasevents = events.length > 0;
|
||||
|
@ -71,9 +71,9 @@ export class AddonCalendarHelperProvider {
|
|||
/**
|
||||
* Check if current user can create/edit events.
|
||||
*
|
||||
* @param {number} [courseId] Course ID. If not defined, site calendar.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<boolean>} Promise resolved with boolean: whether the user can create events.
|
||||
* @param courseId Course ID. If not defined, site calendar.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with boolean: whether the user can create events.
|
||||
*/
|
||||
canEditEvents(courseId?: number, siteId?: string): Promise<boolean> {
|
||||
return this.calendarProvider.canEditEvents(siteId).then((canEdit) => {
|
||||
|
@ -94,8 +94,8 @@ export class AddonCalendarHelperProvider {
|
|||
* Classify events into their respective months and days. If an event duration covers more than one day,
|
||||
* it will be included in all the days it lasts.
|
||||
*
|
||||
* @param {any[]} events Events to classify.
|
||||
* @return {{[monthId: string]: {[day: number]: any[]}}} Object with the classified events.
|
||||
* @param events Events to classify.
|
||||
* @return Object with the classified events.
|
||||
*/
|
||||
classifyIntoMonths(events: any[]): {[monthId: string]: {[day: number]: any[]}} {
|
||||
|
||||
|
@ -128,7 +128,7 @@ export class AddonCalendarHelperProvider {
|
|||
/**
|
||||
* Convenience function to format some event data to be rendered.
|
||||
*
|
||||
* @param {any} e Event to format.
|
||||
* @param e Event to format.
|
||||
*/
|
||||
formatEventData(e: any): void {
|
||||
e.icon = this.EVENTICONS[e.eventtype] || false;
|
||||
|
@ -157,8 +157,8 @@ export class AddonCalendarHelperProvider {
|
|||
/**
|
||||
* Get options (name & value) for each allowed event type.
|
||||
*
|
||||
* @param {any} eventTypes Result of getAllowedEventTypes.
|
||||
* @return {{name: string, value: string}[]} Options.
|
||||
* @param eventTypes Result of getAllowedEventTypes.
|
||||
* @return Options.
|
||||
*/
|
||||
getEventTypeOptions(eventTypes: any): {name: string, value: string}[] {
|
||||
const options = [];
|
||||
|
@ -185,9 +185,9 @@ export class AddonCalendarHelperProvider {
|
|||
/**
|
||||
* Get the month "id" (year + month).
|
||||
*
|
||||
* @param {number} year Year.
|
||||
* @param {number} month Month.
|
||||
* @return {string} The "id".
|
||||
* @param year Year.
|
||||
* @param month Month.
|
||||
* @return The "id".
|
||||
*/
|
||||
getMonthId(year: number, month: number): string {
|
||||
return year + '#' + month;
|
||||
|
@ -198,10 +198,10 @@ export class AddonCalendarHelperProvider {
|
|||
*
|
||||
* The result has the same structure than getMonthlyEvents, but it only contains fields that are actually used by the app.
|
||||
*
|
||||
* @param {number} year Year to get.
|
||||
* @param {number} month Month to get.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved with the response.
|
||||
* @param year Year to get.
|
||||
* @param month Month to get.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with the response.
|
||||
*/
|
||||
getOfflineMonthWeeks(year: number, month: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -256,9 +256,9 @@ export class AddonCalendarHelperProvider {
|
|||
/**
|
||||
* Check if the data of an event has changed.
|
||||
*
|
||||
* @param {any} data Current data.
|
||||
* @param {any} [original] Original data.
|
||||
* @return {boolean} True if data has changed, false otherwise.
|
||||
* @param data Current data.
|
||||
* @param original Original data.
|
||||
* @return True if data has changed, false otherwise.
|
||||
*/
|
||||
hasEventDataChanged(data: any, original?: any): boolean {
|
||||
if (!original) {
|
||||
|
@ -297,11 +297,11 @@ export class AddonCalendarHelperProvider {
|
|||
/**
|
||||
* Check if an event should be displayed based on the filter.
|
||||
*
|
||||
* @param {any} event Event object.
|
||||
* @param {number} courseId Course ID to filter.
|
||||
* @param {number} categoryId Category ID the course belongs to.
|
||||
* @param {any} categories Categories indexed by ID.
|
||||
* @return {boolean} Whether it should be displayed.
|
||||
* @param event Event object.
|
||||
* @param courseId Course ID to filter.
|
||||
* @param categoryId Category ID the course belongs to.
|
||||
* @param categories Categories indexed by ID.
|
||||
* @return Whether it should be displayed.
|
||||
*/
|
||||
shouldDisplayEvent(event: any, courseId: number, categoryId: number, categories: any): boolean {
|
||||
if (event.eventtype == 'user' || event.eventtype == 'site') {
|
||||
|
@ -345,9 +345,9 @@ export class AddonCalendarHelperProvider {
|
|||
* Refresh the month & day for several created/edited/deleted events, and invalidate the months & days
|
||||
* for their repeated events if needed.
|
||||
*
|
||||
* @param {{event: any, repeated: number}[]} events Events that have been touched and number of times each event is repeated.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Resolved when done.
|
||||
* @param events Events that have been touched and number of times each event is repeated.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Resolved when done.
|
||||
*/
|
||||
refreshAfterChangeEvents(events: {event: any, repeated: number}[], siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -458,10 +458,10 @@ export class AddonCalendarHelperProvider {
|
|||
* Refresh the month & day for a created/edited/deleted event, and invalidate the months & days
|
||||
* for their repeated events if needed.
|
||||
*
|
||||
* @param {any} event Event that has been touched.
|
||||
* @param {number} repeated Number of times the event is repeated.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Resolved when done.
|
||||
* @param event Event that has been touched.
|
||||
* @param repeated Number of times the event is repeated.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Resolved when done.
|
||||
*/
|
||||
refreshAfterChangeEvent(event: any, repeated: number, siteId?: string): Promise<any> {
|
||||
return this.refreshAfterChangeEvents([{event: event, repeated: repeated}], siteId);
|
||||
|
|
|
@ -29,7 +29,7 @@ export class AddonCalendarMainMenuHandler implements CoreMainMenuHandler {
|
|||
/**
|
||||
* Check if the handler is enabled on a site level.
|
||||
*
|
||||
* @return {boolean} Whether or not the handler is enabled on a site level.
|
||||
* @return Whether or not the handler is enabled on a site level.
|
||||
*/
|
||||
isEnabled(): boolean | Promise<boolean> {
|
||||
return !this.calendarProvider.isCalendarDisabledInSite();
|
||||
|
@ -38,7 +38,7 @@ export class AddonCalendarMainMenuHandler implements CoreMainMenuHandler {
|
|||
/**
|
||||
* Returns the data needed to render the handler.
|
||||
*
|
||||
* @return {CoreMainMenuHandlerData} Data needed to render the handler.
|
||||
* @return Data needed to render the handler.
|
||||
*/
|
||||
getDisplayData(): CoreMainMenuHandlerData {
|
||||
return {
|
||||
|
|
|
@ -29,9 +29,9 @@ export class AddonCalendarSyncCronHandler implements CoreCronHandler {
|
|||
* Execute the process.
|
||||
* Receives the ID of the site affected, undefined for all sites.
|
||||
*
|
||||
* @param {string} [siteId] ID of the site affected, undefined for all sites.
|
||||
* @param {boolean} [force] Wether the execution is forced (manual sync).
|
||||
* @return {Promise<any>} Promise resolved when done, rejected if failure.
|
||||
* @param siteId ID of the site affected, undefined for all sites.
|
||||
* @param force Wether the execution is forced (manual sync).
|
||||
* @return Promise resolved when done, rejected if failure.
|
||||
*/
|
||||
execute(siteId?: string, force?: boolean): Promise<any> {
|
||||
return this.calendarSync.syncAllEvents(siteId, force);
|
||||
|
@ -40,7 +40,7 @@ export class AddonCalendarSyncCronHandler implements CoreCronHandler {
|
|||
/**
|
||||
* Get the time between consecutive executions.
|
||||
*
|
||||
* @return {number} Time between consecutive executions (in ms).
|
||||
* @return Time between consecutive executions (in ms).
|
||||
*/
|
||||
getInterval(): number {
|
||||
return this.calendarSync.syncInterval;
|
||||
|
|
|
@ -35,11 +35,11 @@ export class AddonCalendarViewLinkHandler extends CoreContentLinksHandlerBase {
|
|||
/**
|
||||
* Get the list of actions for a link (url).
|
||||
*
|
||||
* @param {string[]} siteIds List of sites the URL belongs to.
|
||||
* @param {string} url The URL to treat.
|
||||
* @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param {number} [courseId] Course ID related to the URL. Optional but recommended.
|
||||
* @return {CoreContentLinksAction[]|Promise<CoreContentLinksAction[]>} List of (or promise resolved with list of) actions.
|
||||
* @param siteIds List of sites the URL belongs to.
|
||||
* @param url The URL to treat.
|
||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||
* @return List of (or promise resolved with list of) actions.
|
||||
*/
|
||||
getActions(siteIds: string[], url: string, params: any, courseId?: number):
|
||||
CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> {
|
||||
|
@ -90,11 +90,11 @@ export class AddonCalendarViewLinkHandler extends CoreContentLinksHandlerBase {
|
|||
* Check if the handler is enabled for a certain site (site + user) and a URL.
|
||||
* If not defined, defaults to true.
|
||||
*
|
||||
* @param {string} siteId The site ID.
|
||||
* @param {string} url The URL to treat.
|
||||
* @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param {number} [courseId] Course ID related to the URL. Optional but recommended.
|
||||
* @return {boolean|Promise<boolean>} Whether the handler is enabled for the URL and site.
|
||||
* @param siteId The site ID.
|
||||
* @param url The URL to treat.
|
||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||
* @return Whether the handler is enabled for the URL and site.
|
||||
*/
|
||||
isEnabled(siteId: string, url: string, params: any, courseId?: number): boolean | Promise<boolean> {
|
||||
if (params.view && this.SUPPORTED_VIEWS.indexOf(params.view) == -1) {
|
||||
|
|
|
@ -52,7 +52,7 @@ export class AddonCompetencyCourseComponent {
|
|||
/**
|
||||
* Fetches the competencies and updates the view.
|
||||
*
|
||||
* @return {Promise<void>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected fetchCourseCompetencies(): Promise<void> {
|
||||
return this.competencyProvider.getCourseCompetencies(this.courseId, this.userId).then((competencies) => {
|
||||
|
@ -70,7 +70,7 @@ export class AddonCompetencyCourseComponent {
|
|||
/**
|
||||
* Opens a competency.
|
||||
*
|
||||
* @param {number} competencyId
|
||||
* @param competencyId
|
||||
*/
|
||||
openCompetency(competencyId: number): void {
|
||||
if (this.appProvider.isWide()) {
|
||||
|
@ -83,7 +83,7 @@ export class AddonCompetencyCourseComponent {
|
|||
/**
|
||||
* Opens the summary of a competency.
|
||||
*
|
||||
* @param {number} competencyId
|
||||
* @param competencyId
|
||||
*/
|
||||
openCompetencySummary(competencyId: number): void {
|
||||
this.navCtrl.push('AddonCompetencyCompetencySummaryPage', {competencyId});
|
||||
|
@ -92,7 +92,7 @@ export class AddonCompetencyCourseComponent {
|
|||
/**
|
||||
* Refreshes the competencies.
|
||||
*
|
||||
* @param {any} refresher Refresher.
|
||||
* @param refresher Refresher.
|
||||
*/
|
||||
refreshCourseCompetencies(refresher: any): void {
|
||||
this.competencyProvider.invalidateCourseCompetencies(this.courseId, this.userId).finally(() => {
|
||||
|
|
|
@ -69,7 +69,7 @@ export class AddonCompetencyCompetenciesPage {
|
|||
/**
|
||||
* Fetches the competencies and updates the view.
|
||||
*
|
||||
* @return {Promise<void>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected fetchCompetencies(): Promise<void> {
|
||||
let promise;
|
||||
|
@ -102,7 +102,7 @@ export class AddonCompetencyCompetenciesPage {
|
|||
/**
|
||||
* Opens a competency.
|
||||
*
|
||||
* @param {number} competencyId
|
||||
* @param competencyId
|
||||
*/
|
||||
openCompetency(competencyId: number): void {
|
||||
this.competencyId = competencyId;
|
||||
|
@ -118,7 +118,7 @@ export class AddonCompetencyCompetenciesPage {
|
|||
/**
|
||||
* Refreshes the competencies.
|
||||
*
|
||||
* @param {any} refresher Refresher.
|
||||
* @param refresher Refresher.
|
||||
*/
|
||||
refreshCompetencies(refresher: any): void {
|
||||
let promise;
|
||||
|
|
|
@ -76,7 +76,7 @@ export class AddonCompetencyCompetencyPage {
|
|||
/**
|
||||
* Fetches the competency and updates the view.
|
||||
*
|
||||
* @return {Promise<void>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected fetchCompetency(): Promise<void> {
|
||||
let promise;
|
||||
|
@ -124,7 +124,7 @@ export class AddonCompetencyCompetencyPage {
|
|||
/**
|
||||
* Refreshes the competency.
|
||||
*
|
||||
* @param {any} refresher Refresher.
|
||||
* @param refresher Refresher.
|
||||
*/
|
||||
refreshCompetency(refresher: any): void {
|
||||
let promise;
|
||||
|
@ -144,7 +144,7 @@ export class AddonCompetencyCompetencyPage {
|
|||
/**
|
||||
* Opens the summary of a competency.
|
||||
*
|
||||
* @param {number} competencyId
|
||||
* @param competencyId
|
||||
*/
|
||||
openCompetencySummary(competencyId: number): void {
|
||||
// Decide which navCtrl to use. If this page is inside a split view, use the split view's master nav.
|
||||
|
|
|
@ -55,7 +55,7 @@ export class AddonCompetencyCompetencySummaryPage {
|
|||
/**
|
||||
* Fetches the competency summary and updates the view.
|
||||
*
|
||||
* @return {Promise<void>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected fetchCompetency(): Promise<void> {
|
||||
return this.competencyProvider.getCompetencySummary(this.competencyId).then((competency) => {
|
||||
|
@ -68,7 +68,7 @@ export class AddonCompetencyCompetencySummaryPage {
|
|||
/**
|
||||
* Refreshes the competency summary.
|
||||
*
|
||||
* @param {any} refresher Refresher.
|
||||
* @param refresher Refresher.
|
||||
*/
|
||||
refreshCompetency(refresher: any): void {
|
||||
this.competencyProvider.invalidateCompetencySummary(this.competencyId).finally(() => {
|
||||
|
@ -81,7 +81,7 @@ export class AddonCompetencyCompetencySummaryPage {
|
|||
/**
|
||||
* Opens the summary of a competency.
|
||||
*
|
||||
* @param {number} competencyId
|
||||
* @param competencyId
|
||||
*/
|
||||
openCompetencySummary(competencyId: number): void {
|
||||
// Decide which navCtrl to use. If this page is inside a split view, use the split view's master nav.
|
||||
|
|
|
@ -52,7 +52,7 @@ export class AddonCompetencyPlanPage {
|
|||
/**
|
||||
* Fetches the learning plan and updates the view.
|
||||
*
|
||||
* @return {Promise<void>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected fetchLearningPlan(): Promise<void> {
|
||||
return this.competencyProvider.getLearningPlan(this.planId).then((plan) => {
|
||||
|
@ -74,7 +74,7 @@ export class AddonCompetencyPlanPage {
|
|||
/**
|
||||
* Navigates to a particular competency.
|
||||
*
|
||||
* @param {number} competencyId
|
||||
* @param competencyId
|
||||
*/
|
||||
openCompetency(competencyId: number): void {
|
||||
const navCtrl = this.svComponent ? this.svComponent.getMasterNav() : this.navCtrl;
|
||||
|
@ -88,7 +88,7 @@ export class AddonCompetencyPlanPage {
|
|||
/**
|
||||
* Refreshes the learning plan.
|
||||
*
|
||||
* @param {any} refresher Refresher.
|
||||
* @param refresher Refresher.
|
||||
*/
|
||||
refreshLearningPlan(refresher: any): void {
|
||||
this.competencyProvider.invalidateLearningPlan(this.planId).finally(() => {
|
||||
|
|
|
@ -62,7 +62,7 @@ export class AddonCompetencyPlanListPage {
|
|||
/**
|
||||
* Fetches the learning plans and updates the view.
|
||||
*
|
||||
* @return {Promise<void>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected fetchLearningPlans(): Promise<void> {
|
||||
return this.competencyProvider.getLearningPlans(this.userId).then((plans) => {
|
||||
|
@ -89,7 +89,7 @@ export class AddonCompetencyPlanListPage {
|
|||
/**
|
||||
* Refreshes the learning plans.
|
||||
*
|
||||
* @param {any} refresher Refresher.
|
||||
* @param refresher Refresher.
|
||||
*/
|
||||
refreshLearningPlans(refresher: any): void {
|
||||
this.competencyProvider.invalidateLearningPlans(this.userId).finally(() => {
|
||||
|
@ -102,7 +102,7 @@ export class AddonCompetencyPlanListPage {
|
|||
/**
|
||||
* Opens a learning plan.
|
||||
*
|
||||
* @param {number} planId Learning plan to load.
|
||||
* @param planId Learning plan to load.
|
||||
*/
|
||||
openPlan(planId: number): void {
|
||||
this.planId = planId;
|
||||
|
|
|
@ -33,11 +33,11 @@ export class AddonCompetencyCompetencyLinkHandler extends CoreContentLinksHandle
|
|||
/**
|
||||
* Get the list of actions for a link (url).
|
||||
*
|
||||
* @param {string[]} siteIds List of sites the URL belongs to.
|
||||
* @param {string} url The URL to treat.
|
||||
* @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param {number} [courseId] Course ID related to the URL. Optional but recommended.
|
||||
* @return {CoreContentLinksAction[]|Promise<CoreContentLinksAction[]>} List of (or promise resolved with list of) actions.
|
||||
* @param siteIds List of sites the URL belongs to.
|
||||
* @param url The URL to treat.
|
||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||
* @return List of (or promise resolved with list of) actions.
|
||||
*/
|
||||
getActions(siteIds: string[], url: string, params: any, courseId?: number):
|
||||
CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> {
|
||||
|
@ -59,11 +59,11 @@ export class AddonCompetencyCompetencyLinkHandler extends CoreContentLinksHandle
|
|||
* Check if the handler is enabled for a certain site (site + user) and a URL.
|
||||
* If not defined, defaults to true.
|
||||
*
|
||||
* @param {string} siteId The site ID.
|
||||
* @param {string} url The URL to treat.
|
||||
* @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param {number} [courseId] Course ID related to the URL. Optional but recommended.
|
||||
* @return {boolean|Promise<boolean>} Whether the handler is enabled for the URL and site.
|
||||
* @param siteId The site ID.
|
||||
* @param url The URL to treat.
|
||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||
* @return Whether the handler is enabled for the URL and site.
|
||||
*/
|
||||
isEnabled(siteId: string, url: string, params: any, courseId?: number): boolean | Promise<boolean> {
|
||||
// Handler is disabled if all competency features are disabled.
|
||||
|
|
|
@ -48,8 +48,8 @@ export class AddonCompetencyProvider {
|
|||
/**
|
||||
* Check if all competencies features are disabled.
|
||||
*
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<boolean>} Promise resolved with boolean: whether all competency features are disabled.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with boolean: whether all competency features are disabled.
|
||||
*/
|
||||
allCompetenciesDisabled(siteId?: string): Promise<boolean> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -62,8 +62,8 @@ export class AddonCompetencyProvider {
|
|||
/**
|
||||
* Get cache key for user learning plans data WS calls.
|
||||
*
|
||||
* @param {number} userId User ID.
|
||||
* @return {string} Cache key.
|
||||
* @param userId User ID.
|
||||
* @return Cache key.
|
||||
*/
|
||||
protected getLearningPlansCacheKey(userId: number): string {
|
||||
return this.ROOT_CACHE_KEY + 'userplans:' + userId;
|
||||
|
@ -72,8 +72,8 @@ export class AddonCompetencyProvider {
|
|||
/**
|
||||
* Get cache key for learning plan data WS calls.
|
||||
*
|
||||
* @param {number} planId Plan ID.
|
||||
* @return {string} Cache key.
|
||||
* @param planId Plan ID.
|
||||
* @return Cache key.
|
||||
*/
|
||||
protected getLearningPlanCacheKey(planId: number): string {
|
||||
return this.ROOT_CACHE_KEY + 'learningplan:' + planId;
|
||||
|
@ -82,9 +82,9 @@ export class AddonCompetencyProvider {
|
|||
/**
|
||||
* Get cache key for competency in plan data WS calls.
|
||||
*
|
||||
* @param {number} planId Plan ID.
|
||||
* @param {number} competencyId Competency ID.
|
||||
* @return {string} Cache key.
|
||||
* @param planId Plan ID.
|
||||
* @param competencyId Competency ID.
|
||||
* @return Cache key.
|
||||
*/
|
||||
protected getCompetencyInPlanCacheKey(planId: number, competencyId: number): string {
|
||||
return this.ROOT_CACHE_KEY + 'plancompetency:' + planId + ':' + competencyId;
|
||||
|
@ -93,10 +93,10 @@ export class AddonCompetencyProvider {
|
|||
/**
|
||||
* Get cache key for competency in course data WS calls.
|
||||
*
|
||||
* @param {number} courseId Course ID.
|
||||
* @param {number} competencyId Competency ID.
|
||||
* @param {number} userId User ID.
|
||||
* @return {string} Cache key.
|
||||
* @param courseId Course ID.
|
||||
* @param competencyId Competency ID.
|
||||
* @param userId User ID.
|
||||
* @return Cache key.
|
||||
*/
|
||||
protected getCompetencyInCourseCacheKey(courseId: number, competencyId: number, userId: number): string {
|
||||
return this.ROOT_CACHE_KEY + 'coursecompetency:' + userId + ':' + courseId + ':' + competencyId;
|
||||
|
@ -105,9 +105,9 @@ export class AddonCompetencyProvider {
|
|||
/**
|
||||
* Get cache key for competency summary data WS calls.
|
||||
*
|
||||
* @param {number} competencyId Competency ID.
|
||||
* @param {number} userId User ID.
|
||||
* @return {string} Cache key.
|
||||
* @param competencyId Competency ID.
|
||||
* @param userId User ID.
|
||||
* @return Cache key.
|
||||
*/
|
||||
protected getCompetencySummaryCacheKey(competencyId: number, userId: number): string {
|
||||
return this.ROOT_CACHE_KEY + 'competencysummary:' + userId + ':' + competencyId;
|
||||
|
@ -116,8 +116,8 @@ export class AddonCompetencyProvider {
|
|||
/**
|
||||
* Get cache key for course competencies data WS calls.
|
||||
*
|
||||
* @param {number} courseId Course ID.
|
||||
* @return {string} Cache key.
|
||||
* @param courseId Course ID.
|
||||
* @return Cache key.
|
||||
*/
|
||||
protected getCourseCompetenciesCacheKey(courseId: number): string {
|
||||
return this.ROOT_CACHE_KEY + 'coursecompetencies:' + courseId;
|
||||
|
@ -126,9 +126,9 @@ export class AddonCompetencyProvider {
|
|||
/**
|
||||
* Returns whether competencies are enabled.
|
||||
*
|
||||
* @param {number} courseId Course ID.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} competencies if enabled for the given course, false otherwise.
|
||||
* @param courseId Course ID.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return competencies if enabled for the given course, false otherwise.
|
||||
*/
|
||||
isPluginForCourseEnabled(courseId: number, siteId?: string): Promise<any> {
|
||||
if (!this.sitesProvider.isLoggedIn()) {
|
||||
|
@ -143,9 +143,9 @@ export class AddonCompetencyProvider {
|
|||
/**
|
||||
* Get plans for a certain user.
|
||||
*
|
||||
* @param {number} [userId] ID of the user. If not defined, current user.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise to be resolved when the plans are retrieved.
|
||||
* @param userId ID of the user. If not defined, current user.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise to be resolved when the plans are retrieved.
|
||||
*/
|
||||
getLearningPlans(userId?: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -174,9 +174,9 @@ export class AddonCompetencyProvider {
|
|||
/**
|
||||
* Get a certain plan.
|
||||
*
|
||||
* @param {number} planId ID of the plan.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise to be resolved when the plans are retrieved.
|
||||
* @param planId ID of the plan.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise to be resolved when the plans are retrieved.
|
||||
*/
|
||||
getLearningPlan(planId: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -204,10 +204,10 @@ export class AddonCompetencyProvider {
|
|||
/**
|
||||
* Get a certain competency in a plan.
|
||||
*
|
||||
* @param {number} planId ID of the plan.
|
||||
* @param {number} competencyId ID of the competency.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise to be resolved when the plans are retrieved.
|
||||
* @param planId ID of the plan.
|
||||
* @param competencyId ID of the competency.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise to be resolved when the plans are retrieved.
|
||||
*/
|
||||
getCompetencyInPlan(planId: number, competencyId: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -236,12 +236,12 @@ export class AddonCompetencyProvider {
|
|||
/**
|
||||
* Get a certain competency in a course.
|
||||
*
|
||||
* @param {number} courseId ID of the course.
|
||||
* @param {number} competencyId ID of the competency.
|
||||
* @param {number} [userId] ID of the user. If not defined, current user.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @param {boolean} [ignoreCache] True if it should ignore cached data (it will always fail in offline or server down).
|
||||
* @return {Promise<any>} Promise to be resolved when the plans are retrieved.
|
||||
* @param courseId ID of the course.
|
||||
* @param competencyId ID of the competency.
|
||||
* @param userId ID of the user. If not defined, current user.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @param ignoreCache True if it should ignore cached data (it will always fail in offline or server down).
|
||||
* @return Promise to be resolved when the plans are retrieved.
|
||||
*/
|
||||
getCompetencyInCourse(courseId: number, competencyId: number, userId?: number, siteId?: string, ignoreCache?: boolean)
|
||||
: Promise<any> {
|
||||
|
@ -279,11 +279,11 @@ export class AddonCompetencyProvider {
|
|||
/**
|
||||
* Get a certain competency summary.
|
||||
*
|
||||
* @param {number} competencyId ID of the competency.
|
||||
* @param {number} [userId] ID of the user. If not defined, current user.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @param {boolean} [ignoreCache] True if it should ignore cached data (it will always fail in offline or server down).
|
||||
* @return {Promise<any>} Promise to be resolved when the plans are retrieved.
|
||||
* @param competencyId ID of the competency.
|
||||
* @param userId ID of the user. If not defined, current user.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @param ignoreCache True if it should ignore cached data (it will always fail in offline or server down).
|
||||
* @return Promise to be resolved when the plans are retrieved.
|
||||
*/
|
||||
getCompetencySummary(competencyId: number, userId?: number, siteId?: string, ignoreCache?: boolean): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -318,11 +318,11 @@ export class AddonCompetencyProvider {
|
|||
/**
|
||||
* Get all competencies in a course.
|
||||
*
|
||||
* @param {number} courseId ID of the course.
|
||||
* @param {number} [userId] ID of the user.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @param {boolean} [ignoreCache] True if it should ignore cached data (it will always fail in offline or server down).
|
||||
* @return {Promise<any>} Promise to be resolved when the course competencies are retrieved.
|
||||
* @param courseId ID of the course.
|
||||
* @param userId ID of the user.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @param ignoreCache True if it should ignore cached data (it will always fail in offline or server down).
|
||||
* @return Promise to be resolved when the course competencies are retrieved.
|
||||
*/
|
||||
getCourseCompetencies(courseId: number, userId?: number, siteId?: string, ignoreCache?: boolean): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -373,9 +373,9 @@ export class AddonCompetencyProvider {
|
|||
/**
|
||||
* Invalidates User Learning Plans data.
|
||||
*
|
||||
* @param {number} [userId] ID of the user. If not defined, current user.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved when the data is invalidated.
|
||||
* @param userId ID of the user. If not defined, current user.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved when the data is invalidated.
|
||||
*/
|
||||
invalidateLearningPlans(userId?: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -388,9 +388,9 @@ export class AddonCompetencyProvider {
|
|||
/**
|
||||
* Invalidates Learning Plan data.
|
||||
*
|
||||
* @param {number} planId ID of the plan.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved when the data is invalidated.
|
||||
* @param planId ID of the plan.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved when the data is invalidated.
|
||||
*/
|
||||
invalidateLearningPlan(planId: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -401,10 +401,10 @@ export class AddonCompetencyProvider {
|
|||
/**
|
||||
* Invalidates Competency in Plan data.
|
||||
*
|
||||
* @param {number} planId ID of the plan.
|
||||
* @param {number} competencyId ID of the competency.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved when the data is invalidated.
|
||||
* @param planId ID of the plan.
|
||||
* @param competencyId ID of the competency.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved when the data is invalidated.
|
||||
*/
|
||||
invalidateCompetencyInPlan(planId: number, competencyId: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -415,11 +415,11 @@ export class AddonCompetencyProvider {
|
|||
/**
|
||||
* Invalidates Competency in Course data.
|
||||
*
|
||||
* @param {number} courseId ID of the course.
|
||||
* @param {number} competencyId ID of the competency.
|
||||
* @param {number} [userId] ID of the user. If not defined, current user.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved when the data is invalidated.
|
||||
* @param courseId ID of the course.
|
||||
* @param competencyId ID of the competency.
|
||||
* @param userId ID of the user. If not defined, current user.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved when the data is invalidated.
|
||||
*/
|
||||
invalidateCompetencyInCourse(courseId: number, competencyId: number, userId?: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -432,10 +432,10 @@ export class AddonCompetencyProvider {
|
|||
/**
|
||||
* Invalidates Competency Summary data.
|
||||
*
|
||||
* @param {number} competencyId ID of the competency.
|
||||
* @param {number} [userId] ID of the user. If not defined, current user.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved when the data is invalidated.
|
||||
* @param competencyId ID of the competency.
|
||||
* @param userId ID of the user. If not defined, current user.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved when the data is invalidated.
|
||||
*/
|
||||
invalidateCompetencySummary(competencyId: number, userId?: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -448,10 +448,10 @@ export class AddonCompetencyProvider {
|
|||
/**
|
||||
* Invalidates Course Competencies data.
|
||||
*
|
||||
* @param {number} courseId ID of the course.
|
||||
* @param {number} [userId] ID of the user.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved when the data is invalidated.
|
||||
* @param courseId ID of the course.
|
||||
* @param userId ID of the user.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved when the data is invalidated.
|
||||
*/
|
||||
invalidateCourseCompetencies(courseId: number, userId?: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -477,13 +477,13 @@ export class AddonCompetencyProvider {
|
|||
/**
|
||||
* Report the competency as being viewed in plan.
|
||||
*
|
||||
* @param {number} planId ID of the plan.
|
||||
* @param {number} competencyId ID of the competency.
|
||||
* @param {number} planStatus Current plan Status to decide what action should be logged.
|
||||
* @param {string} [name] Name of the competency.
|
||||
* @param {number} [userId] User ID. If not defined, current user.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved when the WS call is successful.
|
||||
* @param planId ID of the plan.
|
||||
* @param competencyId ID of the competency.
|
||||
* @param planStatus Current plan Status to decide what action should be logged.
|
||||
* @param name Name of the competency.
|
||||
* @param userId User ID. If not defined, current user.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved when the WS call is successful.
|
||||
*/
|
||||
logCompetencyInPlanView(planId: number, competencyId: number, planStatus: number, name?: string, userId?: number,
|
||||
siteId?: string): Promise<any> {
|
||||
|
@ -519,12 +519,12 @@ export class AddonCompetencyProvider {
|
|||
/**
|
||||
* Report the competency as being viewed in course.
|
||||
*
|
||||
* @param {number} courseId ID of the course.
|
||||
* @param {number} competencyId ID of the competency.
|
||||
* @param {string} [name] Name of the competency.
|
||||
* @param {number} [userId] User ID. If not defined, current user.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved when the WS call is successful.
|
||||
* @param courseId ID of the course.
|
||||
* @param competencyId ID of the competency.
|
||||
* @param name Name of the competency.
|
||||
* @param userId User ID. If not defined, current user.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved when the WS call is successful.
|
||||
*/
|
||||
logCompetencyInCourseView(courseId: number, competencyId: number, name?: string, userId?: number, siteId?: string)
|
||||
: Promise<any> {
|
||||
|
@ -558,10 +558,10 @@ export class AddonCompetencyProvider {
|
|||
/**
|
||||
* Report the competency as being viewed.
|
||||
*
|
||||
* @param {number} competencyId ID of the competency.
|
||||
* @param {string} [name] Name of the competency.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved when the WS call is successful.
|
||||
* @param competencyId ID of the competency.
|
||||
* @param name Name of the competency.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved when the WS call is successful.
|
||||
*/
|
||||
logCompetencyView(competencyId: number, name?: string, siteId?: string): Promise<any> {
|
||||
if (competencyId) {
|
||||
|
|
|
@ -30,7 +30,7 @@ export class AddonCompetencyCourseOptionHandler implements CoreCourseOptionsHand
|
|||
|
||||
/**
|
||||
* Whether or not the handler is enabled ona site level.
|
||||
* @return {boolean|Promise<boolean>} Whether or not the handler is enabled on a site level.
|
||||
* @return Whether or not the handler is enabled on a site level.
|
||||
*/
|
||||
isEnabled(): boolean | Promise<boolean> {
|
||||
return true;
|
||||
|
@ -39,11 +39,11 @@ export class AddonCompetencyCourseOptionHandler implements CoreCourseOptionsHand
|
|||
/**
|
||||
* Whether or not the handler is enabled for a certain course.
|
||||
*
|
||||
* @param {number} courseId The course ID.
|
||||
* @param {any} accessData Access type and data. Default, guest, ...
|
||||
* @param {any} [navOptions] Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
|
||||
* @param {any} [admOptions] Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
|
||||
* @return {boolean|Promise<boolean>} True or promise resolved with true if enabled.
|
||||
* @param courseId The course ID.
|
||||
* @param accessData Access type and data. Default, guest, ...
|
||||
* @param navOptions Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
|
||||
* @param admOptions Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
|
||||
* @return True or promise resolved with true if enabled.
|
||||
*/
|
||||
isEnabledForCourse(courseId: number, accessData: any, navOptions?: any, admOptions?: any): boolean | Promise<boolean> {
|
||||
if (accessData && accessData.type == CoreCourseProvider.ACCESS_GUEST) {
|
||||
|
@ -62,9 +62,9 @@ export class AddonCompetencyCourseOptionHandler implements CoreCourseOptionsHand
|
|||
/**
|
||||
* Returns the data needed to render the handler.
|
||||
*
|
||||
* @param {Injector} injector Injector.
|
||||
* @param {number} course The course.
|
||||
* @return {CoreCourseOptionsHandlerData|Promise<CoreCourseOptionsHandlerData>} Data or promise resolved with the data.
|
||||
* @param injector Injector.
|
||||
* @param course The course.
|
||||
* @return Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData?(injector: Injector, course: any): CoreCourseOptionsHandlerData | Promise<CoreCourseOptionsHandlerData> {
|
||||
return {
|
||||
|
@ -77,10 +77,10 @@ export class AddonCompetencyCourseOptionHandler implements CoreCourseOptionsHand
|
|||
/**
|
||||
* Should invalidate the data to determine if the handler is enabled for a certain course.
|
||||
*
|
||||
* @param {number} courseId The course ID.
|
||||
* @param {any} [navOptions] Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
|
||||
* @param {any} [admOptions] Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param courseId The course ID.
|
||||
* @param navOptions Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
|
||||
* @param admOptions Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
invalidateEnabledForCourse(courseId: number, navOptions?: any, admOptions?: any): Promise<any> {
|
||||
if (navOptions && typeof navOptions.competencies != 'undefined') {
|
||||
|
@ -94,8 +94,8 @@ export class AddonCompetencyCourseOptionHandler implements CoreCourseOptionsHand
|
|||
/**
|
||||
* Called when a course is downloaded. It should prefetch all the data to be able to see the addon in offline.
|
||||
*
|
||||
* @param {any} course The course.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param course The course.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
prefetch(course: any): Promise<any> {
|
||||
// Get the competencies in the course.
|
||||
|
|
|
@ -31,8 +31,8 @@ export class AddonCompetencyHelperProvider {
|
|||
/**
|
||||
* Convenient helper to get the user profile image.
|
||||
*
|
||||
* @param {number} userId User Id
|
||||
* @return {Promise<any>} User profile Image URL or true if default icon.
|
||||
* @param userId User Id
|
||||
* @return User profile Image URL or true if default icon.
|
||||
*/
|
||||
getProfile(userId: number): Promise<any> {
|
||||
if (!userId || userId == this.sitesProvider.getCurrentSiteUserId()) {
|
||||
|
@ -50,8 +50,7 @@ export class AddonCompetencyHelperProvider {
|
|||
/**
|
||||
* Get the review status name translated.
|
||||
*
|
||||
* @param {number} status
|
||||
* @return {string}
|
||||
* @param status
|
||||
*/
|
||||
getCompetencyStatusName(status: number): string {
|
||||
let statusTranslateName;
|
||||
|
@ -76,8 +75,7 @@ export class AddonCompetencyHelperProvider {
|
|||
/**
|
||||
* Get the status name translated.
|
||||
*
|
||||
* @param {number} status
|
||||
* @return {string}
|
||||
* @param status
|
||||
*/
|
||||
getPlanStatusName(status: number): string {
|
||||
let statusTranslateName;
|
||||
|
|
|
@ -29,7 +29,7 @@ export class AddonCompetencyMainMenuHandler implements CoreMainMenuHandler {
|
|||
/**
|
||||
* Check if the handler is enabled on a site level.
|
||||
*
|
||||
* @return {boolean} Whether or not the handler is enabled on a site level.
|
||||
* @return Whether or not the handler is enabled on a site level.
|
||||
*/
|
||||
isEnabled(): boolean | Promise<boolean> {
|
||||
// Check the user has at least one learn plan available.
|
||||
|
@ -41,7 +41,7 @@ export class AddonCompetencyMainMenuHandler implements CoreMainMenuHandler {
|
|||
/**
|
||||
* Returns the data needed to render the handler.
|
||||
*
|
||||
* @return {CoreMainMenuHandlerData} Data needed to render the handler.
|
||||
* @return Data needed to render the handler.
|
||||
*/
|
||||
getDisplayData(): CoreMainMenuHandlerData {
|
||||
return {
|
||||
|
|
|
@ -33,11 +33,11 @@ export class AddonCompetencyPlanLinkHandler extends CoreContentLinksHandlerBase
|
|||
/**
|
||||
* Get the list of actions for a link (url).
|
||||
*
|
||||
* @param {string[]} siteIds List of sites the URL belongs to.
|
||||
* @param {string} url The URL to treat.
|
||||
* @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param {number} [courseId] Course ID related to the URL. Optional but recommended.
|
||||
* @return {CoreContentLinksAction[]|Promise<CoreContentLinksAction[]>} List of (or promise resolved with list of) actions.
|
||||
* @param siteIds List of sites the URL belongs to.
|
||||
* @param url The URL to treat.
|
||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||
* @return List of (or promise resolved with list of) actions.
|
||||
*/
|
||||
getActions(siteIds: string[], url: string, params: any, courseId?: number):
|
||||
CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> {
|
||||
|
@ -53,11 +53,11 @@ export class AddonCompetencyPlanLinkHandler extends CoreContentLinksHandlerBase
|
|||
* Check if the handler is enabled for a certain site (site + user) and a URL.
|
||||
* If not defined, defaults to true.
|
||||
*
|
||||
* @param {string} siteId The site ID.
|
||||
* @param {string} url The URL to treat.
|
||||
* @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param {number} [courseId] Course ID related to the URL. Optional but recommended.
|
||||
* @return {boolean|Promise<boolean>} Whether the handler is enabled for the URL and site.
|
||||
* @param siteId The site ID.
|
||||
* @param url The URL to treat.
|
||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||
* @return Whether the handler is enabled for the URL and site.
|
||||
*/
|
||||
isEnabled(siteId: string, url: string, params: any, courseId?: number): boolean | Promise<boolean> {
|
||||
// Handler is disabled if all competency features are disabled.
|
||||
|
|
|
@ -33,11 +33,11 @@ export class AddonCompetencyPlansLinkHandler extends CoreContentLinksHandlerBase
|
|||
/**
|
||||
* Get the list of actions for a link (url).
|
||||
*
|
||||
* @param {string[]} siteIds List of sites the URL belongs to.
|
||||
* @param {string} url The URL to treat.
|
||||
* @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param {number} [courseId] Course ID related to the URL. Optional but recommended.
|
||||
* @return {CoreContentLinksAction[]|Promise<CoreContentLinksAction[]>} List of (or promise resolved with list of) actions.
|
||||
* @param siteIds List of sites the URL belongs to.
|
||||
* @param url The URL to treat.
|
||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||
* @return List of (or promise resolved with list of) actions.
|
||||
*/
|
||||
getActions(siteIds: string[], url: string, params: any, courseId?: number):
|
||||
CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> {
|
||||
|
@ -54,11 +54,11 @@ export class AddonCompetencyPlansLinkHandler extends CoreContentLinksHandlerBase
|
|||
* Check if the handler is enabled for a certain site (site + user) and a URL.
|
||||
* If not defined, defaults to true.
|
||||
*
|
||||
* @param {string} siteId The site ID.
|
||||
* @param {string} url The URL to treat.
|
||||
* @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param {number} [courseId] Course ID related to the URL. Optional but recommended.
|
||||
* @return {boolean|Promise<boolean>} Whether the handler is enabled for the URL and site.
|
||||
* @param siteId The site ID.
|
||||
* @param url The URL to treat.
|
||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||
* @return Whether the handler is enabled for the URL and site.
|
||||
*/
|
||||
isEnabled(siteId: string, url: string, params: any, courseId?: number): boolean | Promise<boolean> {
|
||||
// Handler is disabled if all competency features are disabled.
|
||||
|
|
|
@ -33,8 +33,8 @@ export class AddonCompetencyPushClickHandler implements CorePushNotificationsCli
|
|||
/**
|
||||
* Check if a notification click is handled by this handler.
|
||||
*
|
||||
* @param {any} notification The notification to check.
|
||||
* @return {boolean} Whether the notification click is handled by this handler
|
||||
* @param notification The notification to check.
|
||||
* @return Whether the notification click is handled by this handler
|
||||
*/
|
||||
handles(notification: any): boolean | Promise<boolean> {
|
||||
if (this.utils.isTrueOrOne(notification.notif) && notification.moodlecomponent == 'moodle' &&
|
||||
|
@ -51,8 +51,8 @@ export class AddonCompetencyPushClickHandler implements CorePushNotificationsCli
|
|||
/**
|
||||
* Handle the notification click.
|
||||
*
|
||||
* @param {any} notification The notification to check.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param notification The notification to check.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
handleClick(notification: any): Promise<any> {
|
||||
const contextUrlParams = this.urlUtils.extractUrlParams(notification.contexturl);
|
||||
|
|
|
@ -33,11 +33,11 @@ export class AddonCompetencyUserCompetencyLinkHandler extends CoreContentLinksHa
|
|||
/**
|
||||
* Get the list of actions for a link (url).
|
||||
*
|
||||
* @param {string[]} siteIds List of sites the URL belongs to.
|
||||
* @param {string} url The URL to treat.
|
||||
* @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param {number} [courseId] Course ID related to the URL. Optional but recommended.
|
||||
* @return {CoreContentLinksAction[]|Promise<CoreContentLinksAction[]>} List of (or promise resolved with list of) actions.
|
||||
* @param siteIds List of sites the URL belongs to.
|
||||
* @param url The URL to treat.
|
||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||
* @return List of (or promise resolved with list of) actions.
|
||||
*/
|
||||
getActions(siteIds: string[], url: string, params: any, courseId?: number):
|
||||
CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> {
|
||||
|
@ -53,11 +53,11 @@ export class AddonCompetencyUserCompetencyLinkHandler extends CoreContentLinksHa
|
|||
* Check if the handler is enabled for a certain site (site + user) and a URL.
|
||||
* If not defined, defaults to true.
|
||||
*
|
||||
* @param {string} siteId The site ID.
|
||||
* @param {string} url The URL to treat.
|
||||
* @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param {number} [courseId] Course ID related to the URL. Optional but recommended.
|
||||
* @return {boolean|Promise<boolean>} Whether the handler is enabled for the URL and site.
|
||||
* @param siteId The site ID.
|
||||
* @param url The URL to treat.
|
||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||
* @return Whether the handler is enabled for the URL and site.
|
||||
*/
|
||||
isEnabled(siteId: string, url: string, params: any, courseId?: number): boolean | Promise<boolean> {
|
||||
// Handler is disabled if all competency features are disabled.
|
||||
|
|
|
@ -47,7 +47,7 @@ export class AddonCompetencyUserHandler implements CoreUserProfileHandler {
|
|||
|
||||
/**
|
||||
* Whether or not the handler is enabled on a site level.
|
||||
* @return {boolean|Promise<boolean>} Whether or not the handler is enabled on a site level.
|
||||
* @return Whether or not the handler is enabled on a site level.
|
||||
*/
|
||||
isEnabled(): boolean | Promise<boolean> {
|
||||
return true;
|
||||
|
@ -56,11 +56,11 @@ export class AddonCompetencyUserHandler implements CoreUserProfileHandler {
|
|||
/**
|
||||
* Check if handler is enabled for this user in this context.
|
||||
*
|
||||
* @param {any} user User to check.
|
||||
* @param {number} courseId Course ID.
|
||||
* @param {any} [navOptions] Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
|
||||
* @param {any} [admOptions] Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
|
||||
* @return {boolean|Promise<boolean>} Promise resolved with true if enabled, resolved with false otherwise.
|
||||
* @param user User to check.
|
||||
* @param courseId Course ID.
|
||||
* @param navOptions Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
|
||||
* @param admOptions Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
|
||||
* @return Promise resolved with true if enabled, resolved with false otherwise.
|
||||
*/
|
||||
isEnabledForUser(user: any, courseId: number, navOptions?: any, admOptions?: any): boolean | Promise<boolean> {
|
||||
if (courseId) {
|
||||
|
@ -100,7 +100,7 @@ export class AddonCompetencyUserHandler implements CoreUserProfileHandler {
|
|||
/**
|
||||
* Returns the data needed to render the handler.
|
||||
*
|
||||
* @return {CoreUserProfileHandlerData} Data needed to render the handler.
|
||||
* @return Data needed to render the handler.
|
||||
*/
|
||||
getDisplayData(user: any, courseId: number): CoreUserProfileHandlerData {
|
||||
if (courseId) {
|
||||
|
|
|
@ -54,7 +54,7 @@ export class AddonCourseCompletionReportComponent implements OnInit {
|
|||
/**
|
||||
* Fetch compleiton data.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected fetchCompletion(): Promise<any> {
|
||||
return this.courseCompletionProvider.getCompletion(this.courseId, this.userId).then((completion) => {
|
||||
|
@ -77,7 +77,7 @@ export class AddonCourseCompletionReportComponent implements OnInit {
|
|||
/**
|
||||
* Refresh completion data on PTR.
|
||||
*
|
||||
* @param {any} [refresher] Refresher instance.
|
||||
* @param refresher Refresher instance.
|
||||
*/
|
||||
refreshCompletion(refresher?: any): void {
|
||||
this.courseCompletionProvider.invalidateCourseCompletion(this.courseId, this.userId).finally(() => {
|
||||
|
|
|
@ -30,7 +30,7 @@ export class AddonCourseCompletionCourseOptionHandler implements CoreCourseOptio
|
|||
|
||||
/**
|
||||
* Whether or not the handler is enabled on a site level.
|
||||
* @return {boolean|Promise<boolean>} Whether or not the handler is enabled on a site level.
|
||||
* @return Whether or not the handler is enabled on a site level.
|
||||
*/
|
||||
isEnabled(): boolean | Promise<boolean> {
|
||||
return this.courseCompletionProvider.isPluginViewEnabled();
|
||||
|
@ -39,11 +39,11 @@ export class AddonCourseCompletionCourseOptionHandler implements CoreCourseOptio
|
|||
/**
|
||||
* Whether or not the handler is enabled for a certain course.
|
||||
*
|
||||
* @param {number} courseId The course ID.
|
||||
* @param {any} accessData Access type and data. Default, guest, ...
|
||||
* @param {any} [navOptions] Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
|
||||
* @param {any} [admOptions] Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
|
||||
* @return {boolean|Promise<boolean>} True or promise resolved with true if enabled.
|
||||
* @param courseId The course ID.
|
||||
* @param accessData Access type and data. Default, guest, ...
|
||||
* @param navOptions Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
|
||||
* @param admOptions Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
|
||||
* @return True or promise resolved with true if enabled.
|
||||
*/
|
||||
isEnabledForCourse(courseId: number, accessData: any, navOptions?: any, admOptions?: any): boolean | Promise<boolean> {
|
||||
if (accessData && accessData.type == CoreCourseProvider.ACCESS_GUEST) {
|
||||
|
@ -64,8 +64,8 @@ export class AddonCourseCompletionCourseOptionHandler implements CoreCourseOptio
|
|||
/**
|
||||
* Returns the data needed to render the handler.
|
||||
*
|
||||
* @param {number} courseId The course ID.
|
||||
* @return {CoreCourseOptionsHandlerData} Data.
|
||||
* @param courseId The course ID.
|
||||
* @return Data.
|
||||
*/
|
||||
getDisplayData?(injector: Injector, courseId: number): CoreCourseOptionsHandlerData {
|
||||
return {
|
||||
|
@ -78,10 +78,10 @@ export class AddonCourseCompletionCourseOptionHandler implements CoreCourseOptio
|
|||
/**
|
||||
* Should invalidate the data to determine if the handler is enabled for a certain course.
|
||||
*
|
||||
* @param {number} courseId The course ID.
|
||||
* @param {any} [navOptions] Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
|
||||
* @param {any} [admOptions] Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param courseId The course ID.
|
||||
* @param navOptions Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
|
||||
* @param admOptions Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
invalidateEnabledForCourse(courseId: number, navOptions?: any, admOptions?: any): Promise<any> {
|
||||
return this.courseCompletionProvider.invalidateCourseCompletion(courseId);
|
||||
|
@ -90,8 +90,8 @@ export class AddonCourseCompletionCourseOptionHandler implements CoreCourseOptio
|
|||
/**
|
||||
* Called when a course is downloaded. It should prefetch all the data to be able to see the addon in offline.
|
||||
*
|
||||
* @param {any} course The course.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param course The course.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
prefetch(course: any): Promise<any> {
|
||||
return this.courseCompletionProvider.getCompletion(course.id, undefined, {
|
||||
|
|
|
@ -39,9 +39,9 @@ export class AddonCourseCompletionProvider {
|
|||
* Returns whether or not the user can mark a course as self completed.
|
||||
* It can if it's configured in the course and it hasn't been completed yet.
|
||||
*
|
||||
* @param {number} userId User ID.
|
||||
* @param {any} completion Course completion.
|
||||
* @return {boolean} True if user can mark course as self completed, false otherwise.
|
||||
* @param userId User ID.
|
||||
* @param completion Course completion.
|
||||
* @return True if user can mark course as self completed, false otherwise.
|
||||
*/
|
||||
canMarkSelfCompleted(userId: number, completion: any): boolean {
|
||||
let selfCompletionActive = false,
|
||||
|
@ -65,8 +65,8 @@ export class AddonCourseCompletionProvider {
|
|||
/**
|
||||
* Get completed status text. The language code returned is meant to be translated.
|
||||
*
|
||||
* @param {any} completion Course completion.
|
||||
* @return {string} Language code of the text to show.
|
||||
* @param completion Course completion.
|
||||
* @return Language code of the text to show.
|
||||
*/
|
||||
getCompletedStatusText(completion: any): string {
|
||||
if (completion.completed) {
|
||||
|
@ -90,11 +90,11 @@ export class AddonCourseCompletionProvider {
|
|||
/**
|
||||
* Get course completion status for a certain course and user.
|
||||
*
|
||||
* @param {number} courseId Course ID.
|
||||
* @param {number} [userId] User ID. If not defined, use current user.
|
||||
* @param {any} [preSets] Presets to use when calling the WebService.
|
||||
* @param {string} [siteId] Site ID. If not defined, use current site.
|
||||
* @return {Promise<any>} Promise to be resolved when the completion is retrieved.
|
||||
* @param courseId Course ID.
|
||||
* @param userId User ID. If not defined, use current user.
|
||||
* @param preSets Presets to use when calling the WebService.
|
||||
* @param siteId Site ID. If not defined, use current site.
|
||||
* @return Promise to be resolved when the completion is retrieved.
|
||||
*/
|
||||
getCompletion(courseId: number, userId?: number, preSets?: any, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -125,9 +125,9 @@ export class AddonCourseCompletionProvider {
|
|||
/**
|
||||
* Get cache key for get completion WS calls.
|
||||
*
|
||||
* @param {number} courseId Course ID.
|
||||
* @param {number} useIid User ID.
|
||||
* @return {string} Cache key.
|
||||
* @param courseId Course ID.
|
||||
* @param useIid User ID.
|
||||
* @return Cache key.
|
||||
*/
|
||||
protected getCompletionCacheKey(courseId: number, userId: number): string {
|
||||
return this.ROOT_CACHE_KEY + 'view:' + courseId + ':' + userId;
|
||||
|
@ -136,9 +136,9 @@ export class AddonCourseCompletionProvider {
|
|||
/**
|
||||
* Invalidates view course completion WS call.
|
||||
*
|
||||
* @param {number} courseId Course ID.
|
||||
* @param {number} [userId] User ID. If not defined, use current user.
|
||||
* @return {Promise<any>} Promise resolved when the list is invalidated.
|
||||
* @param courseId Course ID.
|
||||
* @param userId User ID. If not defined, use current user.
|
||||
* @return Promise resolved when the list is invalidated.
|
||||
*/
|
||||
invalidateCourseCompletion(courseId: number, userId?: number): Promise<any> {
|
||||
userId = userId || this.sitesProvider.getCurrentSiteUserId();
|
||||
|
@ -149,7 +149,7 @@ export class AddonCourseCompletionProvider {
|
|||
/**
|
||||
* Returns whether or not the view course completion plugin is enabled for the current site.
|
||||
*
|
||||
* @return {boolean} True if plugin enabled, false otherwise.
|
||||
* @return True if plugin enabled, false otherwise.
|
||||
*/
|
||||
isPluginViewEnabled(): boolean {
|
||||
return this.sitesProvider.isLoggedIn();
|
||||
|
@ -158,9 +158,9 @@ export class AddonCourseCompletionProvider {
|
|||
/**
|
||||
* Returns whether or not the view course completion plugin is enabled for a certain course.
|
||||
*
|
||||
* @param {number} courseId Course ID.
|
||||
* @param {boolean} [preferCache=true] True if shouldn't call WS if data is cached, false otherwise.
|
||||
* @return {Promise<boolean>} Promise resolved with true if plugin is enabled, rejected or resolved with false otherwise.
|
||||
* @param courseId Course ID.
|
||||
* @param preferCache True if shouldn't call WS if data is cached, false otherwise.
|
||||
* @return Promise resolved with true if plugin is enabled, rejected or resolved with false otherwise.
|
||||
*/
|
||||
isPluginViewEnabledForCourse(courseId: number, preferCache: boolean = true): Promise<boolean> {
|
||||
if (!courseId) {
|
||||
|
@ -187,9 +187,9 @@ export class AddonCourseCompletionProvider {
|
|||
/**
|
||||
* Returns whether or not the view course completion plugin is enabled for a certain user.
|
||||
*
|
||||
* @param {number} courseId Course ID.
|
||||
* @param {number} [userId] User ID. If not defined, use current user.
|
||||
* @return {Promise<boolean>} Promise resolved with true if plugin is enabled, rejected or resolved with false otherwise.
|
||||
* @param courseId Course ID.
|
||||
* @param userId User ID. If not defined, use current user.
|
||||
* @return Promise resolved with true if plugin is enabled, rejected or resolved with false otherwise.
|
||||
*/
|
||||
isPluginViewEnabledForUser(courseId: number, userId?: number): Promise<boolean> {
|
||||
// Check if user wants to view his own completion.
|
||||
|
@ -242,8 +242,8 @@ export class AddonCourseCompletionProvider {
|
|||
/**
|
||||
* Mark a course as self completed.
|
||||
*
|
||||
* @param {number} courseId Course ID.
|
||||
* @return {Promise<any>} Resolved on success.
|
||||
* @param courseId Course ID.
|
||||
* @return Resolved on success.
|
||||
*/
|
||||
markCourseAsSelfCompleted(courseId: number): Promise<any> {
|
||||
const params = {
|
||||
|
|
|
@ -42,7 +42,7 @@ export class AddonCourseCompletionUserHandler implements CoreUserProfileHandler
|
|||
|
||||
/**
|
||||
* Whether or not the handler is enabled on a site level.
|
||||
* @return {boolean|Promise<boolean>} Whether or not the handler is enabled on a site level.
|
||||
* @return Whether or not the handler is enabled on a site level.
|
||||
*/
|
||||
isEnabled(): boolean | Promise<boolean> {
|
||||
return this.courseCompletionProvider.isPluginViewEnabled();
|
||||
|
@ -51,11 +51,11 @@ export class AddonCourseCompletionUserHandler implements CoreUserProfileHandler
|
|||
/**
|
||||
* Check if handler is enabled for this user in this context.
|
||||
*
|
||||
* @param {any} user User to check.
|
||||
* @param {number} courseId Course ID.
|
||||
* @param {any} [navOptions] Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
|
||||
* @param {any} [admOptions] Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
|
||||
* @return {boolean|Promise<boolean>} Promise resolved with true if enabled, resolved with false otherwise.
|
||||
* @param user User to check.
|
||||
* @param courseId Course ID.
|
||||
* @param navOptions Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
|
||||
* @param admOptions Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
|
||||
* @return Promise resolved with true if enabled, resolved with false otherwise.
|
||||
*/
|
||||
isEnabledForUser(user: any, courseId: number, navOptions?: any, admOptions?: any): boolean | Promise<boolean> {
|
||||
if (!courseId) {
|
||||
|
@ -84,7 +84,7 @@ export class AddonCourseCompletionUserHandler implements CoreUserProfileHandler
|
|||
/**
|
||||
* Returns the data needed to render the handler.
|
||||
*
|
||||
* @return {CoreUserProfileHandlerData} Data needed to render the handler.
|
||||
* @return Data needed to render the handler.
|
||||
*/
|
||||
getDisplayData(user: any, courseId: number): CoreUserProfileHandlerData {
|
||||
return {
|
||||
|
|
|
@ -89,7 +89,7 @@ export class AddonFilesListPage implements OnDestroy {
|
|||
/**
|
||||
* Refresh the data.
|
||||
*
|
||||
* @param {any} refresher Refresher.
|
||||
* @param refresher Refresher.
|
||||
*/
|
||||
refreshData(refresher: any): void {
|
||||
this.refreshFiles().finally(() => {
|
||||
|
@ -144,7 +144,7 @@ export class AddonFilesListPage implements OnDestroy {
|
|||
/**
|
||||
* Fetch the files.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected fetchFiles(): Promise<any> {
|
||||
let promise;
|
||||
|
@ -193,7 +193,7 @@ export class AddonFilesListPage implements OnDestroy {
|
|||
/**
|
||||
* Refresh the displayed files.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected refreshFiles(): Promise<any> {
|
||||
const promises = [];
|
||||
|
|
|
@ -31,7 +31,7 @@ export class AddonFilesProvider {
|
|||
/**
|
||||
* Check if core_user_get_private_files_info WS call is available.
|
||||
*
|
||||
* @return {boolean} Whether the WS is available, false otherwise.
|
||||
* @return Whether the WS is available, false otherwise.
|
||||
*/
|
||||
canGetPrivateFilesInfo(): boolean {
|
||||
return this.sitesProvider.wsAvailableInCurrentSite('core_user_get_private_files_info');
|
||||
|
@ -40,7 +40,7 @@ export class AddonFilesProvider {
|
|||
/**
|
||||
* Check if user can view his private files.
|
||||
*
|
||||
* @return {boolean} Whether the user can view his private files.
|
||||
* @return Whether the user can view his private files.
|
||||
*/
|
||||
canViewPrivateFiles(): boolean {
|
||||
return this.sitesProvider.getCurrentSite().canAccessMyFiles() && !this.isPrivateFilesDisabledInSite();
|
||||
|
@ -49,7 +49,7 @@ export class AddonFilesProvider {
|
|||
/**
|
||||
* Check if user can view site files.
|
||||
*
|
||||
* @return {boolean} Whether the user can view site files.
|
||||
* @return Whether the user can view site files.
|
||||
*/
|
||||
canViewSiteFiles(): boolean {
|
||||
return !this.isSiteFilesDisabledInSite();
|
||||
|
@ -58,7 +58,7 @@ export class AddonFilesProvider {
|
|||
/**
|
||||
* Check if user can upload private files.
|
||||
*
|
||||
* @return {boolean} Whether the user can upload private files.
|
||||
* @return Whether the user can upload private files.
|
||||
*/
|
||||
canUploadFiles(): boolean {
|
||||
const currentSite = this.sitesProvider.getCurrentSite();
|
||||
|
@ -69,9 +69,9 @@ export class AddonFilesProvider {
|
|||
/**
|
||||
* Get the list of files.
|
||||
*
|
||||
* @param {any} params A list of parameters accepted by the Web service.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any[]>} Promise resolved with the files.
|
||||
* @param params A list of parameters accepted by the Web service.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with the files.
|
||||
*/
|
||||
getFiles(params: any, siteId?: string): Promise<any[]> {
|
||||
|
||||
|
@ -121,8 +121,8 @@ export class AddonFilesProvider {
|
|||
/**
|
||||
* Get cache key for file list WS calls.
|
||||
*
|
||||
* @param {any} params Params of the WS.
|
||||
* @return {string} Cache key.
|
||||
* @param params Params of the WS.
|
||||
* @return Cache key.
|
||||
*/
|
||||
protected getFilesListCacheKey(params: any): string {
|
||||
const root = !params.component ? 'site' : 'my';
|
||||
|
@ -133,7 +133,7 @@ export class AddonFilesProvider {
|
|||
/**
|
||||
* Get the private files of the current user.
|
||||
*
|
||||
* @return {Promise<any[]>} Promise resolved with the files.
|
||||
* @return Promise resolved with the files.
|
||||
*/
|
||||
getPrivateFiles(): Promise<any[]> {
|
||||
return this.getFiles(this.getPrivateFilesRootParams());
|
||||
|
@ -142,7 +142,7 @@ export class AddonFilesProvider {
|
|||
/**
|
||||
* Get params to get root private files directory.
|
||||
*
|
||||
* @return {any} Params.
|
||||
* @return Params.
|
||||
*/
|
||||
protected getPrivateFilesRootParams(): any {
|
||||
return {
|
||||
|
@ -160,9 +160,9 @@ export class AddonFilesProvider {
|
|||
/**
|
||||
* Get private files info.
|
||||
*
|
||||
* @param {number} [userId] User ID. If not defined, current user in the site.
|
||||
* @param {string} [siteId] Site ID. If not defined, use current site.
|
||||
* @return {Promise<any>} Promise resolved with the info.
|
||||
* @param userId User ID. If not defined, current user in the site.
|
||||
* @param siteId Site ID. If not defined, use current site.
|
||||
* @return Promise resolved with the info.
|
||||
*/
|
||||
getPrivateFilesInfo(userId?: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -183,8 +183,8 @@ export class AddonFilesProvider {
|
|||
/**
|
||||
* Get the cache key for private files info WS calls.
|
||||
*
|
||||
* @param {number} userId User ID.
|
||||
* @return {string} Cache key.
|
||||
* @param userId User ID.
|
||||
* @return Cache key.
|
||||
*/
|
||||
protected getPrivateFilesInfoCacheKey(userId: number): string {
|
||||
return this.getPrivateFilesInfoCommonCacheKey() + ':' + userId;
|
||||
|
@ -193,7 +193,7 @@ export class AddonFilesProvider {
|
|||
/**
|
||||
* Get the common part of the cache keys for private files info WS calls.
|
||||
*
|
||||
* @return {string} Cache key.
|
||||
* @return Cache key.
|
||||
*/
|
||||
protected getPrivateFilesInfoCommonCacheKey(): string {
|
||||
return this.ROOT_CACHE_KEY + 'privateInfo';
|
||||
|
@ -202,7 +202,7 @@ export class AddonFilesProvider {
|
|||
/**
|
||||
* Get the site files.
|
||||
*
|
||||
* @return {Promise<any[]>} Promise resolved with the files.
|
||||
* @return Promise resolved with the files.
|
||||
*/
|
||||
getSiteFiles(): Promise<any[]> {
|
||||
return this.getFiles(this.getSiteFilesRootParams());
|
||||
|
@ -211,7 +211,7 @@ export class AddonFilesProvider {
|
|||
/**
|
||||
* Get params to get root site files directory.
|
||||
*
|
||||
* @return {any} Params.
|
||||
* @return Params.
|
||||
*/
|
||||
protected getSiteFilesRootParams(): any {
|
||||
return {
|
||||
|
@ -227,10 +227,10 @@ export class AddonFilesProvider {
|
|||
/**
|
||||
* Invalidates list of files in a certain directory.
|
||||
*
|
||||
* @param {string} root Root of the directory ('my' for private files, 'site' for site files).
|
||||
* @param {string} path Path to the directory.
|
||||
* @param {string} [siteId] Site ID. If not defined, use current site.
|
||||
* @return {Promise<any>} Promise resolved when the data is invalidated.
|
||||
* @param root Root of the directory ('my' for private files, 'site' for site files).
|
||||
* @param path Path to the directory.
|
||||
* @param siteId Site ID. If not defined, use current site.
|
||||
* @return Promise resolved when the data is invalidated.
|
||||
*/
|
||||
invalidateDirectory(root: string, path: string, siteId?: string): Promise<any> {
|
||||
let params;
|
||||
|
@ -252,8 +252,8 @@ export class AddonFilesProvider {
|
|||
/**
|
||||
* Invalidates private files info for all users.
|
||||
*
|
||||
* @param {string} [siteId] Site ID. If not defined, use current site.
|
||||
* @return {Promise<any>} Promise resolved when the data is invalidated.
|
||||
* @param siteId Site ID. If not defined, use current site.
|
||||
* @return Promise resolved when the data is invalidated.
|
||||
*/
|
||||
invalidatePrivateFilesInfo(siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -264,9 +264,9 @@ export class AddonFilesProvider {
|
|||
/**
|
||||
* Invalidates private files info for a certain user.
|
||||
*
|
||||
* @param {number} [userId] User ID. If not defined, current user in the site.
|
||||
* @param {string} [siteId] Site ID. If not defined, use current site.
|
||||
* @return {Promise<any>} Promise resolved when the data is invalidated.
|
||||
* @param userId User ID. If not defined, current user in the site.
|
||||
* @param siteId Site ID. If not defined, use current site.
|
||||
* @return Promise resolved when the data is invalidated.
|
||||
*/
|
||||
invalidatePrivateFilesInfoForUser(userId?: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -279,8 +279,8 @@ export class AddonFilesProvider {
|
|||
/**
|
||||
* Check if Files is disabled in a certain site.
|
||||
*
|
||||
* @param {string} [siteId] Site Id. If not defined, use current site.
|
||||
* @return {Promise<boolean>} Promise resolved with true if disabled, rejected or resolved with false otherwise.
|
||||
* @param siteId Site Id. If not defined, use current site.
|
||||
* @return Promise resolved with true if disabled, rejected or resolved with false otherwise.
|
||||
*/
|
||||
isDisabled(siteId?: string): Promise<boolean> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -291,8 +291,8 @@ export class AddonFilesProvider {
|
|||
/**
|
||||
* Check if Files is disabled in a certain site.
|
||||
*
|
||||
* @param {CoreSite} [site] Site. If not defined, use current site.
|
||||
* @return {boolean} Whether it's disabled.
|
||||
* @param site Site. If not defined, use current site.
|
||||
* @return Whether it's disabled.
|
||||
*/
|
||||
isDisabledInSite(site: CoreSite): boolean {
|
||||
site = site || this.sitesProvider.getCurrentSite();
|
||||
|
@ -303,7 +303,7 @@ export class AddonFilesProvider {
|
|||
/**
|
||||
* Return whether or not the plugin is enabled.
|
||||
*
|
||||
* @return {boolean} True if enabled, false otherwise.
|
||||
* @return True if enabled, false otherwise.
|
||||
*/
|
||||
isPluginEnabled(): boolean {
|
||||
return this.canViewPrivateFiles() || this.canViewSiteFiles() || this.canUploadFiles();
|
||||
|
@ -312,8 +312,8 @@ export class AddonFilesProvider {
|
|||
/**
|
||||
* Check if private files is disabled in a certain site.
|
||||
*
|
||||
* @param {string} [siteId] Site Id. If not defined, use current site.
|
||||
* @return {Promise<boolean>} Promise resolved with true if disabled, rejected or resolved with false otherwise.
|
||||
* @param siteId Site Id. If not defined, use current site.
|
||||
* @return Promise resolved with true if disabled, rejected or resolved with false otherwise.
|
||||
*/
|
||||
isPrivateFilesDisabled(siteId?: string): Promise<boolean> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -324,8 +324,8 @@ export class AddonFilesProvider {
|
|||
/**
|
||||
* Check if private files is disabled in a certain site.
|
||||
*
|
||||
* @param {CoreSite} [site] Site. If not defined, use current site.
|
||||
* @return {boolean} Whether it's disabled.
|
||||
* @param site Site. If not defined, use current site.
|
||||
* @return Whether it's disabled.
|
||||
*/
|
||||
isPrivateFilesDisabledInSite(site?: CoreSite): boolean {
|
||||
site = site || this.sitesProvider.getCurrentSite();
|
||||
|
@ -336,8 +336,8 @@ export class AddonFilesProvider {
|
|||
/**
|
||||
* Check if site files is disabled in a certain site.
|
||||
*
|
||||
* @param {string} [siteId] Site Id. If not defined, use current site.
|
||||
* @return {Promise<boolean>} Promise resolved with true if disabled, rejected or resolved with false otherwise.
|
||||
* @param siteId Site Id. If not defined, use current site.
|
||||
* @return Promise resolved with true if disabled, rejected or resolved with false otherwise.
|
||||
*/
|
||||
isSiteFilesDisabled(siteId?: string): Promise<boolean> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -348,8 +348,8 @@ export class AddonFilesProvider {
|
|||
/**
|
||||
* Check if site files is disabled in a certain site.
|
||||
*
|
||||
* @param {CoreSite} [site] Site. If not defined, use current site.
|
||||
* @return {boolean} Whether it's disabled.
|
||||
* @param site Site. If not defined, use current site.
|
||||
* @return Whether it's disabled.
|
||||
*/
|
||||
isSiteFilesDisabledInSite(site?: CoreSite): boolean {
|
||||
site = site || this.sitesProvider.getCurrentSite();
|
||||
|
@ -360,8 +360,8 @@ export class AddonFilesProvider {
|
|||
/**
|
||||
* Check if upload files is disabled in a certain site.
|
||||
*
|
||||
* @param {string} [siteId] Site Id. If not defined, use current site.
|
||||
* @return {Promise<boolean>} Promise resolved with true if disabled, rejected or resolved with false otherwise.
|
||||
* @param siteId Site Id. If not defined, use current site.
|
||||
* @return Promise resolved with true if disabled, rejected or resolved with false otherwise.
|
||||
*/
|
||||
isUploadDisabled(siteId?: string): Promise<boolean> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -372,8 +372,8 @@ export class AddonFilesProvider {
|
|||
/**
|
||||
* Check if upload files is disabled in a certain site.
|
||||
*
|
||||
* @param {CoreSite} [site] Site. If not defined, use current site.
|
||||
* @return {boolean} Whether it's disabled.
|
||||
* @param site Site. If not defined, use current site.
|
||||
* @return Whether it's disabled.
|
||||
*/
|
||||
isUploadDisabledInSite(site?: CoreSite): boolean {
|
||||
site = site || this.sitesProvider.getCurrentSite();
|
||||
|
@ -384,9 +384,9 @@ export class AddonFilesProvider {
|
|||
/**
|
||||
* Move a file from draft area to private files.
|
||||
*
|
||||
* @param {number} draftId The draft area ID of the file.
|
||||
* @param {string} [siteid] ID of the site. If not defined, use current site.
|
||||
* @return {Promise<any>} Promise resolved in success, rejected otherwise.
|
||||
* @param draftId The draft area ID of the file.
|
||||
* @param siteid ID of the site. If not defined, use current site.
|
||||
* @return Promise resolved in success, rejected otherwise.
|
||||
*/
|
||||
moveFromDraftToPrivate(draftId: number, siteId?: string): Promise<any> {
|
||||
const params = {
|
||||
|
@ -404,8 +404,8 @@ export class AddonFilesProvider {
|
|||
/**
|
||||
* Check the Moodle version in order to check if upload files is working.
|
||||
*
|
||||
* @param {string} [siteId] Site ID. If not defined, use current site.
|
||||
* @return {Promise<boolean>} Promise resolved with true if WS is working, false otherwise.
|
||||
* @param siteId Site ID. If not defined, use current site.
|
||||
* @return Promise resolved with true if WS is working, false otherwise.
|
||||
*/
|
||||
versionCanUploadFiles(siteId?: string): Promise<boolean> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
|
|
@ -30,8 +30,8 @@ export class AddonFilesHelperProvider {
|
|||
/**
|
||||
* Select a file, upload it and move it to private files.
|
||||
*
|
||||
* @param {any} [info] Private files info. See AddonFilesProvider.getPrivateFilesInfo.
|
||||
* @return {Promise<any>} Promise resolved when a file is uploaded, rejected otherwise.
|
||||
* @param info Private files info. See AddonFilesProvider.getPrivateFilesInfo.
|
||||
* @return Promise resolved when a file is uploaded, rejected otherwise.
|
||||
*/
|
||||
uploadPrivateFile(info?: any): Promise<any> {
|
||||
// Calculate the max size.
|
||||
|
|
|
@ -29,7 +29,7 @@ export class AddonFilesMainMenuHandler implements CoreMainMenuHandler {
|
|||
/**
|
||||
* Check if the handler is enabled on a site level.
|
||||
*
|
||||
* @return {boolean} Whether or not the handler is enabled on a site level.
|
||||
* @return Whether or not the handler is enabled on a site level.
|
||||
*/
|
||||
isEnabled(): boolean | Promise<boolean> {
|
||||
return this.filesProvider.isPluginEnabled();
|
||||
|
@ -38,7 +38,7 @@ export class AddonFilesMainMenuHandler implements CoreMainMenuHandler {
|
|||
/**
|
||||
* Returns the data needed to render the handler.
|
||||
*
|
||||
* @return {CoreMainMenuHandlerData} Data needed to render the handler.
|
||||
* @return Data needed to render the handler.
|
||||
*/
|
||||
getDisplayData(): CoreMainMenuHandlerData {
|
||||
return {
|
||||
|
|
|
@ -47,7 +47,7 @@ export class AddonMessageOutputAirnotifierDevicesPage implements OnDestroy {
|
|||
/**
|
||||
* Fetches the list of devices.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected fetchDevices(): Promise<any> {
|
||||
return this.airnotifierProivder.getUserDevices().then((devices) => {
|
||||
|
@ -94,7 +94,7 @@ export class AddonMessageOutputAirnotifierDevicesPage implements OnDestroy {
|
|||
/**
|
||||
* Refresh the list of devices.
|
||||
*
|
||||
* @param {any} refresher Refresher.
|
||||
* @param refresher Refresher.
|
||||
*/
|
||||
refreshDevices(refresher: any): void {
|
||||
this.airnotifierProivder.invalidateUserDevices().finally(() => {
|
||||
|
@ -107,8 +107,8 @@ export class AddonMessageOutputAirnotifierDevicesPage implements OnDestroy {
|
|||
/**
|
||||
* Enable or disable a certain device.
|
||||
*
|
||||
* @param {any} device The device object.
|
||||
* @param {boolean} enable True to enable the device, false to disable it.
|
||||
* @param device The device object.
|
||||
* @param enable True to enable the device, false to disable it.
|
||||
*/
|
||||
enableDevice(device: any, enable: boolean): void {
|
||||
device.updating = true;
|
||||
|
|
|
@ -34,10 +34,10 @@ export class AddonMessageOutputAirnotifierProvider {
|
|||
/**
|
||||
* Enables or disables a device.
|
||||
*
|
||||
* @param {number} deviceId Device ID.
|
||||
* @param {boolean} enable True to enable, false to disable.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved if success.
|
||||
* @param deviceId Device ID.
|
||||
* @param enable True to enable, false to disable.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved if success.
|
||||
*/
|
||||
enableDevice(deviceId: number, enable: boolean, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -62,7 +62,7 @@ export class AddonMessageOutputAirnotifierProvider {
|
|||
/**
|
||||
* Get the cache key for the get user devices call.
|
||||
*
|
||||
* @return {string} Cache key.
|
||||
* @return Cache key.
|
||||
*/
|
||||
protected getUserDevicesCacheKey(): string {
|
||||
return this.ROOT_CACHE_KEY + 'userDevices';
|
||||
|
@ -71,8 +71,8 @@ export class AddonMessageOutputAirnotifierProvider {
|
|||
/**
|
||||
* Get user devices.
|
||||
*
|
||||
* @param {string} [siteId] Site ID. If not defined, use current site.
|
||||
* @return {Promise<any>} Promise resolved with the devices.
|
||||
* @param siteId Site ID. If not defined, use current site.
|
||||
* @return Promise resolved with the devices.
|
||||
*/
|
||||
getUserDevices(siteId?: string): Promise<any> {
|
||||
this.logger.debug('Get user devices');
|
||||
|
@ -95,8 +95,8 @@ export class AddonMessageOutputAirnotifierProvider {
|
|||
/**
|
||||
* Invalidate get user devices.
|
||||
*
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved when data is invalidated.
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved when data is invalidated.
|
||||
*/
|
||||
invalidateUserDevices(siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
|
@ -107,7 +107,7 @@ export class AddonMessageOutputAirnotifierProvider {
|
|||
/**
|
||||
* Returns whether or not the plugin is enabled for the current site.
|
||||
*
|
||||
* @return {boolean} True if enabled, false otherwise.
|
||||
* @return True if enabled, false otherwise.
|
||||
* @since 3.2
|
||||
*/
|
||||
isEnabled(): boolean {
|
||||
|
|
|
@ -29,7 +29,7 @@ export class AddonMessageOutputAirnotifierHandler implements AddonMessageOutputH
|
|||
/**
|
||||
* Whether or not the module is enabled for the site.
|
||||
*
|
||||
* @return {boolean} True if enabled, false otherwise.
|
||||
* @return True if enabled, false otherwise.
|
||||
*/
|
||||
isEnabled(): boolean {
|
||||
return this.airnotifierProvider.isEnabled();
|
||||
|
@ -38,8 +38,8 @@ export class AddonMessageOutputAirnotifierHandler implements AddonMessageOutputH
|
|||
/**
|
||||
* Returns the data needed to render the handler.
|
||||
*
|
||||
* @param {any} processor The processor object.
|
||||
* @return {CoreMainMenuHandlerData} Data.
|
||||
* @param processor The processor object.
|
||||
* @return Data.
|
||||
*/
|
||||
getDisplayData(processor: any): AddonMessageOutputHandlerData {
|
||||
return {
|
||||
|
|
|
@ -24,15 +24,14 @@ import { CoreSitesProvider } from '@providers/sites';
|
|||
export interface AddonMessageOutputHandler extends CoreDelegateHandler {
|
||||
/**
|
||||
* The name of the processor. E.g. 'airnotifier'.
|
||||
* @type {string}
|
||||
*/
|
||||
processorName: string;
|
||||
|
||||
/**
|
||||
* Returns the data needed to render the handler.
|
||||
*
|
||||
* @param {any} processor The processor object.
|
||||
* @return {CoreMainMenuHandlerData} Data.
|
||||
* @param processor The processor object.
|
||||
* @return Data.
|
||||
*/
|
||||
getDisplayData(processor: any): AddonMessageOutputHandlerData;
|
||||
}
|
||||
|
@ -43,31 +42,26 @@ export interface AddonMessageOutputHandler extends CoreDelegateHandler {
|
|||
export interface AddonMessageOutputHandlerData {
|
||||
/**
|
||||
* Handler's priority.
|
||||
* @type {number}
|
||||
*/
|
||||
priority: number;
|
||||
|
||||
/**
|
||||
* Name of the page to load for the handler.
|
||||
* @type {string}
|
||||
*/
|
||||
page: string;
|
||||
|
||||
/**
|
||||
* Label to display for the handler.
|
||||
* @type {string}
|
||||
*/
|
||||
label: string;
|
||||
|
||||
/**
|
||||
* Name of the icon to display for the handler.
|
||||
* @type {string}
|
||||
*/
|
||||
icon: string;
|
||||
|
||||
/**
|
||||
* Params to pass to the page.
|
||||
* @type {any}
|
||||
*/
|
||||
pageParams?: any;
|
||||
}
|
||||
|
@ -88,8 +82,8 @@ export interface AddonMessageOutputHandlerData {
|
|||
/**
|
||||
* Get the display data of the handler.
|
||||
*
|
||||
* @param {string} processor The processor object.
|
||||
* @return {AddonMessageOutputHandlerData} Data.
|
||||
* @param processor The processor object.
|
||||
* @return Data.
|
||||
*/
|
||||
getDisplayData(processor: any): AddonMessageOutputHandlerData {
|
||||
return this.executeFunctionOnEnabled(processor.name, 'getDisplayData', processor);
|
||||
|
|
|
@ -80,8 +80,8 @@ export class AddonMessagesConfirmedContactsComponent implements OnInit, OnDestro
|
|||
/**
|
||||
* Fetch contacts.
|
||||
*
|
||||
* @param {boolean} [refresh=false] True if we are refreshing contacts, false if we are loading more.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param refresh True if we are refreshing contacts, false if we are loading more.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
fetchData(refresh: boolean = false): Promise<any> {
|
||||
this.loadMoreError = false;
|
||||
|
@ -112,8 +112,8 @@ export class AddonMessagesConfirmedContactsComponent implements OnInit, OnDestro
|
|||
/**
|
||||
* Refresh contacts.
|
||||
*
|
||||
* @param {any} [refresher] Refresher.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param refresher Refresher.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
refreshData(refresher?: any): Promise<any> {
|
||||
// No need to invalidate contacts, we always try to get the latest.
|
||||
|
@ -125,8 +125,8 @@ export class AddonMessagesConfirmedContactsComponent implements OnInit, OnDestro
|
|||
/**
|
||||
* Load more contacts.
|
||||
*
|
||||
* @param {any} [infiniteComplete] Infinite scroll complete function. Only used from core-infinite-loading.
|
||||
* @return {Promise<any>} Resolved when done.
|
||||
* @param infiniteComplete Infinite scroll complete function. Only used from core-infinite-loading.
|
||||
* @return Resolved when done.
|
||||
*/
|
||||
loadMore(infiniteComplete?: any): Promise<any> {
|
||||
return this.fetchData().finally(() => {
|
||||
|
@ -137,8 +137,8 @@ export class AddonMessagesConfirmedContactsComponent implements OnInit, OnDestro
|
|||
/**
|
||||
* Notify that a contact has been selected.
|
||||
*
|
||||
* @param {number} userId User id.
|
||||
* @param {boolean} [onInit=false] Whether the contact is selected on initial load.
|
||||
* @param userId User id.
|
||||
* @param onInit Whether the contact is selected on initial load.
|
||||
*/
|
||||
selectUser(userId: number, onInit: boolean = false): void {
|
||||
this.selectedUserId = userId;
|
||||
|
|
|
@ -71,8 +71,8 @@ export class AddonMessagesContactRequestsComponent implements OnInit, OnDestroy
|
|||
/**
|
||||
* Fetch contact requests.
|
||||
*
|
||||
* @param {boolean} [refresh=false] True if we are refreshing contact requests, false if we are loading more.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param refresh True if we are refreshing contact requests, false if we are loading more.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
fetchData(refresh: boolean = false): Promise<any> {
|
||||
this.loadMoreError = false;
|
||||
|
@ -103,8 +103,8 @@ export class AddonMessagesContactRequestsComponent implements OnInit, OnDestroy
|
|||
/**
|
||||
* Refresh contact requests.
|
||||
*
|
||||
* @param {any} [refresher] Refresher.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param refresher Refresher.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
refreshData(refresher?: any): Promise<any> {
|
||||
// Refresh the number of contacts requests to update badges.
|
||||
|
@ -119,8 +119,8 @@ export class AddonMessagesContactRequestsComponent implements OnInit, OnDestroy
|
|||
/**
|
||||
* Load more contact requests.
|
||||
*
|
||||
* @param {any} [infiniteComplete] Infinite scroll complete function. Only used from core-infinite-loading.
|
||||
* @return {Promise<any>} Resolved when done.
|
||||
* @param infiniteComplete Infinite scroll complete function. Only used from core-infinite-loading.
|
||||
* @return Resolved when done.
|
||||
*/
|
||||
loadMore(infiniteComplete?: any): Promise<any> {
|
||||
return this.fetchData().finally(() => {
|
||||
|
@ -131,8 +131,8 @@ export class AddonMessagesContactRequestsComponent implements OnInit, OnDestroy
|
|||
/**
|
||||
* Notify that a contact has been selected.
|
||||
*
|
||||
* @param {number} userId User id.
|
||||
* @param {boolean} [onInit=false] Whether the contact is selected on initial load.
|
||||
* @param userId User id.
|
||||
* @param onInit Whether the contact is selected on initial load.
|
||||
*/
|
||||
selectUser(userId: number, onInit: boolean = false): void {
|
||||
this.selectedUserId = userId;
|
||||
|
|
|
@ -101,8 +101,8 @@ export class AddonMessagesContactsComponent {
|
|||
/**
|
||||
* Refresh the data.
|
||||
*
|
||||
* @param {any} [refresher] Refresher.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param refresher Refresher.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
refreshData(refresher?: any): Promise<any> {
|
||||
let promise;
|
||||
|
@ -125,7 +125,7 @@ export class AddonMessagesContactsComponent {
|
|||
/**
|
||||
* Fetch contacts.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected fetchData(): Promise<any> {
|
||||
this.loadingMessage = this.loadingMessages;
|
||||
|
@ -147,8 +147,8 @@ export class AddonMessagesContactsComponent {
|
|||
|
||||
/**
|
||||
* Sort user list by fullname
|
||||
* @param {any[]} list List to sort.
|
||||
* @return {any[]} Sorted list.
|
||||
* @param list List to sort.
|
||||
* @return Sorted list.
|
||||
*/
|
||||
protected sortUsers(list: any[]): any[] {
|
||||
return list.sort((a, b) => {
|
||||
|
@ -179,8 +179,8 @@ export class AddonMessagesContactsComponent {
|
|||
/**
|
||||
* Search users from the UI.
|
||||
*
|
||||
* @param {string} query Text to search for.
|
||||
* @return {Promise<any>} Resolved when done.
|
||||
* @param query Text to search for.
|
||||
* @return Resolved when done.
|
||||
*/
|
||||
search(query: string): Promise<any> {
|
||||
this.appProvider.closeKeyboard();
|
||||
|
@ -196,8 +196,8 @@ export class AddonMessagesContactsComponent {
|
|||
/**
|
||||
* Perform the search of users.
|
||||
*
|
||||
* @param {string} query Text to search for.
|
||||
* @return {Promise<any>} Resolved when done.
|
||||
* @param query Text to search for.
|
||||
* @return Resolved when done.
|
||||
*/
|
||||
protected performSearch(query: string): Promise<any> {
|
||||
return this.messagesProvider.searchContacts(query).then((result) => {
|
||||
|
@ -214,8 +214,8 @@ export class AddonMessagesContactsComponent {
|
|||
/**
|
||||
* Navigate to a particular discussion.
|
||||
*
|
||||
* @param {number} discussionUserId Discussion Id to load.
|
||||
* @param {boolean} [onlyWithSplitView=false] Only go to Discussion if split view is on.
|
||||
* @param discussionUserId Discussion Id to load.
|
||||
* @param onlyWithSplitView Only go to Discussion if split view is on.
|
||||
*/
|
||||
gotoDiscussion(discussionUserId: number, onlyWithSplitView: boolean = false): void {
|
||||
this.discussionUserId = discussionUserId;
|
||||
|
|
|
@ -139,9 +139,9 @@ export class AddonMessagesDiscussionsComponent implements OnDestroy {
|
|||
/**
|
||||
* Refresh the data.
|
||||
*
|
||||
* @param {any} [refresher] Refresher.
|
||||
* @param {boolean} [refreshUnreadCounts=true] Whteher to refresh unread counts.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param refresher Refresher.
|
||||
* @param refreshUnreadCounts Whteher to refresh unread counts.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
refreshData(refresher?: any, refreshUnreadCounts: boolean = true): Promise<any> {
|
||||
const promises = [];
|
||||
|
@ -163,7 +163,7 @@ export class AddonMessagesDiscussionsComponent implements OnDestroy {
|
|||
/**
|
||||
* Fetch discussions.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected fetchData(): Promise<any> {
|
||||
this.loadingMessage = this.loadingMessages;
|
||||
|
@ -208,8 +208,8 @@ export class AddonMessagesDiscussionsComponent implements OnDestroy {
|
|||
/**
|
||||
* Search messages cotaining text.
|
||||
*
|
||||
* @param {string} query Text to search for.
|
||||
* @return {Promise<any>} Resolved when done.
|
||||
* @param query Text to search for.
|
||||
* @return Resolved when done.
|
||||
*/
|
||||
searchMessage(query: string): Promise<any> {
|
||||
this.appProvider.closeKeyboard();
|
||||
|
@ -229,9 +229,9 @@ export class AddonMessagesDiscussionsComponent implements OnDestroy {
|
|||
/**
|
||||
* Navigate to a particular discussion.
|
||||
*
|
||||
* @param {number} discussionUserId Discussion Id to load.
|
||||
* @param {number} [messageId] Message to scroll after loading the discussion. Used when searching.
|
||||
* @param {boolean} [onlyWithSplitView=false] Only go to Discussion if split view is on.
|
||||
* @param discussionUserId Discussion Id to load.
|
||||
* @param messageId Message to scroll after loading the discussion. Used when searching.
|
||||
* @param onlyWithSplitView Only go to Discussion if split view is on.
|
||||
*/
|
||||
gotoDiscussion(discussionUserId: number, messageId?: number, onlyWithSplitView: boolean = false): void {
|
||||
this.discussionUserId = discussionUserId;
|
||||
|
|
|
@ -91,9 +91,9 @@ export class AddonMessagesContactsPage implements OnDestroy {
|
|||
/**
|
||||
* Set the selected user and open the conversation in the split view if needed.
|
||||
*
|
||||
* @param {string} tab Active tab: "contacts" or "requests".
|
||||
* @param {number} [userId] Id of the selected user, undefined to use the last selected user in the tab.
|
||||
* @param {boolean} [onInit=false] Whether the contact was selected on initial load.
|
||||
* @param tab Active tab: "contacts" or "requests".
|
||||
* @param userId Id of the selected user, undefined to use the last selected user in the tab.
|
||||
* @param onInit Whether the contact was selected on initial load.
|
||||
*/
|
||||
selectUser(tab: string, userId?: number, onInit: boolean = false): void {
|
||||
userId = userId || this.selectedUserId[tab];
|
||||
|
|
|
@ -52,7 +52,7 @@ export class AddonMessagesConversationInfoPage implements OnInit {
|
|||
/**
|
||||
* Fetch the required data.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected fetchData(): Promise<any> {
|
||||
// Get the conversation data first.
|
||||
|
@ -69,8 +69,8 @@ export class AddonMessagesConversationInfoPage implements OnInit {
|
|||
/**
|
||||
* Get conversation members.
|
||||
*
|
||||
* @param {boolean} [loadingMore} Whether we are loading more data or just the first ones.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param loadingMore Whether we are loading more data or just the first ones.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected fetchMembers(loadingMore?: boolean): Promise<any> {
|
||||
this.loadMoreError = false;
|
||||
|
@ -91,8 +91,8 @@ export class AddonMessagesConversationInfoPage implements OnInit {
|
|||
/**
|
||||
* Function to load more members.
|
||||
*
|
||||
* @param {any} [infiniteComplete] Infinite scroll complete function. Only used from core-infinite-loading.
|
||||
* @return {Promise<any>} Resolved when done.
|
||||
* @param infiniteComplete Infinite scroll complete function. Only used from core-infinite-loading.
|
||||
* @return Resolved when done.
|
||||
*/
|
||||
loadMoreMembers(infiniteComplete?: any): Promise<any> {
|
||||
return this.fetchMembers(true).catch((error) => {
|
||||
|
@ -106,8 +106,8 @@ export class AddonMessagesConversationInfoPage implements OnInit {
|
|||
/**
|
||||
* Refresh the data.
|
||||
*
|
||||
* @param {any} [refresher] Refresher.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
* @param refresher Refresher.
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
refreshData(refresher?: any): Promise<any> {
|
||||
const promises = [];
|
||||
|
@ -125,7 +125,7 @@ export class AddonMessagesConversationInfoPage implements OnInit {
|
|||
/**
|
||||
* Close modal.
|
||||
*
|
||||
* @param {number} [userId] User conversation to load.
|
||||
* @param userId User conversation to load.
|
||||
*/
|
||||
closeModal(userId?: number): void {
|
||||
this.viewCtrl.dismiss(userId);
|
||||
|
|
|
@ -136,8 +136,8 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
|||
/**
|
||||
* Adds a new message to the message list.
|
||||
*
|
||||
* @param {any} message Message to be added.
|
||||
* @param {boolean} [keep=true] If set the keep flag or not.
|
||||
* @param message Message to be added.
|
||||
* @param keep If set the keep flag or not.
|
||||
*/
|
||||
protected addMessage(message: any, keep: boolean = true): void {
|
||||
/* Create a hash to identify the message. The text of online messages isn't reliable because it can have random data
|
||||
|
@ -156,7 +156,7 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
|||
/**
|
||||
* Remove a message if it shouldn't be in the list anymore.
|
||||
*
|
||||
* @param {string} hash Hash of the message to be removed.
|
||||
* @param hash Hash of the message to be removed.
|
||||
*/
|
||||
protected removeMessage(hash: any): void {
|
||||
if (this.keepMessageMap[hash]) {
|
||||
|
@ -197,7 +197,7 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
|||
/**
|
||||
* Convenience function to fetch the conversation data.
|
||||
*
|
||||
* @return {Promise<any>} Resolved when done.
|
||||
* @return Resolved when done.
|
||||
*/
|
||||
protected fetchData(): Promise<any> {
|
||||
let loader;
|
||||
|
@ -300,7 +300,7 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
|||
/**
|
||||
* Convenience function to fetch messages.
|
||||
*
|
||||
* @return {Promise<any>} Resolved when done.
|
||||
* @return Resolved when done.
|
||||
*/
|
||||
protected fetchMessages(): Promise<any> {
|
||||
this.loadMoreError = false;
|
||||
|
@ -351,7 +351,7 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
|||
/**
|
||||
* Format and load a list of messages into the view.
|
||||
*
|
||||
* @param {any[]} messages Messages to load.
|
||||
* @param messages Messages to load.
|
||||
*/
|
||||
protected loadMessages(messages: any[]): void {
|
||||
if (this.viewDestroyed) {
|
||||
|
@ -406,9 +406,9 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
|||
/**
|
||||
* Get the conversation.
|
||||
*
|
||||
* @param {number} conversationId Conversation ID.
|
||||
* @param {number} userId User ID.
|
||||
* @return {Promise<boolean>} Promise resolved with a boolean: whether the conversation exists or not.
|
||||
* @param conversationId Conversation ID.
|
||||
* @param userId User ID.
|
||||
* @return Promise resolved with a boolean: whether the conversation exists or not.
|
||||
*/
|
||||
protected getConversation(conversationId: number, userId: number): Promise<boolean> {
|
||||
let promise,
|
||||
|
@ -491,9 +491,9 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
|||
/**
|
||||
* Get the messages of the conversation. Used if group messaging is supported.
|
||||
*
|
||||
* @param {number} pagesToLoad Number of "pages" to load.
|
||||
* @param {number} [offset=0] Offset for message list.
|
||||
* @return {Promise<any[]>} Promise resolved with the list of messages.
|
||||
* @param pagesToLoad Number of "pages" to load.
|
||||
* @param offset Offset for message list.
|
||||
* @return Promise resolved with the list of messages.
|
||||
*/
|
||||
protected getConversationMessages(pagesToLoad: number, offset: number = 0): Promise<any[]> {
|
||||
const excludePending = offset > 0;
|
||||
|
@ -527,12 +527,12 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
|||
/**
|
||||
* Get a discussion. Can load several "pages".
|
||||
*
|
||||
* @param {number} pagesToLoad Number of pages to load.
|
||||
* @param {number} [lfReceivedUnread=0] Number of unread received messages already fetched, so fetch will be done from this.
|
||||
* @param {number} [lfReceivedRead=0] Number of read received messages already fetched, so fetch will be done from this.
|
||||
* @param {number} [lfSentUnread=0] Number of unread sent messages already fetched, so fetch will be done from this.
|
||||
* @param {number} [lfSentRead=0] Number of read sent messages already fetched, so fetch will be done from this.
|
||||
* @return {Promise<any>} Resolved when done.
|
||||
* @param pagesToLoad Number of pages to load.
|
||||
* @param lfReceivedUnread Number of unread received messages already fetched, so fetch will be done from this.
|
||||
* @param lfReceivedRead Number of read received messages already fetched, so fetch will be done from this.
|
||||
* @param lfSentUnread Number of unread sent messages already fetched, so fetch will be done from this.
|
||||
* @param lfSentRead Number of read sent messages already fetched, so fetch will be done from this.
|
||||
* @return Resolved when done.
|
||||
*/
|
||||
protected getDiscussionMessages(pagesToLoad: number, lfReceivedUnread: number = 0, lfReceivedRead: number = 0,
|
||||
lfSentUnread: number = 0, lfSentRead: number = 0): Promise<any> {
|
||||
|
@ -755,7 +755,7 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
|||
|
||||
/**
|
||||
* Wait until fetching is false.
|
||||
* @return {Promise<void>} Resolved when done.
|
||||
* @return Resolved when done.
|
||||
*/
|
||||
protected waitForFetch(): Promise<void> {
|
||||
if (!this.fetching) {
|
||||
|
@ -806,7 +806,7 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
|||
/**
|
||||
* Copy message to clipboard.
|
||||
*
|
||||
* @param {any} message Message to be copied.
|
||||
* @param message Message to be copied.
|
||||
*/
|
||||
copyMessage(message: any): void {
|
||||
const text = this.textUtils.decodeHTMLEntities(message.smallmessage || message.text || '');
|
||||
|
@ -816,8 +816,8 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
|||
/**
|
||||
* Function to delete a message.
|
||||
*
|
||||
* @param {any} message Message object to delete.
|
||||
* @param {number} index Index where the message is to delete it from the view.
|
||||
* @param message Message object to delete.
|
||||
* @param index Index where the message is to delete it from the view.
|
||||
*/
|
||||
deleteMessage(message: any, index: number): void {
|
||||
const canDeleteAll = this.conversation && this.conversation.candeletemessagesforallusers,
|
||||
|
@ -857,8 +857,8 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
|||
/**
|
||||
* Function to load previous messages.
|
||||
*
|
||||
* @param {any} [infiniteComplete] Infinite scroll complete function. Only used from core-infinite-loading.
|
||||
* @return {Promise<any>} Resolved when done.
|
||||
* @param infiniteComplete Infinite scroll complete function. Only used from core-infinite-loading.
|
||||
* @return Resolved when done.
|
||||
*/
|
||||
loadPrevious(infiniteComplete?: any): Promise<any> {
|
||||
let infiniteHeight = this.infinite ? this.infinite.getHeight() : 0;
|
||||
|
@ -959,7 +959,7 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
|||
/**
|
||||
* Sends a message to the server.
|
||||
*
|
||||
* @param {string} text Message text.
|
||||
* @param text Message text.
|
||||
*/
|
||||
sendMessage(text: string): void {
|
||||
let message;
|
||||
|
@ -1046,9 +1046,9 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
|||
* Check date should be shown on message list for the current message.
|
||||
* If date has changed from previous to current message it should be shown.
|
||||
*
|
||||
* @param {any} message Current message where to show the date.
|
||||
* @param {any} [prevMessage] Previous message where to compare the date with.
|
||||
* @return {boolean} If date has changed and should be shown.
|
||||
* @param message Current message where to show the date.
|
||||
* @param prevMessage Previous message where to compare the date with.
|
||||
* @return If date has changed and should be shown.
|
||||
*/
|
||||
showDate(message: any, prevMessage?: any): boolean {
|
||||
if (!prevMessage) {
|
||||
|
@ -1064,9 +1064,9 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
|||
* Check if the user info should be displayed for the current message.
|
||||
* User data is only displayed for group conversations if the previous message was from another user.
|
||||
*
|
||||
* @param {any} message Current message where to show the user info.
|
||||
* @param {any} [prevMessage] Previous message.
|
||||
* @return {boolean} Whether user data should be shown.
|
||||
* @param message Current message where to show the user info.
|
||||
* @param prevMessage Previous message.
|
||||
* @return Whether user data should be shown.
|
||||
*/
|
||||
showUserData(message: any, prevMessage?: any): boolean {
|
||||
return this.isGroup && message.useridfrom != this.currentUserId && this.members[message.useridfrom] &&
|
||||
|
@ -1076,9 +1076,9 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
|||
/**
|
||||
* Check if a css tail should be shown.
|
||||
*
|
||||
* @param {any} message Current message where to show the user info.
|
||||
* @param {any} [nextMessage] Next message.
|
||||
* @return {boolean} Whether user data should be shown.
|
||||
* @param message Current message where to show the user info.
|
||||
* @param nextMessage Next message.
|
||||
* @return Whether user data should be shown.
|
||||
*/
|
||||
showTail(message: any, nextMessage?: any): boolean {
|
||||
return !nextMessage || nextMessage.useridfrom != message.useridfrom || nextMessage.showDate;
|
||||
|
@ -1125,7 +1125,7 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
|||
/**
|
||||
* Change the favourite state of the current conversation.
|
||||
*
|
||||
* @param {Function} [done] Function to call when done.
|
||||
* @param done Function to call when done.
|
||||
*/
|
||||
changeFavourite(done?: () => void): void {
|
||||
this.favouriteIcon = 'spinner';
|
||||
|
@ -1153,7 +1153,7 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
|||
/**
|
||||
* Change the mute state of the current conversation.
|
||||
*
|
||||
* @param {Function} [done] Function to call when done.
|
||||
* @param done Function to call when done.
|
||||
*/
|
||||
changeMute(done?: () => void): void {
|
||||
this.muteIcon = 'spinner';
|
||||
|
@ -1218,7 +1218,7 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
|||
/**
|
||||
* Displays a confirmation modal to block the user of the individual conversation.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when user is blocked or dialog is cancelled.
|
||||
* @return Promise resolved when user is blocked or dialog is cancelled.
|
||||
*/
|
||||
blockUser(): Promise<any> {
|
||||
if (!this.otherMember) {
|
||||
|
@ -1249,7 +1249,7 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
|||
/**
|
||||
* Delete the conversation.
|
||||
*
|
||||
* @param {Function} [done] Function to call when done.
|
||||
* @param done Function to call when done.
|
||||
*/
|
||||
deleteConversation(done?: () => void): void {
|
||||
const confirmMessage = 'addon.messages.' + (this.isSelf ? 'deleteallselfconfirm' : 'deleteallconfirm');
|
||||
|
@ -1276,7 +1276,7 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
|||
/**
|
||||
* Displays a confirmation modal to unblock the user of the individual conversation.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when user is unblocked or dialog is cancelled.
|
||||
* @return Promise resolved when user is unblocked or dialog is cancelled.
|
||||
*/
|
||||
unblockUser(): Promise<any> {
|
||||
if (!this.otherMember) {
|
||||
|
@ -1307,7 +1307,7 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
|||
/**
|
||||
* Displays a confirmation modal to send a contact request to the other user of the individual conversation.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when the request is sent or the dialog is cancelled.
|
||||
* @return Promise resolved when the request is sent or the dialog is cancelled.
|
||||
*/
|
||||
createContactRequest(): Promise<any> {
|
||||
if (!this.otherMember) {
|
||||
|
@ -1338,7 +1338,7 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
|||
/**
|
||||
* Confirms the contact request of the other user of the individual conversation.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when the request is confirmed.
|
||||
* @return Promise resolved when the request is confirmed.
|
||||
*/
|
||||
confirmContactRequest(): Promise<any> {
|
||||
if (!this.otherMember) {
|
||||
|
@ -1360,7 +1360,7 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
|||
/**
|
||||
* Declines the contact request of the other user of the individual conversation.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when the request is confirmed.
|
||||
* @return Promise resolved when the request is confirmed.
|
||||
*/
|
||||
declineContactRequest(): Promise<any> {
|
||||
if (!this.otherMember) {
|
||||
|
@ -1382,7 +1382,7 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
|||
/**
|
||||
* Displays a confirmation modal to remove the other user of the conversation from contacts.
|
||||
*
|
||||
* @return {Promise<any>} Promise resolved when the request is sent or the dialog is cancelled.
|
||||
* @return Promise resolved when the request is sent or the dialog is cancelled.
|
||||
*/
|
||||
removeContact(): Promise<any> {
|
||||
if (!this.otherMember) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue