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
913edbfb
Commit
913edbfb
authored
Jan 23, 2018
by
Romain Courteaud
🐙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_web_renderjs_ui] Dialog: move code outside rjs method
parent
bb7e4503
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
212 additions
and
210 deletions
+212
-210
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.js
...Item/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.js
+210
-208
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.xml
...tem/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.xml
+2
-2
No files found.
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.js
View file @
913edbfb
...
...
@@ -10,173 +10,10 @@
return
[
obj
];
}
rJS
(
window
)
/////////////////////////////////////////////////////////////////
// acquisition
/////////////////////////////////////////////////////////////////
.
declareAcquiredMethod
(
"
jio_putAttachment
"
,
"
jio_putAttachment
"
)
.
declareAcquiredMethod
(
"
redirect
"
,
"
redirect
"
)
.
declareAcquiredMethod
(
"
getUrlFor
"
,
"
getUrlFor
"
)
.
declareAcquiredMethod
(
"
updateHeader
"
,
"
updateHeader
"
)
.
declareAcquiredMethod
(
"
notifySubmitting
"
,
"
notifySubmitting
"
)
.
declareAcquiredMethod
(
"
notifySubmitted
"
,
"
notifySubmitted
"
)
.
declareAcquiredMethod
(
"
translate
"
,
"
translate
"
)
.
declareAcquiredMethod
(
"
notifyChange
"
,
"
notifyChange
"
)
.
declareAcquiredMethod
(
"
updateForm
"
,
"
updateForm
"
)
.
declareAcquiredMethod
(
"
displayFormulatorValidationError
"
,
"
displayFormulatorValidationError
"
)
/////////////////////////////////////////////////////////////////
// Proxy methods to the child gadget
/////////////////////////////////////////////////////////////////
.
declareMethod
(
'
checkValidity
'
,
function
()
{
return
this
.
getDeclaredGadget
(
"
erp5_form
"
)
.
push
(
function
(
declared_gadget
)
{
return
declared_gadget
.
checkValidity
();
});
},
{
mutex
:
'
changestate
'
})
.
declareMethod
(
'
getContent
'
,
function
()
{
return
this
.
getDeclaredGadget
(
"
erp5_form
"
)
.
push
(
function
(
declared_gadget
)
{
return
declared_gadget
.
getContent
();
});
},
{
mutex
:
'
changestate
'
})
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.
declareMethod
(
'
triggerSubmit
'
,
function
()
{
this
.
element
.
querySelector
(
'
input[type="submit"]
'
).
click
();
},
{
mutex
:
'
changestate
'
})
.
declareMethod
(
'
render
'
,
function
(
options
)
{
// copy out wanted items from options and pass it to `changeState`
return
this
.
changeState
({
jio_key
:
options
.
jio_key
,
view
:
options
.
view
,
// ignore options.editable because dialog is always editable
erp5_document
:
options
.
erp5_document
,
form_definition
:
options
.
form_definition
,
erp5_form
:
options
.
erp5_form
||
{}
// ignore global editable state (be always editable)
});
})
.
onStateChange
(
function
()
{
var
form_gadget
=
this
,
icon
,
selector
=
form_gadget
.
element
.
querySelector
(
"
h3
"
),
title
,
i
,
view_list
=
ensureArray
(
this
.
state
.
erp5_document
.
_links
.
action_workflow
);
title
=
this
.
state
.
form_definition
.
title
;
// XXX hardcoded...
switch
(
title
)
{
case
"
Create User
"
:
icon
=
"
ui-icon-user
"
;
break
;
case
"
Create Document
"
:
icon
=
"
ui-icon-file-o
"
;
break
;
case
"
Validate Workflow Action
"
:
icon
=
"
ui-icon-share-alt
"
;
break
;
case
"
Submit
"
:
icon
=
"
ui-icon-check
"
;
break
;
default
:
icon
=
"
ui-icon-random
"
;
break
;
}
for
(
i
=
0
;
i
<
view_list
.
length
;
i
+=
1
)
{
if
(
view_list
[
i
].
href
===
this
.
state
.
view
)
{
title
=
view_list
[
i
].
title
;
}
}
// Calculate the h3 properties
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
all
([
form_gadget
.
translate
(
form_gadget
.
state
.
form_definition
.
title
),
form_gadget
.
translate
(
title
)
]);
})
.
push
(
function
(
translated_title_list
)
{
form_gadget
.
element
.
querySelector
(
'
input.dialogconfirm
'
).
value
=
translated_title_list
[
1
];
selector
.
textContent
=
"
\
u00A0
"
+
translated_title_list
[
0
];
selector
.
className
=
"
ui-content-title ui-body-c ui-icon ui-icon-custom
"
+
icon
;
// Render the erp5_from
return
form_gadget
.
getDeclaredGadget
(
"
erp5_form
"
);
})
.
push
(
function
(
erp5_form
)
{
var
form_options
=
form_gadget
.
state
.
erp5_form
;
// pass own form options to the embedded form
form_options
.
erp5_document
=
form_gadget
.
state
.
erp5_document
;
form_options
.
form_definition
=
form_gadget
.
state
.
form_definition
;
form_options
.
view
=
form_gadget
.
state
.
view
;
form_options
.
jio_key
=
form_gadget
.
state
.
jio_key
;
form_options
.
editable
=
true
;
// dialog is always editable
return
erp5_form
.
render
(
form_options
);
})
.
push
(
function
()
{
// Render the headers
return
RSVP
.
all
([
form_gadget
.
getUrlFor
({
command
:
'
change
'
,
options
:
{
page
:
undefined
,
view
:
undefined
}}),
calculatePageTitle
(
form_gadget
,
form_gadget
.
state
.
erp5_document
)
]);
})
.
push
(
function
(
all_result
)
{
form_gadget
.
element
.
querySelector
(
'
a.dialogcancel
'
).
href
=
all_result
[
0
];
return
form_gadget
.
updateHeader
({
cancel_url
:
all_result
[
0
],
page_title
:
all_result
[
1
]
});
});
})
/** The only way how to force download from javascript (working everywhere)
* is unfortunately constructing <a> and clicking on it
*/
.
declareJob
(
"
forceDownload
"
,
function
(
attachment
)
{
var
attachment_data
=
attachment
.
target
.
response
,
filename
=
/
(?:
^|;
)\s
*filename
\s
*=
\s
*"
?([^
";
]
+
)
/i
.
exec
(
attachment
.
target
.
getResponseHeader
(
"
Content-Disposition
"
)
||
""
),
a_tag
=
document
.
createElement
(
"
a
"
);
if
(
attachment
.
target
.
responseType
!==
"
blob
"
)
{
attachment_data
=
new
Blob
(
[
attachment
.
target
.
response
],
{
type
:
attachment
.
target
.
getResponseHeader
(
"
Content-Type
"
)}
);
}
a_tag
.
style
=
"
display: none
"
;
a_tag
.
href
=
URL
.
createObjectURL
(
attachment_data
);
a_tag
.
download
=
filename
?
filename
[
1
].
trim
()
:
"
untitled
"
;
document
.
body
.
appendChild
(
a_tag
);
a_tag
.
click
();
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
delay
(
10
);
})
.
push
(
function
()
{
URL
.
revokeObjectURL
(
a_tag
.
href
);
document
.
body
.
removeChild
(
a_tag
);
});
})
.
onEvent
(
'
submit
'
,
function
()
{
var
form_gadget
=
this
,
action
=
this
.
state
.
erp5_document
.
_embedded
.
_view
.
_actions
.
put
,
form_id
=
this
.
state
.
erp5_document
.
_embedded
.
_view
.
form_id
,
function
submitDialog
(
gadget
)
{
var
form_gadget
=
gadget
,
action
=
form_gadget
.
state
.
erp5_document
.
_embedded
.
_view
.
_actions
.
put
,
form_id
=
form_gadget
.
state
.
erp5_document
.
_embedded
.
_view
.
form_id
,
redirect_to_parent
;
return
form_gadget
.
notifySubmitting
()
...
...
@@ -381,7 +218,172 @@
}
throw
error
;
});
}
rJS
(
window
)
/////////////////////////////////////////////////////////////////
// acquisition
/////////////////////////////////////////////////////////////////
.
declareAcquiredMethod
(
"
jio_putAttachment
"
,
"
jio_putAttachment
"
)
.
declareAcquiredMethod
(
"
redirect
"
,
"
redirect
"
)
.
declareAcquiredMethod
(
"
getUrlFor
"
,
"
getUrlFor
"
)
.
declareAcquiredMethod
(
"
updateHeader
"
,
"
updateHeader
"
)
.
declareAcquiredMethod
(
"
notifySubmitting
"
,
"
notifySubmitting
"
)
.
declareAcquiredMethod
(
"
notifySubmitted
"
,
"
notifySubmitted
"
)
.
declareAcquiredMethod
(
"
translate
"
,
"
translate
"
)
.
declareAcquiredMethod
(
"
notifyChange
"
,
"
notifyChange
"
)
.
declareAcquiredMethod
(
"
updateForm
"
,
"
updateForm
"
)
.
declareAcquiredMethod
(
"
displayFormulatorValidationError
"
,
"
displayFormulatorValidationError
"
)
/////////////////////////////////////////////////////////////////
// Proxy methods to the child gadget
/////////////////////////////////////////////////////////////////
.
declareMethod
(
'
checkValidity
'
,
function
()
{
return
this
.
getDeclaredGadget
(
"
erp5_form
"
)
.
push
(
function
(
declared_gadget
)
{
return
declared_gadget
.
checkValidity
();
});
},
{
mutex
:
'
changestate
'
})
.
declareMethod
(
'
getContent
'
,
function
()
{
return
this
.
getDeclaredGadget
(
"
erp5_form
"
)
.
push
(
function
(
declared_gadget
)
{
return
declared_gadget
.
getContent
();
});
},
{
mutex
:
'
changestate
'
})
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.
declareMethod
(
'
triggerSubmit
'
,
function
()
{
this
.
element
.
querySelector
(
'
input[type="submit"]
'
).
click
();
},
{
mutex
:
'
changestate
'
})
.
declareMethod
(
'
render
'
,
function
(
options
)
{
// copy out wanted items from options and pass it to `changeState`
return
this
.
changeState
({
jio_key
:
options
.
jio_key
,
view
:
options
.
view
,
// ignore options.editable because dialog is always editable
erp5_document
:
options
.
erp5_document
,
form_definition
:
options
.
form_definition
,
erp5_form
:
options
.
erp5_form
||
{}
// ignore global editable state (be always editable)
});
})
.
onStateChange
(
function
()
{
var
form_gadget
=
this
,
icon
,
selector
=
form_gadget
.
element
.
querySelector
(
"
h3
"
),
title
,
i
,
view_list
=
ensureArray
(
this
.
state
.
erp5_document
.
_links
.
action_workflow
);
title
=
this
.
state
.
form_definition
.
title
;
// XXX hardcoded...
switch
(
title
)
{
case
"
Create User
"
:
icon
=
"
ui-icon-user
"
;
break
;
case
"
Create Document
"
:
icon
=
"
ui-icon-file-o
"
;
break
;
case
"
Validate Workflow Action
"
:
icon
=
"
ui-icon-share-alt
"
;
break
;
case
"
Submit
"
:
icon
=
"
ui-icon-check
"
;
break
;
default
:
icon
=
"
ui-icon-random
"
;
break
;
}
for
(
i
=
0
;
i
<
view_list
.
length
;
i
+=
1
)
{
if
(
view_list
[
i
].
href
===
this
.
state
.
view
)
{
title
=
view_list
[
i
].
title
;
}
}
// Calculate the h3 properties
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
all
([
form_gadget
.
translate
(
form_gadget
.
state
.
form_definition
.
title
),
form_gadget
.
translate
(
title
)
]);
})
.
push
(
function
(
translated_title_list
)
{
form_gadget
.
element
.
querySelector
(
'
input.dialogconfirm
'
).
value
=
translated_title_list
[
1
];
selector
.
textContent
=
"
\
u00A0
"
+
translated_title_list
[
0
];
selector
.
className
=
"
ui-content-title ui-body-c ui-icon ui-icon-custom
"
+
icon
;
// Render the erp5_from
return
form_gadget
.
getDeclaredGadget
(
"
erp5_form
"
);
})
.
push
(
function
(
erp5_form
)
{
var
form_options
=
form_gadget
.
state
.
erp5_form
;
// pass own form options to the embedded form
form_options
.
erp5_document
=
form_gadget
.
state
.
erp5_document
;
form_options
.
form_definition
=
form_gadget
.
state
.
form_definition
;
form_options
.
view
=
form_gadget
.
state
.
view
;
form_options
.
jio_key
=
form_gadget
.
state
.
jio_key
;
form_options
.
editable
=
true
;
// dialog is always editable
return
erp5_form
.
render
(
form_options
);
})
.
push
(
function
()
{
// Render the headers
return
RSVP
.
all
([
form_gadget
.
getUrlFor
({
command
:
'
change
'
,
options
:
{
page
:
undefined
,
view
:
undefined
}}),
calculatePageTitle
(
form_gadget
,
form_gadget
.
state
.
erp5_document
)
]);
})
.
push
(
function
(
all_result
)
{
form_gadget
.
element
.
querySelector
(
'
a.dialogcancel
'
).
href
=
all_result
[
0
];
return
form_gadget
.
updateHeader
({
cancel_url
:
all_result
[
0
],
page_title
:
all_result
[
1
]
});
});
})
/** The only way how to force download from javascript (working everywhere)
* is unfortunately constructing <a> and clicking on it
*/
.
declareJob
(
"
forceDownload
"
,
function
(
attachment
)
{
var
attachment_data
=
attachment
.
target
.
response
,
filename
=
/
(?:
^|;
)\s
*filename
\s
*=
\s
*"
?([^
";
]
+
)
/i
.
exec
(
attachment
.
target
.
getResponseHeader
(
"
Content-Disposition
"
)
||
""
),
a_tag
=
document
.
createElement
(
"
a
"
);
if
(
attachment
.
target
.
responseType
!==
"
blob
"
)
{
attachment_data
=
new
Blob
(
[
attachment
.
target
.
response
],
{
type
:
attachment
.
target
.
getResponseHeader
(
"
Content-Type
"
)}
);
}
a_tag
.
style
=
"
display: none
"
;
a_tag
.
href
=
URL
.
createObjectURL
(
attachment_data
);
a_tag
.
download
=
filename
?
filename
[
1
].
trim
()
:
"
untitled
"
;
document
.
body
.
appendChild
(
a_tag
);
a_tag
.
click
();
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
delay
(
10
);
})
.
push
(
function
()
{
URL
.
revokeObjectURL
(
a_tag
.
href
);
document
.
body
.
removeChild
(
a_tag
);
});
})
.
onEvent
(
'
submit
'
,
function
()
{
return
submitDialog
(
this
);
},
false
,
true
);
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.xml
View file @
913edbfb
...
...
@@ -230,7 +230,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
96
4.3910.33744.24644
</string>
</value>
<value>
<string>
96
5.670.53338.41130
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>
1516
350278.01
</float>
<float>
1516
725149.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