forked from EVOgeek/Vmeda.Online
MOBILE-4362 mycourses: Fix category disappear after PTR
parent
b9e9dade0b
commit
93b8ce274c
|
@ -176,6 +176,8 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
ngOnChanges(changes: SimpleChanges): void {
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
|
super.ngOnChanges(changes);
|
||||||
|
|
||||||
if (this.loaded && changes.block) {
|
if (this.loaded && changes.block) {
|
||||||
// Block was re-fetched, load content.
|
// Block was re-fetched, load content.
|
||||||
this.reloadContent();
|
this.reloadContent();
|
||||||
|
|
|
@ -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, Input, Component, Optional, Inject } from '@angular/core';
|
import { OnInit, Input, Component, Optional, Inject, OnChanges, SimpleChanges } from '@angular/core';
|
||||||
import { CoreLogger } from '@singletons/logger';
|
import { CoreLogger } from '@singletons/logger';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
|
@ -30,7 +30,7 @@ import { CorePromisedValue } from '@classes/promised-value';
|
||||||
@Component({
|
@Component({
|
||||||
template: '',
|
template: '',
|
||||||
})
|
})
|
||||||
export abstract class CoreBlockBaseComponent implements OnInit, ICoreBlockComponent, AsyncDirective {
|
export abstract class CoreBlockBaseComponent implements OnInit, OnChanges, ICoreBlockComponent, AsyncDirective {
|
||||||
|
|
||||||
@Input() title!: string; // The block title.
|
@Input() title!: string; // The block title.
|
||||||
@Input() block!: CoreCourseBlock; // The block to render.
|
@Input() block!: CoreCourseBlock; // The block to render.
|
||||||
|
@ -54,15 +54,31 @@ export abstract class CoreBlockBaseComponent implements OnInit, ICoreBlockCompon
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
if (this.block.configs && this.block.configs.length > 0) {
|
await this.loadContent();
|
||||||
this.block.configs.forEach((config) => {
|
}
|
||||||
config.value = CoreTextUtils.parseJSON(config.value);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.block.configsRecord = CoreUtils.arrayToObject(this.block.configs, 'name');
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
|
if (changes.block) {
|
||||||
|
this.parseConfigs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse configs if needed.
|
||||||
|
*/
|
||||||
|
protected parseConfigs(): void {
|
||||||
|
if (!this.block.configs?.length || this.block.configsRecord) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.loadContent();
|
this.block.configs.forEach((config) => {
|
||||||
|
config.value = CoreTextUtils.parseJSON(config.value);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.block.configsRecord = CoreUtils.arrayToObject(this.block.configs, 'name');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue