Skip to content

Commit

Permalink
(CS) Make event info editable directly
Browse files Browse the repository at this point in the history
  • Loading branch information
jmrauen committed Aug 5, 2014
1 parent d4c2788 commit 9bfbe10
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 9 deletions.
2 changes: 1 addition & 1 deletion system/churchcore/cc_standardview.js
Expand Up @@ -333,7 +333,7 @@ StandardTableView.prototype.renderList = function(entry, newSort) {
if (t.listViewTableHeight!=null) {
rows.push('</table></div>');

rows.push('<div style="min-height:300px; max-height:'+t.listViewTableHeight+'px; overflow-y:auto; overflow-x:auto">');
rows.push('<div style="min-height:300px; position:relative; max-height:'+t.listViewTableHeight+'px; overflow-y:auto; overflow-x:auto">');
rows.push('<table class="'+classes+'" style="margin-bottom:0px" id="AddressTableChild">');
}

Expand Down
29 changes: 25 additions & 4 deletions system/churchcore/churchforms.js
Expand Up @@ -2018,9 +2018,21 @@ $.widget("ct.editable", {
editable.addClass("editmode");
var elem=null;
if (t.options.type=="textarea") {
elem=editable.html('<textarea class="editor" maxlength=200 style="margin:0;width:'+(editable.width()-10)+'px" '
+'>'+t._renderEditor()+'</textarea>')
.find(t.options.type);
var rows=new Array();
rows.push('<div>');
var height=(editable.height()+10);
if (height<40) height=40;
var width=(editable.width()-10);
if (width<123) width=123;
rows.push('<textarea class="editor" maxlength="200" style="margin:0;width:'+width+'px;height:'+height+'px" '
+'>'+t._renderEditor()+'</textarea>');
rows.push('<br/><span class="" style="position:absolute;">');
rows.push(form_renderButton({type:"small", htmlclass:"save btn-primary", label:_("save")}));
rows.push(form_renderButton({type:"small", htmlclass:"cancel ", label:_("cancel")}));
rows.push('</span>');
rows.push('</div>');
var elem=editable.html(rows.join("")).find(t.options.type);

// Limit max character to given maxlength
elem.keyup(function(){
var max = parseInt($(this).attr('maxlength'));
Expand All @@ -2039,6 +2051,14 @@ $.widget("ct.editable", {
elem.focus();
// Not by textarea, otherweise Firefox selected after editing the normal text...
if (t.options.type!="textarea") elem.select();
editable.find(".save").click(function() {
t.success();
return false;
});
editable.find(".cancel").click(function() {
t.cancel();
return false;
});
elem.keyup(function(e) {
if (t.options.autosaveSeconds>0) {
if (t._autosave!=null)
Expand All @@ -2048,7 +2068,8 @@ $.widget("ct.editable", {

// Enter
if (e.keyCode == 13) {
t.success();
if (t.options.type!="textarea")
t.success();
}
// Escape
else if (e.keyCode == 27) {
Expand Down
34 changes: 31 additions & 3 deletions system/churchservice/cs_listview.js
Expand Up @@ -998,11 +998,15 @@ ListView.prototype.renderListEntry = function(event) {

rows.push("<br/>");

if ((event.special!=null) && (event.special!=""))
rows.push("<div class=\"event_info\">"+event.special.htmlize()+"</div>");

if (event.valid_yn==1) {
if (event.valid_yn==0) {
rows.push("<div class=\"event_info\"><small>Event wurde abgesagt!</small></div>");
}
else {
var _authMerker=masterData.auth.write || _bin_ich_admin;
if ((event.special!=null) && (event.special!="")) {
rows.push('<div class="event_info'+(_authMerker?" editable":"")+'">'+event.special.htmlize()+'</div>');
}
// Check if I am a leader of the group
if (!_authMerker)
$.each(masterData.service, function(k,a) {
Expand Down Expand Up @@ -2812,6 +2816,30 @@ ListView.prototype.addFurtherListCallbacks = function(cssid) {
$(cssid+" a.edit-service").click(function() {
t.renderAddServiceToServicegroup(allEvents[$(this).attr("data-event-id")], $(this).attr("data-servicegroup-id"), masterData.user_pid);
});
$(cssid+" div.editable").each(function() {
var id=$(this).parents("tr").attr("id");
$(this).editable({
value:allEvents[id].special,
type:"textarea",
data:id,
render:
function(txt) {
return '<small>'+txt.htmlize()+'</div>';
},
success:
function(newval, data) {
var oldVal=allEvents[data].special;
allEvents[data].special=newval;
churchInterface.jsendWrite({func:"saveNote", text:newval, event_id:data}, function(ok, res) {
if (!ok) {
alert(_("error.occured")+": "+res);
allEvents[data].special=oldVal;
listView.renderList();
}
});
}
});
});

$('#ical_abo').click(function() {
ical_abo();
Expand Down
6 changes: 5 additions & 1 deletion system/includes/churchtools.css
Expand Up @@ -526,5 +526,9 @@ span.tag {
margin-bottom: .4em !important;
}
.addService .checkbox:hover {
background:#DDEDF7;
background:#F2F4F6 !important;
}
div.editable:hover {
background:#F2F4F6 !important;

}

0 comments on commit 9bfbe10

Please sign in to comment.