Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Frederic Thoma
erp5
Commits
b9282d5d
Commit
b9282d5d
authored
Oct 12, 2016
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_web_renderjs_ui] Rewrite checkbox field
Use an html5 input subgadget to handle the DOM events
parent
6f9869b1
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
34 deletions
+61
-34
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_checkboxfield_html.html
...m/web_page_module/rjs_gadget_erp5_checkboxfield_html.html
+1
-3
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_checkboxfield_html.xml
...em/web_page_module/rjs_gadget_erp5_checkboxfield_html.xml
+3
-3
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_checkboxfield_js.js
...eItem/web_page_module/rjs_gadget_erp5_checkboxfield_js.js
+37
-19
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_checkboxfield_js.xml
...Item/web_page_module/rjs_gadget_erp5_checkboxfield_js.xml
+3
-3
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_html5_input_js.js
...TemplateItem/web_page_module/rjs_gadget_html5_input_js.js
+15
-4
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_html5_input_js.xml
...emplateItem/web_page_module/rjs_gadget_html5_input_js.xml
+2
-2
No files found.
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_checkboxfield_html.html
View file @
b9282d5d
...
...
@@ -11,10 +11,8 @@
<!-- custom script -->
<script
src=
"gadget_erp5_field_checkbox.js"
type=
"text/javascript"
></script>
</head>
<body>
<
input
type=
"checkbox"
class=
"ui-btn"
/
>
<
div
data-gadget-url=
"gadget_html5_input.html"
data-gadget-scope=
"sub"
></div
>
</body>
</html>
\ No newline at end of file
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_checkboxfield_html.xml
View file @
b9282d5d
...
...
@@ -234,7 +234,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
9
44.6819.59898.35293
</string>
</value>
<value>
<string>
9
54.35638.15944.23620
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -252,8 +252,8 @@
</tuple>
<state>
<tuple>
<float>
14
35814886.24
</float>
<string>
GMT+2
</string>
<float>
14
76260804.53
</float>
<string>
UTC
</string>
</tuple>
</state>
</object>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_checkboxfield_js.js
View file @
b9282d5d
/*global window, rJS
, RSVP
*/
/*jslint indent: 2, maxerr: 3 */
/*global window, rJS */
/*jslint indent: 2, maxerr: 3
, maxlen: 80
*/
(
function
(
window
,
rJS
)
{
"
use strict
"
;
rJS
(
window
)
.
ready
(
function
(
gadget
)
{
return
gadget
.
getElement
()
.
push
(
function
(
element
)
{
gadget
.
element
=
element
;
});
.
setState
({
type
:
'
checkbox
'
})
.
declareMethod
(
'
render
'
,
function
(
options
)
{
var
input
=
this
.
element
.
querySelector
(
'
input
'
),
field_json
=
options
.
field_json
||
{};
input
.
checked
=
field_json
.
value
||
field_json
.
default
;
input
.
setAttribute
(
'
name
'
,
field_json
.
key
);
input
.
setAttribute
(
'
title
'
,
field_json
.
title
);
if
(
field_json
.
editable
===
0
)
{
input
.
setAttribute
(
"
class
"
,
"
ui-btn ui-state-readonly
"
);
}
var
field_json
=
options
.
field_json
||
{},
state_dict
=
{
checked
:
field_json
.
value
||
field_json
.
default
,
editable
:
field_json
.
editable
,
name
:
field_json
.
key
,
title
:
field_json
.
title
};
return
this
.
changeState
(
state_dict
);
})
.
onStateChange
(
function
()
{
var
gadget
=
this
;
return
this
.
getDeclaredGadget
(
'
sub
'
)
.
push
(
function
(
input
)
{
return
input
.
render
(
gadget
.
state
);
});
})
.
declareMethod
(
'
getContent
'
,
function
()
{
var
input
=
this
.
element
.
querySelector
(
'
input
'
),
result
=
{};
result
[
input
.
getAttribute
(
'
name
'
)]
=
(
input
.
checked
?
1
:
0
);
return
result
;
if
(
this
.
state
.
editable
)
{
return
this
.
getDeclaredGadget
(
'
sub
'
)
.
push
(
function
(
gadget
)
{
return
gadget
.
getContent
();
});
}
return
{};
})
.
declareMethod
(
'
checkValidity
'
,
function
()
{
if
(
this
.
state
.
editable
)
{
return
this
.
getDeclaredGadget
(
'
sub
'
)
.
push
(
function
(
gadget
)
{
return
gadget
.
checkValidity
();
});
}
return
true
;
});
}(
window
,
rJS
));
\ No newline at end of file
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_checkboxfield_js.xml
View file @
b9282d5d
...
...
@@ -230,7 +230,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
9
44.6824.36715.55227
</string>
</value>
<value>
<string>
9
54.35656.703.56354
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -248,8 +248,8 @@
</tuple>
<state>
<tuple>
<float>
14
35815104.42
</float>
<string>
GMT+2
</string>
<float>
14
76262104.61
</float>
<string>
UTC
</string>
</tuple>
</state>
</object>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_html5_input_js.js
View file @
b9282d5d
...
...
@@ -6,7 +6,8 @@
rJS
(
window
)
.
setState
({
editable
:
false
,
value
:
''
,
value
:
undefined
,
checked
:
undefined
,
title
:
''
,
type
:
'
text
'
,
required
:
false
...
...
@@ -15,6 +16,7 @@
.
declareMethod
(
'
render
'
,
function
(
options
)
{
var
state_dict
=
{
value
:
options
.
value
||
""
,
checked
:
options
.
checked
,
editable
:
options
.
editable
,
required
:
options
.
required
,
name
:
options
.
name
,
...
...
@@ -27,8 +29,13 @@
.
onStateChange
(
function
()
{
var
textarea
=
this
.
element
.
querySelector
(
'
input
'
);
textarea
.
setAttribute
(
'
value
'
,
this
.
state
.
value
);
textarea
.
value
=
this
.
state
.
value
;
if
(
this
.
state
.
value
!==
undefined
)
{
textarea
.
setAttribute
(
'
value
'
,
this
.
state
.
value
);
textarea
.
value
=
this
.
state
.
value
;
}
if
(
this
.
state
.
checked
!==
undefined
)
{
textarea
.
checked
=
this
.
state
.
checked
;
}
textarea
.
setAttribute
(
'
name
'
,
this
.
state
.
name
);
textarea
.
setAttribute
(
'
type
'
,
this
.
state
.
type
);
if
(
this
.
state
.
title
)
{
...
...
@@ -64,7 +71,11 @@
input
;
if
(
this
.
state
.
editable
)
{
input
=
this
.
element
.
querySelector
(
'
input
'
);
result
[
input
.
getAttribute
(
'
name
'
)]
=
input
.
value
;
if
(
input
.
value
!==
undefined
)
{
result
[
input
.
getAttribute
(
'
name
'
)]
=
input
.
value
;
}
else
if
(
input
.
checked
!==
undefined
)
{
result
[
input
.
getAttribute
(
'
name
'
)]
=
(
input
.
checked
?
1
:
0
);
}
}
return
result
;
})
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_html5_input_js.xml
View file @
b9282d5d
...
...
@@ -230,7 +230,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
954.3
4535.18115.52548
</string>
</value>
<value>
<string>
954.3
5661.46722.46711
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>
1476
198804.5
</float>
<float>
1476
262019.89
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment