| @@ -25,8 +25,14 @@ | ||
| 25 | 25 | |
| 26 | 26 | jQuery( function( $ ) { |
| 27 | 27 | ( function( $store ) { |
| 28 | 28 | $Vue.component( 'lp-curriculum', { |
| 29 | + data: function() { | |
| 30 | + return { | |
| 31 | + indexOfSection: 0, | |
| 32 | + sections_items: [], | |
| 33 | + } | |
| 34 | + }, | |
| 29 | 35 | template: '#tmpl-lp-course-curriculum', |
| 30 | 36 | computed: { |
| 31 | 37 | status: function() { |
| 32 | 38 | return $store.getters.status; |
| @@ -47,10 +53,36 @@ | ||
| 47 | 53 | count += section.items.length; |
| 48 | 54 | }); |
| 49 | 55 | |
| 50 | 56 | return count + ' ' + (count <= 1 ? labels.singular : labels.plural); |
| 57 | + }, | |
| 58 | + add: function ( indexOfSection ){ | |
| 59 | + setTimeout( () => { | |
| 60 | + const dataSet = this.sections_items[ indexOfSection ]; | |
| 61 | + if ( 'undefined' !== typeof dataSet ) { | |
| 62 | + $store.state.ss.sections.push( dataSet ); | |
| 63 | + this.indexOfSection++; | |
| 64 | + if ( this.sections_items.length > this.indexOfSection ) { | |
| 65 | + this.add( this.indexOfSection ); | |
| 66 | + } | |
| 67 | + } | |
| 68 | + }, 100 ); | |
| 51 | 69 | } |
| 70 | + }, | |
| 71 | + beforeMount: function() { | |
| 72 | + this.sections_items = lpAdminCourseEditorSettings.sections.sections || []; | |
| 73 | + if ( this.sections_items.length > 0 ) { | |
| 74 | + $store.state.ss.sections = [ this.sections_items[0] ]; | |
| 75 | + this.indexOfSection++; | |
| 76 | + } | |
| 77 | + }, | |
| 78 | + mounted: function() { | |
| 79 | + this.firstLoad = false; | |
| 80 | + if ( this.sections_items.length > 1 ) { | |
| 81 | + this.add( this.indexOfSection ); | |
| 82 | + } | |
| 52 | 83 | } |
| 84 | + | |
| 53 | 85 | }); |
| 54 | 86 | |
| 55 | 87 | })( LP_Curriculum_Store ); |
| 56 | 88 | }); |