Skip to content

Commit 12c55d9

Browse files
author
Prateek Rathore
committed
add:
- Support for ui:widget hidden - Section Style Update - DateWidget malformed JS calls issue fix - Removed Slider Widget Support - Add Dropdown Widget Support - Fix RadioWidget to support 0 as index value - Add support for Unsupported Widget
1 parent a00227e commit 12c55d9

File tree

9 files changed

+35
-41
lines changed

9 files changed

+35
-41
lines changed

src/FormStyle.js

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,10 @@ const styles = {
44
container: {
55
flex: 1
66
},
7-
cardContainer: {
7+
sectionContainer: {
88
flex: 1,
9-
borderWidth: 1,
10-
borderRadius: 2,
11-
shadowColor: "#ddd",
12-
borderLeftWidth: 2,
13-
borderRightWidth: 2,
14-
borderBottomWidth: 2,
15-
borderTopWidth: 2,
16-
shadowOffset: {
17-
width: 1,
18-
height: 1
19-
},
209
padding: metrics.cardPadding,
21-
marginTop: metrics.cardMarginTop,
22-
marginBottom: metrics.cardMarginTop,
23-
paddingBottom: metrics.cardMarginTop,
24-
shadowColor: "#ddd",
25-
shadowOpacity: 1.0,
26-
borderColor: "white"
10+
marginBottom: metrics.baseMargin * 3,
2711
},
2812
sectionTitle: {
2913
fontSize: 16,
@@ -37,9 +21,11 @@ const styles = {
3721
button: {
3822
alignItems: 'center',
3923
backgroundColor: "#ad2960",
40-
marginTop: metrics.doubleBaseMargin * 2,
41-
marginBottom: 0,
42-
height:40
24+
margin: metrics.doubleBaseMargin,
25+
justifyContent: 'center',
26+
alignItems: 'center',
27+
height:54,
28+
borderRadius: 10,
4329
},
4430
description: {
4531
fontSize: 14,
@@ -50,9 +36,9 @@ const styles = {
5036
},
5137
buttonText:{
5238
textAlign:"center",
53-
marginTop:8,
54-
fontSize:15,
55-
color:"white"
39+
fontSize:18,
40+
color:"white",
41+
fontWeight: 'bold',
5642
}
5743
};
5844

src/Section.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class Section extends Component {
5555
const sectionFormData = formData.hasOwnProperty(keyName) ? formData[keyName] : {};
5656
return (
5757
<View
58-
style={styles.cardContainer}
58+
style={styles.sectionContainer}
5959
onLayout={e => {
6060
this.props.storeLayoutSection(keyName, e.nativeEvent.layout.height);
6161
}}
@@ -64,7 +64,7 @@ class Section extends Component {
6464

6565
{uiOrder["ui:order"].map(idSchema => {
6666
if (uiOrder[idSchema] == undefined) {
67-
console.log(uiOrder[idSchema] + " Not Found ");
67+
// console.log(uiOrder[idSchema] + " Not Found ");
6868
} else {
6969
const required = this.isRequired(idSchema);
7070
const errors = sectionErrors[idSchema]

src/Util.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const widgetMap = {
4343
text: "TextWidget",
4444
select: "DropDownWidget",
4545
updown: "UnsupportedWidget",
46-
range: "SliderWidget",
46+
range: "UnsupportedWidget",
4747
radio: "RadioWidget",
4848
hidden: "UnsupportedWidget",
4949
checkboxes: "CheckboxesWidget"
@@ -87,7 +87,8 @@ export function getWidget(schema, widget, registeredWidgets = {}) {
8787
}
8888

8989
if (typeof widget !== "string") {
90-
throw new Error(`Unsupported widget definition: ${typeof widget}`);
90+
console.log(widget);
91+
// throw new Error(`Unsupported widget definition: ${typeof widget}`);
9192
}
9293

9394
if (registeredWidgets.hasOwnProperty(widget)) {

src/Widgets/DateWidget.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const DateWidget = props => {
1515
date={value}
1616
mode="date"
1717
placeholder="Select date"
18-
format="MM-DD-YYYY"
18+
format="YYYY-MM-DD"
1919
minDate="1900-05-01"
2020
maxDate={maxDateValue}
2121
confirmBtnText="Confirm"

src/Widgets/DropDownWidget.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const DropDownWidget = props => {
1717
return (
1818
<Picker.Item
1919
label={item.title}
20-
value={item.title}
20+
value={item.enum[0]}
2121
key={item.title}
2222
/>
2323
);

src/Widgets/RadioWidget.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default class RadioForm extends React.Component {
5757
* @returns {boolean} item.value
5858
*/
5959
getIndexFromProps = (props, options) => {
60-
if (props.value) {
60+
if (props.value !== undefined || props.value !== null) {
6161
return _.findIndex(options, function(item) {
6262
return item.value == props.value;
6363
});

src/Widgets/SchemaWidget.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ class SchemaWidget extends Component {
2525
if (this.props.schema.type == "boolean") {
2626
return null;
2727
}
28-
const color = hasErrors(errors) ? styles.requiredColor : {};
28+
const color = hasErrors(errors) ? styles.requiredColor : {};
2929
const { title } = this.props.schema;
3030
return (
3131
<View style={styles.label}>
3232
<Text
33-
style={
34-
this.props.idSchema == "cannula_size" ? styles.title1 : styles.title
35-
}
36-
>
37-
{title}
38-
{this.props.required && <Text style={color}> *</Text>}
33+
style={
34+
this.props.idSchema == "cannula_size" ? styles.title1 : styles.title
35+
}
36+
>
37+
{title}
38+
{this.props.required && <Text style={color}> *</Text>}
3939
</Text>
4040
</View>
4141
);
@@ -61,6 +61,9 @@ class SchemaWidget extends Component {
6161
const _value = value;
6262
const options = {};
6363
const deselectAlert = this.props.schema.deselectAlert;
64+
if (widgetType == "hidden") {
65+
return null;
66+
}
6467
return (
6568
<View
6669
style={styles.container}

src/Widgets/UpsupportedWidget.js renamed to src/Widgets/UnsupportedWidget.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React from "react";
22
import { View, Text, StyleSheet } from "react-native";
3+
import metrics from "../Metrics";
34
/**
45
* Method gives the Unsupported widget in the json schema form
56
* @param {object} props
67
*/
78
const UnsupportedWidget = props => {
8-
console.log(props);
99
return (
1010
<View>
1111
<Text style={styles.textStyle}>UnsupportedWidget</Text>
@@ -15,7 +15,9 @@ const UnsupportedWidget = props => {
1515

1616
const styles = StyleSheet.create({
1717
textStyle: {
18-
fontSize: 30
18+
fontSize: 16,
19+
margin: metrics.doubleBaseMargin,
20+
color: "tomato"
1921
}
2022
});
2123

src/Widgets/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import DateWidget from "./DateWidget";
55
import DropDownWidget from "./DropDownWidget";
66
import SliderWidget from "./SliderWidget";
77
import CheckboxWidget from "./CheckboxWidget";
8+
import UnsupportedWidget from './UnsupportedWidget';
89

910
export default {
1011
TextWidget,
@@ -13,5 +14,6 @@ export default {
1314
DateWidget,
1415
DropDownWidget,
1516
SliderWidget,
16-
CheckboxWidget
17+
CheckboxWidget,
18+
UnsupportedWidget
1719
};

0 commit comments

Comments
 (0)