1212 {{mismatch.type}}
1313 </span >
1414 <span v-else >
15- {{ this. $i18n('statement') }}
15+ {{ $i18n('statement') }}
1616 </span >
1717 </td >
1818 <td :data-header =" $i18n('column-wikidata-value')" >
1919 <span class =" empty-value" v-if =" mismatch.wikidata_value === ''" >
20- {{ this. $i18n('empty-value') }}
20+ {{ $i18n('empty-value') }}
2121 </span >
2222 <a
2323 v-else class =" break-line-link" :href =" statementUrl" target =" _blank" >
9999 </a >
100100 <span class =" upload-date" >{{uploadDate}}</span >
101101 <div class =" description" >
102- {{this. mismatch.import_meta.description}}
102+ {{mismatch.import_meta.description}}
103103 </div >
104104 </cdx-dialog >
105105 </td >
106106 </tr >
107107</template >
108108
109- <script lang="ts">
109+ <script setup lang="ts">
110110import { formatISO } from ' date-fns' ;
111-
112- import type { PropType } from ' vue' ;
113- import { defineComponent } from ' vue' ;
111+ import { computed , ref } from ' vue' ;
114112import { CdxButton , CdxDialog , CdxSelect } from " @wikimedia/codex" ;
115113import { MenuItem } from ' @wmde/wikit-vue-components/dist/components/MenuItem' ;
116-
117114import { LabelledMismatch , ReviewDecision } from " ../types/Mismatch" ;
115+ import { useI18n } from ' vue-banana-i18n' ;
118116
119117const truncateLength = 100 ;
120118
@@ -126,72 +124,54 @@ type ReviewOptionMap = {
126124 [key : string ]: ReviewMenuItem ;
127125};
128126
129- interface MismatchRowState {
130- statusOptions : ReviewOptionMap ;
131- decision : ReviewMenuItem ;
132- reviewStatus : string ;
133- fullDescriptionDialog : boolean ;
134- }
127+ const props = withDefaults ( defineProps < {
128+ mismatch : LabelledMismatch
129+ disabled : boolean
130+ }>(), {
131+ disabled: false
132+ });
135133
136- export default defineComponent ({
137- components: {
138- CdxButton ,
139- CdxDialog ,
140- CdxSelect
141- },
142- props: {
143- mismatch: Object as PropType <LabelledMismatch >,
144- disabled: {
145- type: Boolean ,
146- default: false
147- }
134+ const messages = useI18n ();
135+
136+ const statusOptions: ReviewOptionMap = Object .values (ReviewDecision ).reduce (
137+ (options : ReviewOptionMap , decision : ReviewDecision ) => ({
138+ ... options ,
139+ [decision ]: {
140+ value: decision ,
141+ label: messages .i18n (` review-status-${decision } ` ),
142+ description: " " ,
148143 },
149- computed: {
150- uploadDate(): string {
151- return formatISO (new Date (this .mismatch .import_meta .created_at ), {
152- representation: ' date'
153- });
154- },
155- statementUrl(): string {
156- return ` https://www.wikidata.org/wiki/${this .mismatch .item_id }#${this .mismatch .statement_guid } ` ;
157- },
158- shouldTruncate(): boolean {
159- const text = this .mismatch .import_meta .description ;
160- return text ? text .length > truncateLength : false ;
161- },
162- uploadInfoDescription(): string {
163- const text = this .mismatch .import_meta .description ;
164- return this .shouldTruncate ?
165- text .substring (0 , truncateLength ) + ' ...' : text ;
166- }
167- },
168- data(): MismatchRowState {
169- // The following reducer generates the list of dropdown options based on a list of allowed status values
170- const statusOptions: ReviewOptionMap = Object .values (ReviewDecision ).reduce (
171- (options : ReviewOptionMap , decision : ReviewDecision ) => ({
172- ... options ,
173- [decision ]: {
174- value: decision ,
175- label: this .$i18n (` review-status-${decision } ` ),
176- description: " " ,
177- },
178- }),
179- {}
180- );
181- return {
182- statusOptions ,
183- decision: statusOptions [this .mismatch .review_status ],
184- reviewStatus: String (this .mismatch .review_status ),
185- fullDescriptionDialog: false
186- };
187- },
188- methods: {
189- showDialog(e : Event ) {
190- e .preventDefault ();
191- this .fullDescriptionDialog = true ;
192- }
193- }
144+ }),
145+ {}
146+ );
147+
148+ const uploadDate = computed <string >(() => {
149+ return formatISO (new Date (props .mismatch .import_meta .created_at ), {
150+ representation: ' date'
151+ });
194152});
153+
154+ const statementUrl = computed <string >(() => {
155+ return ` https://www.wikidata.org/wiki/${props .mismatch .item_id }#${props .mismatch .statement_guid } ` ;
156+ });
157+
158+ const shouldTruncate = computed <boolean >(() => {
159+ const text = props .mismatch .import_meta .description ;
160+ return text ? text .length > truncateLength : false ;
161+ });
162+
163+ const uploadInfoDescription = computed <string >(() => {
164+ const text = props .mismatch .import_meta .description ;
165+ return shouldTruncate .value ? text .substring (0 , truncateLength ) + ' ...' : text ;
166+ });
167+
168+ const reviewStatus = ref (String (props .mismatch .review_status ));
169+ const fullDescriptionDialog = ref (false );
170+
171+ function showDialog(e : Event ) {
172+ e .preventDefault ();
173+ fullDescriptionDialog .value = true ;
174+ }
195175 </script >
196176
197177<style lang="scss">
0 commit comments