← All changes
|
assets/src/js/frontend/course-builder/builder-lesson/builder-tab-lesson.js
+10
-6
4.4.3
→
4.4.10
View file →
| @@ -515,13 +515,14 @@ | ||
| 515 | 515 | args: { id_url: 'builder-update-lesson' }, |
| 516 | 516 | lesson_id: lessonId, |
| 517 | 517 | lesson_settings: true, |
| 518 | 518 | _lp_preview: enablePreview ? 'yes' : '', |
| 519 | + return_html: 'yes', | |
| 519 | 520 | }; |
| 520 | 521 | |
| 521 | 522 | const callBack = { |
| 522 | 523 | success: ( response ) => { |
| 523 | - const { status, message } = response; | |
| 524 | + const { status, message, data } = response; | |
| 524 | 525 | lpToastify.show( message, status ); |
| 525 | 526 | |
| 526 | 527 | if ( status === 'error' ) { |
| 527 | 528 | // Revert on error |
| @@ -526,8 +527,10 @@ | ||
| 526 | 527 | if ( status === 'error' ) { |
| 527 | 528 | // Revert on error |
| 528 | 529 | icon.classList.toggle( 'lp-icon-eye' ); |
| 529 | 530 | icon.classList.toggle( 'lp-icon-eye-slash' ); |
| 531 | + } else if ( data?.list_item_html ) { | |
| 532 | + this.replaceItemHtml( elLessonItem, data.list_item_html ); | |
| 530 | 533 | } |
| 531 | 534 | }, |
| 532 | 535 | error: ( error ) => { |
| 533 | 536 | lpToastify.show( error.message || error, 'error' ); |
| @@ -546,12 +549,13 @@ | ||
| 546 | 549 | replaceItemHtml( elLesson, html ) { |
| 547 | 550 | if ( ! elLesson || ! html ) { |
| 548 | 551 | return; |
| 549 | 552 | } |
| 550 | - const tmp = document.createElement( 'div' ); | |
| 551 | - tmp.innerHTML = html; | |
| 552 | - const newEl = tmp.firstElementChild; | |
| 553 | - if ( newEl ) { | |
| 554 | - elLesson.replaceWith( newEl ); | |
| 553 | + | |
| 554 | + const nextLesson = elLesson.nextElementSibling; | |
| 555 | + elLesson.insertAdjacentHTML( 'afterend', html.trim() ); | |
| 556 | + const newLesson = elLesson.nextElementSibling; | |
| 557 | + if ( newLesson && newLesson !== nextLesson ) { | |
| 558 | + elLesson.remove(); | |
| 555 | 559 | } |
| 556 | 560 | } |
| 557 | 561 | } |