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

31.25% Statements 5/16
0% Branches 0/5
0% Functions 0/3
31.25% Lines 5/16

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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107                                                                                                18x 18x 18x 18x     18x                                                                                                        
<template>
	<!--
		WikiLambda Vue component for the inline validation response of ZTester objects.
 
		@copyright 2020– Abstract Wikipedia team; see AUTHORS.txt
		@license MIT
	-->
	<div class="ext-wikilambda-inline-tester-validator">
		<wl-z-object-selector
			v-if="!selectedFunction"
			:type="Constants.Z_FUNCTION"
			:placeholder="$i18n( 'wikilambda-function-typeselector-label' )"
			:selected-id="zFunctionId"
			@input="typeHandler"
		></wl-z-object-selector>
		<template v-else>
			<cdx-button
				v-if="!viewmode"
				:title="$i18n( 'wikilambda-editor-zobject-removekey-tooltip' ).text()"
				:destructive="true"
				@click="typeHandler"
			>
				{{ $i18n( 'wikilambda-editor-removeitem' ).text() }}
			</cdx-button>
			<wl-z-reference
				:zobject-key="selectedFunctionPersistentValue"
				search-type="Z8"
				:readonly="true"
			></wl-z-reference>
		</template>
		<div class="ext-wikilambda-inline-tester-validator">
			<span v-for="argument in zFunctionArguments.slice( 1 )" :key="argument.key">
				{{ argument.label }}:
				<!-- ZInlineTesterValidation -> ZObjectKey -> ZObject -> ZFunction -> ZTesterList ->
					ZTesterAdHoc -> ZInlineTesterValidation -->
				<!-- eslint-disable-next-line vue/no-unregistered-components -->
				<wl-z-object-key
					:zobject-id="findArgumentId( argument.key )"
					:persistent="false"
					:parent-type="Constants.Z_FUNCTION_CALL"
					:z-key="argument.key"
				></wl-z-object-key>
			</span>
		</div>
	</div>
</template>
 
<script>
var Constants = require( '../../Constants.js' ),
	ZFunctionCall = require( '../main-types/ZFunctionCall.vue' ),
	CdxButton = require( '@wikimedia/codex' ).CdxButton,
	mapGetters = require( 'vuex' ).mapGetters;
 
// @vue/component
module.exports = exports = {
	name: 'wl-z-inline-tester-validation',
	components: {
		'cdx-button': CdxButton
	},
	extends: ZFunctionCall,
	provide: function () {
		return {
			viewmode: this.getViewMode
		};
	},
	computed: $.extend( mapGetters( [ 'getViewMode' ] ), {
		firstArgument: function () {
			Iif ( this.zFunctionArguments.length > 1 ) {
				return this.zFunctionArguments[ 0 ];
			}
 
			return false;
		}
	} ),
	watch: {
		firstArgument: function () {
			Iif ( !this.firstArgument ) {
				return;
			}
 
			var firstArgumentId = this.findArgumentId( this.firstArgument.key ),
				zObject = this.getZObjectAsJsonById( firstArgumentId );
 
			Iif ( !zObject || zObject[ Constants.Z_REFERENCE_ID ] === Constants.Z_TESTER_CALL ) {
				return;
			}
 
			this.injectZObject( {
				zobject: {
					Z1K1: Constants.Z_REFERENCE,
					Z9K1: Constants.Z_TESTER_CALL
				},
				key: this.firstArgument.key,
				id: firstArgumentId,
				parent: this.zobjectId
			} );
		}
	}
};
</script>
 
<style lang="less">
.ext-wikilambda-inline-tester-validator {
	display: inline;
}
</style>