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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tristan Cavelier
erp5
Commits
476e9402
Commit
476e9402
authored
Jun 17, 2019
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "DATETIMEFIELDUPDATE WIP recoded (not fully)"
This reverts commit
b8a54f81
.
parent
bc5c3291
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
59 deletions
+50
-59
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_form_js.js
...plateItem/web_page_module/rjs_gadget_erp5_page_form_js.js
+38
-47
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_form_js.xml
...lateItem/web_page_module/rjs_gadget_erp5_page_form_js.xml
+1
-1
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
+11
-11
No files found.
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_form_js.js
View file @
476e9402
...
@@ -70,6 +70,7 @@ and handling data send&receive.
...
@@ -70,6 +70,7 @@ and handling data send&receive.
if
(
typeof
result
[
key
]
===
"
object
"
&&
if
(
typeof
result
[
key
]
===
"
object
"
&&
result
[
key
].
hasOwnProperty
(
"
key
"
)
&&
result
[
key
].
hasOwnProperty
(
"
key
"
)
&&
gadget
.
state
.
options
.
form_content
[
result
[
key
].
key
])
{
gadget
.
state
.
options
.
form_content
[
result
[
key
].
key
])
{
console
.
log
(
"
page_form: in loadFormContent
"
,
result
[
key
][
'
default
'
],
gadget
.
state
.
options
.
form_content
[
result
[
key
].
key
]);
result
[
key
][
'
default
'
]
=
gadget
.
state
.
options
.
form_content
[
result
[
key
].
key
];
result
[
key
][
'
default
'
]
=
gadget
.
state
.
options
.
form_content
[
result
[
key
].
key
];
}
}
}
}
...
@@ -92,25 +93,6 @@ and handling data send&receive.
...
@@ -92,25 +93,6 @@ and handling data send&receive.
}
}
}
}
function
updateErp5DocumentForAfterSave
(
new_erp5_document
,
submitted_content
,
current_content
)
{
var
view
=
new_erp5_document
.
_embedded
.
_view
,
content_key_list
=
Object
.
keys
(
current_content
),
document_reference_dict
=
{},
document_key_list
=
Object
.
keys
(
view
),
i
=
0
,
field
=
null
,
key
=
""
;
for
(;
i
<
document_key_list
.
length
;
i
+=
1
)
{
field
=
view
[
document_key_list
[
i
]];
document_reference_dict
[
field
.
key
]
=
field
;
}
for
(
i
=
0
;
i
<
content_key_list
.
length
;
i
+=
1
)
{
key
=
content_key_list
[
i
];
if
(
document_reference_dict
[
key
]
&&
JSON
.
stringify
(
submitted_content
[
key
])
===
JSON
.
stringify
(
document_reference_dict
[
key
].
default
))
{
document_reference_dict
[
key
].
default
=
current_content
[
key
];
}
}
}
function
warmupGadgetList
(
gadget
,
url_list
)
{
function
warmupGadgetList
(
gadget
,
url_list
)
{
var
i
;
var
i
;
for
(
i
=
0
;
i
<
url_list
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
url_list
.
length
;
i
+=
1
)
{
...
@@ -141,6 +123,7 @@ and handling data send&receive.
...
@@ -141,6 +123,7 @@ and handling data send&receive.
// Proxy methods to the child gadget
// Proxy methods to the child gadget
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
.
declareMethod
(
'
triggerSubmit
'
,
function
triggerSubmit
()
{
.
declareMethod
(
'
triggerSubmit
'
,
function
triggerSubmit
()
{
console
.
log
(
"
page form: triggeringSubmit
"
);
return
this
.
getDeclaredGadget
(
'
fg
'
)
return
this
.
getDeclaredGadget
(
'
fg
'
)
.
push
(
function
(
g
)
{
.
push
(
function
(
g
)
{
return
g
.
triggerSubmit
();
return
g
.
triggerSubmit
();
...
@@ -182,10 +165,15 @@ and handling data send&receive.
...
@@ -182,10 +165,15 @@ and handling data send&receive.
.
allowPublicAcquisition
(
'
notifySubmit
'
,
function
notifySubmit
()
{
.
allowPublicAcquisition
(
'
notifySubmit
'
,
function
notifySubmit
()
{
return
this
.
triggerSubmit
();
return
this
.
triggerSubmit
();
})
})
.
allowPublicAcquisition
(
"
notifyChange
"
,
function
notifyChange
(
argument_list
)
{
.
allowPublicAcquisition
(
"
notifyChange
"
,
function
notifyChange
(
params
)
{
this
.
state
.
changing
=
true
;
var
gadget
=
this
;
return
this
.
notifyChange
.
apply
(
this
,
argument_list
);
console
.
log
(
"
page form: notifyChange
"
,
params
);
})
return
gadget
.
getDeclaredGadget
(
"
fg
"
)
.
push
(
g
=>
g
.
getContent
())
.
push
(
content
=>
{
gadget
.
_XXX_change_content
=
content
;
return
gadget
.
notifyChange
.
apply
(
gadget
,
params
);
});
})
/**/
/**
/**
* Render obtain ERP5 Document and assigned Form Definition.
* Render obtain ERP5 Document and assigned Form Definition.
*
*
...
@@ -309,8 +297,7 @@ and handling data send&receive.
...
@@ -309,8 +297,7 @@ and handling data send&receive.
.
push
(
function
(
result
)
{
.
push
(
function
(
result
)
{
page_template_gadget
=
result
;
page_template_gadget
=
result
;
var
sub_options
=
options
.
fg
||
{},
var
sub_options
=
options
.
fg
||
{};
queue
=
null
;
loadFormContent
(
gadget
,
erp5_document
.
_embedded
.
_view
);
loadFormContent
(
gadget
,
erp5_document
.
_embedded
.
_view
);
...
@@ -321,21 +308,21 @@ and handling data send&receive.
...
@@ -321,21 +308,21 @@ and handling data send&receive.
sub_options
.
jio_key
=
options
.
jio_key
;
// jIO identifier of currently rendered ERP5 document
sub_options
.
jio_key
=
options
.
jio_key
;
// jIO identifier of currently rendered ERP5 document
sub_options
.
editable
=
options
.
editable
;
// form decides on editability of its fields
sub_options
.
editable
=
options
.
editable
;
// form decides on editability of its fields
if
(
gadget
.
state
.
changing
&&
gadget
.
state
.
last_submitted_content
)
{
console
.
log
(
"
page form: page_template_gadget.render
"
,
sub_options
);
queue
=
page_template_gadget
.
getContent
()
return
page_template_gadget
.
getContent
()
// XXX don't do it if jio_key is different than previous one
.
push
(
function
(
content
)
{
.
push
(
function
(
content
)
{
updateErp5DocumentForAfterSave
(
console
.
log
(
"
page form: gadget._XXX_submitted_content
"
,
gadget
.
_XXX_submitted_content
);
sub_options
.
erp5_document
,
console
.
log
(
"
page form: page_template_gadget.getContent
"
,
content
);
JSON
.
parse
(
gadget
.
state
.
last_submitted_content
),
try
{
content
if
(
gadget
.
_XXX_submitted_content
&&
gadget
.
_XXX_change_content
)
);
if
(
sub_options
.
erp5_document
.
_embedded
.
_view
.
my_short_title
.
key
===
"
field_my_short_title
"
)
gadget
.
state
.
last_submitted_content
=
null
;
// free some memory
if
(
gadget
.
_XXX_submitted_content
.
field_my_short_title
===
sub_options
.
erp5_document
.
_embedded
.
_view
.
my_short_title
.
default
)
gadget
.
state
.
changing
=
false
;
if
(
sub_options
.
erp5_document
.
_embedded
.
_view
.
my_short_title
.
default
!==
content
.
field_my_short_title
)
});
sub_options
.
erp5_document
.
_embedded
.
_view
.
my_short_title
.
default
=
content
.
field_my_short_title
;
// please notifyChange at end of this onChangeState ?
}
}
catch
(
_
)
{}
delete
gadget
.
_XXX_change_content
;
delete
gadget
.
_XXX_submitted_content
;
return
(
queue
||
new
RSVP
.
Queue
())
.
push
(
function
()
{
return
page_template_gadget
.
render
(
sub_options
);
return
page_template_gadget
.
render
(
sub_options
);
});
});
})
})
...
@@ -391,6 +378,7 @@ and handling data send&receive.
...
@@ -391,6 +378,7 @@ and handling data send&receive.
on failure it throws an error with the invalid response
on failure it throws an error with the invalid response
*/
*/
.
allowPublicAcquisition
(
"
submitContent
"
,
function
submitContent
(
param_list
)
{
.
allowPublicAcquisition
(
"
submitContent
"
,
function
submitContent
(
param_list
)
{
console
.
log
(
"
page form: submitContent on call
"
);
var
gadget
=
this
,
var
gadget
=
this
,
jio_key
=
param_list
[
0
],
jio_key
=
param_list
[
0
],
target_url
=
param_list
[
1
],
target_url
=
param_list
[
1
],
...
@@ -398,13 +386,9 @@ and handling data send&receive.
...
@@ -398,13 +386,9 @@ and handling data send&receive.
return
gadget
.
notifySubmitting
()
return
gadget
.
notifySubmitting
()
.
push
(
function
()
{
.
push
(
function
()
{
return
gadget
.
getDeclaredGadget
(
"
fg
"
);
return
gadget
.
getDeclaredGadget
(
"
fg
"
)
.
push
(
g
=>
g
.
getContent
()).
push
(
content
=>
{
gadget
.
_XXX_submitted_content
=
content
;
})
;
})
})
.
push
(
function
(
sub_gadget
)
{
.
push
(
function
()
{
return
sub_gadget
.
getContent
();
})
.
push
(
function
(
content
)
{
gadget
.
state
.
last_submitted_content
=
JSON
.
stringify
(
content
);
return
gadget
.
jio_putAttachment
(
jio_key
,
target_url
,
content_dict
);
return
gadget
.
jio_putAttachment
(
jio_key
,
target_url
,
content_dict
);
})
})
.
push
(
function
(
attachment
)
{
.
push
(
function
(
attachment
)
{
...
@@ -418,6 +402,7 @@ and handling data send&receive.
...
@@ -418,6 +402,7 @@ and handling data send&receive.
.
push
(
function
(
response_text
)
{
.
push
(
function
(
response_text
)
{
var
response
=
JSON
.
parse
(
response_text
.
target
.
result
);
var
response
=
JSON
.
parse
(
response_text
.
target
.
result
);
console
.
log
(
"
page form: notifySubmitted
"
);
return
gadget
.
notifySubmitted
({
return
gadget
.
notifySubmitted
({
"
message
"
:
response
.
portal_status_message
,
"
message
"
:
response
.
portal_status_message
,
"
status
"
:
response
.
portal_status_level
||
"
success
"
"
status
"
:
response
.
portal_status_level
||
"
success
"
...
@@ -464,6 +449,7 @@ and handling data send&receive.
...
@@ -464,6 +449,7 @@ and handling data send&receive.
return
response_view
.
_notification
.
message
;
return
response_view
.
_notification
.
message
;
})
})
.
push
(
function
(
translated_message
)
{
.
push
(
function
(
translated_message
)
{
console
.
log
(
"
page form: notifySubmitted
"
);
return
gadget
.
notifySubmitted
({
return
gadget
.
notifySubmitted
({
"
message
"
:
translated_message
,
"
message
"
:
translated_message
,
"
status
"
:
response_view
.
_notification
?
response_view
.
_notification
.
status
:
"
success
"
"
status
"
:
response_view
.
_notification
?
response_view
.
_notification
.
status
:
"
success
"
...
@@ -495,6 +481,7 @@ and handling data send&receive.
...
@@ -495,6 +481,7 @@ and handling data send&receive.
attachment
.
target
.
status
<
400
)
{
attachment
.
target
.
status
<
400
)
{
return
gadget
.
translate
(
"
Action succeeded.
"
)
return
gadget
.
translate
(
"
Action succeeded.
"
)
.
push
(
function
(
translated_message
)
{
.
push
(
function
(
translated_message
)
{
console
.
log
(
"
page form: notifySubmitted
"
);
return
gadget
.
notifySubmitted
({
return
gadget
.
notifySubmitted
({
"
message
"
:
translated_message
,
"
message
"
:
translated_message
,
"
status
"
:
"
success
"
"
status
"
:
"
success
"
...
@@ -509,6 +496,7 @@ and handling data send&receive.
...
@@ -509,6 +496,7 @@ and handling data send&receive.
// likely product of export/report (thus PDF, ODT ...)
// likely product of export/report (thus PDF, ODT ...)
return
gadget
.
translate
(
"
Data received.
"
)
return
gadget
.
translate
(
"
Data received.
"
)
.
push
(
function
(
translated_message
)
{
.
push
(
function
(
translated_message
)
{
console
.
log
(
"
page form: notifySubmitted
"
);
return
gadget
.
notifySubmitted
({
return
gadget
.
notifySubmitted
({
"
message
"
:
translated_message
,
"
message
"
:
translated_message
,
"
status
"
:
"
success
"
"
status
"
:
"
success
"
...
@@ -538,6 +526,7 @@ and handling data send&receive.
...
@@ -538,6 +526,7 @@ and handling data send&receive.
if
(
error
===
undefined
||
error
.
target
===
undefined
)
{
if
(
error
===
undefined
||
error
.
target
===
undefined
)
{
return
gadget
.
translate
(
'
Encountered an unknown error. Try to resubmit.
'
)
return
gadget
.
translate
(
'
Encountered an unknown error. Try to resubmit.
'
)
.
push
(
function
(
translated_message
)
{
.
push
(
function
(
translated_message
)
{
console
.
log
(
"
page form: notifySubmitted
"
);
return
gadget
.
notifySubmitted
({
return
gadget
.
notifySubmitted
({
'
message
'
:
translated_message
,
'
message
'
:
translated_message
,
'
status
'
:
'
error
'
'
status
'
:
'
error
'
...
@@ -562,6 +551,7 @@ and handling data send&receive.
...
@@ -562,6 +551,7 @@ and handling data send&receive.
if
(
error
.
target
.
response
.
type
===
'
application/json
'
||
if
(
error
.
target
.
response
.
type
===
'
application/json
'
||
error
.
target
.
response
.
type
===
'
application/hal+json
'
)
{
error
.
target
.
response
.
type
===
'
application/hal+json
'
)
{
console
.
log
(
"
page form: notifySubmitted
"
);
return
gadget
.
notifySubmitted
()
return
gadget
.
notifySubmitted
()
.
push
(
function
()
{
.
push
(
function
()
{
return
jIO
.
util
.
readBlobAsText
(
error
.
target
.
response
);
return
jIO
.
util
.
readBlobAsText
(
error
.
target
.
response
);
...
@@ -611,6 +601,7 @@ and handling data send&receive.
...
@@ -611,6 +601,7 @@ and handling data send&receive.
// If the response in empty with only HTTP Status code then we display
// If the response in empty with only HTTP Status code then we display
// our static translated error_text to the user
// our static translated error_text to the user
console
.
log
(
"
page form: notifySubmitted
"
);
return
gadget
.
notifySubmitted
()
return
gadget
.
notifySubmitted
()
.
push
(
function
()
{
.
push
(
function
()
{
return
gadget
.
translate
(
error_text
);
return
gadget
.
translate
(
error_text
);
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_form_js.xml
View file @
476e9402
...
@@ -214,7 +214,7 @@
...
@@ -214,7 +214,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
actor
</string>
</key>
<key>
<string>
actor
</string>
</key>
<value>
<string>
ERP5TypeTestCas
e
</string>
</value>
<value>
<string>
zop
e
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
comment
</string>
</key>
<key>
<string>
comment
</string>
</key>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_html5_input_js.js
View file @
476e9402
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
rJS
(
window
)
rJS
(
window
)
.
declareMethod
(
'
render
'
,
function
render
(
options
)
{
.
declareMethod
(
'
render
'
,
function
render
(
options
)
{
//if (this.state && this.state.name === "field_my_short_title" || options && options.name === "field_my_short
_title") console.log("input: render on call", options);
if
(
this
.
state
&&
this
.
state
.
name
===
"
field_my_title
"
||
options
&&
options
.
name
===
"
field_my
_title
"
)
console
.
log
(
"
input: render on call
"
,
options
);
return
this
.
changeState
({
return
this
.
changeState
({
value
:
getFirstNonEmpty
(
options
.
value
,
""
),
value
:
getFirstNonEmpty
(
options
.
value
,
""
),
checked
:
options
.
checked
,
checked
:
options
.
checked
,
...
@@ -42,11 +42,11 @@
...
@@ -42,11 +42,11 @@
})
})
.
onStateChange
(
function
onStateChange
(
modification_dict
)
{
.
onStateChange
(
function
onStateChange
(
modification_dict
)
{
//if (this.state.name === "field_my_short
_title") console.log("input: onStateChange on call", modification_dict);
if
(
this
.
state
.
name
===
"
field_my
_title
"
)
console
.
log
(
"
input: onStateChange on call
"
,
modification_dict
);
var
textarea
=
this
.
element
.
querySelector
(
'
input
'
),
var
textarea
=
this
.
element
.
querySelector
(
'
input
'
),
tmp
;
// general use short-scope variable
tmp
;
// general use short-scope variable
/*
if (modification_dict.hasOwnProperty("value")) { // TRISTAN
if
(
modification_dict
.
hasOwnProperty
(
"
value
"
))
{
// TRISTAN
textarea
.
value
=
this
.
state
.
value
;
textarea
.
value
=
this
.
state
.
value
;
textarea
.
setAttribute
(
'
value
'
,
this
.
state
.
value
);
textarea
.
setAttribute
(
'
value
'
,
this
.
state
.
value
);
}
}
...
@@ -57,17 +57,17 @@
...
@@ -57,17 +57,17 @@
}
else
{
}
else
{
textarea
.
removeAttribute
(
'
checked
'
);
textarea
.
removeAttribute
(
'
checked
'
);
}
}
}
/**/
}
if
(
this
.
state
.
type
===
'
checkbox
'
)
{
if
(
this
.
state
.
type
===
'
checkbox
'
)
{
textarea
.
checked
=
this
.
state
.
checked
;
// TRISTAN
//
textarea.checked = this.state.checked; // TRISTAN
}
else
{
}
else
{
textarea
.
setAttribute
(
'
value
'
,
this
.
state
.
value
);
// TRISTAN
//
textarea.setAttribute('value', this.state.value); // TRISTAN
textarea
.
value
=
this
.
state
.
value
;
// TRISTAN
//
textarea.value = this.state.value; // TRISTAN
}
}
if
(
this
.
state
.
type
===
'
radio
'
)
{
if
(
this
.
state
.
type
===
'
radio
'
)
{
textarea
.
checked
=
this
.
state
.
checked
;
// TRISTAN
//
textarea.checked = this.state.checked; // TRISTAN
}
/**/
}
textarea
.
id
=
this
.
state
.
id
||
this
.
state
.
name
;
textarea
.
id
=
this
.
state
.
id
||
this
.
state
.
name
;
textarea
.
setAttribute
(
'
name
'
,
this
.
state
.
name
);
textarea
.
setAttribute
(
'
name
'
,
this
.
state
.
name
);
...
@@ -223,13 +223,13 @@
...
@@ -223,13 +223,13 @@
.
declareAcquiredMethod
(
"
notifyChange
"
,
"
notifyChange
"
)
.
declareAcquiredMethod
(
"
notifyChange
"
,
"
notifyChange
"
)
//.onEvent('change', function change() {
//.onEvent('change', function change() {
.
onEvent
(
'
change
'
,
function
change
(
event
)
{
.
onEvent
(
'
change
'
,
function
change
(
event
)
{
//if (this.state.name === "field_my_short
_title") console.log("input: event change", event, event.target.value);
if
(
this
.
state
.
name
===
"
field_my
_title
"
)
console
.
log
(
"
input: event change
"
,
event
,
event
.
target
.
value
);
var
input
=
this
.
element
.
querySelector
(
"
input
"
);
// TRISTAN
var
input
=
this
.
element
.
querySelector
(
"
input
"
);
// TRISTAN
if
(
input
)
{
if
(
input
)
{
// force the state to have the current edited value
// force the state to have the current edited value
this
.
state
.
checked
=
input
.
checked
;
this
.
state
.
checked
=
input
.
checked
;
this
.
state
.
value
=
input
.
value
;
this
.
state
.
value
=
input
.
value
;
}
/**/
}
return
RSVP
.
all
([
return
RSVP
.
all
([
this
.
checkValidity
(),
this
.
checkValidity
(),
this
.
notifyChange
(
"
change
"
)
this
.
notifyChange
(
"
change
"
)
...
...
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