Skip to content

Commit

Permalink
MOBILE-3947 core: Fix compile HTML
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyserver committed Dec 18, 2023
1 parent 62164e3 commit de964a9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 33 deletions.
6 changes: 0 additions & 6 deletions src/addons/mod/data/tests/behat/entries.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Feature: Users can manage entries in database activities
| data1 | text | URL | URL link |
| data1 | text | Description | Link description |

@ionic7_failure
Scenario: Create entry
Given I entered the data activity "Web links" on course "Course 1" as "student1" in the app
Then I should find "No entries yet" in the app
Expand All @@ -38,7 +37,6 @@ Feature: Users can manage entries in database activities
Then I should find "https://moodle.org/" in the app
And I should find "Moodle community site" in the app

@ionic7_failure
Scenario: Browse entry
Given I entered the data activity "Web links" on course "Course 1" as "student1" in the app

Expand Down Expand Up @@ -72,7 +70,6 @@ Feature: Users can manage entries in database activities
And I should find "Moodle community site" in the app
And I should find "Moodle Cloud" in the app

@ionic7_failure
Scenario: Students can not edit or delete other user's entries from list and single view in the app
Given I entered the data activity "Web links" on course "Course 1" as "student1" in the app
And I press "Add entries" in the app
Expand All @@ -88,7 +85,6 @@ Feature: Users can manage entries in database activities
And "Edit" "link" should not exist
And "Delete" "link" should not exist

@ionic7_failure
Scenario: Delete entry (student) & Update entry (student)
Given I entered the data activity "Web links" on course "Course 1" as "student1" in the app
And I press "Add entries" in the app
Expand Down Expand Up @@ -148,7 +144,6 @@ Feature: Users can manage entries in database activities
And I should not find "Moodle Cloud" in the app
And I should find "No entries yet" in the app

@ionic7_failure
Scenario: Delete entry (teacher) & Update entry (teacher)
Given I entered the data activity "Web links" on course "Course 1" as "student1" in the app
And I press "Add entries" in the app
Expand Down Expand Up @@ -212,7 +207,6 @@ Feature: Users can manage entries in database activities
And I press "Delete" in the app
And I should not find "Moodle Cloud" in the app

@ionic7_failure
Scenario: Handle number 0 correctly when creating entries
Given the following "activities" exist:
| activity | name | intro | course | idnumber |
Expand Down
3 changes: 0 additions & 3 deletions src/addons/mod/data/tests/behat/sync.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Feature: Users can store entries in database activities when offline and sync wh
| data1 | text | URL | URL link |
| data1 | text | Description | Link description |

@ionic7_failure
Scenario: Create entry (offline)
Given I entered the data activity "Web links" on course "Course 1" as "student1" in the app
And I switch network connection to offline
Expand All @@ -46,7 +45,6 @@ Feature: Users can store entries in database activities when offline and sync wh
And I should find "Moodle community site" in the app
And I should not find "This Database has offline data to be synchronised" in the app

@ionic7_failure
Scenario: Update entry (offline) & Delete entry (offline)
Given I entered the data activity "Web links" on course "Course 1" as "student1" in the app
And I should find "No entries yet" in the app
Expand Down Expand Up @@ -97,7 +95,6 @@ Feature: Users can store entries in database activities when offline and sync wh
And I should not find "Moodle Cloud" in the app
And I should not find "This Database has offline data to be synchronised" in the app

@ionic7_failure
Scenario: Students can undo deleting entries to a database in the app while offline
Given I entered the data activity "Web links" on course "Course 1" as "student1" in the app
And I should find "No entries yet" in the app
Expand Down
2 changes: 0 additions & 2 deletions src/core/features/comments/tests/behat/basic_usage.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Feature: Test basic usage of comments in app
| database | type | name | description |
| data1 | text | Test field name | Test field description |

@ionic7_failure
Scenario: Add comments & Delete comments (database)
# Create database entry and comment as a teacher
Given I entered the data activity "Data" on course "Course 1" as "teacher1" in the app
Expand Down Expand Up @@ -65,7 +64,6 @@ Feature: Test basic usage of comments in app
When I press the back button in the app
Then I should find "Comments (1)" in the app

@ionic7_failure
Scenario: Add comments offline & Delete comments offline & Sync comments (database)
Given I entered the data activity "Data" on course "Course 1" as "teacher1" in the app
And I press "Add entries" in the app
Expand Down
43 changes: 21 additions & 22 deletions src/core/features/compile/components/compile-html/compile-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,42 +114,41 @@ export class CoreCompileHtmlComponent implements OnChanges, OnDestroy, DoCheck {
* @inheritdoc
*/
async ngOnChanges(changes: Record<string, SimpleChange>): Promise<void> {
if (!this.container) {
// Only compile if text/javascript has changed or the forceCompile flag has been set to true.
if (this.text === undefined ||
!(changes.text || changes.javascript || (changes.forceCompile && CoreUtils.isTrueOrOne(this.forceCompile)))) {
return;
}

// Only compile if text/javascript has changed or the forceCompile flag has been set to true.
if (this.text !== undefined && (changes.text || changes.javascript ||
(changes.forceCompile && CoreUtils.isTrueOrOne(this.forceCompile)))) {

// Create a new component and a new module.
this.creatingComponent = true;
this.compiling.emit(true);
// Create a new component and a new module.
this.creatingComponent = true;
this.compiling.emit(true);

try {
const componentClass = await this.getComponentClass();
try {
const componentClass = await this.getComponentClass();

// Destroy previous components.
this.componentRef?.destroy();
// Destroy previous components.
this.componentRef?.destroy();

// Create the component.
// Create the component.
if (this.container) {
this.componentRef = await CoreCompile.createAndCompileComponent(
this.text,
componentClass,
this.container,
this.extraImports,
);
this.componentRef && this.created.emit(this.componentRef.instance);
}
this.componentRef && this.created.emit(this.componentRef.instance);

this.loaded = true;
} catch (error) {
CoreDomUtils.showErrorModal(error);
this.loaded = true;
} catch (error) {
CoreDomUtils.showErrorModal(error);

this.loaded = true;
} finally {
this.creatingComponent = false;
this.compiling.emit(false);
}
this.loaded = true;
} finally {
this.creatingComponent = false;
this.compiling.emit(false);
}
}

Expand Down

0 comments on commit de964a9

Please sign in to comment.