| 1 |
<?php |
| 2 |
/** |
| 3 |
* Template curriculum course. |
| 4 |
* |
| 5 |
* @since 3.0.0 |
| 6 |
*/ |
| 7 |
|
| 8 |
learn_press_admin_view( 'course/sections' ); |
| 9 |
?> |
| 10 |
|
| 11 |
<script type="text/x-template" id="tmpl-lp-course-curriculum"> |
| 12 |
<div class="lp-course-curriculum"> |
| 13 |
<div class="heading"> |
| 14 |
<h4><?php esc_html_e( 'Details', 'learnpress' ); ?> <span :class="['status', status]"></span></h4> |
| 15 |
<div class="section-item-counts"><span>{{countAllItems()}}</span></div> |
| 16 |
<span class="collapse-sections" @click="toggle" :class="isOpen ? 'open' : 'close'"></span> |
| 17 |
</div> |
| 18 |
<lp-list-sections></lp-list-sections> |
| 19 |
</div> |
| 20 |
</script> |
| 21 |
|
| 22 |
<script type="text/javascript"> |
| 23 |
|
| 24 |
window.$Vue = window.$Vue = Vue; |
| 25 |
|
| 26 |
jQuery( function( $ ) { |
| 27 |
( function( $store ) { |
| 28 |
$Vue.component( 'lp-curriculum', { |
| 29 |
data: function() { |
| 30 |
return { |
| 31 |
indexOfSection: 0, |
| 32 |
sections_items: [], |
| 33 |
} |
| 34 |
}, |
| 35 |
template: '#tmpl-lp-course-curriculum', |
| 36 |
computed: { |
| 37 |
status: function() { |
| 38 |
return $store.getters.status; |
| 39 |
}, |
| 40 |
isOpen: function() { |
| 41 |
return ! $store.getters['ss/isHiddenAllSections']; |
| 42 |
} |
| 43 |
}, |
| 44 |
methods: { |
| 45 |
toggle: function() { |
| 46 |
$store.dispatch( 'ss/toggleAllSections' ); |
| 47 |
}, |
| 48 |
countAllItems: function() { |
| 49 |
var count = 0, |
| 50 |
labels = $store.getters['i18n/all'].item_labels; |
| 51 |
|
| 52 |
$.each( $store.getters['ss/sections'], function ( i, section ) { |
| 53 |
count += section.items.length; |
| 54 |
}); |
| 55 |
|
| 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 ); |
| 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 |
} |
| 83 |
} |
| 84 |
|
| 85 |
}); |
| 86 |
|
| 87 |
})( LP_Curriculum_Store ); |
| 88 |
}); |
| 89 |
</script> |
| 90 |
|