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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Amer
erp5
Commits
bdc37f33
Commit
bdc37f33
authored
Apr 24, 2019
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_post: action gadgets handle its own doc creation
parent
ca411361
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
48 deletions
+92
-48
bt5/erp5_post/SkinTemplateItem/portal_skins/erp5_post/gadget_field_new_action_js_script.js.js
...l_skins/erp5_post/gadget_field_new_action_js_script.js.js
+39
-16
bt5/erp5_post/SkinTemplateItem/portal_skins/erp5_post/gadget_field_reply_action_js_script.js.js
...skins/erp5_post/gadget_field_reply_action_js_script.js.js
+53
-32
No files found.
bt5/erp5_post/SkinTemplateItem/portal_skins/erp5_post/gadget_field_new_action_js_script.js.js
View file @
bdc37f33
...
@@ -3,7 +3,8 @@
...
@@ -3,7 +3,8 @@
(
function
(
window
,
rJS
,
RSVP
)
{
(
function
(
window
,
rJS
,
RSVP
)
{
"
use strict
"
;
"
use strict
"
;
var
parent_gadget
,
form_view_gadget
;
var
child_gadget_url
=
'
gadget_erp5_pt_form_view_editable.html
'
,
form_view_gadget_url
=
"
gadget_officejs_form_view.html
"
;
rJS
(
window
)
rJS
(
window
)
...
@@ -12,6 +13,7 @@
...
@@ -12,6 +13,7 @@
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
.
declareAcquiredMethod
(
"
jio_get
"
,
"
jio_get
"
)
.
declareAcquiredMethod
(
"
jio_get
"
,
"
jio_get
"
)
.
declareAcquiredMethod
(
"
jio_put
"
,
"
jio_put
"
)
.
declareAcquiredMethod
(
"
jio_put
"
,
"
jio_put
"
)
.
declareAcquiredMethod
(
"
jio_post
"
,
"
jio_post
"
)
.
declareAcquiredMethod
(
"
getSetting
"
,
"
getSetting
"
)
.
declareAcquiredMethod
(
"
getSetting
"
,
"
getSetting
"
)
.
declareAcquiredMethod
(
'
getUrlParameter
'
,
'
getUrlParameter
'
)
.
declareAcquiredMethod
(
'
getUrlParameter
'
,
'
getUrlParameter
'
)
.
declareAcquiredMethod
(
"
notifySubmitted
"
,
'
notifySubmitted
'
)
.
declareAcquiredMethod
(
"
notifySubmitted
"
,
'
notifySubmitted
'
)
...
@@ -22,28 +24,49 @@
...
@@ -22,28 +24,49 @@
// declared methods
// declared methods
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
.
declareMethod
(
"
render
"
,
function
(
gadget
)
{
.
declareMethod
(
"
createDocument
"
,
function
(
options
)
{
return
form_view_gadget
.
renderGadget
(
gadget
);
var
gadget
=
this
,
doc
=
{
title
:
"
Untitled Document
"
,
portal_type
:
options
.
portal_type
,
parent_relative_url
:
options
.
parent_relative_url
},
key
,
doc_key
;
for
(
key
in
options
)
{
if
(
options
.
hasOwnProperty
(
key
))
{
if
(
key
.
startsWith
(
"
my_
"
))
{
doc_key
=
key
.
replace
(
"
my_
"
,
""
);
doc
[
doc_key
]
=
options
[
key
];
}
}
}
return
gadget
.
jio_post
(
doc
);
})
.
declareMethod
(
"
render
"
,
function
(
parent_gadget
)
{
var
gadget
=
this
;
return
gadget
.
declareGadget
(
form_view_gadget_url
)
.
push
(
function
(
form_view_gadget
)
{
return
form_view_gadget
.
renderGadget
(
parent_gadget
);
});
})
})
.
declareMethod
(
"
handleRender
"
,
function
(
gadget
,
options
,
action_reference
,
form_definition
)
{
.
declareMethod
(
"
handleRender
"
,
function
(
parent_gadget
,
options
,
action_reference
,
form_definition
)
{
var
child_gadget_url
=
'
gadget_erp5_pt_form_view_editable.html
'
,
this_gadget
=
this
;
var
this_gadget
=
this
;
parent_gadget
=
gadget
;
return
RSVP
.
Queue
()
return
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
return
RSVP
.
all
([
return
RSVP
.
all
([
parent_gadget
.
getUrlParameter
(
'
portal_type
'
),
parent_gadget
.
getUrlParameter
(
'
portal_type
'
),
parent_gadget
.
getUrlParameter
(
'
parent_relative_url
'
),
parent_gadget
.
getUrlParameter
(
'
parent_relative_url
'
),
parent_gadget
.
getSetting
(
'
portal_type
'
),
parent_gadget
.
getSetting
(
'
portal_type
'
),
parent_gadget
.
getSetting
(
'
parent_relative_url
'
),
parent_gadget
.
getSetting
(
'
parent_relative_url
'
)
parent_gadget
.
declareGadget
(
"
gadget_officejs_form_view.html
"
)
]);
]);
})
})
.
push
(
function
(
result
)
{
.
push
(
function
(
result
)
{
if
(
result
[
0
]
!==
undefined
)
{
options
.
portal_type
=
result
[
0
];
}
else
{
options
.
portal_type
=
result
[
2
];
}
if
(
result
[
0
]
!==
undefined
)
{
options
.
portal_type
=
result
[
0
];
}
else
{
options
.
portal_type
=
result
[
2
];
}
if
(
result
[
1
]
!==
undefined
)
{
options
.
parent_relative_url
=
result
[
1
];
}
else
{
options
.
parent_relative_url
=
result
[
3
];
}
if
(
result
[
1
]
!==
undefined
)
{
options
.
parent_relative_url
=
result
[
1
];
}
else
{
options
.
parent_relative_url
=
result
[
3
];
}
form_view_gadget
=
result
[
4
];
return
this_gadget
.
createDocument
(
options
)
return
form_view_gadget
.
createDocument
(
options
)
.
push
(
function
(
jio_key
)
{
.
push
(
function
(
jio_key
)
{
return
parent_gadget
.
jio_get
(
jio_key
)
return
parent_gadget
.
jio_get
(
jio_key
)
.
push
(
function
(
new_document
)
{
.
push
(
function
(
new_document
)
{
...
@@ -63,10 +86,10 @@
...
@@ -63,10 +86,10 @@
});
});
})
})
.
declareMethod
(
"
handleSubmit
"
,
function
(
gadget
,
jio_key
,
content_dict
)
{
.
declareMethod
(
"
handleSubmit
"
,
function
(
parent_
gadget
,
jio_key
,
content_dict
)
{
return
gadget
.
notifySubmitting
()
return
parent_
gadget
.
notifySubmitting
()
.
push
(
function
()
{
.
push
(
function
()
{
return
gadget
.
jio_get
(
jio_key
);
return
parent_
gadget
.
jio_get
(
jio_key
);
})
})
.
push
(
function
(
document
)
{
.
push
(
function
(
document
)
{
var
property
;
var
property
;
...
@@ -75,13 +98,13 @@
...
@@ -75,13 +98,13 @@
document
[
property
]
=
content_dict
[
property
];
document
[
property
]
=
content_dict
[
property
];
}
}
}
}
return
gadget
.
jio_put
(
jio_key
,
document
);
return
parent_
gadget
.
jio_put
(
jio_key
,
document
);
})
})
.
push
(
function
()
{
.
push
(
function
()
{
return
gadget
.
notifySubmitted
({
message
:
'
Data Updated
'
,
status
:
'
success
'
});
return
parent_
gadget
.
notifySubmitted
({
message
:
'
Data Updated
'
,
status
:
'
success
'
});
})
})
.
push
(
function
()
{
.
push
(
function
()
{
return
gadget
.
redirect
({
return
parent_
gadget
.
redirect
({
command
:
'
display
'
,
command
:
'
display
'
,
options
:
{
options
:
{
jio_key
:
jio_key
,
jio_key
:
jio_key
,
...
...
bt5/erp5_post/SkinTemplateItem/portal_skins/erp5_post/gadget_field_reply_action_js_script.js.js
View file @
bdc37f33
...
@@ -3,7 +3,8 @@
...
@@ -3,7 +3,8 @@
(
function
(
window
,
rJS
,
RSVP
)
{
(
function
(
window
,
rJS
,
RSVP
)
{
"
use strict
"
;
"
use strict
"
;
var
gadget_utils
;
var
child_gadget_url
=
'
gadget_erp5_pt_form_view_editable.html
'
,
form_view_gadget_url
=
"
gadget_officejs_form_view.html
"
;
rJS
(
window
)
rJS
(
window
)
...
@@ -12,6 +13,7 @@
...
@@ -12,6 +13,7 @@
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
.
declareAcquiredMethod
(
"
jio_get
"
,
"
jio_get
"
)
.
declareAcquiredMethod
(
"
jio_get
"
,
"
jio_get
"
)
.
declareAcquiredMethod
(
"
jio_put
"
,
"
jio_put
"
)
.
declareAcquiredMethod
(
"
jio_put
"
,
"
jio_put
"
)
.
declareAcquiredMethod
(
"
jio_post
"
,
"
jio_post
"
)
.
declareAcquiredMethod
(
"
getSetting
"
,
"
getSetting
"
)
.
declareAcquiredMethod
(
"
getSetting
"
,
"
getSetting
"
)
.
declareAcquiredMethod
(
'
getUrlParameter
'
,
'
getUrlParameter
'
)
.
declareAcquiredMethod
(
'
getUrlParameter
'
,
'
getUrlParameter
'
)
.
declareAcquiredMethod
(
"
notifySubmitted
"
,
'
notifySubmitted
'
)
.
declareAcquiredMethod
(
"
notifySubmitted
"
,
'
notifySubmitted
'
)
...
@@ -22,56 +24,75 @@
...
@@ -22,56 +24,75 @@
// declared methods
// declared methods
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
.
declareMethod
(
"
render
"
,
function
(
gadget
)
{
.
declareMethod
(
"
createDocument
"
,
function
(
options
)
{
return
gadget_utils
.
renderGadget
(
gadget
);
var
gadget
=
this
,
doc
=
{
title
:
"
Untitled Document
"
,
portal_type
:
options
.
portal_type
,
parent_relative_url
:
options
.
parent_relative_url
},
key
,
doc_key
;
for
(
key
in
options
)
{
if
(
options
.
hasOwnProperty
(
key
))
{
if
(
key
.
startsWith
(
"
my_
"
))
{
doc_key
=
key
.
replace
(
"
my_
"
,
""
);
doc
[
doc_key
]
=
options
[
key
];
}
}
}
return
gadget
.
jio_post
(
doc
);
})
.
declareMethod
(
"
render
"
,
function
(
parent_gadget
)
{
var
gadget
=
this
;
return
gadget
.
declareGadget
(
form_view_gadget_url
)
.
push
(
function
(
form_view_gadget
)
{
return
form_view_gadget
.
renderGadget
(
parent_gadget
);
});
})
})
.
declareMethod
(
"
handleRender
"
,
function
(
gadget
,
options
,
action_reference
,
form_definition
)
{
.
declareMethod
(
"
handleRender
"
,
function
(
parent_gadget
,
options
,
action_reference
,
form_definition
)
{
return
gadget
.
declareGadget
(
"
gadget_officejs_form_view.html
"
)
return
parent_gadget
.
jio_get
(
options
.
jio_key
)
.
push
(
function
(
declared_gadget
)
{
.
push
(
function
(
parent_document
)
{
gadget_utils
=
declared_gadget
;
var
title
=
parent_document
.
title
;
var
child_gadget_url
=
'
gadget_erp5_pt_form_view_editable.html
'
;
if
(
!
title
.
startsWith
(
'
Re:
'
))
{
title
=
'
Re:
'
+
parent_document
.
title
;
}
return
gadget
.
jio_get
(
options
.
jio_key
)
return
parent_gadget
.
changeState
({
.
push
(
function
(
parent_document
)
{
doc
:
{
title
:
title
},
var
title
=
parent_document
.
title
;
parent_document
:
parent_document
,
if
(
!
title
.
startsWith
(
'
Re:
'
))
{
title
=
'
Re:
'
+
parent_document
.
title
;
}
child_gadget_url
:
child_gadget_url
,
return
gadget
.
changeState
({
form_definition
:
form_definition
,
doc
:
{
title
:
title
},
view
:
action_reference
,
parent_document
:
parent_document
,
editable
:
true
,
child_gadget_url
:
child_gadget_url
,
has_more_views
:
false
,
form_definition
:
form_definition
,
has_more_actions
:
false
,
view
:
action_reference
,
is_form_list
:
false
editable
:
true
,
has_more_views
:
false
,
has_more_actions
:
false
,
is_form_list
:
false
});
});
});
});
});
})
})
.
declareMethod
(
"
handleSubmit
"
,
function
(
gadget
,
jio_key
,
content_dict
)
{
.
declareMethod
(
"
handleSubmit
"
,
function
(
parent_
gadget
,
jio_key
,
content_dict
)
{
var
document
=
{
var
document
=
{
my_title
:
gadget
.
state
.
doc
.
title
,
my_title
:
parent_
gadget
.
state
.
doc
.
title
,
portal_type
:
gadget
.
state
.
parent_document
.
portal_type
,
portal_type
:
parent_
gadget
.
state
.
parent_document
.
portal_type
,
parent_relative_url
:
gadget
.
state
.
parent_document
.
parent_relative_url
,
parent_relative_url
:
parent_
gadget
.
state
.
parent_document
.
parent_relative_url
,
my_source_reference
:
gadget
.
state
.
parent_document
.
source_reference
my_source_reference
:
parent_
gadget
.
state
.
parent_document
.
source_reference
},
property
;
},
property
;
for
(
property
in
content_dict
)
{
for
(
property
in
content_dict
)
{
if
(
content_dict
.
hasOwnProperty
(
property
))
{
if
(
content_dict
.
hasOwnProperty
(
property
))
{
document
[
'
my_
'
+
property
]
=
content_dict
[
property
];
document
[
'
my_
'
+
property
]
=
content_dict
[
property
];
}
}
}
}
return
gadget_util
s
.
createDocument
(
document
)
return
thi
s
.
createDocument
(
document
)
.
push
(
function
(
id
)
{
.
push
(
function
(
id
)
{
jio_key
=
id
;
jio_key
=
id
;
return
gadget
.
notifySubmitting
();
return
parent_
gadget
.
notifySubmitting
();
})
})
.
push
(
function
()
{
.
push
(
function
()
{
return
gadget
.
notifySubmitted
({
message
:
'
Data Updated
'
,
status
:
'
success
'
});
return
parent_
gadget
.
notifySubmitted
({
message
:
'
Data Updated
'
,
status
:
'
success
'
});
})
})
.
push
(
function
()
{
.
push
(
function
()
{
return
gadget
.
redirect
({
return
parent_
gadget
.
redirect
({
command
:
'
display
'
,
command
:
'
display
'
,
options
:
{
options
:
{
jio_key
:
jio_key
,
jio_key
:
jio_key
,
...
...
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