| 1 |
<?php |
| 2 |
/** |
| 3 |
* Admin question editor: question actions template. |
| 4 |
* |
| 5 |
* @author ThimPress <nhamdv> |
| 6 |
* @since 4.0.0 |
| 7 |
*/ |
| 8 |
?> |
| 9 |
|
| 10 |
<script type="text/x-template" id="tmpl-lp-question-actions"> |
| 11 |
<div class="lp-box-data-head lp-row"> |
| 12 |
<h3 class="heading"><?php esc_html_e( 'Details', 'learnpress' ); ?></h3> |
| 13 |
<div class="lp-question-editor lp-question-editor--right"> |
| 14 |
<div class="lp-question-editor__inner"> |
| 15 |
<div class="question-types"> |
| 16 |
<a>{{typeLabel()}}</a> |
| 17 |
<ul> |
| 18 |
<li v-for="(type, key) in types" :data-type="key" :class="active(key)"> |
| 19 |
<a href="" @click.prevent="changeType(key)">{{type}}</a> |
| 20 |
</li> |
| 21 |
</ul> |
| 22 |
</div> |
| 23 |
</div> |
| 24 |
</div> |
| 25 |
</div> |
| 26 |
</script> |
| 27 |
|
| 28 |
<script type="text/javascript"> |
| 29 |
jQuery( function( $ ) { |
| 30 |
var $store = window.LP_Question_Store; |
| 31 |
var pick = lodash.pick; |
| 32 |
|
| 33 |
window.$Vue = window.$Vue || Vue; |
| 34 |
|
| 35 |
$Vue.component( 'lp-question-actions', { |
| 36 |
template: '#tmpl-lp-question-actions', |
| 37 |
props: ['type'], |
| 38 |
computed: { |
| 39 |
types: function() { |
| 40 |
return $store.getters['types'] |
| 41 |
} |
| 42 |
}, |
| 43 |
methods: { |
| 44 |
typeLabel: function() { |
| 45 |
var types = this.types; |
| 46 |
return types[this.type]; |
| 47 |
}, |
| 48 |
active: function( type ) { |
| 49 |
var classes = ['']; |
| 50 |
|
| 51 |
if ( this.type === type ) { |
| 52 |
classes.push('active'); |
| 53 |
} |
| 54 |
|
| 55 |
var supportTypes = $store.getters['supportAnswerOptions']; |
| 56 |
|
| 57 |
if ( supportTypes.indexOf( type ) === -1 || supportTypes.indexOf( this.type ) === -1 ) { |
| 58 |
classes.push( 'disabled' ) |
| 59 |
} |
| 60 |
|
| 61 |
return classes; |
| 62 |
}, |
| 63 |
changeType: function( type ) { |
| 64 |
if ( this.type !== type ) { |
| 65 |
this.$emit( 'changeType', type ); |
| 66 |
} |
| 67 |
}, |
| 68 |
getQuestionsSupportAnswerOptions: function() { |
| 69 |
var supportTypes = $store.getters['supportAnswerOptions']; |
| 70 |
|
| 71 |
return supportTypes.indexOf( this.type ) !== -1 ? pick( this.types, supportTypes ) : false; |
| 72 |
} |
| 73 |
} |
| 74 |
}); |
| 75 |
}); |
| 76 |
</script> |
| 77 |
|