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
1
Issues
1
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
Roque
erp5
Commits
3f82e201
Commit
3f82e201
authored
May 10, 2019
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_post: refactoring on action gadgets
parent
c7a632f1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
58 deletions
+22
-58
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
+11
-28
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
+11
-30
No files found.
bt5/erp5_post/SkinTemplateItem/portal_skins/erp5_post/gadget_field_new_action_js_script.js.js
View file @
3f82e201
...
...
@@ -14,44 +14,27 @@
// declared methods
/////////////////////////////////////////////////////////////////
.
declareMethod
(
"
createDocument
"
,
function
(
options
)
{
var
gadget
=
this
,
doc
=
{
title
:
"
Untitled Post
"
,
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
(
"
preRenderDocument
"
,
function
(
parent_options
)
{
return
{
title
:
"
Untitled Post
"
};
})
.
declareMethod
(
'
handleSubmit
'
,
function
(
content_dict
,
parent_options
)
{
var
document
=
{
my_title
:
parent_options
.
doc
.
title
,
portal_type
:
parent_options
.
parent_options
.
portal_type
,
parent_relative_url
:
parent_options
.
parent_options
.
parent_relative_url
},
property
;
var
gadget
=
this
,
document
=
{
title
:
parent_options
.
doc
.
title
,
//hardcoded portal_type and relative url (because this action is 'new HTML Post' on 'post_module')
//or, we can get those values from parent_options.form_definition if needed
portal_type
:
"
HTML Post
"
,
parent_relative_url
:
"
post_module
"
},
property
;
delete
content_dict
.
dialog_method
;
for
(
property
in
content_dict
)
{
if
(
content_dict
.
hasOwnProperty
(
property
))
{
document
[
'
my_
'
+
property
]
=
content_dict
[
property
];
document
[
property
]
=
content_dict
[
property
];
}
}
document
.
my_source_reference
=
parent_options
.
parent_options
.
my_
source_reference
;
return
this
.
createDocumen
t
(
document
);
document
.
source_reference
=
parent_options
.
action_options
.
source_reference
;
return
gadget
.
jio_pos
t
(
document
);
});
}(
window
,
rJS
,
RSVP
));
\ No newline at end of file
bt5/erp5_post/SkinTemplateItem/portal_skins/erp5_post/gadget_field_reply_action_js_script.js.js
View file @
3f82e201
...
...
@@ -15,51 +15,32 @@
// declared methods
/////////////////////////////////////////////////////////////////
.
declareMethod
(
"
createDocument
"
,
function
(
options
)
{
var
gadget
=
this
,
doc
=
{
title
:
"
Untitled Post
"
,
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
(
"
preRenderDocument
"
,
function
(
parent_options
)
{
var
gadget
=
this
;
return
gadget
.
jio_get
(
parent_options
.
jio_key
)
.
push
(
function
(
parent_document
)
{
var
title
=
parent_document
.
title
;
if
(
!
title
.
startsWith
(
'
Re:
'
))
{
title
=
'
Re:
'
+
parent_document
.
title
;
}
return
{
title
:
title
,
source_reference
:
parent_document
.
source_reference
};
return
{
title
:
title
,
parent_relative_url
:
parent_document
.
parent_relative_url
,
portal_type
:
parent_document
.
portal_type
,
source_reference
:
parent_document
.
source_reference
};
});
})
.
declareMethod
(
'
handleSubmit
'
,
function
(
content_dict
,
parent_options
)
{
var
document
=
{
my_title
:
parent_options
.
doc
.
title
,
portal_type
:
parent_options
.
parent_options
.
portal_type
,
parent_relative_url
:
parent_options
.
parent_options
.
parent_relative_url
},
property
;
var
gadget
=
this
,
document
=
parent_options
.
doc
,
property
;
delete
content_dict
.
dialog_method
;
for
(
property
in
content_dict
)
{
if
(
content_dict
.
hasOwnProperty
(
property
))
{
document
[
'
my_
'
+
property
]
=
content_dict
[
property
];
document
[
property
]
=
content_dict
[
property
];
}
}
document
.
my_source_reference
=
parent_options
.
doc
.
source_reference
;
return
this
.
createDocument
(
document
);
return
gadget
.
jio_post
(
document
);
});
}(
window
,
rJS
,
RSVP
));
\ No newline at end of file
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