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
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Rafael Monnerat
erp5
Commits
3e075f4f
Commit
3e075f4f
authored
Oct 28, 2016
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_web_renderjs_ui] Reimplement multicheckbox field
parent
ddbcf9ce
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
147 additions
and
98 deletions
+147
-98
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_multicheckboxfield_html.html
..._page_module/rjs_gadget_erp5_multicheckboxfield_html.html
+0
-19
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_multicheckboxfield_html.xml
...b_page_module/rjs_gadget_erp5_multicheckboxfield_html.xml
+3
-3
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_multicheckboxfield_js.js
.../web_page_module/rjs_gadget_erp5_multicheckboxfield_js.js
+141
-73
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_multicheckboxfield_js.xml
...web_page_module/rjs_gadget_erp5_multicheckboxfield_js.xml
+3
-3
No files found.
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_multicheckboxfield_html.html
View file @
3e075f4f
...
@@ -8,29 +8,10 @@
...
@@ -8,29 +8,10 @@
<!-- renderjs -->
<!-- renderjs -->
<script
src=
"rsvp.js"
type=
"text/javascript"
></script>
<script
src=
"rsvp.js"
type=
"text/javascript"
></script>
<script
src=
"renderjs.js"
type=
"text/javascript"
></script>
<script
src=
"renderjs.js"
type=
"text/javascript"
></script>
<script
src=
"gadget_global.js"
type=
"text/javascript"
></script>
<script
src=
"handlebars.js"
type=
"text/javascript"
></script>
<!-- custom script -->
<!-- custom script -->
<script
src=
"gadget_erp5_field_multicheckbox.js"
type=
"text/javascript"
></script>
<script
src=
"gadget_erp5_field_multicheckbox.js"
type=
"text/javascript"
></script>
<script
id=
"unchecked-template"
type=
"text/x-handlebars-template"
>
<
div
class
=
"
ui-field-contain
"
>
<
label
for
=
"
{{text}}
"
data
-
i18n
=
"
{{text}}
"
>
{{
text
}}
<
/label
>
<
input
type
=
"
checkbox
"
value
=
"
{{value}}
"
name
=
"
{{text}}
"
class
=
"
ui-btn
"
data
-
i18n
=
"
{{text}}
"
>
<
/div
>
</script>
<script
id=
"checked-template"
type=
"text/x-handlebars-template"
>
<
diV
class
=
"
ui-field-contain
"
>
<
label
for
=
"
{{text}}
"
data
-
i18n
=
"
{{text}}
"
>
{{
text
}}
<
/label
>
<
input
type
=
"
checkbox
"
value
=
"
{{value}}
"
checked
=
true
data
-
i18n
=
"
{{text}}
"
class
=
"
ui-btn
"
name
=
"
{{text}}
"
>
<
/div
>
</script>
</head>
</head>
<body>
<body>
<fieldset
class=
"ui-controlgroup ui-corner-all ui-controlgroup-vertical"
>
<div
class=
"checkbox_container"
>
</div>
</fieldset>
</body>
</body>
</html>
</html>
\ No newline at end of file
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_multicheckboxfield_html.xml
View file @
3e075f4f
...
@@ -234,7 +234,7 @@
...
@@ -234,7 +234,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
9
44.6874.36886.54937
</string>
</value>
<value>
<string>
9
54.45675.44850.53452
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -252,8 +252,8 @@
...
@@ -252,8 +252,8 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
14
35817983.35
</float>
<float>
14
77656021.33
</float>
<string>
GMT+2
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
</object>
</object>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_multicheckboxfield_js.js
View file @
3e075f4f
/*global window, rJS,
Handlebars, document, RSVP, loopEventListener
*/
/*global window, rJS,
RSVP, document
*/
/*jslint nomen: true, indent: 2, maxerr: 3 */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(
function
(
window
,
rJS
,
Handlebars
,
RSVP
)
{
(
function
(
window
,
rJS
,
RSVP
,
document
)
{
'
use strict
'
;
'
use strict
'
;
/////////////////////////////////////////////////////////////////
// Handlebars
function
appendCheckboxField
(
gadget
,
item
,
checked
)
{
/////////////////////////////////////////////////////////////////
var
input_gadget
,
// Precompile the templates while loading the first gadget instance
label_gadget
;
var
gadget_klass
=
rJS
(
window
),
unchecked_source
=
gadget_klass
.
__template_element
if
(
!
gadget
.
state
.
editable
)
{
.
getElementById
(
"
unchecked-template
"
)
if
(
checked
)
{
.
innerHTML
,
return
gadget
.
declareGadget
(
'
gadget_html5_element.html
'
)
unchecked_template
=
Handlebars
.
compile
(
unchecked_source
),
.
push
(
function
(
result
)
{
checked_source
=
gadget_klass
.
__template_element
label_gadget
=
result
;
.
getElementById
(
"
checked-template
"
)
return
result
.
render
({
.
innerHTML
,
tag
:
'
p
'
,
checked_template
=
Handlebars
.
compile
(
checked_source
);
text_content
:
item
[
0
]
gadget_klass
});
.
ready
(
function
(
g
)
{
})
g
.
props
=
{};
.
push
(
function
()
{
})
gadget
.
element
.
appendChild
(
label_gadget
.
element
);
// Assign the element to a variable
});
.
ready
(
function
(
g
)
{
}
return
g
.
getElement
()
return
;
.
push
(
function
(
element
)
{
}
g
.
props
.
element
=
element
;
});
return
gadget
.
declareGadget
(
'
gadget_html5_input.html
'
,
{
scope
:
item
[
1
]})
})
.
push
(
function
(
result
)
{
.
declareAcquiredMethod
(
"
translateHtml
"
,
"
translateHtml
"
)
input_gadget
=
result
;
var
state_dict
=
{
type
:
'
checkbox
'
,
name
:
gadget
.
state
.
name
,
value
:
item
[
1
],
checked
:
checked
,
editable
:
true
};
return
result
.
render
(
state_dict
);
})
.
push
(
function
()
{
return
gadget
.
declareGadget
(
'
gadget_html5_element.html
'
);
})
.
push
(
function
(
result
)
{
label_gadget
=
result
;
var
state_dict
=
{
tag
:
'
label
'
,
text_content
:
item
[
0
]
};
return
result
.
render
(
state_dict
);
})
.
push
(
function
()
{
var
div
=
document
.
createElement
(
"
div
"
);
div
.
setAttribute
(
"
class
"
,
"
ui-field-contain
"
);
div
.
appendChild
(
label_gadget
.
element
);
div
.
appendChild
(
input_gadget
.
element
);
gadget
.
element
.
appendChild
(
div
);
});
}
rJS
(
window
)
.
declareMethod
(
'
render
'
,
function
(
options
)
{
.
declareMethod
(
'
render
'
,
function
(
options
)
{
var
gadget
=
this
,
var
field_json
=
options
.
field_json
||
{},
tmp
,
state_dict
=
{
template
,
editable
:
field_json
.
editable
,
container
,
name
:
field_json
.
key
,
field_json
=
options
.
field_json
,
item_list
:
field_json
.
items
,
i
;
value_list
:
field_json
.
value
||
field_json
.
default
gadget
.
props
.
field_json
=
field_json
;
};
container
=
gadget
.
props
.
element
.
querySelector
(
"
.checkbox_container
"
);
tmp
=
""
;
return
this
.
changeState
(
state_dict
);
for
(
i
=
0
;
i
<
field_json
.
items
.
length
;
i
+=
1
)
{
})
if
(
field_json
.
default
.
indexOf
(
field_json
.
items
[
i
][
1
])
>
-
1
)
{
template
=
checked_template
;
.
onStateChange
(
function
()
{
}
else
{
var
element
=
this
.
element
,
template
=
unchecked_template
;
gadget
=
this
,
}
value_list
=
this
.
state
.
value_list
,
tmp
+=
template
({
value_dict
=
{},
value
:
field_json
.
items
[
i
][
1
],
item_list
=
this
.
state
.
item_list
,
text
:
field_json
.
items
[
i
][
0
]
i
,
});
queue
;
// Clear first to DOM, append after to reduce flickering/manip
while
(
element
.
firstChild
)
{
element
.
removeChild
(
element
.
firstChild
);
}
}
container
.
innerHTML
=
tmp
;
return
new
RSVP
.
Queue
()
for
(
i
=
0
;
i
<
value_list
.
length
;
i
+=
1
)
{
.
push
(
function
()
{
value_dict
[
value_list
[
i
]]
=
null
;
return
gadget
.
translateHtml
(
container
.
innerHTML
);
}
})
.
push
(
function
(
translated_htmls
)
{
function
enQueue
()
{
var
checkbox_list
;
var
argument_list
=
arguments
;
container
.
innerHTML
=
translated_htmls
;
queue
if
(
field_json
.
editable
!==
1
)
{
.
push
(
function
()
{
checkbox_list
=
container
.
querySelectorAll
(
'
input[type="checkbox"]
'
);
return
appendCheckboxField
.
apply
(
this
,
argument_list
);
for
(
i
=
0
;
i
<
checkbox_list
.
length
;
i
+=
1
)
{
});
checkbox_list
[
i
].
setAttribute
(
"
class
"
,
"
ui-btn ui-shadow ui-state-readonly
"
);
}
}
}
queue
=
new
RSVP
.
Queue
();
});
for
(
i
=
0
;
i
<
item_list
.
length
;
i
+=
1
)
{
enQueue
(
gadget
,
item_list
[
i
],
value_dict
.
hasOwnProperty
(
item_list
[
i
][
1
]));
}
return
queue
;
})
})
.
declareMethod
(
'
getContent
'
,
function
()
{
.
declareMethod
(
'
getContent
'
,
function
()
{
var
gadget
=
this
,
var
i
,
result
=
{},
queue
=
new
RSVP
.
Queue
(),
tmp
=
[],
final_result
=
{},
checkbox_list
=
this
.
props
.
element
.
querySelectorAll
(
'
input[type="checkbox"]
'
),
result_list
=
[],
i
;
gadget
=
this
;
for
(
i
=
0
;
i
<
checkbox_list
.
length
;
i
+=
1
)
{
if
(
checkbox_list
[
i
].
checked
)
{
function
calculateSubContent
(
scope
)
{
tmp
.
push
(
checkbox_list
[
i
].
value
);
queue
.
push
(
function
()
{
return
gadget
.
getDeclaredGadget
(
scope
)
.
push
(
function
(
result
)
{
return
result
.
getContent
();
})
.
push
(
function
(
result
)
{
result_list
.
push
(
result
);
});
});
}
if
(
this
.
state
.
editable
)
{
for
(
i
=
0
;
i
<
gadget
.
state
.
item_list
.
length
;
i
+=
1
)
{
calculateSubContent
(
gadget
.
state
.
item_list
[
i
][
1
]);
}
}
return
queue
.
push
(
function
()
{
var
j
,
value_list
=
[];
for
(
j
=
0
;
j
<
result_list
.
length
;
j
+=
1
)
{
if
(
result_list
[
j
][
gadget
.
state
.
name
])
{
value_list
.
push
(
gadget
.
state
.
item_list
[
j
][
1
]);
}
}
final_result
[
gadget
.
state
.
name
]
=
value_list
;
final_result
[
"
default_
"
+
gadget
.
state
.
name
+
"
:int
"
]
=
0
;
return
final_result
;
});
}
}
result
[
gadget
.
props
.
field_json
.
key
]
=
tmp
;
return
final_result
;
result
[
"
default_
"
+
gadget
.
props
.
field_json
.
key
+
"
:int
"
]
=
0
;
return
result
;
});
});
}(
window
,
rJS
,
Handlebars
,
RSVP
));
}(
window
,
rJS
,
RSVP
,
document
));
\ No newline at end of file
\ No newline at end of file
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_multicheckboxfield_js.xml
View file @
3e075f4f
...
@@ -230,7 +230,7 @@
...
@@ -230,7 +230,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
9
44.6786.16715.57156
</string>
</value>
<value>
<string>
9
54.58934.61981.16162
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -248,8 +248,8 @@
...
@@ -248,8 +248,8 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
14
35813427.52
</float>
<float>
14
77658355.17
</float>
<string>
GMT+2
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
</object>
</object>
...
...
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