commit
dfd5788271
|
@ -14,7 +14,7 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AddonMessagesProvider } from './messages';
|
||||
import { CoreMainMenuDelegate, CoreMainMenuHandler, CoreMainMenuHandlerToDisplay } from '@core/mainmenu/providers/delegate';
|
||||
import { CoreMainMenuHandler, CoreMainMenuHandlerToDisplay } from '@core/mainmenu/providers/delegate';
|
||||
import { CoreCronHandler } from '@providers/cron';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreEventsProvider } from '@providers/events';
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { CoreContentLinksModuleIndexHandler } from '@core/contentlinks/classes/module-index-handler';
|
||||
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
||||
import { AddonModBookProvider } from './book';
|
||||
|
||||
/**
|
||||
* Handler to treat links to book.
|
||||
|
@ -24,6 +25,6 @@ export class AddonModBookLinkHandler extends CoreContentLinksModuleIndexHandler
|
|||
name = 'AddonModBookLinkHandler';
|
||||
|
||||
constructor(courseHelper: CoreCourseHelperProvider) {
|
||||
super(courseHelper, 'mmaModBook', 'book');
|
||||
super(courseHelper, AddonModBookProvider.COMPONENT, 'book');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
// (C) Copyright 2015 Martin Dougiamas
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { IonicModule } from 'ionic-angular';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { CoreComponentsModule } from '@components/components.module';
|
||||
import { CoreCourseComponentsModule } from '@core/course/components/components.module';
|
||||
import { AddonModFolderIndexComponent } from './index/index';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AddonModFolderIndexComponent
|
||||
],
|
||||
imports: [
|
||||
CommonModule,
|
||||
IonicModule,
|
||||
TranslateModule.forChild(),
|
||||
CoreComponentsModule,
|
||||
CoreCourseComponentsModule
|
||||
],
|
||||
providers: [
|
||||
],
|
||||
exports: [
|
||||
AddonModFolderIndexComponent
|
||||
],
|
||||
entryComponents: [
|
||||
AddonModFolderIndexComponent
|
||||
]
|
||||
})
|
||||
export class AddonModFolderComponentsModule {}
|
|
@ -0,0 +1,29 @@
|
|||
<!-- Buttons to add to the header. -->
|
||||
<core-navbar-buttons end>
|
||||
<core-context-menu>
|
||||
<core-context-menu-item *ngIf="externalUrl" [priority]="900" [content]="'core.openinbrowser' | translate" [href]="externalUrl" [iconAction]="'open'"></core-context-menu-item>
|
||||
<core-context-menu-item *ngIf="description" [priority]="800" [content]="'core.moduleintro' | translate" (action)="expandDescription()" [iconAction]="'arrow-forward'"></core-context-menu-item>
|
||||
<core-context-menu-item [priority]="700" [content]="'core.refresh' | translate" (action)="doRefresh(null, $event)" [iconAction]="refreshIcon" [closeOnClick]="false"></core-context-menu-item>
|
||||
<core-context-menu-item *ngIf="prefetchStatusIcon" [priority]="600" [content]="prefetchText" (action)="prefetch()" [iconAction]="prefetchStatusIcon" [closeOnClick]="false"></core-context-menu-item>
|
||||
<core-context-menu-item *ngIf="size" [priority]="500" [content]="size" [iconDescription]="'cube'" (action)="removeFiles()" [iconAction]="'trash'"></core-context-menu-item>
|
||||
</core-context-menu>
|
||||
</core-navbar-buttons>
|
||||
|
||||
<!-- Content. -->
|
||||
<core-loading [hideUntil]="loaded" class="core-loading-center">
|
||||
|
||||
<core-course-module-description [description]="description" [component]="component" [componentId]="componentId"></core-course-module-description>
|
||||
|
||||
<ion-list *ngIf="contents && contents.length > 0">
|
||||
<ng-container *ngFor="let file of contents">
|
||||
<a *ngIf="file.type === 'folder'" ion-item class="item-media" [navPush]="'AddonModFolderIndexPage'" [navParams]="{path: file.filepath, courseId: courseId, module: file}">
|
||||
<img [src]="file.fileicon" alt="" role="presentation" item-start>
|
||||
<p>{{file.name}}</p>
|
||||
</a>
|
||||
<core-file *ngIf="file.type !== 'folder'" [file]="file" [component]="component" [componentId]="file.contextid"></core-file>
|
||||
</ng-container>
|
||||
</ion-list>
|
||||
|
||||
<core-empty-box *ngIf="!contents || contents.length == 0" icon="folder" [message]=" 'addon.mod_folder.emptyfilelist' | translate"></core-empty-box>
|
||||
|
||||
</core-loading>
|
|
@ -0,0 +1,6 @@
|
|||
addon-mod-folder-index {
|
||||
.item-media > img:first-child {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,213 @@
|
|||
// (C) Copyright 2015 Martin Dougiamas
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { Component, OnInit, OnDestroy, Input, Output, EventEmitter } from '@angular/core';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { CoreAppProvider } from '@providers/app';
|
||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||
import { CoreTextUtilsProvider } from '@providers/utils/text';
|
||||
import { CoreCourseProvider } from '@core/course/providers/course';
|
||||
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
||||
import { CoreCourseModuleMainComponent } from '@core/course/providers/module-delegate';
|
||||
import { AddonModFolderProvider } from '../../providers/folder';
|
||||
import { AddonModFolderHelperProvider } from '../../providers/helper';
|
||||
|
||||
/**
|
||||
* Component that displays a folder.
|
||||
* @todo Adding a new file in a folder updates the revision of all the files, so they're all shown as outdated.
|
||||
* To ignore revision in folders we'll have to modify CoreCourseModulePrefetchDelegate, core-file and CoreFilepoolProvider.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'addon-mod-folder-index',
|
||||
templateUrl: 'index.html',
|
||||
})
|
||||
export class AddonModFolderIndexComponent implements OnInit, OnDestroy, CoreCourseModuleMainComponent {
|
||||
@Input() module: any; // The module of the folder.
|
||||
@Input() courseId: number; // Course ID the folder belongs to.
|
||||
@Input() path: string; // For subfolders. Use the path instead of a boolean so Angular detects them as different states.
|
||||
@Output() folderRetrieved?: EventEmitter<any>;
|
||||
|
||||
loaded: boolean;
|
||||
canReload: boolean;
|
||||
component = AddonModFolderProvider.COMPONENT;
|
||||
componentId: number;
|
||||
canGetFolder: boolean;
|
||||
contents: any;
|
||||
|
||||
// Data for context menu.
|
||||
externalUrl: string;
|
||||
description: string;
|
||||
refreshIcon: string;
|
||||
prefetchStatusIcon: string;
|
||||
prefetchText: string;
|
||||
size: string;
|
||||
|
||||
protected isDestroyed;
|
||||
protected statusObserver;
|
||||
|
||||
constructor(private folderProvider: AddonModFolderProvider, private courseProvider: CoreCourseProvider,
|
||||
private domUtils: CoreDomUtilsProvider, private appProvider: CoreAppProvider, private textUtils: CoreTextUtilsProvider,
|
||||
private courseHelper: CoreCourseHelperProvider, private translate: TranslateService,
|
||||
private folderHelper: AddonModFolderHelperProvider) {
|
||||
this.folderRetrieved = new EventEmitter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Component being initialized.
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
this.description = this.module.description;
|
||||
this.componentId = this.module.id;
|
||||
this.externalUrl = this.module.url;
|
||||
this.loaded = false;
|
||||
this.canReload = false;
|
||||
this.refreshIcon = 'spinner';
|
||||
|
||||
this.canGetFolder = this.folderProvider.isGetFolderWSAvailable();
|
||||
|
||||
if (this.path) {
|
||||
// Subfolder. Use module param.
|
||||
this.showModuleData(this.module);
|
||||
this.loaded = true;
|
||||
this.canReload = false;
|
||||
this.refreshIcon = 'refresh';
|
||||
} else {
|
||||
this.fetchContent().then(() => {
|
||||
this.folderProvider.logView(this.module.instance).then(() => {
|
||||
this.courseProvider.checkModuleCompletion(this.courseId, this.module.completionstatus);
|
||||
});
|
||||
}).finally(() => {
|
||||
this.loaded = true;
|
||||
this.canReload = true;
|
||||
this.refreshIcon = 'refresh';
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the data.
|
||||
*
|
||||
* @param {any} [refresher] Refresher.
|
||||
* @param {Function} [done] Function to call when done.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
*/
|
||||
doRefresh(refresher?: any, done?: () => void): Promise<any> {
|
||||
if (this.canReload) {
|
||||
this.refreshIcon = 'spinner';
|
||||
|
||||
this.folderProvider.invalidateContent(this.module.id, this.courseId).catch(() => {
|
||||
// Ignore errors.
|
||||
}).then(() => {
|
||||
return this.fetchContent(true);
|
||||
}).finally(() => {
|
||||
this.refreshIcon = 'refresh';
|
||||
refresher && refresher.complete();
|
||||
done && done();
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
/**
|
||||
* Expand the description.
|
||||
*/
|
||||
expandDescription(): void {
|
||||
this.textUtils.expandText(this.translate.instant('core.description'), this.description, this.component, this.module.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prefetch the module.
|
||||
*/
|
||||
prefetch(): void {
|
||||
this.courseHelper.contextMenuPrefetch(this, this.module, this.courseId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm and remove downloaded files.
|
||||
*/
|
||||
removeFiles(): void {
|
||||
this.courseHelper.confirmAndRemoveFiles(this.module, this.courseId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience function to set scope data using module.
|
||||
* @param {any} module Module to show.
|
||||
*/
|
||||
protected showModuleData(module: any): void {
|
||||
this.description = module.intro || module.description;
|
||||
|
||||
this.folderRetrieved.emit(module);
|
||||
|
||||
if (this.path) {
|
||||
// Subfolder.
|
||||
this.contents = module.contents;
|
||||
} else {
|
||||
this.contents = this.folderHelper.formatContents(module.contents);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Download folder contents.
|
||||
*
|
||||
* @param {boolean} [refresh] Whether we're refreshing data.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
*/
|
||||
protected fetchContent(refresh?: boolean): Promise<any> {
|
||||
let promise;
|
||||
|
||||
if (this.canGetFolder) {
|
||||
promise = this.folderProvider.getFolder(this.courseId, this.module.id).then((folder) => {
|
||||
return this.courseProvider.loadModuleContents(this.module, this.courseId).then(() => {
|
||||
folder.contents = this.module.contents;
|
||||
|
||||
return folder;
|
||||
});
|
||||
});
|
||||
} else {
|
||||
promise = this.courseProvider.getModule(this.module.id, this.courseId).then((folder) => {
|
||||
if (!folder.contents.length && this.module.contents.length && !this.appProvider.isOnline()) {
|
||||
// The contents might be empty due to a cached data. Use the old ones.
|
||||
folder.contents = this.module.contents;
|
||||
}
|
||||
this.module = folder;
|
||||
|
||||
return folder;
|
||||
});
|
||||
}
|
||||
|
||||
return promise.then((folder) => {
|
||||
if (folder) {
|
||||
this.description = folder.intro || folder.description;
|
||||
this.folderRetrieved.emit(folder);
|
||||
}
|
||||
|
||||
this.showModuleData(folder);
|
||||
|
||||
// All data obtained, now fill the context menu.
|
||||
this.courseHelper.fillContextMenu(this, this.module, this.courseId, refresh, this.component);
|
||||
}).catch((error) => {
|
||||
// Error getting data, fail.
|
||||
this.domUtils.showErrorModalDefault(error, 'core.course.errorgetmodule', true);
|
||||
}).finally(() => {
|
||||
this.loaded = true;
|
||||
this.refreshIcon = 'refresh';
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.isDestroyed = true;
|
||||
this.statusObserver && this.statusObserver.off();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
// (C) Copyright 2015 Martin Dougiamas
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { AddonModFolderProvider } from './providers/folder';
|
||||
import { AddonModFolderHelperProvider } from './providers/helper';
|
||||
import { AddonModFolderModuleHandler } from './providers/module-handler';
|
||||
import { CoreCourseModuleDelegate } from '@core/course/providers/module-delegate';
|
||||
import { AddonModFolderComponentsModule } from './components/components.module';
|
||||
import { AddonModFolderPrefetchHandler } from './providers/prefetch-handler';
|
||||
import { AddonModFolderLinkHandler } from './providers/link-handler';
|
||||
import { AddonModFolderPluginFileHandler } from './providers/pluginfile-handler';
|
||||
import { CoreContentLinksDelegate } from '@core/contentlinks/providers/delegate';
|
||||
import { CoreCourseModulePrefetchDelegate } from '@core/course/providers/module-prefetch-delegate';
|
||||
import { CorePluginFileDelegate } from '@providers/plugin-file-delegate';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
],
|
||||
imports: [
|
||||
AddonModFolderComponentsModule
|
||||
],
|
||||
providers: [
|
||||
AddonModFolderProvider,
|
||||
AddonModFolderHelperProvider,
|
||||
AddonModFolderModuleHandler,
|
||||
AddonModFolderPrefetchHandler,
|
||||
AddonModFolderLinkHandler,
|
||||
AddonModFolderPluginFileHandler
|
||||
]
|
||||
})
|
||||
export class AddonModFolderModule {
|
||||
constructor(moduleDelegate: CoreCourseModuleDelegate, moduleHandler: AddonModFolderModuleHandler,
|
||||
prefetchDelegate: CoreCourseModulePrefetchDelegate, prefetchHandler: AddonModFolderPrefetchHandler,
|
||||
contentLinksDelegate: CoreContentLinksDelegate, linkHandler: AddonModFolderLinkHandler,
|
||||
pluginfileDelegate: CorePluginFileDelegate, pluginfileHandler: AddonModFolderPluginFileHandler) {
|
||||
moduleDelegate.registerHandler(moduleHandler);
|
||||
prefetchDelegate.registerHandler(prefetchHandler);
|
||||
contentLinksDelegate.registerHandler(linkHandler);
|
||||
pluginfileDelegate.registerHandler(pluginfileHandler);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"emptyfilelist": "There are no files to show."
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
<ion-header>
|
||||
<ion-navbar>
|
||||
<ion-title><core-format-text [text]="title"></core-format-text></ion-title>
|
||||
|
||||
<ion-buttons end>
|
||||
<!-- The buttons defined by the component will be added in here. -->
|
||||
</ion-buttons>
|
||||
</ion-navbar>
|
||||
</ion-header>
|
||||
<ion-content>
|
||||
<ion-refresher [enabled]="folderComponent.loaded" (ionRefresh)="folderComponent.doRefresh($event)">
|
||||
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
|
||||
</ion-refresher>
|
||||
|
||||
<addon-mod-folder-index [module]="module" [courseId]="courseId" [path]="path" (folderRetrieved)="updateData($event)"></addon-mod-folder-index>
|
||||
</ion-content>
|
|
@ -0,0 +1,33 @@
|
|||
// (C) Copyright 2015 Martin Dougiamas
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { IonicPageModule } from 'ionic-angular';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { CoreDirectivesModule } from '@directives/directives.module';
|
||||
import { AddonModFolderComponentsModule } from '../../components/components.module';
|
||||
import { AddonModFolderIndexPage } from './index';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AddonModFolderIndexPage,
|
||||
],
|
||||
imports: [
|
||||
CoreDirectivesModule,
|
||||
AddonModFolderComponentsModule,
|
||||
IonicPageModule.forChild(AddonModFolderIndexPage),
|
||||
TranslateModule.forChild()
|
||||
],
|
||||
})
|
||||
export class AddonModFolderIndexPageModule {}
|
|
@ -0,0 +1,50 @@
|
|||
// (C) Copyright 2015 Martin Dougiamas
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { Component, ViewChild } from '@angular/core';
|
||||
import { IonicPage, NavParams } from 'ionic-angular';
|
||||
import { AddonModFolderIndexComponent } from '../../components/index/index';
|
||||
|
||||
/**
|
||||
* Page that displays a folder.
|
||||
*/
|
||||
@IonicPage({ segment: 'addon-mod-folder-index' })
|
||||
@Component({
|
||||
selector: 'page-addon-mod-folder-index',
|
||||
templateUrl: 'index.html',
|
||||
})
|
||||
export class AddonModFolderIndexPage {
|
||||
@ViewChild(AddonModFolderIndexComponent) folderComponent: AddonModFolderIndexComponent;
|
||||
|
||||
title: string;
|
||||
module: any;
|
||||
courseId: number;
|
||||
path: string;
|
||||
|
||||
constructor(navParams: NavParams) {
|
||||
this.module = navParams.get('module') || {};
|
||||
this.courseId = navParams.get('courseId');
|
||||
this.path = navParams.get('path');
|
||||
this.title = this.module.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update some data based on the folder instance.
|
||||
*
|
||||
* @param {any} folder Folder instance.
|
||||
*/
|
||||
updateData(folder: any): void {
|
||||
this.title = folder.name || this.title;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,144 @@
|
|||
// (C) Copyright 2015 Martin Dougiamas
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreLoggerProvider } from '@providers/logger';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
import { CoreCourseProvider } from '@core/course/providers/course';
|
||||
|
||||
/**
|
||||
* Service that provides some features for folder.
|
||||
*/
|
||||
@Injectable()
|
||||
export class AddonModFolderProvider {
|
||||
static COMPONENT = 'mmaModFolder';
|
||||
|
||||
protected ROOT_CACHE_KEY = 'mmaModFolder:';
|
||||
protected logger;
|
||||
|
||||
constructor(logger: CoreLoggerProvider, private sitesProvider: CoreSitesProvider, private courseProvider: CoreCourseProvider,
|
||||
private utils: CoreUtilsProvider) {
|
||||
this.logger = logger.getInstance('mmaModFolderProvider');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a folder by course module ID.
|
||||
*
|
||||
* @param {number} courseId Course ID.
|
||||
* @param {number} cmId Course module ID.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved when the book is retrieved.
|
||||
*/
|
||||
getFolder(courseId: number, cmId: number, siteId?: string): Promise<any> {
|
||||
return this.getFolderByKey(courseId, 'coursemodule', cmId, siteId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a folder.
|
||||
*
|
||||
* @param {number} courseId Course ID.
|
||||
* @param {string} key Name of the property to check.
|
||||
* @param {any} value Value to search.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved when the book is retrieved.
|
||||
*/
|
||||
protected getFolderByKey(courseId: number, key: string, value: any, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
const params = {
|
||||
courseids: [courseId]
|
||||
},
|
||||
preSets = {
|
||||
cacheKey: this.getFolderCacheKey(courseId)
|
||||
};
|
||||
|
||||
return site.read('mod_folder_get_folders_by_courses', params, preSets).then((response) => {
|
||||
if (response && response.folders) {
|
||||
const currentFolder = response.folders.find((folder) => {
|
||||
return folder[key] == value;
|
||||
});
|
||||
if (currentFolder) {
|
||||
return currentFolder;
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.reject(null);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cache key for folder data WS calls.
|
||||
*
|
||||
* @param {number} courseId Course ID.
|
||||
* @return {string} Cache key.
|
||||
*/
|
||||
protected getFolderCacheKey(courseId: number): string {
|
||||
return this.ROOT_CACHE_KEY + 'folder:' + courseId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidate the prefetched content.
|
||||
*
|
||||
* @param {number} moduleId The module ID.
|
||||
* @param {number} courseId Course ID of the module.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>}
|
||||
*/
|
||||
invalidateContent(moduleId: number, courseId: number, siteId?: string): Promise<any> {
|
||||
const promises = [];
|
||||
|
||||
promises.push(this.invalidateFolderData(courseId, siteId));
|
||||
promises.push(this.courseProvider.invalidateModule(moduleId, siteId));
|
||||
|
||||
return this.utils.allPromises(promises);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidates folder data.
|
||||
*
|
||||
* @param {number} courseId Course ID.
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<any>} Promise resolved when the data is invalidated.
|
||||
*/
|
||||
invalidateFolderData(courseId: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
return site.invalidateWsCacheForKey(this.getFolderCacheKey(courseId));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not getFolder WS available or not.
|
||||
*
|
||||
* @return {boolean} If WS is avalaible.
|
||||
* @since 3.3
|
||||
*/
|
||||
isGetFolderWSAvailable(): boolean {
|
||||
return this.sitesProvider.wsAvailableInCurrentSite('mod_folder_get_folders_by_courses');
|
||||
}
|
||||
|
||||
/**
|
||||
* Report a folder as being viewed.
|
||||
*
|
||||
* @param {number} id Module ID.
|
||||
* @return {Promise<any>} Promise resolved when the WS call is successful.
|
||||
*/
|
||||
logView(id: number): Promise<any> {
|
||||
const params = {
|
||||
folderid: id
|
||||
};
|
||||
|
||||
return this.sitesProvider.getCurrentSite().write('mod_folder_view_folder', params);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
// (C) Copyright 2015 Martin Dougiamas
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreCourseProvider } from '@core/course/providers/course';
|
||||
|
||||
/**
|
||||
* Service that provides some features for folder.
|
||||
*/
|
||||
@Injectable()
|
||||
export class AddonModFolderHelperProvider {
|
||||
|
||||
constructor(private courseProvider: CoreCourseProvider) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Format folder contents, creating directory structure.
|
||||
* Folders found in filepaths are added to the array. Each folder has the properties: name, fileicon,
|
||||
* type (folder), filepath and contents (array with files and subfolders).
|
||||
*
|
||||
* @param {any[]} contents Folder contents.
|
||||
* @return {any[]} Formatted contents.
|
||||
*/
|
||||
formatContents(contents: any[]): any[] {
|
||||
const files = [],
|
||||
folders = [],
|
||||
folderIcon = this.courseProvider.getModuleIconSrc('folder');
|
||||
|
||||
contents.forEach((entry) => {
|
||||
if (entry.filepath !== '/') {
|
||||
// It's a file in a subfolder. Lets treat the path to add the subfolders to the array.
|
||||
let directories,
|
||||
currentList = folders, // Start at root level.
|
||||
path = entry.filepath,
|
||||
subpath = '';
|
||||
|
||||
// Remove first and last slash if needed.
|
||||
if (path.substr(0, 1) === '/') {
|
||||
path = path.substr(1);
|
||||
}
|
||||
if (path.substr(path.length - 1) === '/') {
|
||||
path = path.slice(0, -1);
|
||||
}
|
||||
|
||||
directories = path.split('/');
|
||||
|
||||
directories.forEach((directory) => {
|
||||
subpath = subpath + '/' + directory;
|
||||
// Search if the directory is already stored in folders array.
|
||||
const foundList = currentList.find((list) => {
|
||||
return list.name === directory;
|
||||
});
|
||||
|
||||
if (foundList) {
|
||||
currentList = foundList.contents;
|
||||
} else {
|
||||
// Directory not found. Add it to the array.
|
||||
const newFolder = {
|
||||
name: directory,
|
||||
fileicon: folderIcon,
|
||||
contents: [],
|
||||
filepath: subpath,
|
||||
type: 'folder'
|
||||
};
|
||||
currentList.push(newFolder);
|
||||
currentList = newFolder.contents;
|
||||
}
|
||||
});
|
||||
|
||||
currentList.push(entry);
|
||||
} else {
|
||||
files.push(entry);
|
||||
}
|
||||
});
|
||||
|
||||
return folders.concat(files);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
// (C) Copyright 2015 Martin Dougiamas
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreContentLinksModuleIndexHandler } from '@core/contentlinks/classes/module-index-handler';
|
||||
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
||||
import { AddonModFolderProvider } from './folder';
|
||||
|
||||
/**
|
||||
* Handler to treat links to resource.
|
||||
*/
|
||||
@Injectable()
|
||||
export class AddonModFolderLinkHandler extends CoreContentLinksModuleIndexHandler {
|
||||
name = 'AddonModFolderLinkHandler';
|
||||
|
||||
constructor(courseHelper: CoreCourseHelperProvider) {
|
||||
super(courseHelper, AddonModFolderProvider.COMPONENT, 'folder');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
// (C) Copyright 2015 Martin Dougiamas
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { NavController, NavOptions } from 'ionic-angular';
|
||||
import { AddonModFolderIndexComponent } from '../components/index/index';
|
||||
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@core/course/providers/module-delegate';
|
||||
import { CoreCourseProvider } from '@core/course/providers/course';
|
||||
|
||||
/**
|
||||
* Handler to support folder modules.
|
||||
*/
|
||||
@Injectable()
|
||||
export class AddonModFolderModuleHandler implements CoreCourseModuleHandler {
|
||||
name = 'folder';
|
||||
|
||||
constructor(private courseProvider: CoreCourseProvider) { }
|
||||
|
||||
/**
|
||||
* Check if the handler is enabled on a site level.
|
||||
*
|
||||
* @return {boolean|Promise<boolean>} Whether or not the handler is enabled on a site level.
|
||||
*/
|
||||
isEnabled(): boolean | Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data required to display the module in the course contents view.
|
||||
*
|
||||
* @param {any} module The module object.
|
||||
* @param {number} courseId The course ID.
|
||||
* @param {number} sectionId The section ID.
|
||||
* @return {CoreCourseModuleHandlerData} Data to render the module.
|
||||
*/
|
||||
getData(module: any, courseId: number, sectionId: number): CoreCourseModuleHandlerData {
|
||||
return {
|
||||
icon: this.courseProvider.getModuleIconSrc('folder'),
|
||||
title: module.name,
|
||||
class: 'addon-mod_folder-handler',
|
||||
showDownloadButton: true,
|
||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
||||
navCtrl.push('AddonModFolderIndexPage', {module: module, courseId: courseId}, options);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the component to render the module. This is needed to support singleactivity course format.
|
||||
* The component returned must implement CoreCourseModuleMainComponent.
|
||||
*
|
||||
* @param {any} course The course object.
|
||||
* @param {any} module The module object.
|
||||
* @return {any} The component to use, undefined if not found.
|
||||
*/
|
||||
getMainComponent(course: any, module: any): any {
|
||||
return AddonModFolderIndexComponent;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
// (C) Copyright 2015 Martin Dougiamas
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CorePluginFileHandler } from '@providers/plugin-file-delegate';
|
||||
|
||||
/**
|
||||
* Handler to treat links to folder.
|
||||
*/
|
||||
@Injectable()
|
||||
export class AddonModFolderPluginFileHandler implements CorePluginFileHandler {
|
||||
name = 'AddonModFolderPluginFileHandler';
|
||||
|
||||
/**
|
||||
* Return the RegExp to match the revision on pluginfile URLs.
|
||||
*
|
||||
* @param {string[]} args Arguments of the pluginfile URL defining component and filearea at least.
|
||||
* @return {RegExp} RegExp to match the revision on pluginfile URLs.
|
||||
*/
|
||||
getComponentRevisionRegExp(args: string[]): RegExp {
|
||||
// Check filearea.
|
||||
if (args[2] == 'content') {
|
||||
// Component + Filearea + Revision
|
||||
return new RegExp('/mod_folder/content/([0-9]+)/');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Should return the string to remove the revision on pluginfile url.
|
||||
*
|
||||
* @param {string[]} args Arguments of the pluginfile URL defining component and filearea at least.
|
||||
* @return {string} String to remove the revision on pluginfile url.
|
||||
*/
|
||||
getComponentRevisionReplace(args: string[]): string {
|
||||
// Component + Filearea + Revision
|
||||
return '/mod_folder/content/0/';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
// (C) Copyright 2015 Martin Dougiamas
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { Injectable, Injector } from '@angular/core';
|
||||
import { CoreCourseModulePrefetchHandlerBase } from '@core/course/classes/module-prefetch-handler';
|
||||
import { AddonModFolderProvider } from './folder';
|
||||
|
||||
/**
|
||||
* Handler to prefetch folders.
|
||||
*/
|
||||
@Injectable()
|
||||
export class AddonModFolderPrefetchHandler extends CoreCourseModulePrefetchHandlerBase {
|
||||
name = 'folder';
|
||||
component = AddonModFolderProvider.COMPONENT;
|
||||
isResource = true;
|
||||
|
||||
constructor(injector: Injector, protected folderProvider: AddonModFolderProvider) {
|
||||
super(injector);
|
||||
}
|
||||
|
||||
/**
|
||||
* Download or prefetch the content.
|
||||
*
|
||||
* @param {any} module The module object returned by WS.
|
||||
* @param {number} courseId Course ID.
|
||||
* @param {boolean} [prefetch] True to prefetch, false to download right away.
|
||||
* @param {string} [dirPath] Path of the directory where to store all the content files. This is to keep the files
|
||||
* relative paths and make the package work in an iframe. Undefined to download the files
|
||||
* in the filepool root folder.
|
||||
* @return {Promise<any>} Promise resolved when all content is downloaded. Data returned is not reliable.
|
||||
*/
|
||||
downloadOrPrefetch(module: any, courseId: number, prefetch?: boolean, dirPath?: string): Promise<any> {
|
||||
const promises = [];
|
||||
|
||||
promises.push(super.downloadOrPrefetch(module, courseId, prefetch));
|
||||
|
||||
if (this.folderProvider.isGetFolderWSAvailable()) {
|
||||
promises.push(this.folderProvider.getFolder(courseId, module.id));
|
||||
}
|
||||
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidate the prefetched content.
|
||||
*
|
||||
* @param {number} moduleId The module ID.
|
||||
* @param {number} courseId Course ID the module belongs to.
|
||||
* @return {Promise<any>} Promise resolved when the data is invalidated.
|
||||
*/
|
||||
invalidateContent(moduleId: number, courseId: number): Promise<any> {
|
||||
return this.folderProvider.invalidateContent(moduleId, courseId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidate WS calls needed to determine module status.
|
||||
*
|
||||
* @param {any} module Module.
|
||||
* @param {number} courseId Course ID the module belongs to.
|
||||
* @return {Promise<any>} Promise resolved when invalidated.
|
||||
*/
|
||||
invalidateModule(module: any, courseId: number): Promise<any> {
|
||||
const promises = [];
|
||||
|
||||
promises.push(this.folderProvider.invalidateFolderData(courseId));
|
||||
promises.push(this.courseProvider.invalidateModule(module.id));
|
||||
|
||||
return Promise.all(promises);
|
||||
}
|
||||
}
|
|
@ -104,6 +104,8 @@ export class AddonModResourceIndexComponent implements OnInit, OnDestroy, CoreCo
|
|||
done && done();
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,15 +17,12 @@ import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
|||
import { CoreCourseProvider } from '@core/course/providers/course';
|
||||
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
||||
import { AddonModResourceProvider } from './resource';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
import { CoreFilepoolProvider } from '@providers/filepool';
|
||||
import { CoreFileProvider } from '@providers/file';
|
||||
import { CoreAppProvider } from '@providers/app';
|
||||
import { CoreMimetypeUtilsProvider } from '@providers/utils/mimetype';
|
||||
import { CoreTextUtilsProvider } from '@providers/utils/text';
|
||||
import { CoreConstants } from '@core/constants';
|
||||
|
||||
/**
|
||||
* Service that provides helper functions for resources.
|
||||
|
@ -43,8 +40,7 @@ export class AddonModResourceHelperProvider {
|
|||
private resourceProvider: AddonModResourceProvider, private courseHelper: CoreCourseHelperProvider,
|
||||
private textUtils: CoreTextUtilsProvider, private mimetypeUtils: CoreMimetypeUtilsProvider,
|
||||
private fileProvider: CoreFileProvider, private appProvider: CoreAppProvider,
|
||||
private filepoolProvider: CoreFilepoolProvider, private utils: CoreUtilsProvider,
|
||||
private sitesProvider: CoreSitesProvider, private translate: TranslateService) {
|
||||
private filepoolProvider: CoreFilepoolProvider, private sitesProvider: CoreSitesProvider) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { CoreContentLinksModuleIndexHandler } from '@core/contentlinks/classes/module-index-handler';
|
||||
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
||||
import { AddonModResourceProvider } from './resource';
|
||||
|
||||
/**
|
||||
* Handler to treat links to resource.
|
||||
|
@ -24,6 +25,6 @@ export class AddonModResourceLinkHandler extends CoreContentLinksModuleIndexHand
|
|||
name = 'AddonModResourceLinkHandler';
|
||||
|
||||
constructor(courseHelper: CoreCourseHelperProvider) {
|
||||
super(courseHelper, AddonModResourceLinkHandler.name, 'resource');
|
||||
super(courseHelper, AddonModResourceProvider.COMPONENT, 'resource');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,9 +25,9 @@ import { CoreUtilsProvider } from '@providers/utils/utils';
|
|||
})
|
||||
export class AddonUserProfileFieldCheckboxComponent implements OnInit {
|
||||
@Input() field: any; // The profile field to be rendered.
|
||||
@Input() edit?: false; // True if editing the field. Defaults to false.
|
||||
@Input() disabled?: false; // True if disabled. Defaults to false.
|
||||
@Input() form?: FormGroup; // Form where to add the form control.
|
||||
@Input() edit = false; // True if editing the field. Defaults to false.
|
||||
@Input() disabled = false; // True if disabled. Defaults to false.
|
||||
@Input() form: FormGroup; // Form where to add the form control.
|
||||
|
||||
constructor(private fb: FormBuilder, protected utils: CoreUtilsProvider) { }
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@ import { CoreUtilsProvider } from '@providers/utils/utils';
|
|||
})
|
||||
export class AddonUserProfileFieldDatetimeComponent implements OnInit {
|
||||
@Input() field: any; // The profile field to be rendered.
|
||||
@Input() edit? = false; // True if editing the field. Defaults to false.
|
||||
@Input() disabled? = false; // True if disabled. Defaults to false.
|
||||
@Input() edit = false; // True if editing the field. Defaults to false.
|
||||
@Input() disabled = false; // True if disabled. Defaults to false.
|
||||
@Input() form?: FormGroup; // Form where to add the form control.
|
||||
|
||||
constructor(private fb: FormBuilder, private timeUtils: CoreTimeUtilsProvider, protected utils: CoreUtilsProvider) { }
|
||||
|
|
|
@ -24,8 +24,8 @@ import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
|||
})
|
||||
export class AddonUserProfileFieldMenuComponent implements OnInit {
|
||||
@Input() field: any; // The profile field to be rendered.
|
||||
@Input() edit? = false; // True if editing the field. Defaults to false.
|
||||
@Input() disabled? = false; // True if disabled. Defaults to false.
|
||||
@Input() edit = false; // True if editing the field. Defaults to false.
|
||||
@Input() disabled = false; // True if disabled. Defaults to false.
|
||||
@Input() form?: FormGroup; // Form where to add the form control.
|
||||
|
||||
constructor(private fb: FormBuilder) { }
|
||||
|
|
|
@ -25,8 +25,8 @@ import { CoreUtilsProvider } from '@providers/utils/utils';
|
|||
})
|
||||
export class AddonUserProfileFieldTextComponent implements OnInit {
|
||||
@Input() field: any; // The profile field to be rendered.
|
||||
@Input() edit? = false; // True if editing the field. Defaults to false.
|
||||
@Input() disabled? = false; // True if disabled. Defaults to false.
|
||||
@Input() edit = false; // True if editing the field. Defaults to false.
|
||||
@Input() disabled = false; // True if disabled. Defaults to false.
|
||||
@Input() form?: FormGroup; // Form where to add the form control.
|
||||
|
||||
constructor(private fb: FormBuilder, protected utils: CoreUtilsProvider) { }
|
||||
|
|
|
@ -24,8 +24,8 @@ import { FormGroup, Validators, FormControl } from '@angular/forms';
|
|||
})
|
||||
export class AddonUserProfileFieldTextareaComponent implements OnInit {
|
||||
@Input() field: any; // The profile field to be rendered.
|
||||
@Input() edit? = false; // True if editing the field. Defaults to false.
|
||||
@Input() disabled? = false; // True if disabled. Defaults to false.
|
||||
@Input() edit = false; // True if editing the field. Defaults to false.
|
||||
@Input() disabled = false; // True if disabled. Defaults to false.
|
||||
@Input() form?: FormGroup; // Form where to add the form control.
|
||||
|
||||
control: FormControl;
|
||||
|
|
|
@ -76,6 +76,7 @@ import { AddonFilesModule } from '@addon/files/files.module';
|
|||
import { AddonModBookModule } from '@addon/mod/book/book.module';
|
||||
import { AddonModLabelModule } from '@addon/mod/label/label.module';
|
||||
import { AddonModResourceModule } from '@addon/mod/resource/resource.module';
|
||||
import { AddonModFolderModule } from '@addon/mod/folder/folder.module';
|
||||
import { AddonMessagesModule } from '@addon/messages/messages.module';
|
||||
import { AddonPushNotificationsModule } from '@addon/pushnotifications/pushnotifications.module';
|
||||
import { AddonRemoteThemesModule } from '@addon/remotethemes/remotethemes.module';
|
||||
|
@ -156,6 +157,7 @@ export const CORE_PROVIDERS: any[] = [
|
|||
AddonModBookModule,
|
||||
AddonModLabelModule,
|
||||
AddonModResourceModule,
|
||||
AddonModFolderModule,
|
||||
AddonMessagesModule,
|
||||
AddonPushNotificationsModule,
|
||||
AddonRemoteThemesModule
|
||||
|
|
|
@ -32,7 +32,7 @@ import { Component, Input, OnChanges, OnDestroy, Output, EventEmitter, SimpleCha
|
|||
})
|
||||
export class CoreChronoComponent implements OnChanges, OnDestroy {
|
||||
@Input() running: boolean; // Set it to true to start the chrono. Set it to false to stop it.
|
||||
@Input() startTime? = 0; // Number of milliseconds to put in the chrono before starting.
|
||||
@Input() startTime = 0; // Number of milliseconds to put in the chrono before starting.
|
||||
@Input() endTime?: number; // Number of milliseconds to stop the chrono.
|
||||
@Input() reset?: boolean; // Set it to true to reset the chrono.
|
||||
@Output() onEnd?: EventEmitter<void>; // Will emit an event when the endTime is reached.
|
||||
|
|
|
@ -49,7 +49,7 @@ export class CoreContextMenuItemComponent implements OnInit, OnDestroy, OnChange
|
|||
@Input() badge?: string; // A badge to show in the item.
|
||||
@Input() badgeClass?: number; // A class to set in the badge.
|
||||
@Input() hidden?: boolean; // Whether the item should be hidden.
|
||||
@Output() action?: EventEmitter<string>; // Will emit an event when the item clicked.
|
||||
@Output() action?: EventEmitter<() => void>; // Will emit an event when the item clicked.
|
||||
|
||||
protected hasAction = false;
|
||||
protected destroyed = false;
|
||||
|
|
|
@ -40,7 +40,7 @@ export class CoreRichTextEditorComponent {
|
|||
// Based on: https://github.com/judgewest2000/Ionic3RichText/
|
||||
// @todo: Resize, images, anchor button, fullscreen...
|
||||
|
||||
@Input() placeholder? = ''; // Placeholder to set in textarea.
|
||||
@Input() placeholder = ''; // Placeholder to set in textarea.
|
||||
@Input() control: FormControl; // Form control.
|
||||
@Output() contentChanged: EventEmitter<string>;
|
||||
|
||||
|
|
|
@ -33,12 +33,12 @@ import { CoreUtilsProvider } from '@providers/utils/utils';
|
|||
export class CoreSearchBoxComponent implements OnInit {
|
||||
@Input() searchLabel?: string; // Label to be used on action button.
|
||||
@Input() placeholder?: string; // Placeholder text for search text input.
|
||||
@Input() autocorrect? = 'on'; // Enables/disable Autocorrection on search text input.
|
||||
@Input() autocorrect = 'on'; // Enables/disable Autocorrection on search text input.
|
||||
@Input() spellcheck?: string | boolean = true; // Enables/disable Spellchecker on search text input.
|
||||
@Input() autoFocus?: string | boolean; // Enables/disable Autofocus when entering view.
|
||||
@Input() lengthCheck? = 3; // Check value length before submit. If 0, any string will be submitted.
|
||||
@Input() showClear? = true; // Show/hide clear button.
|
||||
@Input() disabled? = false; // Disables the input text.
|
||||
@Input() lengthCheck = 3; // Check value length before submit. If 0, any string will be submitted.
|
||||
@Input() showClear = true; // Show/hide clear button.
|
||||
@Input() disabled = false; // Disables the input text.
|
||||
@Output() onSubmit: EventEmitter<string>; // Send data when submitting the search form.
|
||||
@Output() onClear?: EventEmitter<void>; // Send event when clearing the search form.
|
||||
|
||||
|
|
|
@ -46,8 +46,8 @@ export class CoreTabComponent implements OnInit, OnDestroy {
|
|||
@Input() icon?: string; // The tab icon.
|
||||
@Input() badge?: string; // A badge to add in the tab.
|
||||
@Input() badgeStyle?: string; // The badge color.
|
||||
@Input() enabled? = true; // Whether the tab is enabled.
|
||||
@Input() show? = true; // Whether the tab should be shown.
|
||||
@Input() enabled = true; // Whether the tab is enabled.
|
||||
@Input() show = true; // Whether the tab should be shown.
|
||||
@Input() id?: string; // An ID to identify the tab.
|
||||
@Output() ionSelect: EventEmitter<CoreTabComponent> = new EventEmitter<CoreTabComponent>();
|
||||
|
||||
|
|
|
@ -242,15 +242,11 @@ export class CoreTabsComponent implements OnInit, AfterViewInit, OnChanges {
|
|||
protected sortTabs(): void {
|
||||
if (this.originalTabsContainer) {
|
||||
const newTabs = [];
|
||||
let newSelected;
|
||||
|
||||
this.tabs.forEach((tab, index) => {
|
||||
const originalIndex = Array.prototype.indexOf.call(this.originalTabsContainer.children, tab.element);
|
||||
if (originalIndex != -1) {
|
||||
newTabs[originalIndex] = tab;
|
||||
if (this.selected == index) {
|
||||
newSelected = originalIndex;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -238,7 +238,6 @@ export class FileTransferObjectMock extends FileTransferObject {
|
|||
const basicAuthHeader = this.getBasicAuthHeader(url);
|
||||
let fileKey = null,
|
||||
fileName = null,
|
||||
mimeType = null,
|
||||
params = null,
|
||||
headers = null,
|
||||
httpMethod = null;
|
||||
|
@ -254,7 +253,6 @@ export class FileTransferObjectMock extends FileTransferObject {
|
|||
if (options) {
|
||||
fileKey = options.fileKey;
|
||||
fileName = options.fileName;
|
||||
mimeType = options.mimeType;
|
||||
headers = options.headers;
|
||||
httpMethod = options.httpMethod || 'POST';
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
import { Component, OnDestroy, ViewChild } from '@angular/core';
|
||||
import { IonicPage, NavController, NavParams, Tabs } from 'ionic-angular';
|
||||
import { CoreEventsProvider } from '@providers/events';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreMainMenuProvider } from '../../providers/mainmenu';
|
||||
import { CoreMainMenuDelegate, CoreMainMenuHandlerData } from '../../providers/delegate';
|
||||
|
@ -66,7 +65,7 @@ export class CoreMainMenuPage implements OnDestroy {
|
|||
protected redirectPageLoaded = false;
|
||||
|
||||
constructor(private menuDelegate: CoreMainMenuDelegate, private sitesProvider: CoreSitesProvider, navParams: NavParams,
|
||||
private navCtrl: NavController, private eventsProvider: CoreEventsProvider) {
|
||||
private navCtrl: NavController) {
|
||||
this.redirectPage = navParams.get('redirectPage');
|
||||
this.redirectParams = navParams.get('redirectParams');
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ export class CoreMainMenuMorePage implements OnDestroy {
|
|||
|
||||
constructor(private menuDelegate: CoreMainMenuDelegate, private sitesProvider: CoreSitesProvider,
|
||||
private navCtrl: NavController, private mainMenuProvider: CoreMainMenuProvider,
|
||||
private eventsProvider: CoreEventsProvider) {
|
||||
eventsProvider: CoreEventsProvider) {
|
||||
|
||||
this.langObserver = eventsProvider.on(CoreEventsProvider.LANGUAGE_CHANGED, this.loadSiteInfo.bind(this));
|
||||
this.updateSiteObserver = eventsProvider.on(CoreEventsProvider.SITE_UPDATED, this.loadSiteInfo.bind(this),
|
||||
|
|
|
@ -30,7 +30,7 @@ import { CoreConfigConstants } from '../configconstants';
|
|||
export class CoreLinkDirective implements OnInit {
|
||||
@Input() capture?: boolean | string; // If the link needs to be captured by the app.
|
||||
@Input() inApp?: boolean | string; // True to open in embedded browser, false to open in system browser.
|
||||
@Input() autoLogin?= 'check'; // If the link should be open with auto-login. Accepts the following values:
|
||||
@Input() autoLogin = 'check'; // If the link should be open with auto-login. Accepts the following values:
|
||||
// "yes" -> Always auto-login.
|
||||
// "no" -> Never auto-login.
|
||||
// "check" -> Auto-login only if it points to the current site. Default value.
|
||||
|
|
|
@ -21,7 +21,6 @@ import { CoreLoggerProvider } from './logger';
|
|||
import { CoreSitesFactoryProvider } from './sites-factory';
|
||||
import { CoreTextUtilsProvider } from './utils/text';
|
||||
import { CoreUrlUtilsProvider } from './utils/url';
|
||||
import { CoreUtilsProvider } from './utils/utils';
|
||||
import { CoreConstants } from '@core/constants';
|
||||
import { CoreConfigConstants } from '../configconstants';
|
||||
import { CoreSite } from '@classes/site';
|
||||
|
@ -211,9 +210,8 @@ export class CoreSitesProvider {
|
|||
protected siteTablesSchemas = []; // Schemas for site tables. Other providers can add schemas in here.
|
||||
|
||||
constructor(logger: CoreLoggerProvider, private http: HttpClient, private sitesFactory: CoreSitesFactoryProvider,
|
||||
private appProvider: CoreAppProvider, private utils: CoreUtilsProvider, private translate: TranslateService,
|
||||
private eventsProvider: CoreEventsProvider, private urlUtils: CoreUrlUtilsProvider,
|
||||
private textUtils: CoreTextUtilsProvider) {
|
||||
private appProvider: CoreAppProvider, private translate: TranslateService, private urlUtils: CoreUrlUtilsProvider,
|
||||
private eventsProvider: CoreEventsProvider, private textUtils: CoreTextUtilsProvider) {
|
||||
this.logger = logger.getInstance('CoreSitesProvider');
|
||||
|
||||
this.appDB = appProvider.getDB();
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Platform } from 'ionic-angular';
|
||||
import { Observable } from 'rxjs';
|
||||
import { InAppBrowser, InAppBrowserObject } from '@ionic-native/in-app-browser';
|
||||
import { Clipboard } from '@ionic-native/clipboard';
|
||||
import { CoreAppProvider } from '../app';
|
||||
|
@ -699,15 +698,6 @@ export class CoreUtilsProvider {
|
|||
options.location = 'no';
|
||||
}
|
||||
|
||||
// Convert the options to a string.
|
||||
const optionsArray = [];
|
||||
let optionsString;
|
||||
|
||||
for (const name in options) {
|
||||
optionsArray.push(`${name}=${options[name]}`);
|
||||
}
|
||||
optionsString = optionsArray.join(',');
|
||||
|
||||
this.iabInstance = this.iab.create(url, '_blank', options);
|
||||
|
||||
if (this.appProvider.isDesktop() || this.appProvider.isMobile()) {
|
||||
|
|
|
@ -58,7 +58,6 @@
|
|||
"no-unused-variable": true,
|
||||
"no-var-keyword": true,
|
||||
"switch-default": true,
|
||||
"typeof-compare": true,
|
||||
"use-isnan": true,
|
||||
"eofline": true,
|
||||
"indent": [true, "spaces", 4],
|
||||
|
|
Loading…
Reference in New Issue