Skip to content

Commit

Permalink
SAK-26142 Include ability to add syllabus content (and not just a syl…
Browse files Browse the repository at this point in the history
…labus title) to Add syllabus item workflow
  • Loading branch information
relong76 committed Jan 9, 2015
1 parent cc9b0e7 commit 58d2578
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,22 @@ public void updateEntity(EntityReference ref, Object entity, Map<String, Object>
String published = ServerConfigurationService.getBoolean("syllabus.new.published.default", false) ? SyllabusData.ITEM_POSTED : SyllabusData.ITEM_DRAFT;
SyllabusData data = syllabusManager.createSyllabusDataObject(title, new Integer(initPosition), null, null, published, "none", null, null, Boolean.FALSE, null, null);
data.setView("no");
try {
String content = (String) params.get("content");
if (StringUtils.isNotBlank(content)) {
StringBuilder alertMsg = new StringBuilder();
String cleanedText = FormattedText.processFormattedText(content, alertMsg);
if (alertMsg.length() > 0) {
throw new IllegalArgumentException("Error formatting body text: " + alertMsg);
} else {
if (StringUtils.isNotEmpty(cleanedText)) {
data.setAsset(cleanedText);
}
}
}
} catch(Exception e) {
log.error(e.getMessage(), e);
}
syllabusManager.addSyllabusToSyllabusItem(item, data);
}
}
Expand Down
46 changes: 34 additions & 12 deletions syllabus/syllabus-app/src/webapp/js/syllabus.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,26 +503,47 @@ function showConfirmDelete(deleteButton, msgs, event){
}

function showConfirmAdd(msgs, mainframeId){
$('#container', this.top.document).append("<div></div>");
var emptyDiv = $('<div></div>', this.top.document);
$('<div></div>').appendTo('body')
.html('<div><h6>' + msgs.syllabus_title + "</h6><input type='text' id='newTitle'/></div><div style='display:none' id='requiredTitle' class='warning'>" + msgs.required + "</div>")
.html("<div><h6>" + msgs.syllabus_title + "</h6><input type='text' id='newTitle'/></div><div style='display:none' id='requiredTitle' class='warning'>" + msgs.required + "</div>" +
"<h6>" + msgs.syllabus_content + "</h6><div class='editItem bodyInput' id='newContentDiv'><textarea cols='120' id='newContentTextAreaWysiwyg'/></div>")
.dialog({
position: { my: 'center top', at: 'center top', of: $(document)},
modal: true, title: msgs.addItemTitle, zIndex: 10000, autoOpen: true,
width: 'auto', resizable: true,
position: {
my: 'center top',
at: 'center top',
of: $(this.top.document)
},
modal: true,
title: msgs.addItemTitle,
zIndex: 11100,
autoOpen: true,
width: 'auto',
height: 'auto',
resizable: true,
buttons: [
{
text: msgs.bar_new,
click: function () {
var title = $("#newTitle").val();
if(!title || "" == title.trim()){
$("#requiredTitle").show();
setTimeout(function(){$("#requiredTitle").fadeOut();}, 5000);
setTimeout(
function(){
$("#requiredTitle").fadeOut();
},
5000
);
}else{
//id doesn't exist since we are adding a new one
$("#newContentTextAreaWysiwyg").val($('#newContentDiv').find('iframe').contents().find('body').html()).change();
// id doesn't exist since we are adding a new one
var id = "0";
params = {"add" : true,
"title": title,
"siteId": $("#siteId").val()};
params = {
"add" : true,
"title": title,
"siteId": $("#siteId").val(),
"content": $("#newContentTextAreaWysiwyg").val()
};
postAjax(id, params, msgs);
if($("#successInfo").is(":visible")){
location.reload();
Expand All @@ -543,12 +564,13 @@ function showConfirmAdd(msgs, mainframeId){
return false;
},
open: function(event){
if($( "#accordion .group" ).children("h3").size() <= 1){
//we have 1 or 0 items, so make sure the window size is large enough
if($("#accordion .group").children("h3").size() <= 1){
// we have 1 or 0 items, so make sure the window size is large enough
mySetMainFrameHeight(mainframeId);
}
}
});
});
sakai.editor.launch("newContentTextAreaWysiwyg", {}, 900, 300);
}

if(typeof String.prototype.trim !== 'function') {
Expand Down
4 changes: 3 additions & 1 deletion syllabus/syllabus-app/src/webapp/syllabus/main.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
$(function() {
msgs = {
syllabus_title: $("#messages #syllabus_title").html(),
syllabus_content: $("#messages #syllabus_content").html(),
clickToAddTitle: $("#messages #clickToAddTitle").html(),
startdatetitle: $("#messages #startdatetitle").html(),
clickToAddStartDate: $("#messages #clickToAddStartDate").html(),
Expand Down Expand Up @@ -349,7 +350,7 @@
</h:outputFormat>
</syllabus:syllabus_ifnot>
</f:verbatim>

<f:verbatim><div style="padding-top: 600px" frameborder="0"></div></f:verbatim>
</h:form>

<!-- This section is used for internationalization for JS files
Expand All @@ -361,6 +362,7 @@
<f:verbatim>
<span id="messages" style="display:none">
<span id="syllabus_title"></f:verbatim><h:outputText value="#{msgs.syllabus_title}"/><f:verbatim></span>
<span id="syllabus_content"></f:verbatim><h:outputText value="#{msgs.syllabus_content}"/><f:verbatim></span>
<span id="clickToAddTitle"></f:verbatim><h:outputText value="#{msgs.clickToAddTitle}"/><f:verbatim></span>
<span id="startdatetitle"></f:verbatim><h:outputText value="#{msgs.startdatetitle}"/><f:verbatim></span>
<span id="clickToAddStartDate"></f:verbatim><h:outputText value="#{msgs.clickToAddStartDate}"/><f:verbatim></span>
Expand Down

0 comments on commit 58d2578

Please sign in to comment.