Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@
"cdxIconClock",
"cdxIconCalendar",
"cdxIconAlert",
"cdxIconError",
"cdxIconCollapse",
"cdxIconExpand",
"cdxIconPushPin",
Expand Down Expand Up @@ -523,6 +524,12 @@
"neowiki-property-editor-target-schema-required",
"neowiki-property-editor-options",
"neowiki-property-editor-options-unique",
"neowiki-severity-input-label",
"neowiki-severity-warning",
"neowiki-severity-warning-description",
"neowiki-severity-error",
"neowiki-severity-error-description-enforced",
"neowiki-severity-error-description-not-enforced",
"neowiki-save-schema",
"neowiki-edit-summary-label",
"neowiki-edit-summary-placeholder",
Expand Down
6 changes: 6 additions & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@
"neowiki-property-editor-target-schema-required": "Target schema is required.",
"neowiki-property-editor-options": "Options",
"neowiki-property-editor-options-unique": "Each option must be unique.",
"neowiki-severity-input-label": "Severity of \"$1\": $2",
"neowiki-severity-warning": "Warning",
"neowiki-severity-warning-description": "Flags the value as a warning",
"neowiki-severity-error": "Error",
"neowiki-severity-error-description-enforced": "Flags the value as an error and blocks saving",
"neowiki-severity-error-description-not-enforced": "Flags the value as an error",

"neowiki-schema-label": "Schema: $1",

Expand Down
6 changes: 6 additions & 0 deletions i18n/qqq.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@
"neowiki-property-editor-min-exceeds-max": "Error shown in the schema editor when the minimum value exceeds the maximum value for a number property.",
"neowiki-property-editor-options": "Label for the options field in the select property type editor, where schema creators define the allowed values.",
"neowiki-property-editor-options-unique": "Error shown in the schema editor when duplicate option values are entered for a select property.",
"neowiki-severity-input-label": "Accessible name and tooltip of the severity control next to a Constraint in the schema editor. Parameters:\n* $1 - the label of the Constraint's own control, e.g. {{msg-mw|neowiki-property-editor-minimum}} or {{msg-mw|neowiki-property-editor-required}}\n* $2 - the current severity level, one of {{msg-mw|neowiki-severity-warning}} or {{msg-mw|neowiki-severity-error}}",
"neowiki-severity-warning": "Name of the warning severity level of a Constraint: a violation is flagged but never blocks saving. Shown in the severity control's menu in the schema editor and as $1 in {{msg-mw|neowiki-severity-input-label}}.\n{{Identical|Warning}}",
"neowiki-severity-warning-description": "One-line meaning of the warning severity level, shown under {{msg-mw|neowiki-severity-warning}} in the severity control's menu in the schema editor.",
"neowiki-severity-error": "Name of the error severity level of a Constraint: a violation can block saving when the wiki enforces validation. Shown in the severity control's menu in the schema editor and as $1 in {{msg-mw|neowiki-severity-input-label}}.\n{{Identical|Error}}",
"neowiki-severity-error-description-enforced": "One-line meaning of the error severity level on a wiki that enforces validation (writes with new error violations are rejected), shown under {{msg-mw|neowiki-severity-error}} in the severity control's menu in the schema editor. See also {{msg-mw|neowiki-severity-error-description-not-enforced}}.",
"neowiki-severity-error-description-not-enforced": "One-line meaning of the error severity level on a wiki that does not enforce validation (violations are shown but never block saving), shown under {{msg-mw|neowiki-severity-error}} in the severity control's menu in the schema editor. See also {{msg-mw|neowiki-severity-error-description-enforced}}.",
"neowiki-property-editor-relation": "Label for the relation-type input in the schema property editor. The relation type is the graph edge label stored for a relation property.",
"neowiki-property-editor-relation-required": "Validation error shown when the relation type is left empty.",
"neowiki-property-editor-target-schema": "Label for the target-schema picker in the schema property editor. Selects which schema a relation points to.",
Expand Down
5 changes: 5 additions & 0 deletions resources/ext.neowiki/src/NeoWikiExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,11 @@ export class NeoWikiExtension {
return typeof value === 'number' ? value : 300;
}

/** Whether the wiki rejects writes that introduce new error-severity violations (`$wgNeoWikiEnforceValidation`). */
public isValidationEnforced(): boolean {
return mw.config.get( 'wgNeoWikiEnforceValidation' ) === true;
}

public getPropertyTypeRegistry(): PropertyTypeRegistry {
return this.getNeo().getPropertyTypeRegistry();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</template>

<CdxField
class="date-attributes__minimum"
class="date-attributes__minimum ext-neowiki-severity-field"
:status="minimumError === null ? 'default' : 'error'"
:messages="minimumError === null ? {} : { error: minimumError }"
>
Expand All @@ -19,10 +19,16 @@
:model-value="minimumInput"
@update:model-value="updateMinimum"
/>
<SeverityInput
v-if="property.minimum !== undefined"
:constraint="$i18n( 'neowiki-property-editor-minimum' ).text()"
:model-value="property.constraintSeverities?.minimum"
@update:model-value="updateSeverity( 'minimum', $event )"
/>
</CdxField>

<CdxField
class="date-attributes__maximum"
class="date-attributes__maximum ext-neowiki-severity-field"
:status="maximumError === null ? 'default' : 'error'"
:messages="maximumError === null ? {} : { error: maximumError }"
>
Expand All @@ -35,6 +41,12 @@
:model-value="maximumInput"
@update:model-value="updateMaximum"
/>
<SeverityInput
v-if="property.maximum !== undefined"
:constraint="$i18n( 'neowiki-property-editor-maximum' ).text()"
:model-value="property.constraintSeverities?.maximum"
@update:model-value="updateSeverity( 'maximum', $event )"
/>
</CdxField>
</NeoNestedField>
</div>
Expand All @@ -47,6 +59,9 @@ import { DateProperty } from '@/domain/propertyTypes/Date.ts';
import { fromDateInputValue, toDateInputValue } from '@/domain/propertyTypes/dateConversion.ts';
import { AttributesEditorEmits, AttributesEditorProps } from '@/components/SchemaEditor/Property/AttributesEditorContract.ts';
import NeoNestedField from '@/components/common/NeoNestedField.vue';
import SeverityInput from '@/components/SchemaEditor/Property/SeverityInput.vue';
import { withConstraintSeverity } from '@/domain/PropertyDefinition.ts';
import type { Severity } from '@/domain/Severity.ts';

const props = defineProps<AttributesEditorProps<DateProperty>>();
const emit = defineEmits<AttributesEditorEmits<DateProperty>>();
Expand Down Expand Up @@ -100,4 +115,8 @@ const updateMaximum = ( value: string ): void => {
minimumError.value = null;
emit( 'update:property', { maximum: fromDateInputValue( value ) } );
};

const updateSeverity = ( constraint: 'minimum' | 'maximum', severity: Severity ): void => {
emit( 'update:property', withConstraintSeverity( props.property, constraint, severity ) );
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</template>

<CdxField
class="datetime-attributes__minimum"
class="datetime-attributes__minimum ext-neowiki-severity-field"
:status="minimumError === null ? 'default' : 'error'"
:messages="minimumError === null ? {} : { error: minimumError }"
>
Expand All @@ -19,10 +19,16 @@
:model-value="minimumInput"
@update:model-value="updateMinimum"
/>
<SeverityInput
v-if="property.minimum !== undefined"
:constraint="$i18n( 'neowiki-property-editor-minimum' ).text()"
:model-value="property.constraintSeverities?.minimum"
@update:model-value="updateSeverity( 'minimum', $event )"
/>
</CdxField>

<CdxField
class="datetime-attributes__maximum"
class="datetime-attributes__maximum ext-neowiki-severity-field"
:status="maximumError === null ? 'default' : 'error'"
:messages="maximumError === null ? {} : { error: maximumError }"
>
Expand All @@ -35,6 +41,12 @@
:model-value="maximumInput"
@update:model-value="updateMaximum"
/>
<SeverityInput
v-if="property.maximum !== undefined"
:constraint="$i18n( 'neowiki-property-editor-maximum' ).text()"
:model-value="property.constraintSeverities?.maximum"
@update:model-value="updateSeverity( 'maximum', $event )"
/>
</CdxField>
</NeoNestedField>
</div>
Expand All @@ -47,6 +59,9 @@ import { DateTimeProperty } from '@/domain/propertyTypes/DateTime.ts';
import { fromLocalInputValue, toLocalInputValue } from '@/domain/propertyTypes/dateTimeConversion.ts';
import { AttributesEditorEmits, AttributesEditorProps } from '@/components/SchemaEditor/Property/AttributesEditorContract.ts';
import NeoNestedField from '@/components/common/NeoNestedField.vue';
import SeverityInput from '@/components/SchemaEditor/Property/SeverityInput.vue';
import { withConstraintSeverity } from '@/domain/PropertyDefinition.ts';
import type { Severity } from '@/domain/Severity.ts';

const props = defineProps<AttributesEditorProps<DateTimeProperty>>();
const emit = defineEmits<AttributesEditorEmits<DateTimeProperty>>();
Expand Down Expand Up @@ -100,4 +115,8 @@ const updateMaximum = ( value: string ): void => {
minimumError.value = null;
emit( 'update:property', { maximum: fromLocalInputValue( value ) } );
};

const updateSeverity = ( constraint: 'minimum' | 'maximum', severity: Severity ): void => {
emit( 'update:property', withConstraintSeverity( props.property, constraint, severity ) );
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</template>

<CdxField
class="number-attributes__minimum"
class="number-attributes__minimum ext-neowiki-severity-field"
:status="minimumError === null ? 'default' : 'error'"
:messages="minimumError === null ? {} : { error: minimumError }"
>
Expand All @@ -20,10 +20,16 @@
input-type="number"
@update:model-value="updateMinimum"
/>
<SeverityInput
v-if="property.minimum !== undefined"
:constraint="$i18n( 'neowiki-property-editor-minimum' ).text()"
:model-value="property.constraintSeverities?.minimum"
@update:model-value="updateSeverity( 'minimum', $event )"
/>
</CdxField>

<CdxField
class="number-attributes__maximum"
class="number-attributes__maximum ext-neowiki-severity-field"
:status="maximumError === null ? 'default' : 'error'"
:messages="maximumError === null ? {} : { error: maximumError }"
>
Expand All @@ -36,6 +42,12 @@
input-type="number"
@update:model-value="updateMaximum"
/>
<SeverityInput
v-if="property.maximum !== undefined"
:constraint="$i18n( 'neowiki-property-editor-maximum' ).text()"
:model-value="property.constraintSeverities?.maximum"
@update:model-value="updateSeverity( 'maximum', $event )"
/>
</CdxField>
</NeoNestedField>

Expand All @@ -61,9 +73,12 @@
import { ref, watch } from 'vue';
import { CdxField, CdxTextInput } from '@wikimedia/codex';
import { NumberProperty } from '@/domain/propertyTypes/Number.ts';
import { withConstraintSeverity } from '@/domain/PropertyDefinition.ts';
import type { Severity } from '@/domain/Severity.ts';
import { AttributesEditorEmits, AttributesEditorProps } from '@/components/SchemaEditor/Property/AttributesEditorContract.ts';
import { minExceedsMax } from '@/components/SchemaEditor/Property/minExceedsMax.ts';
import NeoNestedField from '@/components/common/NeoNestedField.vue';
import SeverityInput from '@/components/SchemaEditor/Property/SeverityInput.vue';

const props = defineProps<AttributesEditorProps<NumberProperty>>();
const emit = defineEmits<AttributesEditorEmits<NumberProperty>>();
Expand Down Expand Up @@ -119,6 +134,10 @@ const updateMaximum = ( value: string ): void => {
emit( 'update:property', { maximum: parseNumber( value ) } );
};

const updateSeverity = ( constraint: 'minimum' | 'maximum', severity: Severity ): void => {
emit( 'update:property', withConstraintSeverity( props.property, constraint, severity ) );
};

const updatePrecision = ( value: string ): void => {
precisionInput.value = value;
const numValue = parseNumber( value );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</CdxCheckbox>
</CdxField>

<CdxField>
<CdxField class="select-attributes__options ext-neowiki-severity-field">
<template #label>
{{ $i18n( 'neowiki-property-editor-options' ).text() }}
</template>
Expand All @@ -19,6 +19,12 @@
:status="optionsError === null ? 'default' : 'error'"
@update:input-chips="updateOptions"
/>
<SeverityInput
v-if="property.options.length > 0"
:constraint="$i18n( 'neowiki-property-editor-options' ).text()"
:model-value="property.constraintSeverities?.options"
@update:model-value="updateSeverity"
/>
<template
v-if="optionsError !== null"
#help-text
Expand All @@ -34,7 +40,10 @@ import { computed, ref } from 'vue';
import { CdxCheckbox, CdxChipInput, CdxField } from '@wikimedia/codex';
import type { ChipInputItem } from '@wikimedia/codex';
import { SelectOption, SelectProperty } from '@/domain/propertyTypes/Select.ts';
import { withConstraintSeverity } from '@/domain/PropertyDefinition.ts';
import type { Severity } from '@/domain/Severity.ts';
import { AttributesEditorEmits, AttributesEditorProps } from '@/components/SchemaEditor/Property/AttributesEditorContract.ts';
import SeverityInput from '@/components/SchemaEditor/Property/SeverityInput.vue';

const props = defineProps<AttributesEditorProps<SelectProperty>>();
const emit = defineEmits<AttributesEditorEmits<SelectProperty>>();
Expand Down Expand Up @@ -62,4 +71,8 @@ const updateOptions = ( chips: ChipInputItem[] ): void => {
const updateMultiple = ( value: boolean ): void => {
emit( 'update:property', { multiple: value } );
};

const updateSeverity = ( severity: Severity ): void => {
emit( 'update:property', withConstraintSeverity( props.property, 'options', severity ) );
};
</script>
Loading