All files / ext.wikilambda.edit/components/function ZTesterListItem.vue

63.63% Statements 7/11
100% Branches 0/0
0% Functions 0/4
63.63% Lines 7/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89                                                                              18x 18x 18x 18x 18x 18x     18x                                                                                  
<template>
	<!--
		WikiLambda Vue component for ZObject references to ZTesters in ZLists.
 
		@copyright 2020– Abstract Wikipedia team; see AUTHORS.txt
		@license MIT
	-->
	<li class="ext-wikilambda-zlistItem">
		<cdx-button
			v-if="!( getViewMode || readonly )"
			class="z-list-item-remove"
			:destructive="true"
			:title="tooltipRemoveListItem"
			@click="$emit( 'remove-item', zobjectId )"
		>
			{{ $i18n( 'wikilambda-editor-removeitem' ).text() }}
		</cdx-button>
		<select v-if="!hasReference" @change="selectTester">
			<option disabled selected>
				{{ $i18n( "wikilambda-tester-selector" ).text() }}
			</option>
			<option
				v-for="zTesterId in getUnattachedZTesters"
				:key="zTesterId"
				:value="zTesterId"
			>
				{{ getZkeyLabels[ zTesterId ] }}
			</option>
		</select>
		<wl-z-reference
			v-else
			:zobject-id="zobjectId"
			:search-type="zType"
			:readonly="true"
		></wl-z-reference>
	</li>
</template>
 
<script>
var Constants = require( '../../Constants.js' ),
	ZListItem = require( '../main-types/ZListItem.vue' ),
	ZReference = require( '../main-types/ZReference.vue' ),
	CdxButton = require( '@wikimedia/codex' ).CdxButton,
	mapGetters = require( 'vuex' ).mapGetters,
	mapActions = require( 'vuex' ).mapActions;
 
// @vue/component
module.exports = exports = {
	name: 'wl-z-tester-list-item',
	components: {
		'wl-z-reference': ZReference,
		'cdx-button': CdxButton
	},
	extends: ZListItem,
	computed: $.extend( mapGetters( [
		'getZObjectById',
		'getUnattachedZTesters',
		'getZkeyLabels',
		'getZTesterResults',
		'getViewMode'
	] ),
	{
		referenceValue: function () {
			return this.findKeyInArray( Constants.Z_REFERENCE_ID, this.zobject ).value;
		},
		hasReference: function () {
			return !!this.referenceValue;
		},
		testerStatus: function () {
			return this.getZTesterResults[ this.referenceValue ];
		}
	}
	),
	methods: $.extend( mapActions( [ 'performTest', 'fetchZKeys' ] ), {
		selectTester: function ( event ) {
			this.$store.dispatch( 'injectZObject', {
				zobject: {
					Z1K1: Constants.Z_REFERENCE,
					Z9K1: event.target.value
				},
				key: Constants.Z_IMPLEMENTATION_FUNCTION,
				id: this.zobjectId,
				parent: this.getZObjectById( this.zobjectId ).parent
			} );
		}
	} )
};
</script>