Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
making jqgrid view generic for both collections and random lists
- Loading branch information
Showing
5 changed files
with
131 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{% load item_tags %} | ||
<table id="jqgrid_list{{identifier}}"></table> | ||
<div id="jqgrid_pager{{identifier}}"></div> | ||
<script type="text/javascript"> | ||
|
||
if (typeof(openDialog) == 'undefined') { | ||
function openDialog(name) | ||
{ | ||
var dialogBox = $("#" + name); | ||
dialogBox.dialog({ | ||
autoOpen: false, | ||
bgiframe: true, | ||
modal: true, | ||
close: function(event, ui) {dialogBox.dialog('destroy')} | ||
}); | ||
dialogBox.dialog('open'); | ||
} | ||
} | ||
|
||
$(document).ready(function () { | ||
$("#jqgrid_list{{identifier}}").jqGrid({ | ||
url: '{{url}}', | ||
postData: {{post_data_json}}, | ||
datatype: "json", | ||
colNames: {{col_names_json}}, | ||
colModel: {{col_model_json}}, | ||
rowNum: 10, | ||
rowList: [10,20,50,100], | ||
viewrecords: true, | ||
pager: '#jqgrid_pager{{identifier}}', | ||
height: "100%", | ||
autowidth: true, | ||
multiselect: true, | ||
{% if collection %} | ||
{% ifagentcan 'modify_membership' item %} | ||
gridComplete: function(){ | ||
var ids = $("#jqgrid_list{{ identifier }}").getDataIDs(); | ||
for (var i = 0; i < ids.length; i++) { | ||
var id = ids[i]; | ||
var deleteButton = '<button type="button" onclick="$(\'#removememberform{{identifier}}\')[0].elements[0].value = '+id+'; $(\'#removememberform{{identifier}}\')[0].submit();"><span class="ui-icon ui-icon-trash"></span></button>'; | ||
|
||
$("#jqgrid_list{{ identifier }}").setRowData(id, {actions: deleteButton}); | ||
} | ||
}, | ||
{% endifagentcan %} | ||
{% endif %} | ||
}); | ||
$("#jqgrid_list{{identifier}}").jqGrid('navGrid','#jqgrid_pager{{identifier}}',{edit:false,add:false,del:false}); | ||
$("#jqgrid_list{{identifier}}").jqGrid('navButtonAdd',"#jqgrid_pager{{identifier}}",{caption:"Columns",title:"Choose columns",buttonicon:"ui-icon-gear",onClickButton:function(){$("#jqgrid_list{{identifier}}").jqGrid('columnChooser',{});}}); | ||
{% if collection %} | ||
{% ifagentcan 'modify_membership' collection %} | ||
$("#jqgrid_list{{identifier}}").jqGrid('navButtonAdd',"#jqgrid_pager{{identifier}}",{caption:"Add",title:"Add an item to {% viewable_name collection %}",buttonicon:"ui-icon-circle-plus",onClickButton:function(){openDialog('addmember{{collection.pk}}');}}) | ||
{% endifagentcan %} | ||
|
||
{% if cur_agent_in_collection %} | ||
{% ifagentcan 'remove_self' collection %} | ||
$("#jqgrid_list{{identifier}}").jqGrid('navButtonAdd',"#jqgrid_pager{{identifier}}",{caption:"Leave",title:"Remove my membership in {% viewable_name collection %}",buttonicon:"ui-icon-person",onClickButton:function(){$('#removeselfform{{identifier}}')[0].submit();}}) | ||
{% endifagentcan %} | ||
{% else %} | ||
{% ifagentcan 'add_self' collection %} | ||
$("#jqgrid_list{{identifier}}").jqGrid('navButtonAdd',"#jqgrid_pager{{identifier}}",{caption:"Join",title:"Become a member of {% viewable_name collection %}",buttonicon:"ui-icon-person",onClickButton:function(){$('#addselfform{{identifier}}')[0].submit();}}) | ||
{% endifagentcan %} | ||
{% endif %} | ||
{% endif %} | ||
}); | ||
</script> | ||
|
||
{% if collection %} | ||
<form id="removememberform{{identifier}}" method="post" enctype="multipart/form-data" action="{% url item_url viewer=viewer_name,action="removemember",noun=collection.pk %}?redirect={{ full_path|urlencode }}" style="display: none;"> | ||
<input type="hidden" name="item" value="" /> | ||
</form> | ||
|
||
{% newmemberdialog %} | ||
|
||
<form id="removeselfform{{identifier}}" method="post" enctype="multipart/form-data" action="{% url item_url viewer=viewer_name,action="removemember",noun=collection.pk %}?redirect={{ full_path|urlencode }}" class="item_form"> | ||
<input type="hidden" name="item" value="{{ cur_agent.pk }}" /> | ||
</form> | ||
|
||
<form id="addselfform{{identifier}}" method="post" enctype="multipart/form-data" action="{% url item_url viewer=viewer_name,action="addmember",noun=collection.pk %}?redirect={{ full_path|urlencode }}" class="item_form"> | ||
<input type="hidden" name="item" value="{{ cur_agent.pk }}" /> | ||
</form> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters