Skip to content

Commit

Permalink
Fixed issue #05597 No feedback from 'share panel', also fixed range o…
Browse files Browse the repository at this point in the history
…f other nonfunctioning problems with share panel such as delete not working, change 'can_edit' not working
  • Loading branch information
jcleeland committed Jul 11, 2012
1 parent 03c4b3d commit 77183f4
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 56 deletions.
5 changes: 3 additions & 2 deletions application/controllers/admin/participantsaction.php
Expand Up @@ -207,7 +207,7 @@ function getShareInfo_json()
{
$oShared = User::getName($row['share_uid']); //for conversion of uid to human readable names
$owner = User::getName($row['owner_uid']);
$aData->rows[$i]['id'] = $row['participant_id'];
$aData->rows[$i]['id'] = $row['participant_id']."--".$row['share_uid']; //This is the unique combination per record
$aData->rows[$i]['cell'] = array($row['firstname'], $row['lastname'], $row['email'], $oShared[0]['full_name'], $row['share_uid'], $owner[0]['full_name'], $row['date_added'], $row['can_edit']);
$i++;
}
Expand Down Expand Up @@ -241,9 +241,10 @@ function getShareInfo_json()
function editShareInfo()
{
$operation = Yii::app()->request->getPost('oper');
$shareIds = Yii::app()->request->getPost('id');
if ($operation == 'del') // If operation is delete , it will delete, otherwise edit it
{
ParticipantShares::deleteRow($_POST);
ParticipantShares::deleteRow($shareIds);
}
else
{
Expand Down
19 changes: 12 additions & 7 deletions application/models/ParticipantShares.php
Expand Up @@ -118,19 +118,24 @@ public function storeParticipantShare($data)

function updateShare($data)
{
$criteria = new CDbCriteria;
$criteria->addCondition('participant_id = :participant_id')->bindParam(":participant_id", $data['participant_id'], PDO::PARAM_STR);
$criteria->addCondition('share_uid = :shareuid')->bindParam(":shareuid", $data['shareuid'], PDO::PARAM_INT);
ParticipantShares::model()->updateAll($data,$criteria);
list($participantId, $shareuid)=explode("--", $data['participant_id']);
$updatedata=array("participant_id"=>$participantId, "share_uid"=>$data['share_uid'], "can_edit"=>$data['can_edit']);
$criteria = new CDbCriteria;
$criteria->addCondition("participant_id = '$participantId'");
$criteria->addCondition("share_uid = '$shareuid' ");
ParticipantShares::model()->updateAll($updatedata,$criteria);
}

function deleteRow($rows)
{
// Converting the comma seperated id's to an array to delete multiple rows
$rowid=explode(",",$rows['id']);
foreach($rowid as $row)
$rowid=explode(",",$rows);
foreach($rowid as $row)
{
Yii::app()->db->createCommand()->delete('{{participant_shares}}','participant_id = :participant_id')->bindParam(":participant_id", $row, PDO::PARAM_STR);
list($participantId, $uId)=explode("--", $row);
Yii::app()->db
->createCommand()
->delete('{{participant_shares}}',"participant_id = '$participantId' AND share_uid = $uId");
}
}
}
14 changes: 13 additions & 1 deletion application/views/admin/participants/sharePanel_view.php
@@ -1,7 +1,19 @@
<script type="text/javascript">
var shareinfoUrl = "<?php echo Yii::app()->getController()->createUrl("admin/participants/getShareInfo_json"); ?>";
var editurlshare = "<?php echo Yii::app()->getController()->createUrl("admin/participants/editShareInfo"); ?>";
var isadmin = "<?php echo (Yii::app()->session['USER_RIGHT_SUPERADMIN'] == '1' ? 1 : 0); ?>"
var isadmin = "<?php echo (Yii::app()->session['USER_RIGHT_SUPERADMIN'] == '1' ? 1 : 0); ?>";

/* Colnames and heading for survey links subgrid */
var firstNameText= "<?php $clang->eT("First name") ?>";
var lastNameText = "<?php $clang->eT("Last name") ?>";
var emailText = "<?php $clang->eT("E-Mail") ?>";
var sharedWithText="<?php $clang->eT("Shared with") ?>";
var sharedUidText= "<?php $clang->eT("Shared user id") ?>";
var ownerText = "<?php $clang->eT("Owner") ?>";
var dateAddedText= "<?php $clang->eT("Date added") ?>";
var canEditText = "<?php $clang->eT("Can edit?") ?>";


</script>
<div class='header ui-widget-header'><strong><?php $clang->eT("Share panel"); ?> </strong></div>
<br/>
Expand Down
15 changes: 13 additions & 2 deletions scripts/admin/attributeControl.js
Expand Up @@ -41,8 +41,19 @@ $(document).ready(function() {
}
});

jQuery('#attributeControl').jqGrid('navGrid','#pager', {add:true, del:true, edit:true}, {width:400}, {width:400, reloadAfterSubmit: false,
afterSubmit: function (response) { return [true, '', response.responseText]; }}, {}, {multipleSearch:true, width:600});
jQuery('#attributeControl').jqGrid('navGrid',
'#pager',
{add:true, del:true, edit:true},
{width:400},
{ width:400,
reloadAfterSubmit: false,
afterSubmit: function (response) {
return [true, '', response.responseText];
}
},
{},
{multipleSearch:true, width:600}
);

});

Expand Down
98 changes: 54 additions & 44 deletions scripts/admin/sharePanel.js
Expand Up @@ -4,75 +4,85 @@ Please Note: we are not using the normal jqgrid cell edit here.
*/
function ajaxSave(rowid,shareduid) {
var state;
var cbId="#check_"+rowid+"_"+shareduid;

if($('#check_'+rowid+'_'+shareduid).is(':checked'))
if($(cbId).is(':checked'))
{
state = "true";
state="true";
}
else
else
{
state ="false";
}
$.post(editurlshare, { participant_id: rowid, can_edit: state, shared_uid: shareduid } );
}
$(document).ready(function() {
//script for jqGrid
//script for jqGrid

if(isadmin == 1)
{
var colNames = '["First Name","Last Name","E-Mail","Shared With","shared_uid","Owner","Date Added","Can Edit"]';
var CM = [ {name:'firstname',index:'firstname', width:60,align:"center",editable:false},
{name:'lastname',index:'lastname', width:60,align:"center",editable:false},
{name:'email',index:'email', width:130,align:"center",editable:false},
{name:'sharedwith',index:'sharedwith', width:130,align:"center",editable:false,width:40},
var colNames = '["'+firstNameText+'", "'+lastNameText+'", "'+emailText+'", "'+sharedWithText+'", "'+sharedUidText+'", "'+ownerText+'", "'+dateAddedText+'", "'+canEditText+'"]';
var CM = [ {name:'firstname',index:'firstname', width:60,align:"center",editable:false},
{name:'lastname',index:'lastname', width:60,align:"center",editable:false},
{name:'email',index:'email', width:130,align:"center",editable:false},
{name:'sharedwith',index:'sharedwith', width:130,align:"center",editable:false,width:40},
{name:'shareduid',index:'shareduid',hidden: true,editable:false},
{name:'Owner',index:'Owner', width:130,align:"center",editable:false,width:40},
{name:'dateadded',index:'dateadded', width:80,align:"center",editable:false},
{name:'Owner',index:'Owner', width:130,align:"center",editable:false,width:40},
{name:'dateadded',index:'dateadded', width:80,align:"center",editable:false},
{name: 'canedit', width: 40, align: 'center', editable: true, formatter: checkboxFormatter, edittype: 'checkbox'}];
}
else
{
var colNames = '["First Name","Last Name","E-Mail","Shared With","shared_uid","Date Added","Can Edit"]';
var CM = [ {name:'firstname',index:'firstname', width:60,align:"center",editable:false},
{name:'lastname',index:'lastname', width:60,align:"center",editable:false},
{name:'email',index:'email', width:130,align:"center",editable:false},
{name:'sharedwith',index:'sharedwith', width:130,align:"center",editable:false,width:40},
var colNames = '["'+firstNameText+'", "'+lastNameText+'", "'+emailText+'", "'+sharedWithText+'", "'+sharedUidText+'", "'+dateAddedText+'", "'+canEditText+'"]';
var CM = [ {name:'firstname',index:'firstname', width:60,align:"center",editable:false},
{name:'lastname',index:'lastname', width:60,align:"center",editable:false},
{name:'email',index:'email', width:130,align:"center",editable:false},
{name:'sharedwith',index:'sharedwith', width:130,align:"center",editable:false,width:40},
{name:'shareduid',index:'shareduid',hidden: true,editable:false},
{name:'dateadded',index:'dateadded', width:80,align:"center",editable:false},
{name:'dateadded',index:'dateadded', width:80,align:"center",editable:false},
{name: 'canedit', width: 40, align: 'center', editable: true, formatter: checkboxFormatter, edittype: 'checkbox'}];
}

var lastSel;
jQuery("#sharePanel").jqGrid({
align:"center",
url: shareinfoUrl,
editurl : editurlshare,
datatype: "json",
mtype: "post",
editable : true,
colNames: jQuery.parseJSON(colNames),
colModel: CM,
height: "100%",
width: "100%",
rowNum: 25,
scrollOffset:0,
autowidth: true,
sortname : "firstname",
rowList: [25,50,100,250,500,1000,5000,10000],
multiselect: true,
loadonce: true,
pager: "#pager"
align:"center",
url: shareinfoUrl,
editurl : editurlshare,
datatype: "json",
mtype: "post",
editable : true,
colNames: jQuery.parseJSON(colNames),
colModel: CM,
height: "100%",
width: "100%",
rowNum: 25,
scrollOffset:0,
autowidth: true,
sortname : "firstname",
rowList: [25,50,100,250,500,1000,2000,5000],
multiselect: true,
loadonce: true,
pager: "#pager"
});
function checkboxFormatter(cellvalue, options, rowObject) {
cellvalue = cellvalue + "";
cellvalue = cellvalue.toLowerCase();
var bchk = cellvalue.search(/(false|0|no|off|n)/i) < 0 ? " checked=\"checked\"" : "";
/* Adding a name and the shared user id to the checkbox here with the format check_rowId_shared_uid so that in the ajax save function we get the currect selected value instead of the one
provided by custom formatter so that the user can toggle on a single checkbox and still the values are stored at the database. The only thing that can be unique accross the share panel is the row id and share user id*/

return "<input type='checkbox' name=check_"+options.rowId+"_"+rowObject[4]+" id=check_"+options.rowId+"_"+rowObject[4]+" onclick=\"ajaxSave('" + options.rowId + "','" + rowObject[4] +"');\" " + bchk + " value='" + cellvalue + "' offval='no' />"
}
jQuery('#sharePanel').jqGrid('navGrid','#pager',{add:false,del:true,edit:false});
cellvalue = cellvalue + "";
cellvalue = cellvalue.toLowerCase();
var bchk = cellvalue.search(/(false|0|no|off|n)/i) < 0 ? " checked=\"checked\"" : "";
/* Adding a name and the shared user id to the checkbox here with the format check_rowId_shared_uid
* so that in the ajax save function we get the currect selected value instead of the one
* provided by custom formatter so that the user can toggle on a single checkbox and still
* the values are stored at the database. The only thing that can be unique accross the
* share panel is the row id and share user id
* */
return "<input type='checkbox' name='check_"+options.rowId+"_"+rowObject[4]+"' id='check_"+options.rowId+"_"+rowObject[4]+"' onclick=\"ajaxSave('" + options.rowId + "','" + rowObject[4] +"');\" " + bchk + " value='" + cellvalue + "' offval='no' />"
}
jQuery('#sharePanel').jqGrid('navGrid',
'#pager',
{add:false,del:true,edit:false},
{closeAfterDel: true,
reloadAfterSubmit: true
}
);
$.extend(jQuery.jgrid.edit,{closeAfterAdd: true,reloadAfterSubmit: true,closeOnEspace:true});


Expand Down

0 comments on commit 77183f4

Please sign in to comment.