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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Mukul
erp5
Commits
0ca621e9
Commit
0ca621e9
authored
Oct 20, 2016
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_web_renderjs_ui] Reimplemented FileField
parent
c6253d8c
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
88 additions
and
54 deletions
+88
-54
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_filefield_html.html
...eItem/web_page_module/rjs_gadget_erp5_filefield_html.html
+0
-1
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_filefield_html.xml
...teItem/web_page_module/rjs_gadget_erp5_filefield_html.xml
+2
-2
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_filefield_js.js
...plateItem/web_page_module/rjs_gadget_erp5_filefield_js.js
+61
-41
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_filefield_js.xml
...lateItem/web_page_module/rjs_gadget_erp5_filefield_js.xml
+2
-2
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_html5_input_html.html
...lateItem/web_page_module/rjs_gadget_html5_input_html.html
+1
-0
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_html5_input_html.xml
...plateItem/web_page_module/rjs_gadget_html5_input_html.xml
+2
-2
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
+18
-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_filefield_html.html
View file @
0ca621e9
...
...
@@ -14,6 +14,5 @@
</head>
<body>
<input
type=
"file"
>
</body>
</html>
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_filefield_html.xml
View file @
0ca621e9
...
...
@@ -234,7 +234,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
9
48.40112.47919.55415
</string>
</value>
<value>
<string>
9
54.45675.44850.53452
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>
14
53368107.2
</float>
<float>
14
76949800.7
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_filefield_js.js
View file @
0ca621e9
/*global window, rJS
, RSVP, jIO
*/
/*jslint
nomen: true,
indent: 2, maxerr: 3 */
(
function
(
window
,
rJS
,
RSVP
,
jIO
)
{
/*global window, rJS
*/
/*jslint indent: 2, maxerr: 3 */
(
function
(
window
,
rJS
)
{
"
use strict
"
;
rJS
(
window
)
.
ready
(
function
(
gadget
)
{
return
gadget
.
getElement
()
.
push
(
function
(
element
)
{
gadget
.
element
=
element
;
});
.
setState
({
tag
:
'
p
'
,
type
:
'
file
'
})
.
declareAcquiredMethod
(
"
notifyValid
"
,
"
notifyValid
"
)
.
declareAcquiredMethod
(
"
notifyInvalid
"
,
"
notifyInvalid
"
)
.
declareAcquiredMethod
(
"
notifyChange
"
,
"
notifyChange
"
)
.
declareMethod
(
'
render
'
,
function
(
options
)
{
var
input
=
this
.
element
.
querySelector
(
'
input
'
),
field_json
=
options
.
field_json
||
{};
var
field_json
=
options
.
field_json
||
{},
state_dict
=
{
editable
:
field_json
.
editable
,
required
:
field_json
.
required
,
name
:
field_json
.
key
,
title
:
field_json
.
title
};
return
this
.
changeState
(
state_dict
);
})
input
.
setAttribute
(
'
name
'
,
field_json
.
key
);
input
.
setAttribute
(
'
title
'
,
field_json
.
title
);
if
(
field_json
.
required
===
1
)
{
input
.
setAttribute
(
'
required
'
,
'
required
'
);
.
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
'
);
}
if
(
field_json
.
editable
!==
1
)
{
input
.
setAttribute
(
'
readonly
'
,
'
readonly
'
);
input
.
setAttribute
(
'
data-wrapper-class
'
,
'
ui-state-readonly
'
);
// input.setAttribute('disabled', 'disabled');
return
result
.
push
(
function
(
input
)
{
return
input
.
render
(
gadget
.
state
);
});
})
.
declareMethod
(
'
getContent
'
,
function
()
{
if
(
this
.
state
.
editable
)
{
return
this
.
getDeclaredGadget
(
'
sub
'
)
.
push
(
function
(
gadget
)
{
return
gadget
.
getContent
();
});
}
return
{};
})
.
declareMethod
(
'
getContent
'
,
function
()
{
var
gadget
=
this
,
input
=
gadget
.
element
.
querySelector
(
'
input
'
),
file
=
input
.
files
[
0
];
if
(
file
===
undefined
)
{
return
{};
.
declareMethod
(
'
getTextContent
'
,
function
()
{
return
""
;
})
.
declareMethod
(
'
checkValidity
'
,
function
()
{
if
(
this
.
state
.
editable
)
{
return
this
.
getDeclaredGadget
(
'
sub
'
)
.
push
(
function
(
gadget
)
{
return
gadget
.
checkValidity
();
});
}
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
jIO
.
util
.
readBlobAsDataURL
(
file
);
})
.
push
(
function
(
evt
)
{
var
result
=
{};
result
[
input
.
getAttribute
(
'
name
'
)]
=
{
url
:
evt
.
target
.
result
,
file_name
:
file
.
name
};
return
result
;
});
return
true
;
});
}(
window
,
rJS
,
RSVP
,
jIO
));
}(
window
,
rJS
));
\ No newline at end of file
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_filefield_js.xml
View file @
0ca621e9
...
...
@@ -230,7 +230,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
9
48.41920.59644.21196
</string>
</value>
<value>
<string>
9
54.47126.41874.54613
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>
14
53476561.59
</float>
<float>
14
76950143.07
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_html5_input_html.html
View file @
0ca621e9
...
...
@@ -7,6 +7,7 @@
<!-- renderjs -->
<script
src=
"rsvp.js"
type=
"text/javascript"
></script>
<script
src=
"renderjs.js"
type=
"text/javascript"
></script>
<script
src=
"jiodev.js"
type=
"text/javascript"
></script>
<!-- custom script -->
<script
src=
"gadget_html5_input.js"
type=
"text/javascript"
></script>
</head>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_html5_input_html.xml
View file @
0ca621e9
...
...
@@ -234,7 +234,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
954.
2976.31424.22323
</string>
</value>
<value>
<string>
954.
45675.44850.53452
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>
147
5499560.34
</float>
<float>
147
6952312.41
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_html5_input_js.js
View file @
0ca621e9
/*global window, rJS, RSVP */
/*global window, rJS, RSVP
, jIO
*/
/*jslint indent: 2, maxerr: 3, maxlen: 80 */
(
function
(
window
,
rJS
,
RSVP
)
{
(
function
(
window
,
rJS
,
RSVP
,
jIO
)
{
"
use strict
"
;
rJS
(
window
)
...
...
@@ -74,7 +74,21 @@
input
;
if
(
this
.
state
.
editable
)
{
input
=
this
.
element
.
querySelector
(
'
input
'
);
if
(
this
.
state
.
type
===
'
checkbox
'
)
{
if
(
this
.
state
.
type
===
'
file
'
)
{
if
(
input
.
files
[
0
]
!==
undefined
)
{
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
jIO
.
util
.
readBlobAsDataURL
(
input
.
files
[
0
]);
})
.
push
(
function
(
evt
)
{
result
[
input
.
getAttribute
(
'
name
'
)]
=
{
url
:
evt
.
target
.
result
,
file_name
:
input
.
files
[
0
].
name
};
return
result
;
});
}
}
else
if
(
this
.
state
.
type
===
'
checkbox
'
)
{
result
[
input
.
getAttribute
(
'
name
'
)]
=
(
input
.
checked
?
1
:
0
);
}
else
{
result
[
input
.
getAttribute
(
'
name
'
)]
=
input
.
value
;
...
...
@@ -145,4 +159,4 @@
return
this
.
notifyInvalid
(
evt
.
target
.
validationMessage
);
},
true
,
false
);
}(
window
,
rJS
,
RSVP
));
\ No newline at end of file
}(
window
,
rJS
,
RSVP
,
jIO
));
\ No newline at end of file
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_html5_input_js.xml
View file @
0ca621e9
...
...
@@ -230,7 +230,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
954.4
5675.44850.53452
</string>
</value>
<value>
<string>
954.4
7167.27024.21401
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>
1476
869880.85
</float>
<float>
1476
952365.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