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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Romain Courteaud
erp5
Commits
adfb08e4
Commit
adfb08e4
authored
May 15, 2018
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_web_renderjs_ui] Label, string fields: reduce number of async code
parent
a3c6df2f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
47 deletions
+49
-47
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_label_field_js.js
...ateItem/web_page_module/rjs_gadget_erp5_label_field_js.js
+37
-33
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_label_field_js.xml
...teItem/web_page_module/rjs_gadget_erp5_label_field_js.xml
+2
-2
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_stringfield_js.js
...ateItem/web_page_module/rjs_gadget_erp5_stringfield_js.js
+8
-10
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_stringfield_js.xml
...teItem/web_page_module/rjs_gadget_erp5_stringfield_js.xml
+2
-2
No files found.
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_label_field_js.js
View file @
adfb08e4
...
@@ -74,18 +74,13 @@
...
@@ -74,18 +74,13 @@
label_text
:
''
,
label_text
:
''
,
error_text
:
''
,
error_text
:
''
,
label
:
true
,
// the label element is already present in the HTML template
label
:
true
,
// the label element is already present in the HTML template
css_class
:
''
css_class
:
''
,
})
first_call
:
false
.
ready
(
function
()
{
return
this
.
changeState
({
container_element
:
this
.
element
.
querySelector
(
'
div
'
),
// matches the closest div
label_element
:
this
.
element
.
querySelector
(
'
label
'
)
});
})
})
.
declareMethod
(
'
render
'
,
function
(
options
)
{
.
declareMethod
(
'
render
'
,
function
(
options
)
{
var
state_dict
=
{
var
state_dict
=
{
first_call
:
true
,
label_text
:
options
.
field_json
.
title
||
''
,
label_text
:
options
.
field_json
.
title
||
''
,
label
:
options
.
label
,
label
:
options
.
label
,
field_url
:
getFieldTypeGadgetUrl
(
options
.
field_type
),
field_url
:
getFieldTypeGadgetUrl
(
options
.
field_type
),
...
@@ -107,7 +102,16 @@
...
@@ -107,7 +102,16 @@
var
gadget
=
this
,
var
gadget
=
this
,
span
,
span
,
css_class
,
css_class
,
i
;
i
,
queue
,
new_div
;
if
(
modification_dict
.
hasOwnProperty
(
'
first_call
'
))
{
gadget
.
props
=
{
container_element
:
gadget
.
element
.
querySelector
(
'
div
'
),
label_element
:
gadget
.
element
.
querySelector
(
'
label
'
)
};
}
if
(
gadget
.
state
.
hidden
&&
!
modification_dict
.
error_text
)
{
if
(
gadget
.
state
.
hidden
&&
!
modification_dict
.
error_text
)
{
this
.
element
.
hidden
=
true
;
this
.
element
.
hidden
=
true
;
...
@@ -116,9 +120,9 @@
...
@@ -116,9 +120,9 @@
}
}
if
(
modification_dict
.
hasOwnProperty
(
'
label_text
'
))
{
if
(
modification_dict
.
hasOwnProperty
(
'
label_text
'
))
{
this
.
state
.
label_element
.
textContent
=
this
.
state
.
label_text
;
this
.
props
.
label_element
.
textContent
=
this
.
state
.
label_text
;
}
}
this
.
state
.
label_element
.
setAttribute
(
'
for
'
,
gadget
.
state
.
scope
);
this
.
props
.
label_element
.
setAttribute
(
'
for
'
,
gadget
.
state
.
scope
);
if
(
modification_dict
.
hasOwnProperty
(
'
css_class
'
)
&&
this
.
state
.
css_class
)
{
if
(
modification_dict
.
hasOwnProperty
(
'
css_class
'
)
&&
this
.
state
.
css_class
)
{
css_class
=
this
.
state
.
css_class
.
split
(
'
'
);
css_class
=
this
.
state
.
css_class
.
split
(
'
'
);
...
@@ -129,7 +133,7 @@
...
@@ -129,7 +133,7 @@
if
(
modification_dict
.
hasOwnProperty
(
'
error_text
'
))
{
if
(
modification_dict
.
hasOwnProperty
(
'
error_text
'
))
{
// first remove old errors
// first remove old errors
span
=
this
.
state
.
container_element
.
lastElementChild
;
span
=
this
.
props
.
container_element
.
lastElementChild
;
if
((
span
!==
null
)
&&
(
span
.
tagName
.
toLowerCase
()
!==
'
span
'
))
{
if
((
span
!==
null
)
&&
(
span
.
tagName
.
toLowerCase
()
!==
'
span
'
))
{
span
=
null
;
span
=
null
;
}
}
...
@@ -138,42 +142,42 @@
...
@@ -138,42 +142,42 @@
if
(
span
===
null
)
{
if
(
span
===
null
)
{
span
=
document
.
createElement
(
'
span
'
);
span
=
document
.
createElement
(
'
span
'
);
span
.
textContent
=
this
.
state
.
error_text
;
span
.
textContent
=
this
.
state
.
error_text
;
this
.
state
.
container_element
.
appendChild
(
span
);
this
.
props
.
container_element
.
appendChild
(
span
);
}
else
{
}
else
{
span
.
textContent
=
this
.
state
.
error_text
;
span
.
textContent
=
this
.
state
.
error_text
;
}
}
}
else
if
(
span
!==
null
)
{
}
else
if
(
span
!==
null
)
{
this
.
state
.
container_element
.
removeChild
(
span
);
this
.
props
.
container_element
.
removeChild
(
span
);
}
}
}
}
// Remove/add label_element from DOM
// Remove/add label_element from DOM
if
(
modification_dict
.
hasOwnProperty
(
'
label
'
))
{
if
(
modification_dict
.
hasOwnProperty
(
'
label
'
))
{
if
(
this
.
state
.
label
===
true
)
{
if
(
this
.
state
.
label
===
true
)
{
this
.
state
.
container_element
.
insertBefore
(
this
.
state
.
label_element
,
this
.
state
.
container_element
.
firstChild
);
this
.
props
.
container_element
.
insertBefore
(
this
.
props
.
label_element
,
this
.
props
.
container_element
.
firstChild
);
}
else
{
}
else
{
this
.
state
.
container_element
.
removeChild
(
this
.
state
.
label_element
);
this
.
props
.
container_element
.
removeChild
(
this
.
props
.
label_element
);
}
}
}
}
if
(
modification_dict
.
hasOwnProperty
(
'
options
'
))
{
if
(
modification_dict
.
hasOwnProperty
(
'
options
'
))
{
if
(
this
.
state
.
field_url
)
{
if
(
this
.
state
.
field_url
)
{
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
if
(
modification_dict
.
hasOwnProperty
(
'
field_url
'
))
{
if
(
modification_dict
.
hasOwnProperty
(
'
field_url
'
))
{
return
gadget
.
declareGadget
(
gadget
.
state
.
field_url
,
{
//if (!modification_dict.hasOwnProperty('first_call')) {
scope
:
SCOPE
gadget
.
props
.
container_element
.
removeChild
(
})
gadget
.
props
.
container_element
.
querySelector
(
'
div
'
)
.
push
(
function
(
field_gadget
)
{
gadget
.
state
.
container_element
.
removeChild
(
gadget
.
state
.
container_element
.
querySelector
(
'
div
'
)
);
);
gadget
.
state
.
container_element
.
appendChild
(
field_gadget
.
element
);
//}
return
field_gadget
;
new_div
=
document
.
createElement
(
'
div
'
);
gadget
.
props
.
container_element
.
appendChild
(
new_div
);
queue
=
gadget
.
declareGadget
(
gadget
.
state
.
field_url
,
{
scope
:
SCOPE
,
element
:
new_div
});
});
}
else
{
queue
=
gadget
.
getDeclaredGadget
(
SCOPE
);
}
}
return
gadget
.
getDeclaredGadget
(
SCOPE
);
return
queue
})
.
push
(
function
(
field_gadget
)
{
.
push
(
function
(
field_gadget
)
{
return
field_gadget
.
render
(
gadget
.
state
.
options
);
return
field_gadget
.
render
(
gadget
.
state
.
options
);
});
});
...
@@ -224,7 +228,7 @@
...
@@ -224,7 +228,7 @@
})
})
.
declareJob
(
'
deferErrorTextRender
'
,
function
(
error_text
)
{
.
declareJob
(
'
deferErrorTextRender
'
,
function
(
error_text
)
{
return
this
.
changeState
({
error_text
:
error_text
});
return
this
.
changeState
({
first_call
:
true
,
error_text
:
error_text
});
});
});
}(
window
,
document
,
rJS
,
RSVP
));
}(
window
,
document
,
rJS
,
RSVP
));
\ No newline at end of file
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_label_field_js.xml
View file @
adfb08e4
...
@@ -230,7 +230,7 @@
...
@@ -230,7 +230,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
96
6.41667.10868.48810
</string>
</value>
<value>
<string>
96
7.36537.34665.7628
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -248,7 +248,7 @@
...
@@ -248,7 +248,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
152
3002550.46
</float>
<float>
152
6396024.69
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_stringfield_js.js
View file @
adfb08e4
...
@@ -31,22 +31,20 @@
...
@@ -31,22 +31,20 @@
var
element
=
this
.
element
,
var
element
=
this
.
element
,
gadget
=
this
,
gadget
=
this
,
url
,
url
,
result
;
result
,
new_div
;
if
(
modification_dict
.
hasOwnProperty
(
'
editable
'
))
{
if
(
modification_dict
.
hasOwnProperty
(
'
editable
'
))
{
if
(
gadget
.
state
.
editable
)
{
if
(
gadget
.
state
.
editable
)
{
url
=
'
gadget_html5_input.html
'
;
url
=
'
gadget_html5_input.html
'
;
}
else
{
}
else
{
url
=
'
gadget_html5_element.html
'
;
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
)
{
while
(
element
.
firstChild
)
{
element
.
removeChild
(
element
.
firstChild
);
element
.
removeChild
(
element
.
firstChild
);
}
}
element
.
appendChild
(
input
.
element
);
new_div
=
document
.
createElement
(
'
div
'
);
return
input
;
element
.
appendChild
(
new_div
)
;
});
result
=
this
.
declareGadget
(
url
,
{
scope
:
'
sub
'
,
element
:
new_div
});
}
else
{
}
else
{
result
=
this
.
getDeclaredGadget
(
'
sub
'
);
result
=
this
.
getDeclaredGadget
(
'
sub
'
);
}
}
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_stringfield_js.xml
View file @
adfb08e4
...
@@ -230,7 +230,7 @@
...
@@ -230,7 +230,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
965.
12118.35525.1655
</string>
</value>
<value>
<string>
965.
41976.11439.18449
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -248,7 +248,7 @@
...
@@ -248,7 +248,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
15
17929158.68
</float>
<float>
15
26396915.47
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</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