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 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 3x 3x 3x 3x 3x 19x 19x 19x 19x 19x 21x 21x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | <!--
WikiLambda Vue componen for function editor language block. Contains all
the function fields for a given input language.
@copyright 2020– Abstract Wikipedia team; see AUTHORS.txt
@license MIT
-->
<template>
<div
class="ext-wikilambda-app-function-editor-language-block"
data-testid="function-editor-language-block"
>
<!-- component that displays the language selector -->
<wl-function-editor-language
class="ext-wikilambda-app-function-editor-language-block__row"
data-testid="function-editor-language-selector"
:z-language="zLanguage"
:function-languages="functionLanguages"
:index="index"
@language-changed="onLanguageChanged"
></wl-function-editor-language>
<!-- component that displays name for a language -->
<wl-function-editor-name
class="ext-wikilambda-app-function-editor-language-block__row"
data-testid="function-editor-name-input"
:z-language="zLanguage"
:lang-label-data="langLabelData"
@name-updated="onLabelsUpdated"
></wl-function-editor-name>
<!-- component that displays the description for a language -->
<wl-function-editor-description
class="ext-wikilambda-app-function-editor-language-block__row"
data-testid="function-editor-description-input"
:z-language="zLanguage"
:lang-label-data="langLabelData"
@description-updated="onLabelsUpdated"
></wl-function-editor-description>
<!-- component that displays aliases for a language -->
<wl-function-editor-aliases
class="ext-wikilambda-app-function-editor-language-block__row"
data-testid="function-editor-alias-input"
:z-language="zLanguage"
@alias-updated="onLabelsUpdated"
></wl-function-editor-aliases>
<!-- component that displays list of inputs for a language -->
<wl-function-editor-inputs
class="ext-wikilambda-app-function-editor-language-block__row"
data-testid="function-editor-inputs"
:z-language="zLanguage"
:is-main-language-block="isMainLanguageBlock"
:can-edit="canEditFunction"
:lang-label-data="langLabelData"
:tooltip-icon="iconLock"
:tooltip-message="i18n( 'wikilambda-editor-fn-edit-definition-tooltip-content' ).text()"
@argument-label-updated="onLabelsUpdated"
></wl-function-editor-inputs>
<!-- component that displays output for a language -->
<wl-function-editor-output
v-if="isMainLanguageBlock"
class="ext-wikilambda-app-function-editor-language-block__row"
data-testid="function-editor-output"
:can-edit="canEditFunction"
:tooltip-icon="iconLock"
:tooltip-message="i18n( 'wikilambda-editor-fn-edit-definition-tooltip-content' ).text()"
></wl-function-editor-output>
</div>
</template>
<script>
const { computed, defineComponent, inject } = require( 'vue' );
const icons = require( '../../../../lib/icons.json' );
const useMainStore = require( '../../../store/index.js' );
// Function editor components
const FunctionEditorAliases = require( './FunctionEditorAliases.vue' );
const FunctionEditorDescription = require( './FunctionEditorDescription.vue' );
const FunctionEditorInputs = require( './FunctionEditorInputs.vue' );
const FunctionEditorLanguage = require( './FunctionEditorLanguage.vue' );
const FunctionEditorName = require( './FunctionEditorName.vue' );
const FunctionEditorOutput = require( './FunctionEditorOutput.vue' );
module.exports = exports = defineComponent( {
name: 'wl-function-editor-language-block',
components: {
'wl-function-editor-language': FunctionEditorLanguage,
'wl-function-editor-name': FunctionEditorName,
'wl-function-editor-description': FunctionEditorDescription,
'wl-function-editor-aliases': FunctionEditorAliases,
'wl-function-editor-inputs': FunctionEditorInputs,
'wl-function-editor-output': FunctionEditorOutput
},
props: {
zLanguage: {
type: String,
required: true
},
index: {
type: Number,
default: 0
},
functionLanguages: {
type: Array,
default: () => [ ]
}
},
emits: [ 'language-changed', 'labels-updated' ],
setup( props, { emit } ) {
const i18n = inject( 'i18n' );
const store = useMainStore();
// Constants
const iconLock = icons.cdxIconLock;
// Language block data
/**
* Returns whether the current language block is the first (main) one
*
* @return {boolean}
*/
const isMainLanguageBlock = computed( () => props.index === 0 );
/**
* Returns the label data of the blocks language
*
* @return {LabelData}
*/
const langLabelData = computed( () => store.getLabelDataForLangCode( props.zLanguage ) );
// Edit permissions
/**
* Returns whether the user can edit the function
*
* TODO (T301667): restrict to only certain user roles
*
* @return {boolean}
*/
const canEditFunction = computed( () => store.isCreateNewPage ? true : store.isUserLoggedIn );
// Actions
/**
* Emits a language changed event
*
* @param {string} value
*/
function onLanguageChanged( value ) {
emit( 'language-changed', {
language: value,
index: props.index
} );
}
/**
* Emits a labels updated event
*/
function onLabelsUpdated() {
emit( 'labels-updated' );
}
return {
canEditFunction,
iconLock,
isMainLanguageBlock,
langLabelData,
i18n,
onLanguageChanged,
onLabelsUpdated
};
}
} );
</script>
<style lang="less">
@import '../../../ext.wikilambda.app.variables.less';
.ext-wikilambda-app-function-editor-language-block {
padding-top: @spacing-150;
border-bottom: 1px solid @border-color-subtle;
&:first-child {
border-top: 1px solid @border-color-subtle;
}
.ext-wikilambda-app-function-editor-language-block__row {
display: flex;
margin-bottom: @spacing-150;
gap: @spacing-100;
@media screen and ( max-width: @max-width-breakpoint-mobile ) {
flex-direction: column;
}
}
}
</style>
|