@@ -2,14 +2,14 @@ import React, { useState, useContext, useEffect } from 'react';
2
2
import Modal from 'react-modal'
3
3
import AppContext from "../components/AppContext" ;
4
4
5
-
6
- const ModalPrintSize = ( { show, handleOK, handleCancel, paperusablesize } ) => {
5
+ const ModalPrintSize = ( { show, handleOK, handleCancel, paperusablesize, title} ) => {
7
6
const { GetLocaleString } = useContext ( AppContext ) ;
8
7
const [ SelectedSize , setSelectedSize ] = useState ( 0 ) ;
9
8
const [ Name , setName ] = useState ( 'New' ) ;
10
9
const [ usableWidth , setUsableWidth ] = useState ( 210 ) ;
11
10
const [ usableHeight , setUsableHeight ] = useState ( 297 - 45 ) ;
12
11
const [ usableSize , setUsableSize ] = useState ( [ ...paperusablesize ] || [ ] ) ;
12
+ const [ Message , setMessage ] = useState ( "" ) ;
13
13
14
14
useEffect ( ( ) => {
15
15
@@ -28,7 +28,8 @@ const ModalPrintSize = ({ show, handleOK, handleCancel, paperusablesize }) => {
28
28
} , [ usableSize ] ) ;
29
29
30
30
const render_lock = ( locked ) => {
31
- return locked ? String . fromCodePoint ( 0x1f512 ) : " " ;
31
+ return locked ? String . fromCodePoint ( 0x1f512 ) : " " ;
32
+
32
33
}
33
34
34
35
const onOk = ( ) => {
@@ -50,8 +51,15 @@ const ModalPrintSize = ({ show, handleOK, handleCancel, paperusablesize }) => {
50
51
let index = parseInt ( SelectedSize ) ;
51
52
let option = [ ...usableSize ] ;
52
53
let data = { name : Name , width : usableWidth , height : usableHeight , lock : false } ;
53
- option [ index ] = data ;
54
- setUsableSize ( option ) ;
54
+ if ( ! option [ index ] . lock )
55
+ {
56
+ option [ index ] = data ;
57
+ setUsableSize ( option ) ;
58
+ }
59
+ else {
60
+ setMessage ( GetLocaleString ( "param.modal.updatelocked" ) ) ;
61
+ }
62
+
55
63
}
56
64
const onDelete = ( ) => {
57
65
if ( SelectedSize ) {
@@ -65,7 +73,7 @@ const ModalPrintSize = ({ show, handleOK, handleCancel, paperusablesize }) => {
65
73
}
66
74
}
67
75
const onDuplicate = ( ) => {
68
- if ( SelectedSize ) {
76
+ if ( SelectedSize >= 0 ) {
69
77
let data = [ ...usableSize ] ;
70
78
let elem = { ...data [ SelectedSize ] } ;
71
79
elem . name += " Copy" ;
@@ -75,7 +83,29 @@ const ModalPrintSize = ({ show, handleOK, handleCancel, paperusablesize }) => {
75
83
76
84
}
77
85
}
86
+
87
+ const render_message = ( ) => {
88
+ if ( Message . length > 0 )
89
+ return ( < div className = 'content' >
90
+ < div class = "alert alert-danger alert-white rounded" >
91
+ { Message }
92
+ < button type = "button" class = "close"
93
+ data-dismiss = "alert"
94
+ aria-hidden = "true"
95
+ onClick = { ( ) => { setMessage ( "" ) } } > ×</ button >
96
+ < div class = "icon" > < i class = "fa fa-check" > </ i > </ div >
97
+ </ div >
98
+
99
+ </ div > ) ;
100
+ return ( < div className = 'content' >
101
+
102
+ < div class = "rounded" >
103
+
78
104
105
+ < div class = "icon" > < i class = "fa fa-check" > </ i > </ div >
106
+ </ div >
107
+ </ div > )
108
+ }
79
109
return (
80
110
81
111
< div
@@ -90,12 +120,15 @@ const ModalPrintSize = ({ show, handleOK, handleCancel, paperusablesize }) => {
90
120
} } >
91
121
< Modal
92
122
isOpen = { show }
93
- contentLabel = ""
123
+ contentLabel = "Toto "
94
124
aria = { { hidden : false , label : ' ' } }
95
-
125
+ onRequestClose = { ( ) => { onCancel ( ) } }
96
126
>
127
+
97
128
< div className = 'MakeColumn100' >
129
+
98
130
< div >
131
+ < h2 > { title ? title : "" } </ h2 >
99
132
< select
100
133
onChange = { ( e ) => {
101
134
console . log ( e ) ;
@@ -109,7 +142,7 @@ const ModalPrintSize = ({ show, handleOK, handleCancel, paperusablesize }) => {
109
142
value = { SelectedSize }
110
143
id = "usablepaper"
111
144
name = "usablepaper"
112
- className = 'select_param '
145
+ className = 'select_modal '
113
146
size = "6"
114
147
>
115
148
{ usableSize . map ( ( item , index ) => {
@@ -123,20 +156,9 @@ const ModalPrintSize = ({ show, handleOK, handleCancel, paperusablesize }) => {
123
156
</ div >
124
157
< div >
125
158
< div className = 'pure-form pure-form-aligned' >
126
- < div className = 'content' >
127
- < div class = "alert alert-danger alert-white rounded" >
128
- blabla
129
- < button type = "button" class = "close" data-dismiss = "alert" aria-hidden = "true" > ×</ button >
130
- < div class = "icon" > < i class = "fa fa-check" > </ i > </ div >
131
- </ div >
132
- < div class = "rounded" >
133
-
134
-
135
- < div class = "icon" > < i class = "fa fa-check" > </ i > </ div >
136
- </ div >
137
- </ div >
159
+ { render_message ( ) }
138
160
< div className = 'pure-control-group' >
139
- < legend > A legend for size </ legend >
161
+ < legend > { GetLocaleString ( "param.modal.details" ) } </ legend >
140
162
< fieldset >
141
163
< label for = 'myInputWUDiag' >
142
164
{ GetLocaleString ( "param.usable.diag.name" ) } :
@@ -195,35 +217,35 @@ const ModalPrintSize = ({ show, handleOK, handleCancel, paperusablesize }) => {
195
217
< button className = "pad-button pure-button"
196
218
onClick = { ( ) => { onAdd ( ) } }
197
219
>
198
- Add
220
+ { GetLocaleString ( "param.modal.add" ) }
199
221
</ button >
200
222
< button className = "pad-button pure-button"
201
223
onClick = { ( ) => { onDelete ( ) } }
202
224
>
203
- Delete
225
+ { GetLocaleString ( "param.modal.delete" ) }
204
226
</ button >
205
227
< button className = "pad-button pure-button"
206
228
onClick = { ( ) => { onUpdate ( ) } }
207
229
>
208
- Update
230
+ { GetLocaleString ( "param.modal.update" ) }
209
231
</ button >
210
232
< button className = "pad-button pure-button"
211
233
onClick = { ( ) => { onDuplicate ( ) } }
212
234
>
213
- Duplicate
235
+ { GetLocaleString ( "param.modal.duplicate" ) }
214
236
</ button >
215
237
</ fieldset >
216
238
< fieldset >
217
239
< button className = "pad-button pure-button"
218
240
onClick = { ( ) => { onOk ( ) } }
219
241
>
220
- Ok
242
+ { GetLocaleString ( "param.modal.ok" ) }
221
243
222
244
</ button >
223
245
< button className = "pad-button pure-button"
224
246
onClick = { ( ) => { onCancel ( ) } }
225
247
>
226
- Cancel
248
+ { GetLocaleString ( "param.modal.cancel" ) }
227
249
228
250
</ button >
229
251
</ fieldset >
0 commit comments