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
Alain Takoudjou
erp5
Commits
fca49e31
Commit
fca49e31
authored
Jan 11, 2019
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_messenger: get rid of code in gadget field
- code removed: post comment; render form; editor
parent
d551b9c3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
159 deletions
+39
-159
bt5/erp5_messenger/SkinTemplateItem/portal_skins/erp5_messenger/gadget_postlist.html.html
...tem/portal_skins/erp5_messenger/gadget_postlist.html.html
+0
-16
bt5/erp5_messenger/SkinTemplateItem/portal_skins/erp5_messenger/gadget_postlist.js.js
...ateItem/portal_skins/erp5_messenger/gadget_postlist.js.js
+39
-143
No files found.
bt5/erp5_messenger/SkinTemplateItem/portal_skins/erp5_messenger/gadget_postlist.html.html
View file @
fca49e31
...
@@ -37,25 +37,9 @@
...
@@ -37,25 +37,9 @@
</head>
</head>
<body>
<body>
<div
class=
"ui-body-c"
>
<div
class=
"ui-body-c"
>
<div
data-gadget-url=
"gadget_erp5_form.html"
data-gadget-scope=
"erp5_form"
data-gadget-sandbox=
"public"
>
</div>
<form>
<form>
<p
style=
"background-color:#0E81C2;color:white;margin:1em 0;padding:0.5em"
>
Comments:
</p>
<p
style=
"background-color:#0E81C2;color:white;margin:1em 0;padding:0.5em"
>
Comments:
</p>
<ol
id=
"post_list"
></ol>
<ol
id=
"post_list"
></ol>
<h3
class=
"ui-content-title ui-body-c ui-icon ui-icon-custom ui-icon-random"
id=
"comment-title"
name=
"comment-title"
>
Post a comment
</h3>
<div
data-gadget-url=
"gadget_editor.html"
data-gadget-scope=
"editor"
data-gadget-sandbox=
""
>
</div>
<div
id=
"file_upload_div"
>
<input
value=
""
name=
"attachment"
id=
"attachment"
type=
"file"
title=
"Upload"
>
</div>
<input
data-theme=
"b"
data-inline=
"true"
type=
"submit"
data-i18n=
"[value]Post Comment"
value=
"Post Comment"
data-icon=
"check"
disabled
class=
"ui-disabled"
/>
</form>
</form>
</div>
</div>
</body>
</body>
...
...
bt5/erp5_messenger/SkinTemplateItem/portal_skins/erp5_messenger/gadget_postlist.js.js
View file @
fca49e31
/*jslint nomen: true, indent: 2 */
/*jslint nomen: true, indent: 2 */
/*global window, rJS, RSVP, document,moment,
FormData,
jIO, Handlebars*/
/*global window, rJS, RSVP, document,moment, jIO, Handlebars*/
(
function
(
window
,
rJS
,
RSVP
,
document
,
moment
,
FormData
,
jIO
,
Handlebars
)
{
(
function
(
window
,
rJS
,
RSVP
,
document
,
moment
,
jIO
,
Handlebars
)
{
"
use strict
"
;
"
use strict
"
;
var
gadget_klass
=
rJS
(
window
),
var
gadget_klass
=
rJS
(
window
),
comment_list_template
=
Handlebars
.
compile
(
comment_list_template
=
Handlebars
.
compile
(
...
@@ -10,11 +10,8 @@
...
@@ -10,11 +10,8 @@
rJS
(
window
)
rJS
(
window
)
.
declareAcquiredMethod
(
"
getSetting
"
,
"
getSetting
"
)
.
declareAcquiredMethod
(
"
getSetting
"
,
"
getSetting
"
)
.
declareAcquiredMethod
(
"
getSettingList
"
,
"
getSettingList
"
)
.
declareAcquiredMethod
(
"
jio_getAttachment
"
,
"
jio_getAttachment
"
)
.
declareAcquiredMethod
(
"
jio_getAttachment
"
,
"
jio_getAttachment
"
)
.
declareAcquiredMethod
(
"
jio_putAttachment
"
,
"
jio_putAttachment
"
)
.
declareAcquiredMethod
(
"
jio_putAttachment
"
,
"
jio_putAttachment
"
)
.
declareAcquiredMethod
(
"
notifySubmitted
"
,
"
notifySubmitted
"
)
.
declareAcquiredMethod
(
"
redirect
"
,
"
redirect
"
)
.
declareMethod
(
'
render
'
,
function
(
options
)
{
.
declareMethod
(
'
render
'
,
function
(
options
)
{
var
gadget
=
this
;
var
gadget
=
this
;
...
@@ -36,148 +33,47 @@
...
@@ -36,148 +33,47 @@
.
onStateChange
(
function
()
{
.
onStateChange
(
function
()
{
var
gadget
=
this
;
var
gadget
=
this
;
// render the erp5 form
return
gadget
.
jio_getAttachment
(
return
gadget
.
getDeclaredGadget
(
"
erp5_form
"
)
'
post_module
'
,
.
push
(
function
(
erp5_form
)
{
gadget
.
hateoas_url
+
gadget
.
options
.
jio_key
+
"
/MessengerThread_getCommentPostListAsJson
"
return
gadget
.
getDeclaredGadget
(
"
editor
"
)
)
.
push
(
function
(
editor
)
{
return
[
editor
,
erp5_form
];
.
push
(
function
(
post_list
)
{
});
function
getPostWithLinkAndLocalDate
(
post
)
{
})
post
.
date_formatted
=
moment
(
post
.
date
).
format
(
'
LLLL
'
);
post
.
date_relative
=
moment
(
post
.
date
).
fromNow
();
.
push
(
function
(
gadgets
)
{
if
(
post
.
attachment_link
===
null
)
{
var
form_options
=
gadget
.
state
.
erp5_form
,
return
post
;
rendered_field
,
}
key
,
if
(
post
.
attachment_link
.
indexOf
(
"
image_module
"
)
!==
-
1
)
{
editor
=
gadgets
[
0
],
return
gadget
.
getImageUrl
(
post
.
attachment_link
).
push
(
erp5_form
=
gadgets
[
1
];
return
new
RSVP
.
Queue
()
/* TODO: I get an error with this
// I think that this rendering is the key to refresh the comment list including the new element
// some times, after a "post comment" the list is refreshed but the new post doens't appear
.push(
function () {
return RSVP.all([
erp5_form.render(form_options),
editor.render({
value: "",
key: "comment",
portal_type: "HTML Post",
editable: true,
editor: gadget.state.preferred_editor,
maximize: true
})
]);
}
)
*/
.
push
(
function
()
{
// make our submit button editable
var
element
=
gadget
.
element
.
querySelector
(
'
input[type="submit"]
'
);
element
.
removeAttribute
(
'
disabled
'
);
element
.
classList
.
remove
(
'
ui-disabled
'
);
});
})
.
push
(
function
()
{
return
gadget
.
jio_getAttachment
(
'
post_module
'
,
gadget
.
hateoas_url
+
gadget
.
options
.
jio_key
+
"
/MessengerThread_getCommentPostListAsJson
"
);
})
.
push
(
function
(
post_list
)
{
function
getPostWithLinkAndLocalDate
(
post
)
{
post
.
date_formatted
=
moment
(
post
.
date
).
format
(
'
LLLL
'
);
post
.
date_relative
=
moment
(
post
.
date
).
fromNow
();
if
(
post
.
attachment_link
===
null
)
{
return
post
;
}
if
(
post
.
attachment_link
.
indexOf
(
"
image_module
"
)
!==
-
1
)
{
return
gadget
.
getImageUrl
(
post
.
attachment_link
).
push
(
function
(
attachment_link
)
{
post
.
attachment_link
=
attachment_link
;
return
post
;
}
);
}
return
gadget
.
getDocumentUrl
(
post
.
attachment_link
).
push
(
function
(
attachment_link
)
{
function
(
attachment_link
)
{
post
.
attachment_link
=
attachment_link
;
post
.
attachment_link
=
attachment_link
;
return
post
;
return
post
;
}
}
);
);
}
}
// build links with attachments and localized dates
return
gadget
.
getDocumentUrl
(
post
.
attachment_link
).
push
(
var
queue_list
=
[],
i
=
0
;
function
(
attachment_link
)
{
for
(
i
=
0
;
i
<
post_list
.
length
;
i
+=
1
)
{
post
.
attachment_link
=
attachment_link
;
queue_list
.
push
(
getPostWithLinkAndLocalDate
(
post_list
[
i
]));
return
post
;
}
return
RSVP
.
all
(
queue_list
);
})
.
push
(
function
(
comment_list
)
{
var
comments
=
gadget
.
element
.
querySelector
(
"
#post_list
"
);
comments
.
innerHTML
=
comment_list_template
({
comments
:
comment_list
});
})
;
})
.
declareJob
(
'
submitPostComment
'
,
function
()
{
var
gadget
=
this
,
submitButton
=
null
,
queue
=
null
;
submitButton
=
gadget
.
element
.
querySelector
(
"
input[type=submit]
"
);
submitButton
.
disabled
=
true
;
submitButton
.
classList
.
add
(
"
ui-disabled
"
);
function
enableSubmitButton
()
{
submitButton
.
disabled
=
false
;
submitButton
.
classList
.
remove
(
"
ui-disabled
"
);
}
queue
=
gadget
.
notifySubmitted
({
message
:
"
Posting comment
"
})
.
push
(
function
()
{
var
choose_file_html_element
=
gadget
.
element
.
querySelector
(
'
#attachment
'
),
file_blob
=
choose_file_html_element
.
files
[
0
],
url
=
gadget
.
hateoas_url
+
gadget
.
options
.
jio_key
+
"
/MessengerThread_createNewMessengerPost
"
,
data
=
new
FormData
();
data
.
append
(
"
title
"
,
"
hardcoded title!
"
);
//TODO
data
.
append
(
"
follow_up
"
,
gadget
.
options
.
jio_key
);
data
.
append
(
"
predecessor
"
,
''
);
data
.
append
(
"
text_content
"
,
"
this is a hardcoded comment!
"
);
//TODO
data
.
append
(
"
file
"
,
file_blob
);
//TODO
// reset the file upload, otherwise next comment would upload same file again
choose_file_html_element
.
value
=
""
;
// XXX: Hack, call jIO.util.ajax directly to pass the file blob
// Because the jio_putAttachment will call readBlobAsText, which
// will broke the binary file. Call the jIO.util.ajax directly
// will not touch the blob
return
jIO
.
util
.
ajax
({
"
type
"
:
"
POST
"
,
"
url
"
:
url
,
"
data
"
:
data
,
"
xhrFields
"
:
{
withCredentials
:
true
}
}
});
);
})
}
.
push
(
function
()
{
// build links with attachments and localized dates
return
new
RSVP
.
Queue
().
push
(
function
()
{
var
queue_list
=
[],
i
=
0
;
gadget
.
notifySubmitted
({
message
:
"
Comment added
"
,
status
:
"
success
"
});
for
(
i
=
0
;
i
<
post_list
.
length
;
i
+=
1
)
{
}).
push
(
function
()
{
queue_list
.
push
(
getPostWithLinkAndLocalDate
(
post_list
[
i
]));
return
gadget
.
redirect
({
command
:
'
reload
'
});
}
});
return
RSVP
.
all
(
queue_list
);
},
function
(
e
)
{
})
enableSubmitButton
();
.
push
(
function
(
comment_list
)
{
return
gadget
.
notifySubmitted
({
message
:
"
Error:
"
+
e
,
status
:
"
error
"
});
var
comments
=
gadget
.
element
.
querySelector
(
"
#post_list
"
);
});
comments
.
innerHTML
=
comment_list_template
({
comments
:
comment_list
});
return
queue
;
})
;
})
})
.
onLoop
(
function
()
{
.
onLoop
(
function
()
{
...
@@ -188,8 +84,8 @@
...
@@ -188,8 +84,8 @@
});
});
},
5000
)
},
5000
)
.
onEvent
(
'
submit
'
,
function
()
{
/*
.onEvent('submit', function () {
return this.submitPostComment();
return this.submitPostComment();
});
})
*/
;
}(
window
,
rJS
,
RSVP
,
document
,
moment
,
FormData
,
jIO
,
Handlebars
));
}(
window
,
rJS
,
RSVP
,
document
,
moment
,
jIO
,
Handlebars
));
\ No newline at end of file
\ 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