Skip to content

Commit b760192

Browse files
committed
Support external identifier property
Bug: T285656 Change-Id: Ia15deba7a601b475cba046b9c2024e5a850758bc
1 parent 0aa7ec6 commit b760192

File tree

8 files changed

+47
-14
lines changed

8 files changed

+47
-14
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"react-bootstrap": "^1.5.2",
1515
"react-dom": "^17.0.2",
1616
"react-redux": "^7.2.3",
17-
"react-scripts": "4.0.3",
17+
"react-scripts": "^4.0.3",
1818
"react-typeahead": "^2.0.0-alpha.8",
1919
"redux": "^4.0.5",
2020
"redux-thunk": "^2.3.0",

src/components/DataTable/Widget/EditorWidget.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ function EditorWidget({ itemId, pItem }) {
5656
setOptions(data.search)
5757
})
5858
}
59-
} else if (pItem.type === 'string' && e.key === 'Enter') {
59+
} else if (
60+
e.key === 'Enter' &&
61+
(pItem.type === 'string' || pItem.type === 'external-id')
62+
) {
6063
createClaimById(newValue, pItem.type);
6164
}
6265
}

src/components/DataTable/Widget/FormEditorWidget.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ function FormEditorWidget({ itemId, pItem }) {
5656
setOptions(data.search)
5757
})
5858
}
59-
} else if (pItem.type === 'string' && e.key === 'Enter') {
59+
} else if (
60+
e.key === 'Enter' &&
61+
(pItem.type === 'string' || pItem.type === 'external-id')
62+
) {
6063
createClaimById(newValue, pItem.type);
6164
}
6265
}

src/components/DataTable/Widget/FormPropertyWidget.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function FormPropertyWidget({ pItem, itemId }) {
1818
let itemDataValue;
1919
if (itemType === "wikibase-lexeme" || itemType === "wikibase-item") {
2020
itemDataValue = itemMainsnak.datavalue.value.id
21-
} else if (itemType === "string") {
21+
} else if (itemType === "string" || itemType === "external-id") {
2222
itemDataValue = itemMainsnak.datavalue.value
2323
}
2424

@@ -68,7 +68,10 @@ function FormPropertyWidget({ pItem, itemId }) {
6868
}
6969

7070
// Property having string nature can be edit by Enter
71-
if (e.key === "Enter" && pItem.type === "string") {
71+
if (
72+
e.key === "Enter" &&
73+
( pItem.type === "string" || pItem.type === "external-id" )
74+
) {
7275
onEditClaim(newValue)
7376
}
7477
}
@@ -100,7 +103,12 @@ function FormPropertyWidget({ pItem, itemId }) {
100103
}
101104

102105
const getCellContent = () => {
103-
if (pItem.type === "string" || pItem.type === "wikibase-item" || pItem.type === "wikibase-lexeme") {
106+
if (
107+
pItem.type === "string" ||
108+
pItem.type === "external-id" ||
109+
pItem.type === "wikibase-item" ||
110+
pItem.type === "wikibase-lexeme"
111+
) {
104112
return <>
105113
<input disabled value={itemText} className="propertyCellInput" />
106114
<div style={{ marginLeft: -30, display: 'inline', zIndex: 999 }}>

src/components/DataTable/Widget/PropertyWidget.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function PropertyWidget({ pItem, itemId }) {
1717
let itemDataValue;
1818
if (itemType === "wikibase-lexeme" || itemType === "wikibase-item") {
1919
itemDataValue = itemMainsnak.datavalue.value.id
20-
} else if (itemType === "string") {
20+
} else if (itemType === "string" || itemType === "external-id") {
2121
itemDataValue = itemMainsnak.datavalue.value
2222
}
2323

@@ -67,7 +67,10 @@ function PropertyWidget({ pItem, itemId }) {
6767
}
6868

6969
// Property having string nature can be edit by Enter
70-
if (e.key === "Enter" && pItem.type === "string") {
70+
if (
71+
e.key === "Enter" &&
72+
( pItem.type === "string" || pItem.type === "external-id" )
73+
) {
7174
onEditClaim(newValue)
7275
}
7376
}
@@ -99,7 +102,12 @@ function PropertyWidget({ pItem, itemId }) {
99102
}
100103

101104
const getCellContent = () => {
102-
if (pItem.type === "string" || pItem.type === "wikibase-item" || pItem.type === "wikibase-lexeme") {
105+
if (
106+
pItem.type === "string" ||
107+
pItem.type === "external-id" ||
108+
pItem.type === "wikibase-item" ||
109+
pItem.type === "wikibase-lexeme"
110+
) {
103111
return <>
104112
<input disabled value={itemText} className="propertyCellInput" />
105113
<div style={{ marginLeft: -30, display: 'inline', zIndex: 999 }}>

src/components/DataTable/Widget/SenseEditorWidget.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ function SenseEditorWidget({ itemId, pItem }) {
5656
setOptions(data.search)
5757
})
5858
}
59-
} else if (pItem.type === 'string' && e.key === 'Enter') {
59+
} else if (
60+
e.key === 'Enter' &&
61+
(pItem.type === 'string' || pItem.type === 'external-id')
62+
) {
6063
createClaimById(newValue, pItem.type);
6164
}
6265
}

src/components/DataTable/Widget/SensePropertyWidget.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function SensePropertyWidget({ pItem, itemId }) {
1818
let itemDataValue;
1919
if (itemType === "wikibase-lexeme" || itemType === "wikibase-item") {
2020
itemDataValue = itemMainsnak.datavalue.value.id
21-
} else if (itemType === "string") {
21+
} else if (itemType === "string" || itemType === "external-id") {
2222
itemDataValue = itemMainsnak.datavalue.value
2323
}
2424

@@ -68,7 +68,10 @@ function SensePropertyWidget({ pItem, itemId }) {
6868
}
6969

7070
// Property having string nature can be edit by Enter
71-
if (e.key === "Enter" && pItem.type === "string") {
71+
if (
72+
e.key === "Enter" &&
73+
( pItem.type === "string" || pItem.type === "external-id" )
74+
) {
7275
onEditClaim(newValue)
7376
}
7477
}
@@ -100,7 +103,12 @@ function SensePropertyWidget({ pItem, itemId }) {
100103
}
101104

102105
const getCellContent = () => {
103-
if (pItem.type === "string" || pItem.type === "wikibase-item" || pItem.type === "wikibase-lexeme") {
106+
if (
107+
pItem.type === "string" ||
108+
pItem.type === "external-id" ||
109+
pItem.type === "wikibase-item" ||
110+
pItem.type === "wikibase-lexeme"
111+
) {
104112
return <>
105113
<input disabled value={itemText} className="propertyCellInput" />
106114
<div style={{ marginLeft: -30, display: 'inline', zIndex: 999 }}>

src/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function getTypeByString(item) {
2222
* @return {boolean}
2323
*/
2424
export function allowProperties(item) {
25-
return ['wikibase-item', 'wikibase-lexeme', 'string'].includes(item)
25+
return ['wikibase-item', 'wikibase-lexeme', 'string', 'external-id'].includes(item)
2626
}
2727

2828
/**

0 commit comments

Comments
 (0)