Skip to content

Commit dad261e

Browse files
committed
MOBILE-3893 assign: Fix editing files offline
Changes to the allowOffline property of AddonModAssignSubmissionPluginComponent were not being detected and passed to the submission plugin component.
1 parent 0e7a278 commit dad261e

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/addons/mod/assign/components/submission-plugin/submission-plugin.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import { Component, Input, OnInit, Type, ViewChild } from '@angular/core';
15+
import { Component, Input, OnChanges, SimpleChanges, Type, ViewChild } from '@angular/core';
1616
import { CoreDynamicComponent } from '@components/dynamic-component/dynamic-component';
1717
import {
1818
AddonModAssignAssign,
@@ -34,7 +34,7 @@ import { toBoolean } from '@/core/transforms/boolean';
3434
selector: 'addon-mod-assign-submission-plugin',
3535
templateUrl: 'addon-mod-assign-submission-plugin.html',
3636
})
37-
export class AddonModAssignSubmissionPluginComponent implements OnInit {
37+
export class AddonModAssignSubmissionPluginComponent implements OnChanges {
3838

3939
@ViewChild(CoreDynamicComponent) dynamicComponent!: CoreDynamicComponent<AddonModAssignSubmissionPluginBaseComponent>;
4040

@@ -57,7 +57,7 @@ export class AddonModAssignSubmissionPluginComponent implements OnInit {
5757
/**
5858
* @inheritdoc
5959
*/
60-
async ngOnInit(): Promise<void> {
60+
async ngOnChanges(changes: SimpleChanges): Promise<void> {
6161
if (!this.plugin) {
6262
this.pluginLoaded = true;
6363

@@ -73,8 +73,19 @@ export class AddonModAssignSubmissionPluginComponent implements OnInit {
7373
}
7474
this.plugin.name = name;
7575

76-
// Check if the plugin has defined its own component to render itself.
77-
this.pluginComponent = await AddonModAssignSubmissionDelegate.getComponentForPlugin(this.plugin, this.edit);
76+
if (changes.plugin || changes.edit) {
77+
// Check if the plugin has defined its own component to render itself.
78+
this.pluginComponent = await AddonModAssignSubmissionDelegate.getComponentForPlugin(this.plugin, this.edit);
79+
80+
this.pluginLoaded = !this.pluginComponent;
81+
82+
if (!this.pluginComponent) {
83+
// Data to render the plugin.
84+
this.text = AddonModAssign.getSubmissionPluginText(this.plugin);
85+
this.files = AddonModAssign.getSubmissionPluginAttachments(this.plugin);
86+
this.notSupported = AddonModAssignSubmissionDelegate.isPluginSupported(this.plugin.type);
87+
}
88+
}
7889

7990
if (this.pluginComponent) {
8091
// Prepare the data to pass to the component.
@@ -86,12 +97,6 @@ export class AddonModAssignSubmissionPluginComponent implements OnInit {
8697
edit: this.edit,
8798
allowOffline: this.allowOffline,
8899
};
89-
} else {
90-
// Data to render the plugin.
91-
this.text = AddonModAssign.getSubmissionPluginText(this.plugin);
92-
this.files = AddonModAssign.getSubmissionPluginAttachments(this.plugin);
93-
this.notSupported = AddonModAssignSubmissionDelegate.isPluginSupported(this.plugin.type);
94-
this.pluginLoaded = true;
95100
}
96101
}
97102

0 commit comments

Comments
 (0)