MOBILE-2351 survey: Fix PR problems
parent
978f69ea50
commit
5f107f604b
|
@ -12,14 +12,10 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component, Optional } from '@angular/core';
|
import { Component, Optional, Injector } from '@angular/core';
|
||||||
import { Content, PopoverController } from 'ionic-angular';
|
import { Content, PopoverController } from 'ionic-angular';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
|
||||||
import { CoreAppProvider } from '@providers/app';
|
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 { CoreCourseProvider } from '@core/course/providers/course';
|
||||||
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
|
||||||
import { CoreCourseModuleMainResourceComponent } from '@core/course/classes/main-resource-component';
|
import { CoreCourseModuleMainResourceComponent } from '@core/course/classes/main-resource-component';
|
||||||
import { AddonModBookProvider, AddonModBookContentsMap, AddonModBookTocChapter } from '../../providers/book';
|
import { AddonModBookProvider, AddonModBookContentsMap, AddonModBookTocChapter } from '../../providers/book';
|
||||||
import { AddonModBookPrefetchHandler } from '../../providers/prefetch-handler';
|
import { AddonModBookPrefetchHandler } from '../../providers/prefetch-handler';
|
||||||
|
@ -42,12 +38,10 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp
|
||||||
protected currentChapter: string;
|
protected currentChapter: string;
|
||||||
protected contentsMap: AddonModBookContentsMap;
|
protected contentsMap: AddonModBookContentsMap;
|
||||||
|
|
||||||
constructor(private bookProvider: AddonModBookProvider, private courseProvider: CoreCourseProvider,
|
constructor(injector: Injector, private bookProvider: AddonModBookProvider, private courseProvider: CoreCourseProvider,
|
||||||
protected domUtils: CoreDomUtilsProvider, private appProvider: CoreAppProvider,
|
private appProvider: CoreAppProvider, private prefetchDelegate: AddonModBookPrefetchHandler,
|
||||||
protected textUtils: CoreTextUtilsProvider, protected courseHelper: CoreCourseHelperProvider,
|
private popoverCtrl: PopoverController, @Optional() private content: Content) {
|
||||||
private prefetchDelegate: AddonModBookPrefetchHandler, private popoverCtrl: PopoverController,
|
super(injector);
|
||||||
protected translate: TranslateService, @Optional() private content: Content) {
|
|
||||||
super(textUtils, courseHelper, translate, domUtils);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,13 +12,9 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component, Input } from '@angular/core';
|
import { Component, Input, Injector } from '@angular/core';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
|
||||||
import { CoreAppProvider } from '@providers/app';
|
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 { CoreCourseProvider } from '@core/course/providers/course';
|
||||||
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
|
||||||
import { CoreCourseModuleMainResourceComponent } from '@core/course/classes/main-resource-component';
|
import { CoreCourseModuleMainResourceComponent } from '@core/course/classes/main-resource-component';
|
||||||
import { AddonModFolderProvider } from '../../providers/folder';
|
import { AddonModFolderProvider } from '../../providers/folder';
|
||||||
import { AddonModFolderHelperProvider } from '../../providers/helper';
|
import { AddonModFolderHelperProvider } from '../../providers/helper';
|
||||||
|
@ -39,11 +35,9 @@ export class AddonModFolderIndexComponent extends CoreCourseModuleMainResourceCo
|
||||||
canGetFolder: boolean;
|
canGetFolder: boolean;
|
||||||
contents: any;
|
contents: any;
|
||||||
|
|
||||||
constructor(private folderProvider: AddonModFolderProvider, private courseProvider: CoreCourseProvider,
|
constructor(injector: Injector, private folderProvider: AddonModFolderProvider, private courseProvider: CoreCourseProvider,
|
||||||
protected domUtils: CoreDomUtilsProvider, private appProvider: CoreAppProvider,
|
private appProvider: CoreAppProvider, private folderHelper: AddonModFolderHelperProvider) {
|
||||||
protected textUtils: CoreTextUtilsProvider, protected courseHelper: CoreCourseHelperProvider,
|
super(injector);
|
||||||
protected translate: TranslateService, private folderHelper: AddonModFolderHelperProvider) {
|
|
||||||
super(textUtils, courseHelper, translate, domUtils);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,13 +12,9 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component } from '@angular/core';
|
import { Component, Injector } from '@angular/core';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
|
||||||
import { CoreAppProvider } from '@providers/app';
|
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 { CoreCourseProvider } from '@core/course/providers/course';
|
||||||
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
|
||||||
import { CoreCourseModuleMainResourceComponent } from '@core/course/classes/main-resource-component';
|
import { CoreCourseModuleMainResourceComponent } from '@core/course/classes/main-resource-component';
|
||||||
import { AddonModPageProvider } from '../../providers/page';
|
import { AddonModPageProvider } from '../../providers/page';
|
||||||
import { AddonModPageHelperProvider } from '../../providers/helper';
|
import { AddonModPageHelperProvider } from '../../providers/helper';
|
||||||
|
@ -37,12 +33,10 @@ export class AddonModPageIndexComponent extends CoreCourseModuleMainResourceComp
|
||||||
contents: any;
|
contents: any;
|
||||||
protected fetchContentDefaultError = 'addon.mod_page.errorwhileloadingthepage';
|
protected fetchContentDefaultError = 'addon.mod_page.errorwhileloadingthepage';
|
||||||
|
|
||||||
constructor(private pageProvider: AddonModPageProvider, private courseProvider: CoreCourseProvider,
|
constructor(injector: Injector, private pageProvider: AddonModPageProvider, private courseProvider: CoreCourseProvider,
|
||||||
protected domUtils: CoreDomUtilsProvider, private appProvider: CoreAppProvider,
|
private appProvider: CoreAppProvider, private pageHelper: AddonModPageHelperProvider,
|
||||||
protected textUtils: CoreTextUtilsProvider, protected courseHelper: CoreCourseHelperProvider,
|
|
||||||
protected translate: TranslateService, private pageHelper: AddonModPageHelperProvider,
|
|
||||||
private pagePrefetch: AddonModPagePrefetchHandler) {
|
private pagePrefetch: AddonModPagePrefetchHandler) {
|
||||||
super(textUtils, courseHelper, translate, domUtils);
|
super(injector);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,13 +12,9 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component } from '@angular/core';
|
import { Component, Injector } from '@angular/core';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
|
||||||
import { CoreAppProvider } from '@providers/app';
|
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 { CoreCourseProvider } from '@core/course/providers/course';
|
||||||
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
|
||||||
import { CoreCourseModuleMainResourceComponent } from '@core/course/classes/main-resource-component';
|
import { CoreCourseModuleMainResourceComponent } from '@core/course/classes/main-resource-component';
|
||||||
import { AddonModResourceProvider } from '../../providers/resource';
|
import { AddonModResourceProvider } from '../../providers/resource';
|
||||||
import { AddonModResourcePrefetchHandler } from '../../providers/prefetch-handler';
|
import { AddonModResourcePrefetchHandler } from '../../providers/prefetch-handler';
|
||||||
|
@ -39,12 +35,10 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource
|
||||||
src: string;
|
src: string;
|
||||||
contentText: string;
|
contentText: string;
|
||||||
|
|
||||||
constructor(private resourceProvider: AddonModResourceProvider, private courseProvider: CoreCourseProvider,
|
constructor(injector: Injector, private resourceProvider: AddonModResourceProvider, private courseProvider: CoreCourseProvider,
|
||||||
protected domUtils: CoreDomUtilsProvider, private appProvider: CoreAppProvider,
|
private appProvider: CoreAppProvider, private prefetchHandler: AddonModResourcePrefetchHandler,
|
||||||
protected textUtils: CoreTextUtilsProvider, protected courseHelper: CoreCourseHelperProvider,
|
|
||||||
protected translate: TranslateService, private prefetchHandler: AddonModResourcePrefetchHandler,
|
|
||||||
private resourceHelper: AddonModResourceHelperProvider) {
|
private resourceHelper: AddonModResourceHelperProvider) {
|
||||||
super(textUtils, courseHelper, translate, domUtils);
|
super(injector);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
<!-- Content. -->
|
<!-- Content. -->
|
||||||
<core-loading [hideUntil]="loaded" class="core-loading-center">
|
<core-loading [hideUntil]="loaded" class="core-loading-center">
|
||||||
|
|
||||||
<core-course-module-description *ngIf="mode != 'iframe'" [description]="description" [component]="component" [componentId]="componentId"></core-course-module-description>
|
<core-course-module-description [description]="description" [component]="component" [componentId]="componentId"></core-course-module-description>
|
||||||
|
|
||||||
<!-- Survey already done -->
|
<!-- Survey already done -->
|
||||||
<ion-card padding *ngIf="survey && survey.surveydone">
|
<ion-card padding *ngIf="survey && survey.surveydone">
|
||||||
|
|
|
@ -12,17 +12,8 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component, Optional } from '@angular/core';
|
import { Component, Optional, Injector } from '@angular/core';
|
||||||
import { Content } from 'ionic-angular';
|
import { Content } from 'ionic-angular';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
|
||||||
import { Network } from '@ionic-native/network';
|
|
||||||
import { CoreAppProvider } from '@providers/app';
|
|
||||||
import { CoreCourseProvider } from '@core/course/providers/course';
|
|
||||||
import { CoreSitesProvider } from '@providers/sites';
|
|
||||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
|
||||||
import { CoreTextUtilsProvider } from '@providers/utils/text';
|
|
||||||
import { CoreEventsProvider } from '@providers/events';
|
|
||||||
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
|
||||||
import { CoreCourseModuleMainActivityComponent } from '@core/course/classes/main-activity-component';
|
import { CoreCourseModuleMainActivityComponent } from '@core/course/classes/main-activity-component';
|
||||||
import { AddonModSurveyProvider } from '../../providers/survey';
|
import { AddonModSurveyProvider } from '../../providers/survey';
|
||||||
import { AddonModSurveyHelperProvider } from '../../providers/helper';
|
import { AddonModSurveyHelperProvider } from '../../providers/helper';
|
||||||
|
@ -47,14 +38,10 @@ export class AddonModSurveyIndexComponent extends CoreCourseModuleMainActivityCo
|
||||||
protected userId: number;
|
protected userId: number;
|
||||||
protected syncEventName = AddonModSurveySyncProvider.AUTO_SYNCED;
|
protected syncEventName = AddonModSurveySyncProvider.AUTO_SYNCED;
|
||||||
|
|
||||||
constructor(private surveyProvider: AddonModSurveyProvider, protected courseProvider: CoreCourseProvider,
|
constructor(injector: Injector, private surveyProvider: AddonModSurveyProvider, @Optional() private content: Content,
|
||||||
protected domUtils: CoreDomUtilsProvider, protected appProvider: CoreAppProvider,
|
private surveyHelper: AddonModSurveyHelperProvider, private surveyOffline: AddonModSurveyOfflineProvider,
|
||||||
protected courseHelper: CoreCourseHelperProvider, protected translate: TranslateService, network: Network,
|
private surveySync: AddonModSurveySyncProvider) {
|
||||||
private surveyHelper: AddonModSurveyHelperProvider, protected sitesProvider: CoreSitesProvider,
|
super(injector);
|
||||||
protected eventsProvider: CoreEventsProvider, private surveyOffline: AddonModSurveyOfflineProvider,
|
|
||||||
private surveySync: AddonModSurveySyncProvider, @Optional() private content: Content,
|
|
||||||
protected textUtils: CoreTextUtilsProvider) {
|
|
||||||
super(textUtils, courseHelper, translate, domUtils, sitesProvider, courseProvider, network, appProvider, eventsProvider);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -26,10 +26,10 @@ export class AddonModSurveyHelperProvider {
|
||||||
/**
|
/**
|
||||||
* Turns a string with values separated by commas into an array.
|
* Turns a string with values separated by commas into an array.
|
||||||
*
|
*
|
||||||
* @param {string} value Value to convert.
|
* @param {any} value Value to convert.
|
||||||
* @return {string[]} Array.
|
* @return {string[]} Array.
|
||||||
*/
|
*/
|
||||||
protected commaStringToArray(value: string): string[] {
|
protected commaStringToArray(value: any): string[] {
|
||||||
if (typeof value == 'string') {
|
if (typeof value == 'string') {
|
||||||
if (value.length > 0) {
|
if (value.length > 0) {
|
||||||
return value.split(',');
|
return value.split(',');
|
||||||
|
|
|
@ -26,7 +26,7 @@ export class AddonModSurveyOfflineProvider {
|
||||||
protected logger;
|
protected logger;
|
||||||
|
|
||||||
// Variables for database.
|
// Variables for database.
|
||||||
protected SURVEY_TABLE = 'mma_mod_survey_answers';
|
protected SURVEY_TABLE = 'addon_mod_survey_answers';
|
||||||
protected tablesSchema = [
|
protected tablesSchema = [
|
||||||
{
|
{
|
||||||
name: this.SURVEY_TABLE,
|
name: this.SURVEY_TABLE,
|
||||||
|
@ -171,7 +171,7 @@ export class AddonModSurveyOfflineProvider {
|
||||||
timecreated: new Date().getTime()
|
timecreated: new Date().getTime()
|
||||||
};
|
};
|
||||||
|
|
||||||
return site.getDb().insertOrUpdateRecord(this.SURVEY_TABLE, entry, {surveyid: surveyId, userid: userId});
|
return site.getDb().insertRecord(this.SURVEY_TABLE, entry);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ export class AddonModSurveyProvider {
|
||||||
promises.push(this.getSurvey(courseId, moduleId).then((survey) => {
|
promises.push(this.getSurvey(courseId, moduleId).then((survey) => {
|
||||||
const ps = [];
|
const ps = [];
|
||||||
|
|
||||||
// Do not invalidate wiki data before getting wiki info, we need it!
|
// Do not invalidate activity data before getting activity info, we need it!
|
||||||
ps.push(this.invalidateSurveyData(courseId, siteId));
|
ps.push(this.invalidateSurveyData(courseId, siteId));
|
||||||
ps.push(this.invalidateQuestions(survey.id, siteId));
|
ps.push(this.invalidateQuestions(survey.id, siteId));
|
||||||
|
|
||||||
|
@ -268,7 +268,6 @@ export class AddonModSurveyProvider {
|
||||||
|
|
||||||
return site.write('mod_survey_submit_answers', params).then((response) => {
|
return site.write('mod_survey_submit_answers', params).then((response) => {
|
||||||
if (!response.status) {
|
if (!response.status) {
|
||||||
// There was an error, and it should be translated already.
|
|
||||||
return this.utils.createFakeWSError('');
|
return this.utils.createFakeWSError('');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,15 +12,11 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component } from '@angular/core';
|
import { Component, Injector } from '@angular/core';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
|
||||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
|
||||||
import { CoreTextUtilsProvider } from '@providers/utils/text';
|
|
||||||
import { CoreCourseProvider } from '@core/course/providers/course';
|
import { CoreCourseProvider } from '@core/course/providers/course';
|
||||||
import { CoreCourseModuleMainResourceComponent } from '@core/course/classes/main-resource-component';
|
import { CoreCourseModuleMainResourceComponent } from '@core/course/classes/main-resource-component';
|
||||||
import { AddonModUrlProvider } from '../../providers/url';
|
import { AddonModUrlProvider } from '../../providers/url';
|
||||||
import { AddonModUrlHelperProvider } from '../../providers/helper';
|
import { AddonModUrlHelperProvider } from '../../providers/helper';
|
||||||
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component that displays a url.
|
* Component that displays a url.
|
||||||
|
@ -35,11 +31,9 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo
|
||||||
canGetUrl: boolean;
|
canGetUrl: boolean;
|
||||||
url: string;
|
url: string;
|
||||||
|
|
||||||
constructor(private urlProvider: AddonModUrlProvider, private courseProvider: CoreCourseProvider,
|
constructor(injector: Injector, private urlProvider: AddonModUrlProvider, private courseProvider: CoreCourseProvider,
|
||||||
protected domUtils: CoreDomUtilsProvider, protected textUtils: CoreTextUtilsProvider,
|
private urlHelper: AddonModUrlHelperProvider) {
|
||||||
protected translate: TranslateService, private urlHelper: AddonModUrlHelperProvider,
|
super(injector);
|
||||||
protected courseHelper: CoreCourseHelperProvider) {
|
|
||||||
super(textUtils, courseHelper, translate, domUtils);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,10 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { Injector } from '@angular/core';
|
||||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
|
||||||
import { CoreTextUtilsProvider } from '@providers/utils/text';
|
|
||||||
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
|
||||||
import { CoreSitesProvider } from '@providers/sites';
|
import { CoreSitesProvider } from '@providers/sites';
|
||||||
import { CoreCourseProvider } from '@core/course/providers/course';
|
import { CoreCourseProvider } from '@core/course/providers/course';
|
||||||
import { CoreEventsProvider } from '@providers/events';
|
import { CoreEventsProvider } from '@providers/events';
|
||||||
|
@ -39,11 +36,22 @@ export class CoreCourseModuleMainActivityComponent extends CoreCourseModuleMainR
|
||||||
protected onlineObserver: any; // It will observe the status of the network connection.
|
protected onlineObserver: any; // It will observe the status of the network connection.
|
||||||
protected syncEventName: string; // Auto sync event name.
|
protected syncEventName: string; // Auto sync event name.
|
||||||
|
|
||||||
constructor(protected textUtils: CoreTextUtilsProvider, protected courseHelper: CoreCourseHelperProvider,
|
// List of services that will be injected using injector.
|
||||||
protected translate: TranslateService, protected domUtils: CoreDomUtilsProvider,
|
// It's done like this so subclasses don't have to send all the services to the parent in the constructor.
|
||||||
protected sitesProvider: CoreSitesProvider, protected courseProvider: CoreCourseProvider, network: Network,
|
protected sitesProvider: CoreSitesProvider;
|
||||||
protected appProvider: CoreAppProvider, protected eventsProvider: CoreEventsProvider) {
|
protected courseProvider: CoreCourseProvider;
|
||||||
super(textUtils, courseHelper, translate, domUtils);
|
protected appProvider: CoreAppProvider;
|
||||||
|
protected eventsProvider: CoreEventsProvider;
|
||||||
|
|
||||||
|
constructor(injector: Injector) {
|
||||||
|
super(injector);
|
||||||
|
|
||||||
|
this.sitesProvider = injector.get(CoreSitesProvider);
|
||||||
|
this.courseProvider = injector.get(CoreCourseProvider);
|
||||||
|
this.appProvider = injector.get(CoreAppProvider);
|
||||||
|
this.eventsProvider = injector.get(CoreEventsProvider);
|
||||||
|
|
||||||
|
const network = injector.get(Network);
|
||||||
|
|
||||||
// Refresh online status when changes.
|
// Refresh online status when changes.
|
||||||
this.onlineObserver = network.onchange().subscribe((online) => {
|
this.onlineObserver = network.onchange().subscribe((online) => {
|
||||||
|
@ -57,6 +65,11 @@ export class CoreCourseModuleMainActivityComponent extends CoreCourseModuleMainR
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
|
|
||||||
|
this.hasOffline = false;
|
||||||
|
this.syncIcon = 'spinner';
|
||||||
|
this.siteId = this.sitesProvider.getCurrentSiteId();
|
||||||
|
this.moduleName = this.courseProvider.translateModuleName(this.moduleName);
|
||||||
|
|
||||||
if (this.syncEventName) {
|
if (this.syncEventName) {
|
||||||
// Refresh data if this discussion is synchronized automatically.
|
// Refresh data if this discussion is synchronized automatically.
|
||||||
this.syncObserver = this.eventsProvider.on(this.syncEventName, (data) => {
|
this.syncObserver = this.eventsProvider.on(this.syncEventName, (data) => {
|
||||||
|
@ -66,11 +79,6 @@ export class CoreCourseModuleMainActivityComponent extends CoreCourseModuleMainR
|
||||||
}
|
}
|
||||||
}, this.siteId);
|
}, this.siteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.hasOffline = false;
|
|
||||||
this.syncIcon = 'spinner';
|
|
||||||
this.siteId = this.sitesProvider.getCurrentSiteId();
|
|
||||||
this.moduleName = this.courseProvider.translateModuleName(this.moduleName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -100,7 +108,7 @@ export class CoreCourseModuleMainActivityComponent extends CoreCourseModuleMainR
|
||||||
/**
|
/**
|
||||||
* Compares sync event data with current data to check if refresh content is needed.
|
* Compares sync event data with current data to check if refresh content is needed.
|
||||||
*
|
*
|
||||||
* @param {any} syncEventData Data receiven on sync observer.
|
* @param {any} syncEventData Data received on sync observer.
|
||||||
* @return {boolean} True if refresh is needed, false otherwise.
|
* @return {boolean} True if refresh is needed, false otherwise.
|
||||||
*/
|
*/
|
||||||
protected isRefreshSyncNeeded(syncEventData: any): boolean {
|
protected isRefreshSyncNeeded(syncEventData: any): boolean {
|
||||||
|
@ -110,8 +118,8 @@ export class CoreCourseModuleMainActivityComponent extends CoreCourseModuleMainR
|
||||||
/**
|
/**
|
||||||
* Perform the refresh content function.
|
* Perform the refresh content function.
|
||||||
*
|
*
|
||||||
* @param {boolean} [sync=false] If the refresh is needs syncing.
|
* @param {boolean} [sync=false] If the refresh needs syncing.
|
||||||
* @param {boolean} [showErrors=false] If show errors to the user of hide them.
|
* @param {boolean} [showErrors=false] Wether to show errors to the user or hide them.
|
||||||
* @return {Promise<any>} Resolved when done.
|
* @return {Promise<any>} Resolved when done.
|
||||||
*/
|
*/
|
||||||
protected refreshContent(sync: boolean = false, showErrors: boolean = false): Promise<any> {
|
protected refreshContent(sync: boolean = false, showErrors: boolean = false): Promise<any> {
|
||||||
|
@ -126,8 +134,8 @@ export class CoreCourseModuleMainActivityComponent extends CoreCourseModuleMainR
|
||||||
* Download the component contents.
|
* Download the component contents.
|
||||||
*
|
*
|
||||||
* @param {boolean} [refresh=false] Whether we're refreshing data.
|
* @param {boolean} [refresh=false] Whether we're refreshing data.
|
||||||
* @param {boolean} [sync=false] If the refresh is needs syncing.
|
* @param {boolean} [sync=false] If the refresh needs syncing.
|
||||||
* @param {boolean} [showErrors=false] If show errors to the user of hide them.
|
* @param {boolean} [showErrors=false] Wether to show errors to the user or hide them.
|
||||||
* @return {Promise<any>} Promise resolved when done.
|
* @return {Promise<any>} Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
protected fetchContent(refresh: boolean = false, sync: boolean = false, showErrors: boolean = false): Promise<any> {
|
protected fetchContent(refresh: boolean = false, sync: boolean = false, showErrors: boolean = false): Promise<any> {
|
||||||
|
@ -138,8 +146,8 @@ export class CoreCourseModuleMainActivityComponent extends CoreCourseModuleMainR
|
||||||
* Loads the component contents and shows the corresponding error.
|
* Loads the component contents and shows the corresponding error.
|
||||||
*
|
*
|
||||||
* @param {boolean} [refresh=false] Whether we're refreshing data.
|
* @param {boolean} [refresh=false] Whether we're refreshing data.
|
||||||
* @param {boolean} [sync=false] If the refresh is needs syncing.
|
* @param {boolean} [sync=false] If the refresh needs syncing.
|
||||||
* @param {boolean} [showErrors=false] If show errors to the user of hide them.
|
* @param {boolean} [showErrors=false] Wether to show errors to the user or hide them.
|
||||||
* @return {Promise<any>} Promise resolved when done.
|
* @return {Promise<any>} Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
protected loadContent(refresh?: boolean, sync: boolean = false, showErrors: boolean = false): Promise<any> {
|
protected loadContent(refresh?: boolean, sync: boolean = false, showErrors: boolean = false): Promise<any> {
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { OnInit, OnDestroy, Input, Output, EventEmitter } from '@angular/core';
|
import { OnInit, OnDestroy, Input, Output, EventEmitter, Injector } from '@angular/core';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||||
import { CoreTextUtilsProvider } from '@providers/utils/text';
|
import { CoreTextUtilsProvider } from '@providers/utils/text';
|
||||||
|
@ -43,8 +43,18 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy,
|
||||||
protected statusObserver; // Observer of package status changed, used when calling fillContextMenu.
|
protected statusObserver; // Observer of package status changed, used when calling fillContextMenu.
|
||||||
protected fetchContentDefaultError = 'core.course.errorgetmodule'; // Default error to show when loading contents.
|
protected fetchContentDefaultError = 'core.course.errorgetmodule'; // Default error to show when loading contents.
|
||||||
|
|
||||||
constructor(protected textUtils: CoreTextUtilsProvider, protected courseHelper: CoreCourseHelperProvider,
|
// List of services that will be injected using injector.
|
||||||
protected translate: TranslateService, protected domUtils: CoreDomUtilsProvider) {
|
// It's done like this so subclasses don't have to send all the services to the parent in the constructor.
|
||||||
|
protected textUtils: CoreTextUtilsProvider;
|
||||||
|
protected courseHelper: CoreCourseHelperProvider;
|
||||||
|
protected translate: TranslateService;
|
||||||
|
protected domUtils: CoreDomUtilsProvider;
|
||||||
|
|
||||||
|
constructor(injector: Injector) {
|
||||||
|
this.textUtils = injector.get(CoreTextUtilsProvider);
|
||||||
|
this.courseHelper = injector.get(CoreCourseHelperProvider);
|
||||||
|
this.translate = injector.get(TranslateService);
|
||||||
|
this.domUtils = injector.get(CoreDomUtilsProvider);
|
||||||
this.dataRetrieved = new EventEmitter();
|
this.dataRetrieved = new EventEmitter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue