@kaspernj/api-maker 1.0.253 → 1.0.254
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/bootstrap/card.jsx +11 -1
- package/src/inputs/attachment.jsx +27 -8
package/package.json
CHANGED
package/src/bootstrap/card.jsx
CHANGED
|
@@ -13,6 +13,7 @@ export default class ApiMakerBootstrapCard extends React.PureComponent {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
static propTypes = {
|
|
16
|
+
cardRef: PropTypes.object,
|
|
16
17
|
className: PropTypes.string,
|
|
17
18
|
children: PropTypes.node,
|
|
18
19
|
controls: PropTypes.node,
|
|
@@ -26,6 +27,8 @@ export default class ApiMakerBootstrapCard extends React.PureComponent {
|
|
|
26
27
|
table: PropTypes.bool.isRequired
|
|
27
28
|
}
|
|
28
29
|
|
|
30
|
+
cardRef = React.createRef()
|
|
31
|
+
|
|
29
32
|
constructor (props) {
|
|
30
33
|
super(props)
|
|
31
34
|
this.state = {
|
|
@@ -35,6 +38,7 @@ export default class ApiMakerBootstrapCard extends React.PureComponent {
|
|
|
35
38
|
|
|
36
39
|
render () {
|
|
37
40
|
const {
|
|
41
|
+
cardRef,
|
|
38
42
|
children,
|
|
39
43
|
className,
|
|
40
44
|
controls,
|
|
@@ -50,11 +54,17 @@ export default class ApiMakerBootstrapCard extends React.PureComponent {
|
|
|
50
54
|
} = this.props
|
|
51
55
|
const {expanded} = digs(this.state, "expanded")
|
|
52
56
|
const cardHeaderStyle = {display: "flex"}
|
|
57
|
+
const cardRefToUse = cardRef || this.cardRef
|
|
53
58
|
|
|
54
59
|
if (!expanded) cardHeaderStyle["borderBottom"] = "0"
|
|
55
60
|
|
|
56
61
|
return (
|
|
57
|
-
<div
|
|
62
|
+
<div
|
|
63
|
+
className={classNames("component-bootstrap-card", "card", "card-default", className)}
|
|
64
|
+
data-has-footer={Boolean(footer)}
|
|
65
|
+
ref={cardRefToUse}
|
|
66
|
+
{...restProps}
|
|
67
|
+
>
|
|
58
68
|
{(controls || expandable || header) &&
|
|
59
69
|
<div className="card-header" style={cardHeaderStyle}>
|
|
60
70
|
<div className="card-header-label" style={{alignSelf: "center", marginRight: "auto"}}>
|
|
@@ -4,11 +4,17 @@ import {Checkbox} from "./checkbox"
|
|
|
4
4
|
export default class ApiMakerInputsAttachment extends BaseComponent {
|
|
5
5
|
static propTypes = {
|
|
6
6
|
className: PropTypes.string,
|
|
7
|
-
model: PropTypes.object.isRequired
|
|
7
|
+
model: PropTypes.object.isRequired,
|
|
8
|
+
onPurgeChanged: PropTypes.func,
|
|
9
|
+
purgeName: PropTypes.string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
state = {
|
|
13
|
+
purgeChecked: false
|
|
8
14
|
}
|
|
9
15
|
|
|
10
16
|
render() {
|
|
11
|
-
const {checkboxComponent, className, inputProps, model, wrapperOpts, ...restProps} = this.props
|
|
17
|
+
const {attribute, checkboxComponent, className, inputProps, label, model, name, onPurgeChanged, purgeName, wrapperOpts, ...restProps} = this.props
|
|
12
18
|
const CheckboxComponent = checkboxComponent || Checkbox
|
|
13
19
|
|
|
14
20
|
inputProps.type = "file"
|
|
@@ -22,17 +28,19 @@ export default class ApiMakerInputsAttachment extends BaseComponent {
|
|
|
22
28
|
}
|
|
23
29
|
{this.getUrl() &&
|
|
24
30
|
<div className="input-checkbox" style={{paddingTop: "15px", paddingBottom: "15px"}}>
|
|
25
|
-
<CheckboxComponent inputProps={{id: this.getPurgeInputId(), name: this.getPurgeInputName()}} />
|
|
31
|
+
<CheckboxComponent inputProps={{id: this.getPurgeInputId(), name: this.getPurgeInputName()}} onChange={this.props.onPurgeChanged} />
|
|
26
32
|
<label className="checkbox-label" htmlFor={this.getPurgeInputId()}>
|
|
27
33
|
{I18n.t("js.shared.delete")}
|
|
28
34
|
</label>
|
|
29
35
|
</div>
|
|
30
36
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
{!this.state.purgeChecked &&
|
|
38
|
+
<ApiMakerInput
|
|
39
|
+
defaultValue={null}
|
|
40
|
+
inputProps={inputProps}
|
|
41
|
+
model={model}
|
|
42
|
+
/>
|
|
43
|
+
}
|
|
36
44
|
</div>
|
|
37
45
|
)
|
|
38
46
|
}
|
|
@@ -53,7 +61,12 @@ export default class ApiMakerInputsAttachment extends BaseComponent {
|
|
|
53
61
|
}
|
|
54
62
|
|
|
55
63
|
getPurgeInputName() {
|
|
64
|
+
if ("purgeName" in this.props) return this.props.purgeName
|
|
65
|
+
|
|
56
66
|
const {inputProps} = digs(this.props, "inputProps")
|
|
67
|
+
|
|
68
|
+
if (!inputProps.name) return null
|
|
69
|
+
|
|
57
70
|
const match = inputProps.name.match(/^(.+)\[(.+?)\]$/)
|
|
58
71
|
const purgeInputName = `${match[1]}[${match[2]}_purge]`
|
|
59
72
|
|
|
@@ -72,4 +85,10 @@ export default class ApiMakerInputsAttachment extends BaseComponent {
|
|
|
72
85
|
isImage() {
|
|
73
86
|
return this.getContentType()?.startsWith("image/")
|
|
74
87
|
}
|
|
88
|
+
|
|
89
|
+
onPurgeChanged = (e) => {
|
|
90
|
+
this.setState({purgeChecked: digg(e, "target", "checked")})
|
|
91
|
+
|
|
92
|
+
if (this.props.onPurgeChanged) this.props.onPurgeChanged(e)
|
|
93
|
+
}
|
|
75
94
|
}
|