Permission table is in a separate template
authorverrierj
Wed, 23 Nov 2011 11:01:47 +0100
changeset 246 f76edbe6d06b
parent 245 953228fcbb56
child 247 f98f1a6e15f1
Permission table is in a separate template
src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/create_ldt.html
src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/permissions.html
src/ldt/ldt/static/ldt/css/style.css
--- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/create_ldt.html	Mon Nov 21 15:33:17 2011 +0100
+++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/create_ldt.html	Wed Nov 23 11:01:47 2011 +0100
@@ -15,34 +15,7 @@
 	<link rel="stylesheet" href="{{LDT_MEDIA_PREFIX}}css/ldt.css" />
 	<link rel="stylesheet" href="{{LDT_MEDIA_PREFIX}}css/ldtform.css" />
 	<link rel="stylesheet" href="{{LDT_MEDIA_PREFIX}}css/workspace.css" />
-	<style type="text/css" >
-		textarea {
-			padding: 0px;
-			height: 100px;
-		}
-		
-		#lefttable {
-            float: left;
-        }
-        
-        .choice {
-            font-weight: bold;
-        }
-        
-        .perm_read, .perm_write {
-        	text-decoration: none;
-        	color: black;
-        }
-        
-        .permission {
-            cursor: pointer;
-        }
-        
-        .permcol {
-            width: 110px;
-        }
-        	
-	</style>
+	
 {% endblock %}
 
 {% block js_declaration %}
@@ -89,39 +62,9 @@
 		$("#close_button").click(function (e) {
 			e.preventDefault();
 			parent.$.nmTop().close();
-		});
-		
-		$(".permission").live("click", function () {
-            var group_name = $(this).attr('value');
-        	var group_id = group_name.split('_').pop();
-            
-            $("a[value=\"" + group_name + "\"]").removeClass('choice');
-            $(this).addClass('choice');
-            
-            if ($(this).hasClass('perm_read')) {
-            	var perm = 'read';
-            } else {
-            	var perm = 'write';            	
-            }
-            
-            $(".perm_field",$(this).closest('tr')).attr('value', perm);
-        });
-        
-        $(".checkbox_group").bind("change", function() {
-            var line = $(this).closest('tr');
-            
-            if (!$(this).is(":checked")) {
-                $(".choice", line).removeClass('choice');
-                $(".perm_read, .perm_write", line).removeClass('permission');
-            } else {
-                $(".perm_read", line).addClass('choice');
-                $(".perm_read, .perm_write", line).addClass('permission');
-            }
-        });        
+		});		
 
-		check_uncheck_all("content");
 		check_uncheck_all("group");
-		activate_initial_permissions();	
 				
 	});
 	</script>
@@ -190,46 +133,8 @@
 		</div>
 	</div>	
      
-   <div id="righttable" class="span-11">
-	    <label>{% trans "group list"%}</label>
-	
-        <div class="span-10 last" id="ldtcreatecontentslistcontainer">
-            <div class="span-10 last projectscontentstablediv" id="ldtcreatecontentstablediv">
-                <table class="projectscontentstable">
-                    {{ management_form }}
-                
-                    <tr class="projectscontentsheader last" id="contentslistheader">
-                        <td class="cellcheckbox">
-                        {% if groups|length > 1 %}
-                        	<input class="selectallgroups" id="global_checkbox_group" type="checkbox" checked="true"/>
-                        {% endif %}                            
-                        </td>				
-                        <td class="projectcontentsheadertitle">{% trans "nom" %}</td>
-                        <td class="projectcontentsheadertitle permcol" >{% trans "Permissions" %}</td>
-                    </tr>
-                
-                    <tbody class="projectscontentsbody" id="grouplist">
-                
-				    {% for form, group in group_form %}			    			    
-				    <tr class="imageline projectscontentsoddline">
-				    	<td class="cellcheckbox">{{ form.share }}</td>
-				    	<td class="projecttitle">{{ group.name }}</td>
-				    	<td>
-				    	<a value="group_{{group.id}}" class="perm_read" title="{% trans "This group can read the project" %}">{% trans "perm.read" %}</a>
-				        <a value="group_{{group.id}}" class="perm_write" title="{% trans "This group can change the project" %}">{% trans "perm.write" %}</a>
-				       	</td>
-				       	{{ form.perms }}
-				       	{{ form.group }}
-				    </tr>
-				    {% endfor %} 
-				                
-                    </tbody>
-                </table>		
-            </div>		
-        </div>       
-    </div> 
-               
-               
+    {% include "ldt/ldt_utils/partial/permissions.html" %}
+                   
     <div id="submitcontent-buttons" class="span-11 last">
 		<button type="button" id="close_button"  value="close">{% trans 'close_cancel' %}</button>
 		{% if ldt_id %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/permissions.html	Wed Nov 23 11:01:47 2011 +0100
@@ -0,0 +1,95 @@
+{% load i18n %}
+
+<script type="text/javascript">
+	
+	function activate_initial_permissions() {		
+		$("#grouplist tr").each(function (e) {
+			if ($("input[type=checkbox]", $(this)).is(":checked")) {
+				var perm = $(".perm_field", $(this)).val();
+				if (perm) {
+					$(".perm_read, .perm_write", $(this)).addClass("pointer");
+				}				
+				if (perm == 'read') {
+					$(".perm_read", $(this)).addClass("bold");
+				} else if (perm == 'write') {
+					$(".perm_write", $(this)).addClass("bold");
+				} 				
+			}
+		});
+	}
+	
+	$(document).ready(function() {	
+				
+		$(".pointer").live("click", function () {
+            var group_name = $(this).attr('value');
+        	var group_id = group_name.split('_').pop();
+            
+            $("a[value=\"" + group_name + "\"]").removeClass('bold');
+            $(this).addClass('bold');
+            
+            if ($(this).hasClass('perm_read')) {
+            	var perm = 'read';
+            } else {
+            	var perm = 'write';            	
+            }
+            
+            $(".perm_field",$(this).closest('tr')).attr('value', perm);
+        });
+        
+        $(".checkbox_group").bind("change", function() {
+            var line = $(this).closest('tr');
+            
+            if (!$(this).is(":checked")) {
+                $(".bold", line).removeClass('bold');
+                $(".perm_read, .perm_write", line).removeClass('pointer');
+            } else {
+                $(".perm_read", line).addClass('bold');
+                $(".perm_read, .perm_write", line).addClass('pointer');
+            }
+        });        
+
+		check_uncheck_all("group");
+		activate_initial_permissions();	
+				
+	});
+</script>
+
+
+<div id="righttable" class="span-11">
+	    <label>{% trans "group list"%}</label>
+	
+        <div class="span-10 last" id="ldtcreatecontentslistcontainer">
+            <div class="span-10 last projectscontentstablediv" id="ldtcreatecontentstablediv">
+                <table class="projectscontentstable">
+                    {{ management_form }}
+                
+                    <tr class="projectscontentsheader last" id="contentslistheader">
+                        <td class="cellcheckbox">
+                        {% if groups|length > 1 %}
+                        	<input class="selectallgroups" id="global_checkbox_group" type="checkbox" checked="true"/>
+                        {% endif %}                            
+                        </td>				
+                        <td class="projectcontentsheadertitle">{% trans "nom" %}</td>
+                        <td class="projectcontentsheadertitle span-3" >{% trans "Permissions" %}</td>
+                    </tr>
+                
+                    <tbody class="projectscontentsbody" id="grouplist">
+                
+				    {% for form, group in group_form %}			    			    
+				    <tr class="imageline projectscontentsoddline">
+				    	<td class="cellcheckbox">{{ form.share }}</td>
+				    	<td class="projecttitle">{{ group.name }}</td>
+				    	<td>
+				    	<a value="group_{{group.id}}" class="perm_read" title="{% trans "This group can read the project" %}">{% trans "perm.read" %}</a>
+				        <a value="group_{{group.id}}" class="perm_write" title="{% trans "This group can change the project" %}">{% trans "perm.write" %}</a>
+				       	</td>
+				       	{{ form.perms }}
+				       	{{ form.group }}
+				    </tr>
+				    {% endfor %} 
+				                
+                    </tbody>
+                </table>		
+            </div>		
+      </div>       
+</div>      
--- a/src/ldt/ldt/static/ldt/css/style.css	Mon Nov 21 15:33:17 2011 +0100
+++ b/src/ldt/ldt/static/ldt/css/style.css	Wed Nov 23 11:01:47 2011 +0100
@@ -223,11 +223,28 @@
     text-decoration:underline;
 }
 
-.errorlist
-{
+#lefttable {
+	float: left;
+}
+
+.bold {
+	font-weight: bold;
+}
+
+.perm_read, .perm_write {
+	text-decoration: none;
+    color: black;
+}
+
+.pointer {
+	cursor: pointer;
+}
+
+.errorlist {
     color: red;
     font-size:12px
 }
+
 .ui-tooltip-dark .ui-tooltip-content {
  	font-size: 1.1em;
 	border-width: 0px;