| 1 |
<?php |
| 2 |
/** |
| 3 |
* Template list sections. |
| 4 |
* |
| 5 |
* @since 3.0.0 |
| 6 |
*/ |
| 7 |
|
| 8 |
learn_press_admin_view( 'course/section' ); |
| 9 |
learn_press_admin_view( 'course/new-section' ); |
| 10 |
?> |
| 11 |
|
| 12 |
<script type="text/x-template" id="tmpl-lp-list-sections"> |
| 13 |
<div class="curriculum-sections"> |
| 14 |
<lp-section v-for="(section, index) in sections" :section="section" :index="index" :disableCurriculum="disableCurriculum" :key="index"></lp-section> |
| 15 |
|
| 16 |
<div class="add-new-section" v-if="!disableCurriculum"> |
| 17 |
<lp-new-section></lp-new-section> |
| 18 |
</div> |
| 19 |
</div> |
| 20 |
</script> |
| 21 |
|
| 22 |
<script type="text/javascript"> |
| 23 |
window.$Vue = window.$Vue || Vue; |
| 24 |
|
| 25 |
jQuery( function( $ ) { |
| 26 |
( function( $store ) { |
| 27 |
$Vue.component( 'lp-list-sections', { |
| 28 |
template: '#tmpl-lp-list-sections', |
| 29 |
computed: { |
| 30 |
sections: function() { |
| 31 |
return $store.getters['ss/sections']; |
| 32 |
}, |
| 33 |
disableCurriculum: function() { |
| 34 |
return $store.getters['disable_curriculum']; |
| 35 |
} |
| 36 |
}, |
| 37 |
created: function() { |
| 38 |
var _self = this; |
| 39 |
|
| 40 |
setTimeout( function() { |
| 41 |
var $el = $( '.curriculum-sections' ); |
| 42 |
|
| 43 |
$el.sortable({ |
| 44 |
handle: '.section-head .movable', |
| 45 |
axis: 'y', |
| 46 |
items: "> .section", |
| 47 |
update: function () { |
| 48 |
_self.sort(); |
| 49 |
} |
| 50 |
}); |
| 51 |
}, 1000 ); |
| 52 |
}, |
| 53 |
methods: { |
| 54 |
sort: function() { |
| 55 |
var _items = $( '.curriculum-sections>div.section' ), |
| 56 |
order = _items.map( function() { |
| 57 |
return $( this ).data( 'section-id' ); |
| 58 |
}).get(); |
| 59 |
|
| 60 |
$store.dispatch( 'ss/updateSectionsOrder', order ); |
| 61 |
} |
| 62 |
} |
| 63 |
}); |
| 64 |
})( LP_Curriculum_Store ); |
| 65 |
}); |
| 66 |
</script> |
| 67 |
|