Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ayush Tiwari
erp5
Commits
bfd06301
Commit
bfd06301
authored
Oct 17, 2016
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_web_renderjs_ui] Rewrite float field
parent
157c669d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
88 deletions
+72
-88
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_floatfield_html.html
...Item/web_page_module/rjs_gadget_erp5_floatfield_html.html
+0
-1
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_floatfield_html.xml
...eItem/web_page_module/rjs_gadget_erp5_floatfield_html.xml
+3
-3
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_floatfield_js.js
...lateItem/web_page_module/rjs_gadget_erp5_floatfield_js.js
+67
-82
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_floatfield_js.xml
...ateItem/web_page_module/rjs_gadget_erp5_floatfield_js.xml
+2
-2
No files found.
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_floatfield_html.html
View file @
bfd06301
...
...
@@ -13,6 +13,5 @@
</head>
<body>
<input
type=
'number'
/>
</body>
</html>
\ No newline at end of file
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_floatfield_html.xml
View file @
bfd06301
...
...
@@ -220,7 +220,7 @@
</item>
<item>
<key>
<string>
actor
</string>
</key>
<value>
<string>
xiaowu
</string>
</value>
<value>
<string>
zope
</string>
</value>
</item>
<item>
<key>
<string>
comment
</string>
</key>
...
...
@@ -234,7 +234,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
9
40.63282.44183.51353
</string>
</value>
<value>
<string>
9
54.34618.13218.7202
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>
14
23905795.16
</float>
<float>
14
76697790.84
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_floatfield_js.js
View file @
bfd06301
/*global window, rJS
, RSVP, loopEventListener
*/
/*global window, rJS */
/*jslint indent: 2, maxerr: 3 */
(
function
(
window
,
rJS
,
RSVP
,
loopEventListener
)
{
(
function
(
window
,
rJS
)
{
"
use strict
"
;
rJS
(
window
)
.
ready
(
function
(
gadget
)
{
return
gadget
.
getElement
()
.
push
(
function
(
element
)
{
gadget
.
element
=
element
;
});
})
.
declareAcquiredMethod
(
"
notifyValid
"
,
"
notifyValid
"
)
.
declareAcquiredMethod
(
"
notifyInvalid
"
,
"
notifyInvalid
"
)
.
declareAcquiredMethod
(
"
notifyChange
"
,
"
notifyChange
"
)
.
declareMethod
(
'
getTextContent
'
,
function
()
{
return
this
.
element
.
querySelector
(
'
input
'
).
getAttribute
(
'
value
'
);
.
setState
({
tag
:
'
p
'
,
step
:
1
,
type
:
"
number
"
})
.
declareMethod
(
'
render
'
,
function
(
options
)
{
var
input
=
this
.
element
.
querySelector
(
'
input
'
),
step
=
0.00000001
,
field_json
=
options
.
field_json
||
{};
input
.
setAttribute
(
'
value
'
,
field_json
.
value
||
field_json
.
default
||
""
);
if
(
field_json
.
precision
!==
""
)
{
step
=
1
/
Math
.
pow
(
10
,
field_json
.
precision
);
}
input
.
setAttribute
(
"
step
"
,
step
);
input
.
setAttribute
(
'
name
'
,
field_json
.
key
);
input
.
setAttribute
(
'
title
'
,
field_json
.
title
);
if
(
field_json
.
required
===
1
)
{
input
.
setAttribute
(
'
required
'
,
'
required
'
);
var
field_json
=
options
.
field_json
||
{},
state_dict
=
{
value
:
field_json
.
value
||
field_json
.
default
||
""
,
editable
:
field_json
.
editable
,
required
:
field_json
.
required
,
name
:
field_json
.
key
,
title
:
field_json
.
title
,
precision
:
field_json
.
precision
};
state_dict
.
text_content
=
state_dict
.
value
;
if
(
field_json
.
precision
)
{
state_dict
.
step
=
1
/
Math
.
pow
(
10
,
field_json
.
precision
);
}
else
{
state_dict
.
step
=
0.00000001
;
}
if
(
field_json
.
editable
!==
1
)
{
input
.
setAttribute
(
'
readonly
'
,
'
readonly
'
);
input
.
setAttribute
(
'
data-wrapper-class
'
,
'
ui-state-disabled ui-state-readonly
'
);
input
.
setAttribute
(
'
disabled
'
,
'
disabled
'
);
return
this
.
changeState
(
state_dict
);
})
.
onStateChange
(
function
(
modification_dict
)
{
var
element
=
this
.
element
,
gadget
=
this
,
url
,
result
;
if
(
modification_dict
.
hasOwnProperty
(
'
editable
'
))
{
if
(
gadget
.
state
.
editable
)
{
url
=
'
gadget_html5_input.html
'
;
}
else
{
url
=
'
gadget_html5_element.html
'
;
}
result
=
this
.
declareGadget
(
url
,
{
scope
:
'
sub
'
})
.
push
(
function
(
input
)
{
// Clear first to DOM, append after to reduce flickering/manip
while
(
element
.
firstChild
)
{
element
.
removeChild
(
element
.
firstChild
);
}
element
.
appendChild
(
input
.
element
);
return
input
;
});
}
else
{
result
=
this
.
getDeclaredGadget
(
'
sub
'
);
}
return
result
.
push
(
function
(
input
)
{
return
input
.
render
(
gadget
.
state
);
});
})
.
declareMethod
(
'
getContent
'
,
function
()
{
var
input
=
this
.
element
.
querySelector
(
'
input
'
),
result
=
{};
result
[
input
.
getAttribute
(
'
name
'
)]
=
input
.
value
;
return
result
;
})
.
declareMethod
(
'
checkValidity
'
,
function
()
{
var
result
;
result
=
this
.
element
.
querySelector
(
'
input
'
).
checkValidity
();
if
(
result
)
{
return
this
.
notifyValid
()
.
push
(
function
()
{
return
result
;
if
(
this
.
state
.
editable
)
{
return
this
.
getDeclaredGadget
(
'
sub
'
)
.
push
(
function
(
gadget
)
{
return
gadget
.
getContent
();
});
}
return
result
;
return
{}
;
})
.
declareService
(
function
()
{
////////////////////////////////////
// Check field validity when the value changes
////////////////////////////////////
var
field_gadget
=
this
;
function
notifyChange
()
{
return
RSVP
.
all
([
field_gadget
.
checkValidity
(),
field_gadget
.
notifyChange
()
]);
}
// Listen to input change
return
loopEventListener
(
field_gadget
.
element
.
querySelector
(
'
input
'
),
'
change
'
,
false
,
notifyChange
);
.
declareMethod
(
'
getTextContent
'
,
function
()
{
return
this
.
getDeclaredGadget
(
'
sub
'
)
.
push
(
function
(
gadget
)
{
return
gadget
.
getTextContent
();
});
})
.
declareService
(
function
()
{
////////////////////////////////////
// Inform when the field input is invalid
////////////////////////////////////
var
field_gadget
=
this
;
function
notifyInvalid
(
evt
)
{
return
field_gadget
.
notifyInvalid
(
evt
.
target
.
validationMessage
);
.
declareMethod
(
'
checkValidity
'
,
function
()
{
if
(
this
.
state
.
editable
)
{
return
this
.
getDeclaredGadget
(
'
sub
'
)
.
push
(
function
(
gadget
)
{
return
gadget
.
checkValidity
();
});
}
// Listen to input change
return
loopEventListener
(
field_gadget
.
element
.
querySelector
(
'
input
'
),
'
invalid
'
,
false
,
notifyInvalid
);
return
true
;
});
}(
window
,
rJS
,
RSVP
,
loopEventListener
));
\ No newline at end of file
}(
window
,
rJS
));
\ No newline at end of file
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_floatfield_js.xml
View file @
bfd06301
...
...
@@ -230,7 +230,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
9
49.15478.31551.48810
</string>
</value>
<value>
<string>
9
54.34618.13218.7202
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>
14
55899205.51
</float>
<float>
14
76698259.52
</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